/* ================================================================
   Friendly Auth — the sign-in / sign-up / password screens.

   Layout borrowed from nextbard.com: a brand column beside the card,
   a segmented switch instead of a buried "no account yet?" link, and
   monospace for anything the machine produced.

   Colour comes from the landing page instead — the same tokens the
   .lf block in index.html declares, so a coach who clicks "Sign in"
   in the header does not walk into a different product. Sky ground,
   white cards, one indigo brand, Bricolage headings.

   Scoped entirely under #authPage. The only DOM this file needs
   beyond auth.css is .auth-brand and .auth-segs, both rendered by
   js/auth.js (see brandPanel() and modeSwitch()).
   ================================================================ */

#authPage {
  /* The landing declares its palette on .lf, a subtree this screen is not
     inside, so those variables cannot be inherited. Nearly all of them are
     the same values style.css already publishes on :root, so we point at
     those — change --accent there and this screen follows. The literals are
     the fallbacks, and the two tokens below that carry no :root twin. */

  /* ── Ground and paper — landing --sky / --sky-2 / --card ── */
  --fa-sky:   #f1f4fb;        /* NOT :root --bg (#eceef3); the landing's is lighter */
  --fa-sky-2: #e7ecf7;
  --fa-card:  var(--surface, #ffffff);

  /* ── Ink ── */
  --fa-ink:       var(--ink, #14171f);
  --fa-ink-soft:  var(--muted, #5b626f);
  --fa-ink-faint: #8a909c;    /* between :root --muted-2 and --line-strong */

  /* ── Hairlines ── */
  --fa-line:   var(--line, #e4e7ee);
  --fa-line-2: var(--line-strong, #d2d7e1);

  /* ── Brand, and the two signal colours the app already scores with ── */
  --fa-brand:      var(--accent, #3a55e6);
  --fa-brand-deep: var(--accent-strong, #2b40c4);
  --fa-brand-wash: var(--accent-soft, #eef0fe);
  --fa-point:      var(--good, #0d7539);      /* a rally that scored */
  --fa-point-wash: var(--good-soft, #e6f6ec);
  --fa-bad:        var(--bad, #d3413a);       /* an error */
  --fa-bad-wash:   var(--bad-soft, #fdeceb);

  /* ── Elevation — landing --shadow / --shadow-sm ── */
  --fa-shadow:    0 24px 60px -30px rgba(32, 38, 75, .35);
  --fa-shadow-sm: 0 12px 30px -18px rgba(32, 38, 75, .4);

  /* Same three families, in the same three roles, as the landing page. */
  --fa-display: 'Bricolage Grotesque', 'Bricolage Fallback', system-ui, sans-serif;
  --fa-body:    'Plus Jakarta Sans', 'Jakarta Fallback', system-ui, sans-serif;
  --fa-mono:    'JetBrains Mono', 'JBMono Fallback', ui-monospace, Consolas, monospace;

  background: var(--fa-sky);
  color: var(--fa-ink);
  font-family: var(--fa-body);
  color-scheme: light;
  position: relative;
  overflow: hidden;
  padding: 32px 24px;
}

/* Two very faint washes so the flat sky has a direction to it. Kept far
   below the landing's own contrast — this is ground, not decoration. */
#authPage::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(56vmax 40vmax at 10% -10%, rgba(58, 85, 230, .07), transparent 60%),
    radial-gradient(46vmax 38vmax at 94% 110%, rgba(58, 85, 230, .05), transparent 58%);
}

/* ── Shell: brand panel beside the card ─────────────────────────── */
#authPage .auth-shell {
  position: relative;         /* above the wash */
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  align-items: center;
  gap: 72px;
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
}

/* ── Brand panel ─────────────────────────────────────────────────── */
#authPage .auth-brand {
  min-width: 0;
}

/* The landing's eyebrow: a white pill with a pulsing brand dot. Same
   shape here, with the dot supplied by CSS since the markup has none. */
#authPage .auth-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 22px;
  padding: 7px 14px 7px 10px;
  background: var(--fa-card);
  border: 1px solid var(--fa-line);
  border-radius: 99px;
  box-shadow: var(--fa-shadow-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--fa-ink-soft);
}

#authPage .auth-eyebrow::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--fa-brand);
  box-shadow: 0 0 0 4px var(--fa-brand-wash);
  animation: fa-pulse 1.7s ease-in-out infinite;
}

/* Declared here rather than reused from the landing's keyframes — the
   auth screen must not break if that style block ever moves. */
@keyframes fa-pulse {
  0%, 100% { opacity: 1;  transform: scale(1); }
  50%      { opacity: .5; transform: scale(.82); }
}

@media (prefers-reduced-motion: reduce) {
  #authPage .auth-eyebrow::before { animation: none; }
}

#authPage .auth-brand-title {
  margin: 0 0 16px;
  font-family: var(--fa-display);
  font-size: clamp(30px, 3.4vw, 42px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.028em;
  color: var(--fa-ink);
}

#authPage .auth-brand-sub {
  margin: 0 0 36px;
  max-width: 46ch;
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--fa-ink-soft);
}

/* ── Console strip ───────────────────────────────────────────────── */
/* A still frame of the product, drawn the way the landing hero draws it:
   the mic and the transcript on top, one row per action the parser found,
   then what the rally did to the match. Same chips, same colours, same
   card — someone who scrolled the landing has already met this panel. */
#authPage .auth-console {
  border: 1px solid var(--fa-line);
  border-radius: 22px;
  background: var(--fa-card);
  box-shadow: var(--fa-shadow-sm);
  overflow: hidden;
  max-width: 460px;
}

/* ── Heard: mic, transcript, level meter ── */
#authPage .auth-heard {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 15px 16px 13px;
  border-bottom: 1px solid var(--fa-line);
  background: var(--fa-sky);
}

#authPage .auth-mic {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fa-brand);
  color: #fff;
  box-shadow: 0 6px 14px -6px rgba(58, 85, 230, .9);
}

#authPage .auth-heard-txt {
  min-width: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--fa-ink-soft);
}

#authPage .auth-heard-txt .k {
  display: block;
  margin-bottom: 2px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fa-brand);
}

#authPage .auth-heard-txt em {
  font-style: italic;
  color: var(--fa-ink);
}

/* The level meter is the only thing on this screen that moves, because the
   one thing the product needs a visitor to picture is talking to it. */
#authPage .auth-eq {
  flex: none;
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
  margin-top: 4px;
}

#authPage .auth-eq span {
  width: 3px;
  border-radius: 9px;
  background: var(--fa-brand);
  animation: fa-eq 1s ease-in-out infinite;
}

#authPage .auth-eq span:nth-child(1) { height: 6px; }
#authPage .auth-eq span:nth-child(2) { height: 13px; animation-delay: .15s; }
#authPage .auth-eq span:nth-child(3) { height: 9px;  animation-delay: .3s; }
#authPage .auth-eq span:nth-child(4) { height: 14px; animation-delay: .45s; }

@keyframes fa-eq {
  0%, 100% { transform: scaleY(.45); }
  50%      { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  #authPage .auth-eq span { animation: none; }
}

/* ── The actions the parser found ── */
#authPage .auth-rows {
  padding: 14px 16px 15px;
}

#authPage .auth-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
}

#authPage .auth-row + .auth-row {
  margin-top: 7px;
}

/* The code a coach reads on the match screen: side, skill, jersey, and the
   evaluation symbol. Monospace so the columns line up down the list. */
#authPage .auth-chip {
  flex: none;
  min-width: 78px;
  padding: 3px 7px;
  border-radius: 7px;
  text-align: center;
  font-family: var(--fa-mono);
  font-size: 11px;
  font-weight: 700;
}

#authPage .auth-chip.pos { background: var(--fa-point-wash); color: var(--fa-point); }
#authPage .auth-chip.neu { background: #fcf3e1;              color: #a06a12; }

#authPage .auth-row .lbl   { min-width: 0; color: var(--fa-ink-soft); }
#authPage .auth-row .lbl b { color: var(--fa-ink); font-weight: 700; }

#authPage .auth-row .pt {
  flex: none;
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--fa-point-wash);
  color: var(--fa-point);
  font-family: var(--fa-mono);
  font-size: 10px;
  font-weight: 700;
}

/* ── What the rally did to the match ── */
#authPage .auth-console-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--fa-line);
}

#authPage .auth-score {
  font-family: var(--fa-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--fa-ink);
}

#authPage .auth-score i {
  margin: 0 2px;
  font-style: normal;
  color: var(--fa-ink-faint);
}

/* Which number belongs to which side. Quiet enough that the score still
   reads first. */
#authPage .auth-score b {
  font-size: 11px;
  font-weight: 700;
  color: var(--fa-ink-faint);
}

#authPage .auth-foot-note {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--fa-ink-faint);
}

#authPage .auth-foot-note b { color: var(--fa-brand); font-weight: 700; }

/* ── Card ────────────────────────────────────────────────────────── */
#authPage .auth-card {
  background: var(--fa-card);
  border: 1px solid var(--fa-line);
  border-radius: 22px;
  padding: 36px 34px 32px;
  max-width: none;
  box-shadow: var(--fa-shadow);
}

/* ── Logo ────────────────────────────────────────────────────────── */
/* Same mark as the landing header's .lf-mark, down to the ball in the
   corner — the two sit one click apart, so any drift shows. */
#authPage .auth-logo-box {
  position: relative;
  background: linear-gradient(150deg, var(--fa-brand), var(--fa-brand-deep));
  color: #fff;
  border-radius: 13px;
  font-family: var(--fa-display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: normal;
  box-shadow: 0 8px 18px -8px rgba(58, 85, 230, .9);
}

#authPage .auth-logo-box::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .85);
}

#authPage .auth-logo-text {
  font-family: var(--fa-display);
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--fa-ink);
}

#authPage .auth-logo-text small {
  font-family: var(--fa-mono);
  font-weight: 500;
  letter-spacing: .16em;
  color: var(--fa-ink-faint);
}

/* The card's own logo is a duplicate while the brand panel is up. */
#authPage .auth-logo--card { display: none; }

/* ── Mode switcher ───────────────────────────────────────────────── */
/* Segmented control: a sky track with the active half lifted out of it
   in white. Both labels stay legible at rest, so the card answers "can I
   sign up here?" without the coach reading to the bottom. */
#authPage .auth-segs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 24px;
  background: var(--fa-sky-2);
  border: 1px solid var(--fa-line);
  border-radius: 13px;
}

#authPage .auth-seg {
  padding: 9px 12px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--fa-ink-soft);
  font-family: var(--fa-body);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background .16s, color .16s, border-color .16s, box-shadow .16s;
}

#authPage .auth-seg:hover:not(.is-active) {
  color: var(--fa-ink);
  background: rgba(255, 255, 255, .55);
}

#authPage .auth-seg.is-active {
  background: var(--fa-card);
  border-color: var(--fa-line-2);
  color: var(--fa-ink);
  box-shadow: 0 4px 10px -6px rgba(32, 38, 75, .45);
  cursor: default;
}

/* ── Headings ────────────────────────────────────────────────────── */
#authPage .auth-title {
  font-family: var(--fa-display);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.025em;
  color: var(--fa-ink);
  margin-bottom: 8px;
}

#authPage .auth-sub {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--fa-ink-soft);
  margin-bottom: 24px;
}

/* ── Message banner ──────────────────────────────────────────────── */
#authPage .auth-message {
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
}

#authPage .auth-message--error {
  background: var(--fa-bad-wash);
  border: 1px solid rgba(211, 65, 58, .22);
  color: var(--fa-bad);
}

#authPage .auth-message--success {
  background: var(--fa-point-wash);
  border: 1px solid rgba(13, 117, 57, .22);
  color: var(--fa-point);
}

/* ── Google button ───────────────────────────────────────────────── */
/* The landing's ghost button: white, 1.5px hairline, ink label. */
#authPage .auth-btn-google {
  background: var(--fa-card);
  border: 1.5px solid var(--fa-line-2);
  border-radius: 13px;
  color: var(--fa-ink);
  font-family: var(--fa-body);
  font-weight: 700;
  font-size: 14.5px;
  padding: 12px 20px;
  box-shadow: none;
  transition: background .16s, border-color .16s;
}

#authPage .auth-btn-google:hover:not(:disabled) {
  background: var(--fa-sky);
  border-color: var(--fa-ink-faint);
}

/* ── Divider ─────────────────────────────────────────────────────── */
#authPage .auth-divider {
  margin: 22px 0;
  font-family: var(--fa-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .16em;
  color: var(--fa-ink-faint);
}

#authPage .auth-divider::before,
#authPage .auth-divider::after {
  background: var(--fa-line);
}

/* ── Fields ──────────────────────────────────────────────────────── */
#authPage .auth-label {
  font-family: var(--fa-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .16em;
  color: var(--fa-ink-faint);
}

#authPage .auth-input {
  background: var(--fa-card);
  border: 1px solid var(--fa-line-2);
  border-radius: 13px;
  color: var(--fa-ink);
  font-family: var(--fa-body);
  font-size: 15px;
  font-weight: 500;
  padding: 12px 14px;
  height: auto;
  transition: border-color .16s, box-shadow .16s, background .16s;
}

#authPage .auth-input::placeholder { color: var(--fa-ink-faint); }

#authPage .auth-input:focus {
  background: var(--fa-card);
  border-color: var(--fa-brand);
  box-shadow: 0 0 0 3px rgba(58, 85, 230, .16);
}

/* The field already announces focus with a brand border and a ring; the
   page-wide 3px outline on top of that reads as an error state. */
#authPage .auth-input:focus-visible { outline: none; }

/* Confirm-password mismatch. Colour is not carrying this on its own — the
   hint below the field says it in words too. */
#authPage .auth-input.is-invalid {
  border-color: var(--fa-bad);
  background: var(--fa-bad-wash);
}

#authPage .auth-input.is-invalid:focus {
  border-color: var(--fa-bad);
  background: var(--fa-card);
  box-shadow: 0 0 0 3px rgba(211, 65, 58, .16);
}

#authPage .auth-hint {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--fa-bad);
}

#authPage .auth-hint[hidden] { display: none; }

/* Chrome tints autofilled fields a fixed pale yellow that clashes with the
   sky. There is no property that clears it — the standing trick is an inset
   shadow large enough to cover the cell. */
#authPage .auth-input:-webkit-autofill,
#authPage .auth-input:-webkit-autofill:hover,
#authPage .auth-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--fa-ink);
  -webkit-box-shadow: 0 0 0 40px var(--fa-card) inset;
  caret-color: var(--fa-ink);
}

/* ── Primary button ──────────────────────────────────────────────── */
#authPage .auth-btn-primary {
  background: var(--fa-brand);
  color: #fff;
  border-radius: 13px;
  font-family: var(--fa-body);
  font-size: 15px;
  font-weight: 800;
  padding: 13px 20px;
  height: auto;
  margin-top: 8px;
  box-shadow: 0 12px 26px -12px rgba(58, 85, 230, .9);
  transition: background .16s, box-shadow .16s, transform .1s;
}

#authPage .auth-btn-primary:hover:not(:disabled) {
  background: var(--fa-brand-deep);
  box-shadow: 0 16px 30px -12px rgba(58, 85, 230, .9);
}

#authPage .auth-btn-primary:disabled {
  opacity: .5;
  box-shadow: none;
}

/* ── Links ───────────────────────────────────────────────────────── */
#authPage .auth-switch {
  color: var(--fa-ink-soft);
  font-size: 13px;
}

#authPage .auth-link {
  color: var(--fa-brand);
  font-family: var(--fa-body);
  font-weight: 700;
  text-decoration: none;
}

#authPage .auth-link:hover {
  color: var(--fa-brand-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Forgot-password screen ──────────────────────────────────────── */
#authPage .auth-forgot-icon {
  background: var(--fa-brand-wash);
  border: 1px solid #c5cdfb;
  border-radius: 13px;
}

#authPage .auth-forgot-icon svg { stroke: var(--fa-brand); }

#authPage .auth-build { color: var(--fa-ink-faint); }

/* ── Focus ring — same as the landing's ──────────────────────────── */
#authPage :focus-visible {
  outline: 3px solid var(--fa-brand);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ── Below 960px: the card stands alone ──────────────────────────── */
/* The brand panel is the first thing to go. It is decorative, and a coach
   on a phone or in the Android shell wants the form, not the pitch. */
@media (max-width: 960px) {
  #authPage {
    padding: 0;
    overflow-y: auto;
  }

  #authPage .auth-brand { display: none; }

  #authPage .auth-shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    max-width: 460px;
    padding: 40px 18px 32px;
  }

  #authPage .auth-logo--card {
    display: flex;
    margin-bottom: 24px;
  }

  #authPage .auth-card {
    width: 100%;
    /* Auto margins, not justify-content:center. Both centre the card when
       there is room, but centring a flex child that is taller than its
       container pushes the top of it above the scroll origin, where it
       cannot be reached — and the sign-up form with its confirm field is
       taller than a short phone. Auto margins collapse to zero instead. */
    margin-block: auto;
    padding: 30px 24px 28px;
    border-radius: 24px;
    /* Keep the card readable as a card here: white paper on the sky ground
       is the landing's own figure/ground, and it survives the narrow width
       where the dark treatment could not. */
    border: 1px solid var(--fa-line);
  }

  #authPage .auth-title { font-size: 28px; }

  #authPage .auth-input {
    /* ≥16px so iOS Safari doesn't zoom the page on focus */
    font-size: 16px;
    padding: 14px 14px;
  }

  #authPage .auth-btn-google,
  #authPage .auth-btn-primary { padding: 14px 20px; }
}
