/* Joey Math -- design system. Palette and figure tokens are lifted from
   bank/make_review.py so the figures render identically here as they did in
   the review tool. Defined on :root, redefined for dark, never inline. */

:root {
  --paper: #FAFAF6; --paper-2: #F3F3EE; --card: #FFFDF8; --ground: #EAE7DE;
  --ink: #17203A; --ink-2: #4D5670; --ink-3: #828AA1;
  --gold: #C9860F; --gold-deep: #93630A; --gold-tint: #FBF0D9;
  --teal: #1F7A6C; --teal-tint: #E2F2EF;
  --coral: #C2553F; --coral-tint: #F9E9E3;
  --rule: #C6CCDD; --line: #D9D4C7;

  --fig-fill: #FBF0D9; --fig-stroke: #93630A; --fig-faint: #C6CCDD;
  --fig-accent-fill: #E2F2EF; --fig-accent-stroke: #1F7A6C; --fig-label: #4D5670;
  --fig-top: #FBF0D9; --fig-left: #E7D4AD; --fig-right: #D0B98A;

  --serif: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151B2E; --paper-2: #1C2337; --card: #1F2639; --ground: #0D1220;
    --ink: #EDEFF6; --ink-2: #A9B1C7; --ink-3: #7B849E;
    --gold: #F0B429; --gold-deep: #F7CC5C; --gold-tint: #33280F;
    --teal: #52D6C0; --teal-tint: #10332E;
    --coral: #FF8A72; --coral-tint: #391D16;
    --rule: #333B58; --line: #272F49;

    --fig-fill: #34290F; --fig-stroke: #F0B429; --fig-faint: #3A4268;
    --fig-accent-fill: #10332E; --fig-accent-stroke: #52D6C0; --fig-label: #A9B1C7;
    --fig-top: #4C3C19; --fig-left: #392D12; --fig-right: #29200C;
  }
}
:root[data-theme="dark"] {
  --paper: #151B2E; --paper-2: #1C2337; --card: #1F2639; --ground: #0D1220;
  --ink: #EDEFF6; --ink-2: #A9B1C7; --ink-3: #7B849E;
  --gold: #F0B429; --gold-deep: #F7CC5C; --gold-tint: #33280F;
  --teal: #52D6C0; --teal-tint: #10332E;
  --coral: #FF8A72; --coral-tint: #391D16;
  --rule: #333B58; --line: #272F49;

  --fig-fill: #34290F; --fig-stroke: #F0B429; --fig-faint: #3A4268;
  --fig-accent-fill: #10332E; --fig-accent-stroke: #52D6C0; --fig-label: #A9B1C7;
  --fig-top: #4C3C19; --fig-left: #392D12; --fig-right: #29200C;
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, color-mix(in srgb, var(--ink-2) 9%, transparent) 31px 32px);
}

img { max-width: 100%; }

/* Every number the kid reads is lining, tabular figures -- Garamond's
   default old-style digits dip below the baseline and jitter on timers. */
.num, .choice .val, .dots .n, dd.ans, .streak-count, .stat-num, table td, table th {
  font-variant-numeric: lining-nums tabular-nums;
}

a { color: var(--gold-deep); }

/* The ruled paper is nice as an ambient page texture but hard to read text
   over -- so the main content sits on its own solid sheet, the same way
   the settings form does, and the ruling only shows in the margin around it. */
.wrap {
  max-width: 720px; margin: 20px auto; padding: 28px 24px 40px;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 6px;
}
.wrap.wide { max-width: 1040px; }
@media (max-width: 520px) {
  .wrap { margin: 0; border-width: 0 0 1.5px; border-radius: 0; padding: 22px 20px 36px; }
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0 0 10px; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 12px; }
.deck { color: var(--ink-2); }

/* Header / chrome */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 14px 20px; border-bottom: 2px solid var(--ink); background: var(--paper);
  font-family: var(--sans); font-size: .8rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
}
.topbar .wordmark { font-family: var(--serif); font-size: 1.3rem; font-weight: 600;
  letter-spacing: -.01em; color: var(--ink); text-transform: none; }
.topbar .wordmark em { font-style: italic; color: var(--gold-deep); }
.topbar nav { display: flex; gap: 18px; align-items: center; }
.topbar nav a { color: var(--ink-2); text-decoration: none; }
.topbar nav a:hover { color: var(--gold-deep); }
.kid-badge { display: inline-flex; align-items: center; gap: 7px; }
.kid-icon { width: 26px; height: 26px; padding: 4px; border-radius: 50%; background: var(--paper-2);
  border: 1.5px solid var(--line); object-fit: contain; box-sizing: content-box; }
.kid-icon.kid-icon-lg { width: 44px; height: 44px; padding: 6px; }

/* Coach > Kids: icon/name/password/edit all lined up on one baseline per
   row, and Edit pushed to the row's far edge instead of just sitting in
   its own narrow column. */
.kids-table td { vertical-align: middle; }
.kids-table td:last-child { text-align: right; }

/* Kid-facing top nav -- always visible, so there's never a screen (mid-run
   included) a kid can't get back out of. */
.kid-nav {
  display: flex; gap: 0; flex-wrap: nowrap; align-items: center;
  padding: 0 20px; background: var(--paper-2); border-bottom: 1.5px solid var(--line);
  font-family: var(--sans); font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
/* Even spacing -- each item carries its own padding rather than a flex
   gap, so the rhythm is the same regardless of label length. The
   button_to items are wrapped in a <form>, which is the flex child here,
   not the button inside it. */
.kid-nav .navlink {
  display: inline-flex; align-items: center; flex: none; white-space: nowrap;
  color: var(--ink-2); text-decoration: none; background: none; border: none;
  border-bottom: 2px solid transparent; padding: 13px 16px 11px;
  font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer;
}
/* Gated to real pointer devices -- on a touch scroll, swiping the nav
   sideways starts the drag on whatever item is under the finger, and iOS
   Safari leaves that item's :hover state visually stuck afterwards. With
   :hover using the same gold as .active, that reads as two nav items
   selected at once. Real mice don't have this problem, so only they get
   the hover color. */
@media (hover: hover) {
  .kid-nav .navlink:hover { color: var(--gold-deep); }
}
.kid-nav .navlink.active { color: var(--gold-deep); border-bottom-color: var(--gold-deep); }

.flash { max-width: 720px; margin: 16px auto 0; padding-inline: 20px; }
.flash .msg {
  border-left: 3px solid var(--gold); background: var(--gold-tint); color: var(--ink);
  padding: 11px 15px; border-radius: 0 5px 5px 0; margin-bottom: 10px; font-size: .92rem;
}
.flash .msg.alert { border-left-color: var(--coral); background: var(--coral-tint); }

/* Cards -- 2px borders, small radius, left border carries status */
.card {
  background: var(--card); border: 2px solid var(--line); border-radius: 5px;
  padding: 20px 22px; margin-bottom: 16px;
}
.card.now { border-left: 5px solid var(--gold); }
.card.done { border-left: 5px solid var(--teal); }
.team-question .figure { margin-top: 12px; }
.team-question .notes { background: var(--paper-2); border-color: var(--rule); margin: 16px 0 0; }

/* The four doors on /today */
.doors { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
@media (max-width: 520px) { .doors { grid-template-columns: 1fr; } }
.door {
  display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 2px solid var(--line); border-radius: 5px;
  padding: 22px 20px; min-height: 44px; transition: border-color .15s;
}
.door:hover { border-color: var(--gold); }
button.door { width: 100%; text-align: left; font: inherit; cursor: pointer; }
.door.disabled { opacity: .5; cursor: not-allowed; }
.door .label { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; margin-bottom: 4px; }
.door .sub { color: var(--ink-2); font-size: .86rem; }
.door-icon { width: 28px; height: 28px; object-fit: contain; margin-bottom: 10px; }

/* Kid picker on / */
.kid-doors { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 24px; }
@media (max-width: 480px) { .kid-doors { grid-template-columns: 1fr; } }
.kid-door {
  display: block; background: var(--card); border: 2px solid var(--line); border-radius: 5px; padding: 20px;
  text-align: center; text-decoration: none; color: inherit; transition: border-color .15s;
}
a.kid-door:hover { border-color: var(--gold); }
.kid-door .name { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; margin-bottom: 10px; }
.kid-door input[type="password"] { width: 100%; margin-bottom: 10px; }
.kid-door input[type="submit"] { width: 100%; }

/* Forms */
label { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 5px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
select, textarea {
  font: inherit; font-size: 1rem; width: 100%; padding: 10px 12px; min-height: 44px;
  border: 1.5px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink);
}
textarea { min-height: 80px; }
.field { margin-bottom: 14px; }

/* Buttons default to a compact size everywhere (coach area, nav, chrome).
   Kid-facing gameplay controls (Go, Check, Try again, Next question...)
   opt into .lg, which is the one guaranteed to meet the 44px tap-target
   rule -- two of these will be tapped on an iPad, on the floor. .xs is for
   dense inline row actions (reorder/remove in the coach question list),
   which are mouse-driven admin controls, not something a kid taps. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: .76rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; text-decoration: none; cursor: pointer;
  padding: 7px 14px; min-height: 34px; border-radius: 4px; border: 1.5px solid var(--ink);
  background: var(--ink); color: var(--paper);
}
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn.danger { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.lg { padding: 12px 22px; min-height: 44px; font-size: .86rem; }
#answer_actions .btn.lg { display: flex; width: 100%; }
.btn.xs { padding: 3px 9px; min-height: 26px; font-size: .66rem; letter-spacing: .02em; }
.btn-row { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.btn-row form { display: contents; }

/* Question screen */
.progress-dots { display: flex; gap: 7px; margin-bottom: 20px; flex-wrap: wrap; }
.progress-dots .dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--rule);
  background: var(--card); }
.progress-dots .dot.done { background: var(--teal); border-color: var(--teal); }
.progress-dots .dot.current { background: var(--gold); border-color: var(--gold); }

.setup { font-family: var(--serif); font-size: 1.15rem; line-height: 1.55; margin-bottom: 16px; }
.ask { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; line-height: 1.45; margin: 16px 0; }

.figure {
  background: var(--card); border: 1px solid var(--rule); border-radius: 4px; padding: 16px;
  margin-bottom: 18px;
}
.figure svg { display: block; width: 100%; height: auto; max-width: 100%; }
.fig-fill { fill: var(--fig-fill); }
.fig-stroke { stroke: var(--fig-stroke); fill: none; }
.fig-fill.fig-stroke { fill: var(--fig-fill); stroke: var(--fig-stroke); }
.fig-faint { stroke: var(--fig-faint); fill: none; }
.fig-accent-fill { fill: var(--fig-accent-fill); }
.fig-accent-stroke { stroke: var(--fig-accent-stroke); }
.fig-label { fill: var(--fig-label); font-family: var(--sans); }
.fig-face-top { fill: var(--fig-top); stroke: var(--fig-stroke); }
.fig-face-left { fill: var(--fig-left); stroke: var(--fig-stroke); }
.fig-face-right { fill: var(--fig-right); stroke: var(--fig-stroke); }
.fig-num { fill: var(--ink-3); font-family: var(--serif); font-variant-numeric: lining-nums tabular-nums; }

.choices { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--card); border: 1.5px solid var(--rule); border-radius: 4px;
  padding: 12px 16px; min-height: 44px; font: inherit; cursor: pointer; color: var(--ink);
}
.choice .ltr {
  font-family: var(--sans); font-size: .78rem; font-weight: 700; width: 26px; height: 26px;
  border-radius: 50%; flex: none; display: grid; place-items: center;
  border: 1.5px solid var(--rule); color: var(--ink-2);
}
.choice .val { font-family: var(--serif); font-size: 1.25rem; }
.choice[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-tint); }
.choice[aria-pressed="true"] .ltr { background: var(--gold); border-color: var(--gold); color: var(--card); }
.choice.correct { border-color: var(--teal); background: var(--teal-tint); }
.choice.correct .ltr { background: var(--teal); border-color: var(--teal); color: var(--card); }
.choice.wrong { border-color: var(--coral); background: var(--coral-tint); }
.choice.wrong .ltr { background: var(--coral); border-color: var(--coral); color: var(--card); }

.fillin input { font-family: var(--serif); font-size: 1.3rem; text-align: center; }

.help-check { display: flex; align-items: center; gap: 10px; margin: 6px 0 20px; font-size: .92rem; color: var(--ink-2); }
.help-check input { width: 20px; height: 20px; flex: none; }

.feedback { display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 18px; border-radius: 5px; margin-bottom: 16px; border-left: 4px solid var(--teal); background: var(--teal-tint); }
.feedback.not-yet { border-left-color: var(--coral); background: var(--coral-tint); }
.feedback .headline { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; margin-bottom: 6px; }
.feedback .solution { color: var(--ink-2); font-size: .95rem; }
.feedback-icon { width: 36px; height: 36px; flex: none; object-fit: contain; }

/* The mini social layer -- only ever shown on a correct answer. */
.notes { background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 16px 18px; margin-bottom: 16px; }
.notes h3 { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 12px; }
.note-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.note-list li { display: flex; align-items: center; gap: 10px; }
.note-icon { width: 20px; height: 20px; padding: 3px; border-radius: 50%; background: var(--paper-2);
  border: 1.5px solid var(--line); object-fit: contain; box-sizing: content-box; flex: none; }
.note-text { font-size: .92rem; line-height: 1.5; }
.note-text strong { color: var(--ink-2); }
.note-form label { margin-bottom: 8px; }
.note-form-row { display: flex; flex-direction: column; gap: 8px; }
.note-form-row input[type="submit"] { width: 100%; }
.note-hint { margin: 8px 0 0; font-size: .78rem; }

/* A soft build-out: each block settles in a beat after the one before it. */
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.reveal { animation: reveal .4s ease-out both; }
@media (prefers-reduced-motion: reduce) { .reveal { animation: none; } }

.stamp {
  display: inline-flex; align-items: center; gap: 6px; font-size: .66rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--gold-deep);
  background: var(--gold-tint); border: 1px solid var(--gold); border-radius: 100px; padding: 4px 11px;
}

/* Awards */
.award-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 18px; }
.award {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 5px; padding: 16px;
  text-align: center; opacity: .35;
}
.award.earned { opacity: 1; border-color: var(--gold); }
.award .icon { width: 48px; height: 48px; margin-bottom: 8px; object-fit: contain; }
.award:not(.earned) .icon { filter: grayscale(1); }
.award .label { font-family: var(--serif); font-weight: 600; font-size: .95rem; }

/* Team chart */
.chart-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 20px; overflow-x: auto; }

/* A visible break between "how the team is scoring" and "what the team has
   conquered together" -- two different questions, so the page should read
   as two rooms, not one long scroll. */
.team-section + .team-section { margin-top: 36px; padding-top: 32px; border-top: 2px solid var(--ink); }

/* Tables (mostly coach area) */
table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: .9rem; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .65rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); border-bottom: 1.5px solid var(--rule); }
/* A table forced to width:100% inside a narrow .tw scroller has nowhere
   to put wide content but wrap/squeeze it -- .tw never actually gets to
   scroll. Let it size to its content instead (still filling the width
   when there's room to) so columns keep their natural width and .tw's
   overflow-x does the work it's there for. */
.tw { overflow-x: auto; }
.tw table { width: max-content; min-width: 100%; }

.pill { display: inline-block; font-size: .68rem; font-weight: 600; letter-spacing: .04em;
  border-radius: 100px; padding: 2px 10px; background: var(--paper-2); color: var(--ink-2); }
.pill.help { background: var(--coral-tint); color: var(--coral); }
.pill.verified { background: var(--teal-tint); color: var(--teal); }
.pill.draft { background: var(--gold-tint); color: var(--gold-deep); }
.pill.needs-work { background: var(--coral-tint); color: var(--coral); }

.result-cell { display: flex; align-items: center; gap: 8px; }

.note-edit-form { display: flex; gap: 6px; align-items: center; min-width: 260px; }
.note-edit-form input[type="text"] { min-height: 34px; padding: 6px 10px; font-size: .86rem; }

.seg { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; }
.seg a, .seg button { flex: none; font-size: .78rem; font-weight: 600; padding: 7px 13px; border-radius: 100px;
  border: 1.5px solid var(--rule); background: var(--card); color: var(--ink-2); text-decoration: none; cursor: pointer; }
.seg a.active, .seg button.active { border-color: var(--gold); background: var(--gold-tint); color: var(--gold-deep); }

/* Coach question rows: current questions + add-question candidates. Each
   row is its own <tbody> so a hidden preview row can sit right under it. */
.qrow-actions { display: flex; gap: 4px; flex-wrap: nowrap; white-space: nowrap; }
.qrow-preview td { background: var(--paper-2); padding: 14px 16px; }
.figure.small { padding: 10px; max-width: 320px; }
.q-preview .ask { font-size: 1.05rem; margin: 8px 0; }
.q-preview .setup { font-size: .95rem; margin-bottom: 8px; }
.q-preview-choices { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.q-preview-choices li { display: flex; align-items: center; gap: 8px; font-size: .92rem; }
.q-preview-choices .ltr {
  font-size: .65rem; font-weight: 700; width: 20px; height: 20px; border-radius: 50%;
  display: inline-grid; place-items: center; border: 1.5px solid var(--rule); color: var(--ink-2); flex: none;
}
.q-preview-choices li.is-answer { color: var(--teal); font-weight: 600; }
.q-preview-choices li.is-answer .ltr { background: var(--teal); border-color: var(--teal); color: var(--card); }

.coach-nav {
  display: flex; gap: 16px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 16px; margin-bottom: 22px; border-bottom: 1.5px solid var(--line);
}
.coach-nav a { text-decoration: none; color: var(--ink-2); font-size: .8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; flex: none; white-space: nowrap; }
.coach-nav a.active { color: var(--gold-deep); }

.coach-login input[type="submit"] { width: 100%; }

.muted { color: var(--ink-3); }
.mt { margin-top: 18px; }

/* Kid icon picker -- coach/kids/edit and, read-only, next to each name
   on the sign-in doors. */
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; margin-bottom: 16px; }
.icon-option { display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 1.5px solid var(--rule); border-radius: 5px; padding: 10px 6px; cursor: pointer; }
.icon-option img { width: 44px; height: 44px; border-radius: 50%; background: var(--paper-2); object-fit: cover; }
.icon-option span { font-size: .64rem; color: var(--ink-2); text-transform: capitalize; }
.icon-option:has(input:checked) { border-color: var(--gold); background: var(--gold-tint); }
.icon-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.kid-door .icon-tag { width: 56px; height: 56px; padding: 8px; border-radius: 50%; background: var(--paper-2);
  border: 1.5px solid var(--line); object-fit: contain; box-sizing: content-box; margin-bottom: 10px; }
.kid-door.single { max-width: 320px; margin: 0 auto; }
.kid-door.single .icon-tag { width: 88px; height: 88px; padding: 14px; }

.site-footer { max-width: 720px; margin: 40px auto 0; padding: 16px 20px 30px;
  font-size: .72rem; color: var(--ink-3); text-align: center; }
.site-footer a { color: var(--ink-3); text-decoration: underline; }
