/* ============ FizzyQuiz new UI: one layer over every page ============
   Loaded last (after theme.css), so every page picks up the same pieces: clean type, soft cards, pill buttons,
   a calm top bar, segmented tabs, flat quiz answers and spring motion. Colours come from theme.css tokens,
   so white and dark both work. Rules that must beat styles injected by js files start with :root. */

:root {
  --r-card: 22px;
  --r-row: 18px;
  --r-ctl: 14px;
  --spring-soft: cubic-bezier(.22, 1, .36, 1);
  --press: cubic-bezier(.3, 0, .2, 1);
  --ring-focus: 0 0 0 3px color-mix(in srgb, var(--brand) 26%, transparent);
  --hair: inset 0 0 0 1px var(--line);
}
:root[data-theme="dark"] { --ring-focus: 0 0 0 3px color-mix(in srgb, var(--brand-2) 40%, transparent); }

/* ---------- type ---------- */
body { font-feature-settings: "ss01", "cv11"; text-rendering: optimizeLegibility; }
h1 { font-family: var(--ui); font-weight: 700; letter-spacing: -.035em; line-height: 1.05; }
h2, h3 { letter-spacing: -.025em; }
.page-head h1 { font-size: clamp(1.9rem, 3.4vw, 2.6rem); }
.section-title { font-size: 1.12rem; font-weight: 700; letter-spacing: -.02em; color: var(--ink); margin: 32px 0 12px; }
.section-title a { font-size: .88rem; font-weight: 600; color: var(--muted); transition: color .2s; }
.section-title a:hover { color: var(--ink); }
.eyebrow { color: var(--muted); font-weight: 600; letter-spacing: .1em; }
.muted { color: var(--muted); }
::selection { background: color-mix(in srgb, var(--brand) 22%, transparent); }
:focus-visible { outline: none; box-shadow: var(--ring-focus) !important; }

/* ---------- page motion: rise in with a soft blur ---------- */
.view { animation: ui-view .55s var(--spring-soft) both; }
@keyframes ui-view { from { opacity: 0; transform: translateY(10px); filter: blur(6px); } }
.stagger > * { animation: ui-rise .6s var(--spring-soft) both; }
@keyframes ui-rise { from { opacity: 0; transform: translateY(14px) scale(.985); filter: blur(4px); } }

/* ---------- buttons: pills with a soft press ---------- */
/* Primary is a black pill in white mode (a white pill in dark mode), as on the reference designs. Blue stays the accent. */
.btn { border-radius: 999px; padding: 12px 22px; font-weight: 600; letter-spacing: -.01em; gap: 8px;
  background: var(--ink); color: var(--bg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 1px 2px rgba(15,17,21,.16), 0 8px 18px -10px rgba(15,17,21,.5);
  transition: transform .2s var(--spring-soft), box-shadow .2s, background .2s, filter .2s; }
.btn:hover { filter: none; transform: translateY(-1px); background: color-mix(in srgb, var(--ink) 86%, var(--bg));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 2px 4px rgba(15,17,21,.14), 0 14px 26px -12px rgba(15,17,21,.55); }
.btn:active { transform: scale(.97); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 1px rgba(15,17,21,.12); transition-duration: .08s; }
:root[data-theme="dark"] .btn:not(.ghost):not(.good) { box-shadow: inset 0 -1px 0 rgba(0,0,0,.12), 0 8px 18px -10px rgba(0,0,0,.8); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 0; box-shadow: var(--hair), 0 1px 2px rgba(15,17,21,.05); }
.btn.ghost:hover { background: var(--well); border-color: transparent; box-shadow: var(--hair), 0 4px 12px -6px rgba(15,17,21,.12); }
.btn.ghost:active { transform: scale(.97); box-shadow: var(--hair); }
.btn.good { background: var(--good); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 6px 16px -6px color-mix(in srgb, var(--good) 60%, transparent); }
.btn.lg { padding: 15px 28px; font-size: 1.08rem; border-radius: 999px; }
.btn.sm { padding: 8px 14px; font-size: .88rem; border-radius: 999px; }
.btn .i { width: 18px; height: 18px; transition: transform .25s var(--spring-soft); }
.btn:hover .i:last-child { transform: translateX(2px); }
:root[data-theme="dark"] .btn.ghost { background: var(--well); }
:root[data-theme="dark"] .btn.ghost:hover { background: var(--well-2); }

/* ---------- cards and rows ---------- */
.card { border-radius: var(--r-card); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(15,17,21,.04); }
a.card, button.card, .mode-card, .lvl-tile { transition: transform .3s var(--spring-soft), box-shadow .3s, border-color .3s; }
a.card:hover, button.card:hover, .mode-card:hover, .lvl-tile:hover { transform: translateY(-3px); border-color: var(--line-2); box-shadow: 0 1px 2px rgba(15,17,21,.04), 0 18px 40px -18px rgba(15,17,21,.18); }
a.card:active, button.card:active, .mode-card:active, .lvl-tile:active { transform: scale(.985); transition-duration: .1s; }
.mode-card .ico, .list-row .ico { background: var(--well); }
.mode-card .ico .i { color: var(--ink); }
.lvl-tile { border-radius: var(--r-row); }

.list-row { border-radius: var(--r-row); padding: 14px 16px; border: 1px solid var(--line); box-shadow: none; gap: 14px; }
.list-row:hover { transform: translateY(-2px); border-color: var(--line-2); box-shadow: 0 14px 30px -16px rgba(15,17,21,.18); }
.list-row:active { transform: scale(.99); }
.list-row .ico { width: 44px; height: 44px; border-radius: 13px; }
.list-row b { font-weight: 600; letter-spacing: -.01em; }
.list-row .chev { color: var(--line-2); }
.list-row:hover .chev { color: var(--ink); }
:root[data-theme="dark"] .card:hover, :root[data-theme="dark"] .list-row:hover { box-shadow: 0 18px 40px -18px rgba(0,0,0,.8); }

/* ---------- pills, tags, progress ---------- */
.tag { background: var(--well); color: var(--ink-2); font-weight: 600; padding: 4px 10px; }
.pill { box-shadow: var(--hair); background: var(--surface); font-weight: 600; }
.bar { height: 10px; background: var(--well); box-shadow: inset 0 1px 1px rgba(15,17,21,.05); }
.bar > i { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 75%, #fff), var(--brand)); position: relative; overflow: hidden;
  animation: grow 1.1s var(--spring-soft) both; }
.bar > i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); transform: translateX(-100%); animation: ui-sheen 2.6s ease-in-out 1.1s infinite; }
@keyframes ui-sheen { 0% { transform: translateX(-100%); } 40%, 100% { transform: translateX(120%); } }

/* ---------- segmented tabs: a white pill on a grey track ---------- */
.tabs { background: var(--well); border: 0; border-radius: 14px; padding: 4px; gap: 2px; }
.tabs button { border-radius: 10px; font-weight: 600; color: var(--muted); transition: color .2s, background .25s var(--spring-soft), box-shadow .25s; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15,17,21,.08), 0 2px 8px -2px rgba(15,17,21,.08); }
:root[data-theme="dark"] .tabs button[aria-pressed="true"] { background: var(--well-2); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, 0 2px 8px rgba(0,0,0,.4); }

/* ---------- inputs ---------- */
.field input, .field select, .field textarea, .type-row input { border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface); transition: border-color .2s, box-shadow .2s, background .2s; }
.field input:focus, .field select:focus, .field textarea:focus, .type-row input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring-focus); }

/* ---------- home hero: white, with a soft colour glow ---------- */
.hero { color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 1px 2px rgba(15,17,21,.04), 0 30px 60px -36px rgba(15,17,21,.18); isolation: isolate; }
.hero::before { content: ""; position: absolute; inset: -40% -10% auto auto; width: 70%; aspect-ratio: 1; z-index: -1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%), radial-gradient(closest-side at 30% 70%, color-mix(in srgb, #a855f7 12%, transparent), transparent 70%);
  animation: ui-glow 14s ease-in-out infinite alternate; }
@keyframes ui-glow { to { transform: translate(-8%, 10%) scale(1.1) rotate(20deg); } }
.hero h1 { color: var(--ink); }
.hero p { color: var(--muted); opacity: 1; }
.hero .blob { display: none; }
.hero .btn { background: var(--ink); color: var(--bg); box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 8px 18px -10px rgba(15,17,21,.5); }
.hero .btn.ghost { background: var(--surface); color: var(--ink); border: 0; box-shadow: var(--hair); }
.hero .btn.ghost:hover { background: var(--well); }
.ring .track { stroke: var(--well-2); }
.ring .val { stroke: var(--brand); transition: stroke-dashoffset 1.4s var(--spring-soft); }
.ring b { color: var(--ink); letter-spacing: -.03em; }
.ring small { color: var(--muted); opacity: 1; }
.ring.lit::before { background: color-mix(in srgb, #f97316 10%, var(--surface)); }
.streak-stat > div:last-child small { color: var(--muted); opacity: 1; }
:root[data-theme="dark"] .hero { background: linear-gradient(180deg, var(--surface), var(--bg)); box-shadow: 0 30px 60px -36px rgba(0,0,0,.9); }

/* ---------- game cards ---------- */
.game-card { border-radius: var(--r-card); box-shadow: 0 1px 2px rgba(15,17,21,.06); transition: transform .4s var(--spring-soft), box-shadow .4s; }
.game-card:hover { transform: translateY(-4px) scale(1.01); box-shadow: 0 30px 50px -24px rgba(15,17,21,.45); }
.game-card canvas { transition: transform .9s var(--spring-soft); }
.game-card .play-dot { box-shadow: 0 6px 16px rgba(0,0,0,.25); }

/* ---------- quiz ---------- */
/* Tick progress bar: thin ticks, dark where done, grey where not; the newest tick pops taller. */
.quiz-top .bar { height: 24px; border-radius: 0; background: transparent; box-shadow: none; overflow: visible; position: relative;
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 3px, transparent 3px 7px); mask: repeating-linear-gradient(90deg, #000 0 3px, transparent 3px 7px); }
.quiz-top .bar::before { content: ""; position: absolute; inset: 4px 0; background: var(--line-2); border-radius: 2px; }
.quiz-top .bar > i { position: relative; z-index: 1; height: 100%; background: var(--ink); border-radius: 0; transition: width .6s var(--spring-soft);
  clip-path: inset(4px 0 4px 0); animation: none; }
.quiz-top .bar > i::after { left: auto; right: 0; width: 12px; transform: none; background: var(--brand); animation: none; inset: 0 0 0 auto; }
.q-card { border-radius: 26px; padding: 32px; animation: ui-q-in .5s var(--spring-soft) both; }
@keyframes ui-q-in { from { opacity: 0; transform: translateX(28px); filter: blur(4px); } }
.q-card.out { animation: ui-q-out .28s var(--press) both; }
@keyframes ui-q-out { to { opacity: 0; transform: translateX(-24px); filter: blur(4px); } }
.q-kind { color: var(--muted); font-weight: 600; }
.q-text { font-weight: 600; letter-spacing: -.025em; }
.passage { background: var(--well); }
.choice { border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(15,17,21,.04); font-weight: 500; transition: transform .2s var(--spring-soft), border-color .2s, background .2s, box-shadow .2s; }
.choice:hover { border-color: var(--line-2); background: var(--well); transform: translateY(-1px); }
.choice:active { transform: scale(.98); box-shadow: none; transition-duration: .08s; }
.choice .k { border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--muted); font-weight: 600; transition: all .2s var(--spring-soft); }
.choice:hover .k { border-color: var(--ink); color: var(--ink); }
.choice.right { border-color: color-mix(in srgb, var(--good) 60%, transparent); background: var(--good-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 14%, transparent); animation: ui-pop .45s var(--spring) both; }
.choice.wrong { border-color: color-mix(in srgb, var(--bad) 60%, transparent); background: var(--bad-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 12%, transparent); }
.choice.right .k, .choice.wrong .k { border-color: transparent; }
.choice.dim { opacity: .45; filter: saturate(.4); }
@keyframes ui-pop { 40% { transform: scale(1.025); } }
.feedback { border-radius: 18px; animation: ui-rise .45s var(--spring-soft) both; }
:root[data-theme="dark"] .feedback.right { color: #86efac; }
:root[data-theme="dark"] .feedback.wrong { color: #fda4af; }
.results .big-emoji { animation: ui-float 3s ease-in-out infinite; }
@keyframes ui-float { 50% { transform: translateY(-6px) rotate(-3deg); } }
.result-stats div { background: var(--well); border-radius: 18px; }
.result-stats b { letter-spacing: -.03em; }

/* ---------- toasts ---------- */
/* Stacked toasts: a white card; older ones tuck in behind it, smaller and fainter. */
#toasts { display: grid; justify-items: center; }
.toast { grid-area: 1 / 1; border-radius: 16px; background: var(--surface); color: var(--ink); font-weight: 600; padding: 12px 18px 12px 14px;
  box-shadow: 0 0 0 1px var(--line), 0 10px 28px -6px rgba(15,17,21,.14); animation: ui-toast .55s var(--spring) both;
  transition: transform .45s var(--spring-soft), opacity .35s, filter .35s; }
.toast small { color: var(--muted); opacity: 1; }
.toast .e .i { color: var(--brand); }
.toast:not(:last-child) { transform: translateY(-10px) scale(.94); opacity: .6; }
.toast:not(:last-child):not(:nth-last-child(2)) { transform: translateY(-20px) scale(.88); opacity: .3; }
.toast:nth-last-child(n+4) { opacity: 0; }
@keyframes ui-toast { from { opacity: 0; transform: translateY(24px) scale(.9); filter: blur(4px); } }
:root[data-theme="dark"] .toast { background: var(--well); box-shadow: 0 0 0 1px var(--line-2), 0 14px 30px -8px rgba(0,0,0,.8); }

/* ---------- top bar (styles injected by js/topnav.js, so these start with :root) ---------- */
:root .tn { padding-top: 10px; padding-bottom: 10px; border-bottom-color: color-mix(in srgb, var(--line) 70%, transparent) !important; }
:root .tn-menus { gap: 2px; }
:root .tn-btn { font-weight: 500; color: var(--ink-2); padding: 8px 13px; border-radius: 999px; transition: background .2s, color .2s; }
:root .tn-btn:hover, :root .tn-btn[aria-expanded="true"] { background: var(--well); color: var(--ink); }
:root .tn-menu.on .tn-btn { color: var(--ink); background: var(--well); font-weight: 600; }
:root .tn-drop { border-radius: 20px; padding: 6px; border-color: var(--line); transform-origin: top center; animation: ui-drop .28s var(--spring-soft) both; }
:root .tn-me-drop, :root .tn-all { transform-origin: top right; }
@keyframes ui-drop { from { opacity: 0; scale: .96; translate: 0 -6px; filter: blur(4px); } }
:root .tn-row { border-radius: 14px; padding: 9px 10px; transition: background .15s; }
:root .tn-row:hover, :root .tn-row[aria-current] { background: var(--well); }
:root .tn-row[aria-current] .tn-letter { background: var(--ink); color: var(--bg); }
:root .tn-letter { border-radius: 10px; font-weight: 700; background: var(--well) !important; }
:root .tn-row:hover .tn-letter { background: var(--surface) !important; box-shadow: var(--hair); }
:root .tn-row[aria-current] .tn-letter { background: var(--ink) !important; }
:root .tn-pill { border: 0; box-shadow: var(--hair); background: var(--surface); font-weight: 700; transition: background .2s, transform .2s var(--spring-soft); }
:root .tn-pill:hover { background: var(--well); }
:root .tn-me { border: 0; box-shadow: var(--hair); background: var(--surface); transition: background .2s; }
:root .tn-me:hover { background: var(--well); }
:root .tn-q { border-radius: 999px !important; transition: background .2s, box-shadow .2s; }
:root .tn-q:focus-within { box-shadow: var(--ring-focus); }
:root .tn-stats { border: 0; background: var(--well) !important; border-radius: 16px; }
:root .tn-stat { border: 0; box-shadow: var(--hair); border-radius: 12px; }
:root .tn-link { border: 0; box-shadow: var(--hair); border-radius: 12px; transition: background .15s; }
:root .tn-link:hover { background: var(--well); }
:root .tn-burger { border: 0; box-shadow: var(--hair); border-radius: 12px; }
:root .shop-switch a { border: 1px solid var(--line); border-radius: 18px; }
:root .shop-switch a:hover { border-color: var(--line-2); }
:root .shop-switch a[aria-current] { border-color: var(--ink); background: var(--surface); }
:root .shop-switch a[aria-current] .i { background: var(--ink); color: var(--bg); }
:root[data-theme="dark"] .tn-pill, :root[data-theme="dark"] .tn-me, :root[data-theme="dark"] .tn-link, :root[data-theme="dark"] .tn-stat, :root[data-theme="dark"] .tn-burger { background: var(--well); }

/* ---------- landing page (signed out) ---------- */
.landing h1, .landing h2, .landing h3 { font-family: var(--ui); font-weight: 700; letter-spacing: -.045em; }
.landing-button { border-radius: 999px; box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 8px 20px -8px color-mix(in srgb, var(--brand) 60%, transparent); }
.landing-button:active { transform: scale(.97); box-shadow: inset 0 1px 0 rgba(255,255,255,.18); }
.landing-button-light { box-shadow: var(--hair); }
.landing-button-light:active { box-shadow: var(--hair); }
.landing-level { border-radius: 20px; box-shadow: var(--hair); border: 0; }
.landing-level:hover { box-shadow: var(--hair), 0 18px 40px -18px rgba(15,17,21,.2); }
.landing-features article { border-radius: 20px; }

/* ---------- high school / college ---------- */
.hs-btn, .hs-course, .hs-unit { border-radius: var(--r-row); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .view, .stagger > *, .q-card, .feedback, .toast, :root .tn-drop { animation: none !important; }
  .hero::before, .bar > i::after { animation: none; }
}

/* Settings: the white or dark switch lives here now (and nowhere else). */
#settings .set-theme { margin: 0 0 16px; }
.set-theme { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border-radius: 16px; background: var(--surface); box-shadow: var(--hair); }
.set-theme-l { display: grid; gap: 2px; }
.set-theme-l small { font-size: .82rem; }
