/* The account page. Everything structural, every colour and the type stack
   come from site.css - this file only holds what is specific to signing in.
   It used to carry its own palette (`light-dark(#f6f5f1, #181a18)`, a green
   button) and its own `color-scheme`, which meant two things: the page
   followed the OS rather than the theme the user picked with the toggle, and
   its primary button was a different colour from every other button on the
   site. Both are gone. Reference tokens here, never hex. */

/* site.css lays out `main` as a centred flex column, which is what both
   states below want - a narrow card, or a settings column. The account
   column's width is declared here, next to the rule that consumes it, so the
   .pageIntro above the cards lines up with them (see site.css). */
:root { --page-width: 640px; }

/* An explicit display in a stylesheet beats the UA's [hidden] rule, so every
   panel here that is display:flex/grid AND toggled by the hidden attribute
   would render anyway. This puts hidden back in charge. */
[hidden] { display: none !important; }

/* ---- shared furniture --------------------------------------------------
   Matched to the cards and controls the rest of the site already uses
   (see learning.css, today.html): --panel on --bg, 14px radius, controls on
   --panel-alt with a --border-strong outline. */
.authCard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px 26px;
  box-shadow: var(--shadow-md);
}

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--sunken);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 11px 12px;
}
.field input::placeholder { color: var(--text-faint); }
.field input:hover { border-color: var(--border-mid); }

/* The site's press button (see .pressBtn in site.css), applied to every
   button on this page rather than to an opt-in class, because every control
   here is one. */
button {
  font: inherit;
  color: var(--text-dim);
  background: var(--panel);
  border: 2px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: 13px 22px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 4px 0 var(--border-strong);
  cursor: pointer;
  transition: filter 0.12s ease;
}
button:active { transform: translateY(4px); box-shadow: 0 0 0 var(--border-strong); }
button:hover:not(:disabled) { filter: brightness(0.97); }
button:disabled { opacity: .5; cursor: default; transform: none; }
.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 4px 0 var(--accent-edge);
}
.primary:active { box-shadow: 0 0 0 var(--accent-edge); }
/* A button that has to read as text: "Create one", "Forgot your password?".
   Styled down rather than up, because the page has exactly one primary action
   and everything else competing with it is noise. */
.link {
  background: transparent;
  border-color: transparent;
  color: var(--accent-link);
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link:hover:not(:disabled) { background: transparent; border-color: transparent; color: var(--accent); }
.link:active { transform: none; box-shadow: none; }
.quiet {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
  font-size: 12px;
  padding: 9px 16px;
  box-shadow: 0 3px 0 var(--border-strong);
}
.quiet:active { box-shadow: 0 0 0 var(--border-strong); }
.quiet:hover:not(:disabled) { background: var(--panel-alt); color: var(--text); }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.field input:focus-visible { outline-offset: 0; border-color: var(--accent); }

/* ---- feedback ----------------------------------------------------------
   One banner per thing that can go wrong, rendered next to the form that
   caused it. The page used to have a single #status line under the title
   carrying every message on the page, so a password error appeared a long way
   from the password field - and the page's first paint was the sentence
   "Loading sign-in...". #status is still here, for the page-level problems
   that belong to no single form (sign-in unavailable, session expired). */
.feedback {
  font-size: 13.5px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--sunken);
  color: var(--text-dim);
  overflow-wrap: anywhere;
}
.feedback[data-error="true"] {
  background: var(--bad-tint);
  color: var(--bad-tint-fg);
}
#status { margin: 0 auto 20px; width: 100%; max-width: var(--page-width); }
.cardFeedback { margin-top: 16px; }

/* ---- the first paint ---------------------------------------------------
   The SDK is fetched after /api/auth/config answers, so there is a real wait
   here. A skeleton the shape of the card that is coming, rather than a line of
   body copy announcing the wait. */
#loading { width: 100%; max-width: 420px; margin: 0 auto; }
.skelLine {
  height: 13px;
  border-radius: 7px;
  background: var(--track);
  animation: skelPulse 1.4s ease-in-out infinite;
}
.skelLine + .skelLine { margin-top: 14px; }
.skelLine.tall { height: 42px; border-radius: 8px; }
.skelLine.short { width: 38%; }
@keyframes skelPulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) {
  .skelLine { animation: none; }
}

/* ---- signed out: the front door ---------------------------------------
   A narrow centred column with the mark above it. This is the one screen on
   the site a stranger may land on first, so it gets the hero treatment that
   index.html gets rather than the .pageIntro every interior page shares. */
#signed-out { width: 100%; max-width: 420px; margin: 0 auto; position: relative; }
/* The same warm band the landing page opens with, so arriving at /auth from
   the site does not feel like leaving it. It is painted on <main> rather than
   on the card, because a 420px-wide wash is a glow, not weather. */
body.authSignedOut main { background: var(--grad-wash); }
#signed-out .confetti.p1 { top: 34px; left: -58px; }
#signed-out .confetti.p2 { top: 128px; right: -52px; width: 14px; height: 14px; }
#signed-out .confetti.p3 { top: 286px; left: -66px; transform: rotate(-32deg); }
#signed-out .confetti.p4 { bottom: 150px; right: -58px; }
#signed-out .confetti.p5 { bottom: 54px; left: -48px; width: 19px; height: 19px; }
/* The field has to be allowed outside the 420px column, and on a narrow
   screen there is no outside, so it goes away. */
#signed-out .confettiField { overflow: visible; }
@media (max-width: 560px) { #signed-out .confettiField { display: none; } }
.authHero { text-align: center; margin-bottom: 22px; }
.authHeroMark {
  height: 104px; width: auto; display: block; margin: 0 auto 10px;
  filter: drop-shadow(0 10px 20px var(--shadow));
  animation: authBob 5s ease-in-out infinite;
}
@keyframes authBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) { .authHeroMark { animation: none; } }
.authHero h1 {
  font-size: 29px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 8px;
}
.authHero p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
}
#credentials .primary, #signup .primary { width: 100%; margin-top: 4px; }
.formFoot { margin-top: 14px; text-align: center; font-size: 13px; }

/* Paw prints walking up to the one remaining decision, the same ornament the
   landing page uses ahead of its call to action. */
.authSwitch {
  margin-top: 24px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-muted);
}
.authSwitch .pawTrail { margin-bottom: 14px; gap: 13px; }

/* ---- signed in: the account page -------------------------------------- */
#signed-in { width: 100%; max-width: var(--page-width); margin: 0 auto; }
#signed-in .authCard + .authCard { margin-top: 16px; }
.cardHead {
  display: flex;
  align-items: center;
  gap: 13px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.cardHead h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--text-bright);
}
.cardNote {
  margin: 10px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
}
/* The value a card is about - the email, the linked username - set apart from
   the prose around it so the card answers its own question at a glance. */
.cardValue {
  margin: 14px 0 0;
  padding: 11px 13px;
  background: var(--sunken);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cardValue strong { font-weight: 650; color: var(--text-bright); }
.cardForm { margin-top: 16px; }
.cardForm .field:last-of-type { margin-bottom: 18px; }
/* Every actions row on this page follows the block it acts on, so the gap
   above it belongs to the row rather than to each use site. */
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
/* "Continue to Chesster" is a link, not a button, but it is the primary action
   of its card - so .primary has to carry the shape the `button` rule above
   gives buttons for free. */
a.primary {
  display: inline-flex; align-items: center;
  font: inherit; font-size: 14px; font-weight: 800;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 13px 22px;
  border-radius: var(--r-xl);
  border: 2px solid var(--accent);
  text-decoration: none;
}

/* The inline name entry is one row: the name and the button that checks it. */
.inlineField { display: flex; gap: 10px; align-items: flex-end; }
.inlineField .field { flex: 1; min-width: 0; margin-bottom: 0; }

@media (max-width: 720px) {
  .authCard { padding: 20px 18px; }
  .authHeroMark { height: 76px; }
  .inlineField { display: block; }
  .inlineField .field { margin-bottom: 14px; }
}

/* ---- after sign-up: the onboarding questions ---------------------------
   A native <dialog>, so focus trapping, Escape and the backdrop come from the
   browser. Answers are chips (radio/checkbox inputs under a label) rather than
   dropdowns: every option is visible and one tap picks it. */
.onboarding {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: auto;
}
.onboarding::backdrop { background: rgb(0 0 0 / .45); }
.onboarding h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text-bright);
}
.onboarding .cardNote { margin: 6px 0 18px; }
/* showModal() focuses the title rather than the first chip, whose focus ring
   would read as a second selection. */
.onboarding h2:focus { outline: none; }
.ask { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.ask legend {
  padding: 0;
  margin-bottom: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}
.ask legend em { font-style: normal; font-weight: 500; color: var(--text-faint); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-block;
  padding: 8px 13px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--panel-alt);
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  transition: background .12s ease, border-color .12s ease;
}
.chip:hover span { border-color: var(--border-mid); }
.chip input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.askRow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.askHint { display: block; min-height: 1.3em; margin-top: 5px; font-size: 12px; color: var(--text-faint); }
.field select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--sunken);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 11px 12px;
}
.onboardingActions { justify-content: space-between; margin-top: 6px; }
@media (max-width: 520px) {
  .askRow { grid-template-columns: 1fr; gap: 0; }
}
