/* VoicePal v2 login and sign-up. Builds on v2.css tokens, .sheet and .btn.
   Thesis: the logo's microphone speaks. A radial voiceprint on a dark stage, a quiet form on paper, everything on one grid. */

:root {
  --danger: #b3372b;
  --auth-edge: clamp(2.4rem, 4vw, 5.6rem);
}

@view-transition {
  navigation: auto;
}

.auth {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: calc(100svh - 2rem);
  padding: 1rem;
}

/* ---------- Stage ---------- */

.stage-auth {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  min-height: 56rem;
  padding: var(--auth-edge);
  border-radius: var(--r-panel);
  background: radial-gradient(60% 50% at 50% 44%, var(--stage-glow), transparent 75%),
    linear-gradient(180deg, var(--stage-top), var(--stage-bottom));
  color: var(--on-dark);
  view-transition-name: auth-stage;
}

.stage-auth canvas {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
}

/* Logo at the exact centre of the voiceprint */
.stage-auth__mark {
  position: absolute;
  top: 44%;
  left: 50%;
  width: clamp(7.2rem, 8vw, 10.4rem);
  height: auto;
  transform: translate(-50%, -50%);
}

.stage-auth__line {
  max-width: 18ch;
  font-size: clamp(3rem, 3.2vw, 4.6rem);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

/* ---------- Form column: every row shares the same two edges ---------- */

.auth__side {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 3.2rem;
  min-width: 0;
  padding: var(--auth-edge) var(--auth-edge) calc(var(--auth-edge) * 0.7);
}

.auth__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.6rem;
  font-size: 1.5rem;
}

.auth__row a:not(.brand) {
  font-weight: 600;
  text-underline-offset: 0.2em;
}

.auth__row a:not(.brand):hover {
  color: var(--signal);
  text-decoration: underline;
}

.auth__row span {
  color: var(--ink-soft);
}

.auth__foot {
  color: var(--ink-soft);
  font-size: 1.4rem;
}

.auth__main {
  display: grid;
  align-content: center;
  gap: 3.2rem;
  width: 100%;
  min-width: 0;
}

.auth__head h1 {
  font-size: clamp(4.4rem, 5vw, 7.2rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.05em;
  text-wrap: balance;
}

.auth__head p {
  max-width: 44ch;
  margin-top: 1.6rem;
  color: var(--ink-soft);
  font-size: 1.8rem;
  line-height: 1.45;
}

/* One entrance, on the column only */
.js .auth__main > * {
  animation: auth-in 0.8s var(--ease) both;
}

.js .auth__main > :nth-child(2) { animation-delay: 0.07s; }
.js .auth__main > :nth-child(3) { animation-delay: 0.14s; }
.js .auth__main > :nth-child(4) { animation-delay: 0.21s; }

@keyframes auth-in {
  from {
    opacity: 0;
    transform: translateY(1.6rem);
  }
}

/* ---------- Who is logging in ---------- */

.who {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0.4rem;
  border-radius: var(--r-card);
  background: var(--line);
}

.who::before {
  content: "";
  position: absolute;
  top: 0.4rem;
  bottom: 0.4rem;
  left: 0.4rem;
  width: calc(50% - 0.4rem);
  border-radius: 0.5rem;
  background: var(--surface);
  transition: transform 0.35s var(--ease);
}

.who.is-parent::before {
  transform: translateX(100%);
}

.who button {
  position: relative;
  min-height: 4.4rem;
  border: 0;
  border-radius: 0.5rem;
  background: none;
  color: var(--ink-soft);
  font-size: 1.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease;
}

.who button:hover,
.who button[aria-selected="true"] {
  color: var(--ink);
}

/* Both panes share one cell so nothing jumps when switching */
.panes {
  display: grid;
}

.pane {
  grid-area: 1 / 1;
  display: grid;
  gap: 1.6rem;
  align-content: start;
  min-width: 0;
}

.pane.is-away {
  visibility: hidden;
}

.pane.is-here {
  animation: pane-in 0.4s var(--ease) both;
}

@keyframes pane-in {
  from {
    opacity: 0;
    transform: translateY(0.8rem);
  }
}

.pane__text {
  color: var(--ink-soft);
  font-size: 1.6rem;
  line-height: 1.5;
}

.auth-field {
  display: grid;
  gap: 0.8rem;
}

.auth-field label {
  font-size: 1.45rem;
  font-weight: 600;
}

.auth-field input {
  width: 100%;
  min-height: 5.4rem;
  padding: 0 1.6rem;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.7rem;
  transition: border-color 0.2s ease;
}

.auth-field input:hover {
  border-color: var(--ink-soft);
}

.auth-field input:focus-visible {
  border-color: var(--signal);
  outline-offset: 1px;
}

.auth-field small {
  color: var(--ink-soft);
  font-size: 1.35rem;
  line-height: 1.4;
}

.auth-submit {
  width: 100%;
  min-height: 5.4rem;
  font-size: 1.6rem;
}

.auth-submit:disabled {
  opacity: 0.75;
  cursor: progress;
}

.auth-submit .spin {
  display: none;
  width: 1.6rem;
  height: 1.6rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.auth-submit.is-busy .spin {
  display: block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-error {
  padding: 1.2rem 1.4rem;
  border-radius: var(--r-card);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  color: var(--danger);
  font-size: 1.45rem;
  line-height: 1.4;
}

/* Sign-up: what actually happens next (a real sequence) */
.next-steps {
  display: grid;
  border-top: 1px solid var(--line);
  counter-reset: next;
}

.next-steps li {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr);
  align-items: baseline;
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 1.6rem;
}

.next-steps li::before {
  counter-increment: next;
  content: counter(next);
  color: var(--signal);
  font-weight: 600;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .auth {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .stage-auth {
    min-height: 0;
    height: 25svh;
    padding: 0;
  }

  .stage-auth__line {
    display: none;
  }

  .stage-auth__mark {
    top: 50%;
    width: 5.6rem;
  }

  .auth__side {
    gap: 2.4rem;
    padding: 2rem 0 0.8rem;
  }

  .auth__row a:not(.brand) {
    white-space: nowrap;
  }

  .auth__main {
    align-content: start;
    gap: 2.4rem;
  }
}

@media (max-width: 480px) {
  .auth__row span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  .js .auth__main > *,
  .pane.is-here {
    animation: none;
  }

  .who::before,
  .who button,
  .auth-field input {
    transition: none;
  }
}
