/* Studalo: sign up, log in and onboarding. One full-screen layer over the app. Values come from tokens.css only. */

.welcome {
  position: fixed; inset: 0; height: 100dvh; z-index: calc(var(--z-bar) + 10); /* over the tab bar and study, under sheets and toasts */
  background: var(--paper); overflow-y: auto; overscroll-behavior: contain;
  padding: env(safe-area-inset-top, 0px) max(var(--s-4), env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + var(--kb, 0px)) max(var(--s-4), env(safe-area-inset-left, 0px)); /* + the keyboard, so every field can scroll clear of it */
}
.welcome[data-closing] { opacity: 0; transition: opacity var(--dur-base) var(--ease-out); pointer-events: none; }

/* ── Sign up / Log in ─────────────────────────────
   One centered column: the name and one line, a Sign up | Log in switch, then the form on a card that flips
   to its other side when you switch. Nothing beside it. */
.auth { min-height: 100%; display: grid; justify-items: center; align-content: start; padding: var(--s-10) 0 var(--s-8); }
.auth-box { width: min(100%, 400px); display: grid; gap: var(--s-5); }
.auth-brand { display: grid; justify-items: center; gap: var(--s-2); margin-bottom: var(--s-2); text-align: center; }
.auth-logo { font-size: var(--fs-display); text-decoration: none; border-radius: var(--r-control); }
.auth-tag { font-size: var(--fs-callout); line-height: var(--lh-callout); }

/* Sign up | Log in: a pill that slides under the choice (concentric: r-control − 4px) */
.auth-seg { --pad: 4px; position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: var(--pad); border-radius: var(--r-control); background: var(--sunk); }
.auth-seg button { position: relative; z-index: 1; min-height: 40px; border: 0; border-radius: calc(var(--r-control) - var(--pad)); background: none; color: var(--ink-2);
  font-size: var(--fs-callout); font-weight: var(--w-semi); cursor: pointer; transition: color var(--dur-fast) ease; }
.auth-seg button[aria-pressed="true"] { color: var(--ink); }
.seg-pill { position: absolute; top: var(--pad); bottom: var(--pad); left: var(--pad); width: calc((100% - var(--pad) * 2) / 2); border-radius: calc(var(--r-control) - var(--pad));
  background: var(--surface); box-shadow: var(--shadow-low); transition: translate var(--dur-flip) var(--ease-in-out); }
.auth-seg[data-mode="login"] .seg-pill { translate: 100% 0; }

/* The card: white, raised like a flashcard. It turns over when you switch. */
.auth-card { display: grid; gap: var(--s-4); align-content: start; padding: var(--s-5); border: 1px solid var(--edge); border-radius: var(--r-card);
  background: var(--surface); box-shadow: var(--shadow-card); backface-visibility: hidden; }
.auth-alert:empty { display: none; }
.auth-form { display: grid; gap: var(--s-4); }
.auth-field { display: grid; gap: var(--s-2); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); }
.auth-legal { text-align: center; text-wrap: balance; }
/* Age: "I'm 13 or over" (a 44px-tall tap area), with "I'm under 13" beside it */
.age-field { grid-template-columns: 1fr auto; align-items: center; column-gap: var(--s-3); }
.age-field .age-check { grid-row: 1; grid-column: 1; }
.age-field .age-young { grid-row: 1; grid-column: 2; color: var(--ink-2); font-size: var(--fs-footnote); font-weight: var(--w-medium); }
.age-field .field-error { grid-row: 2; grid-column: 1 / -1; }
.age-check { display: flex; align-items: center; gap: var(--s-3); min-height: 44px; cursor: pointer; font-weight: var(--w-medium); }
.age-check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); cursor: pointer; }/* Confirm your email: one box for the code, spaced so it's easy to check against the email */
.code-head { display: flex; align-items: flex-start; gap: var(--s-3); }
.code-head > svg { width: 24px; height: 24px; flex: none; margin-top: 2px; color: var(--accent); }
.code-head b { color: var(--ink); font-weight: var(--w-semi); overflow-wrap: anywhere; }
.code-input { text-align: center; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; font-weight: var(--w-semi); }
.code-more { display: flex; justify-content: space-between; gap: var(--s-3); }
.link:disabled { color: var(--ink-2); cursor: default; }

/* Remembered on this device: your face and email, then only the password */
.auth-who { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); border-radius: var(--r-group); background: var(--sunk); }
.auth-who .avatar { width: var(--hit); height: var(--hit); }
.auth-who-text { flex: 1; min-width: 0; }
.auth-who-text > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Text buttons that read as links. The hit area grows past the text so it stays tappable. */
.link { position: relative; padding: 0; border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: var(--w-semi); cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.link::after { content: ""; position: absolute; inset: calc(var(--s-3) * -1) calc(var(--s-2) * -1); }

/* "Continue with Google": Google's light theme (white, 1px inside stroke, dark text, the standard G at full color) */
.btn-google { gap: var(--s-3); background: var(--surface); color: var(--google-ink); box-shadow: inset 0 0 0 1px var(--google-line); }
.btn-google img { width: 20px; height: 20px; flex: none; }
.btn-google:active { background: color-mix(in oklab, var(--surface), var(--google-ink) 6%); }
@media (hover: hover) and (pointer: fine) { .btn-google:hover { background: color-mix(in oklab, var(--surface), var(--google-ink) 4%); } }

.auth-or { display: flex; align-items: center; gap: var(--s-3); color: var(--ink-2); font-size: var(--fs-footnote); line-height: var(--lh-footnote); }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Password: show/hide inside the field, the rule up front, a Caps Lock warning */
.pw { position: relative; display: grid; gap: var(--s-2); }
.pw .field { padding-right: calc(var(--hit) + var(--s-1)); }
.pw-toggle { position: absolute; top: 2px; right: 2px; width: var(--hit); height: var(--hit); display: grid; place-items: center; padding: 0; border: 0;
  border-radius: calc(var(--r-control) - 2px); background: none; color: var(--ink-2); cursor: pointer; transition: transform var(--dur-press) var(--ease-out); }
.pw-toggle:active { transform: scale(0.92); }
.pw-toggle svg { width: 20px; height: 20px; }
@media (hover: hover) and (pointer: fine) { .pw-toggle:hover { color: var(--ink); } }
.pw-rule, .caps { display: flex; align-items: center; gap: var(--s-1); margin-top: calc(var(--s-1) * -1); font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: var(--w-medium); }
.pw-rule { color: var(--ink-2); transition: color var(--dur-fast) ease; }
.pw-rule svg, .caps svg { width: 16px; height: 16px; flex: none; }
.pw-rule[data-met] { color: var(--good); }
.auth-field:has([aria-invalid="true"]) .pw-rule { display: none; } /* the error says it instead */
.caps { color: var(--again); }

/* "Did you mean …@gmail.com?" */
.suggest { justify-self: start; display: inline-flex; flex-wrap: wrap; gap: 0 var(--s-1); margin: calc(var(--s-2) * -1) 0 0 calc(var(--s-2) * -1); padding: var(--s-2);
  border: 0; border-radius: var(--r-chip); background: none; color: var(--ink-2); font-size: var(--fs-footnote); line-height: var(--lh-footnote); text-align: left; cursor: pointer; }
.suggest b { color: var(--accent-text); font-weight: var(--w-semi); }
@media (hover: hover) and (pointer: fine) { .suggest:hover { background: var(--sunk); } }
a.link { text-decoration: none; }

/* Tablets and desktop: the same column in the middle of the screen, with more room inside the card */
@media (min-width: 720px) {
  .auth { align-content: center; }
  .auth-box { width: min(100%, 420px); }
  .auth-card { padding: var(--s-8); border-radius: var(--r-sheet); }
}

/* Desktop: two sides. Left: what Studalo is, in big type on Mauve. Right: the form. Phones and tablets: the form only. */
.auth-side { display: none; }
@media (min-width: 1024px) {
  .welcome:has(.auth) { padding: 0; }
  .auth { align-content: stretch; grid-template-rows: minmax(100dvh, auto); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; justify-items: stretch; padding: 0; min-height: 100%; }
  .auth-side { display: flex; flex-direction: column; justify-content: space-between; gap: var(--s-10); padding: var(--s-10) var(--s-16) var(--s-12);
    background: var(--accent); color: var(--on-accent); }
  .auth-side-logo { align-self: flex-start; font-size: var(--fs-title-1); text-decoration: none; }
  .auth-side-logo .wordmark { color: var(--on-accent); }
  .auth-side-logo .wordmark-s-top { stroke: var(--brand-pale); }
  .auth-side-logo .wordmark-s-bot { stroke: var(--on-accent); }
  .auth-side-title { margin: 0; max-width: 14ch; font-size: var(--fs-hero-2); line-height: var(--lh-hero-2); letter-spacing: var(--tr-hero-2); font-weight: var(--w-bold); }
  .auth-side-list { display: grid; gap: var(--s-4); margin: 0; padding: 0; list-style: none; font-size: var(--fs-headline); font-weight: var(--w-medium); }
  .auth-side-list li { display: flex; align-items: center; gap: var(--s-3); }
  .auth-side-list svg { width: 22px; height: 22px; flex: none; opacity: 0.8; }
  /* The three cards from the home page's last section, dealt onto the Mauve as you arrive */
  .auth-side-mid { display: grid; gap: var(--s-10); }
  .auth-fan { --spread: 104px; position: relative; width: calc(var(--spread) * 2 + 148px); height: 108px; }
  .auth-fan span { position: absolute; left: 50%; top: var(--s-3); width: 148px; height: 92px; margin-left: -74px; display: grid; place-items: center; padding: var(--s-2);
    border-radius: var(--r-control); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); font-size: var(--fs-headline); font-weight: var(--w-semi);
    transform: translateX(calc((var(--i) - 1) * var(--spread))) rotate(var(--r));
    animation: auth-deal var(--dur-reveal) var(--ease-pop) both; animation-delay: calc(120ms + var(--i) * 90ms); }
  .auth-fan span:nth-child(2) { z-index: 1; top: 0; }
  .auth-box { align-self: center; justify-self: center; width: min(100% - var(--s-16), 400px); padding: var(--s-10) 0; }
  .auth-box .auth-brand { display: none; } /* the left side says it */
  .auth-card { padding: 0; border: 0; background: none; box-shadow: none; }
}
/* ── Onboarding ─────────────────────────────────── */
.welcome:has(.ob) { overflow: hidden; }
.ob { width: 100%; max-width: 560px; height: 100%; margin-inline: auto; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.ob-top { display: grid; grid-template-columns: var(--hit) minmax(0, 1fr) minmax(var(--hit), auto); align-items: center; gap: var(--s-3); height: 56px; }
.ob-top [data-hide] { visibility: hidden; }
.ob-progress { height: 6px; }
.ob-body { --pad: var(--s-4); min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin-inline: calc(var(--s-4) * -1); padding: var(--s-4) var(--s-4) calc(var(--s-6) + var(--kb, 0px)); }
.ob-step { display: grid; gap: var(--s-6); align-content: start; }
.ob-head { display: grid; gap: var(--s-2); }
.ob-title:focus { outline: none; } /* focus moves here for screen readers when a step opens */
.ob-foot { display: grid; gap: var(--s-3); padding: var(--s-3) 0 var(--s-4); background: var(--paper);
  translate: 0 calc(var(--kb, 0px) * -1); } /* rides above the on-screen keyboard, like sheets */
.ob-foot .swipe-hint { margin-top: calc(var(--s-1) * -1); }

/* Your name and face: the face is drawn from your name until you choose a look */
.ob-me { display: grid; justify-items: center; gap: var(--s-1); }
.ob-me .btn-quiet { min-height: 36px; font-size: var(--fs-callout); }
.ob-me .btn-quiet svg { width: 18px; height: 18px; }
/* Your look */
.ob-look { display: grid; justify-items: center; gap: var(--s-3); }
.ob-look .t-title-3 { min-height: var(--lh-title-3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-av { width: 112px; height: 112px; }
.ob-rows { display: grid; gap: var(--s-4); }

/* Subjects: pick any; each becomes a folder */
.subj-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
@media (min-width: 560px) { .subj-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.subj { display: flex; align-items: center; gap: var(--s-3); min-width: 0; min-height: var(--hit-lg); padding: 0 var(--s-3); border: 0; border-radius: var(--r-control);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge), var(--shadow-low); color: var(--ink); font-size: var(--fs-callout); font-weight: var(--w-semi); text-align: left; cursor: pointer;
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.subj:active { transform: scale(var(--press-scale)); }
.subj > svg { width: 22px; height: 22px; flex: none; color: var(--ink-2); transition: color var(--dur-fast) ease; }
.subj-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subj-check { width: 20px; height: 20px; flex: none; display: grid; place-items: center; border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent);
  opacity: 0; transform: scale(0.6); transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.subj-check svg { width: 14px; height: 14px; }
.subj[aria-pressed="true"] { background: var(--accent-tint); color: var(--accent-text); box-shadow: inset 0 0 0 1.5px var(--accent); }
.subj[aria-pressed="true"] > svg { color: var(--accent-text); }
.subj[aria-pressed="true"] .subj-check { opacity: 1; transform: none; }
.subj-add { background: none; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--accent-text); }
.subj-add > svg { color: var(--accent-text); }
.subj-add[aria-expanded="true"] { background: var(--sunk); box-shadow: none; }
.subj.is-new { animation: pop var(--dur-sheet) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .subj:hover:not([aria-pressed="true"]) { background: color-mix(in oklab, var(--surface), var(--ink) 3%); } }
.subj-new { display: flex; gap: var(--s-2); }
.subj-new .field { flex: 1; min-width: 0; }
.subj-new-wrap { display: grid; gap: var(--s-2); }

/* Swipe the card: the real study card. Swiping is the lesson; the labels under it light up as you swipe (and can be tapped). */
.ob-coach { min-height: calc(var(--lh-body) * 2); }
.ob-stage .flash { height: clamp(240px, 46dvh, 380px); }
.guides { display: flex; justify-content: space-between; gap: var(--s-3); margin-top: calc(var(--s-3) * -1); }
.guide { display: inline-flex; align-items: center; gap: var(--s-1); min-height: var(--hit); padding: 0 var(--s-3); border: 0; border-radius: var(--r-pill);
  background: none; color: var(--ink-2); font-size: var(--fs-callout); font-weight: var(--w-semi); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-press) var(--ease-out); }
.guide svg { width: 18px; height: 18px; flex: none; }
.guide:active { transform: scale(var(--press-scale)); }
.guide[data-g="-1"][data-armed] { background: var(--again-tint); color: var(--again); }
.guide[data-g="1"][data-armed] { background: var(--accent-tint); color: var(--accent-text); }
@media (hover: hover) and (pointer: fine) { .guide:hover:not([data-armed]) { background: var(--sunk); color: var(--ink); } }
@media (hover: hover) and (pointer: fine) and (min-width: 720px) { .guide svg { display: none; } } /* the ← → keys say it */

/* Reminder: one a day at most */
.ob-choices .row { min-height: 64px; }
.ob-choices .row[aria-checked="true"] { background: var(--accent-tint); }
.ob-choices .row[aria-checked="true"] .row-icon { color: var(--accent-text); }
.ob-choices [aria-checked="true"] .check { background: var(--accent); border-color: var(--accent); }
.ob-choices [aria-checked="true"] .check svg { opacity: 1; }

/* A step that ends something: centered, in the middle of the screen on phones */
.ob-body:has(.ob-done, .ob-center) { display: grid; align-content: safe center; }
.ob-center { justify-items: center; text-align: center; padding-top: var(--s-4); }
.ob-center p { max-width: 34ch; }

/* All set: your face pops, pieces burst, your folders are dealt in */
.ob-done { display: grid; justify-items: center; gap: var(--s-2); text-align: center; padding-top: var(--s-4); }
.ob-done-hero { position: relative; display: grid; place-items: center; margin-bottom: var(--s-4); }
.ob-done .ob-av { position: relative; z-index: 1; animation: pop var(--dur-sheet) var(--ease-out) both; }
.ob-done-hero .burst { top: 50%; }
.ob-done-hero .burst i { animation-delay: calc(120ms + var(--d)); } /* design-ok: start delay staging the celebration; each motion is ≤ --dur-sheet */
.ob-done > h1, .ob-done > p { animation: ms-rise var(--dur-base) var(--ease-out) both; animation-delay: 160ms; } /* design-ok: start delay; lands after the face */
.ob-done-actions { display: grid; gap: var(--s-2); }
/* What's ready, said back to you: folders, your first set, your reminder */
.ob-sum { display: grid; gap: var(--s-2); width: min(100%, 24rem); margin: var(--s-3) 0 0; padding: 0; list-style: none; text-align: left; }
.ob-sum li { display: flex; align-items: center; gap: var(--s-3); min-height: 48px; padding: var(--s-2) var(--s-4); border-radius: var(--r-control);
  background: var(--surface); box-shadow: var(--shadow-low); font-size: var(--fs-callout); line-height: var(--lh-callout); color: var(--ink-2);
  animation: deal var(--dur-base) var(--ease-out) both; animation-delay: calc(260ms + var(--i) * 60ms); } /* design-ok: start delay staging the celebration; each motion is ≤ --dur-base */
.ob-sum b { color: var(--ink); font-weight: var(--w-semi); }
.ob-sum svg { width: 20px; height: 20px; flex: none; color: var(--accent-text); }

/* Tablets and desktop: the button follows the content instead of sitting at the bottom of a tall screen */
@media (min-width: 720px) {
  .welcome:has(.ob) { overflow-y: auto; }
  .ob { height: auto; min-height: 100%; grid-template-rows: auto auto 1fr; }
  .ob-body { overflow: visible; margin-inline: 0; padding: var(--s-10) 0 0; }
  .ob-foot { align-self: start; padding-top: var(--s-8); translate: none; }
  .ob-done-actions { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) .ob-done .ob-av, :root:not([data-motion="full"]) .ob-done > *,
  :root:not([data-motion="full"]) .ob-sum li,
  :root:not([data-motion="full"]) .subj.is-new { animation: ms-fade var(--dur-fast) ease both; }
  :root:not([data-motion="full"]) .seg-pill { transition: none; }
  :root:not([data-motion="full"]) .subj:active, :root:not([data-motion="full"]) .pw-toggle:active, :root:not([data-motion="full"]) .guide:active { transform: none; }
  :root:not([data-motion="full"]) .auth-fan span { animation: ms-fade var(--dur-fast) ease both; }
}
@keyframes auth-deal { from { opacity: 0; transform: translateY(48px) scale(0.9); } }
