/* C4C — community quiz.
   Built on the Ei design system (../design-system). Tokens are loaded from
   /tokens; this file only places them.

   Register: default, white mode. Colour jobs, per guides/color.md:
     teal    the one primary action per view, and focus rings — nothing else
     purple  the reader's own answer
     green / red   the verdict on an answer (the work)
     green / orange   the verdict on the reader (their standing)
     blue    metadata chips and the pending-reveal state
     grey    everything that claims no meaning
   All free text is a .t-* class; nothing here sets a type size for it. */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--grey-10);
  font-family: var(--font-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ol, ul, fieldset, figure { margin: 0; padding: 0; }
img { max-width: 100%; }

/* ── Page frame ─────────────────────────────────────────────────────────── */

.page,
.site-foot {
  width: 100%;
  max-width: 808px;          /* 760 column + 2 × 24 gutter */
  margin-inline: auto;
  padding-inline: 24px;
}

/* Header bar as on aidt.site: a white strip across the page with the
   AI & Digital Thinking lockup at its left edge. The mark and the wordmark's
   navy come from that site — brand artwork, not UI tokens — and the navy is
   used nowhere else here. Not a link. */
.site-head {
  background: var(--grey-white);
  border-bottom: 1px solid var(--grey-30);
}
.site-head__inner {
  display: flex; align-items: center;
  height: 80px;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 24px;
}
.site-head__logo { display: flex; align-items: center; gap: 12px; }
.site-head__logo img { display: block; height: 40px; width: auto; }
.site-head__logo span {
  color: #013b68;
  font-family: var(--font-body); font-size: 1.1rem; font-weight: 700;
  letter-spacing: 0.5px; white-space: nowrap;
}

.page { padding-top: 40px; padding-bottom: 56px; }

.hero { margin-bottom: 32px; }
.hero .t-overline { margin-bottom: 12px; }
.hero__lede { margin-top: 12px; max-width: 56ch; }

.site-foot { padding-bottom: 32px; }

#app { display: flex; flex-direction: column; gap: 24px; }

.section-head { margin-top: 24px; }

/* Cards arrive, they don't pop. */
#app > * { animation: rise .45s var(--card-ease) both; }
#app > *:nth-child(2) { animation-delay: .07s; }
#app > *:nth-child(3) { animation-delay: .14s; }
#app > *:nth-child(4) { animation-delay: .21s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ── Chips — a mark: bg + border + text of one family ───────────────────── */

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--grey-40);
  border-radius: 120px;
  background: var(--grey-20);
  color: var(--grey-90);
  font-family: var(--font-body);
  font-size: var(--text-label);
  font-weight: 600;
  line-height: var(--lh-label);
  white-space: nowrap;
}
.chip .mono { font-family: var(--font-mono); font-weight: 600; }
.chip--info    { background: var(--blue-10);    border-color: var(--blue-30);    color: var(--blue-70); }
.chip--purple  { background: var(--purple-10);  border-color: var(--purple-30);  color: var(--purple-70); }
.chip--success { background: var(--success-10); border-color: var(--success-30); color: var(--grey-90); }
.chip--orange  { background: var(--orange-10);  border-color: var(--orange-30);  color: var(--orange-70); }

/* ── Banner — a surface: bg + border + text, token only on the dot ──────── */

.banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--blue-30);
  border-radius: var(--card-radius-inner);
  background: var(--blue-10);
}
.banner .t-body { color: var(--blue-70); }
.banner__dot {
  flex: none; width: 8px; height: 8px; margin-top: .6em;
  border-radius: 50%; background: var(--blue-60);
}
.banner--error { background: var(--error-20); border-color: var(--error-30); }
.banner--error .t-body { color: var(--grey-90); }
.banner--error .banner__dot { background: var(--error-60); }

/* Dates and other alphanumerics sit in mono, inline at the size of their line. */
.date { font-family: var(--font-mono); font-size: .92em; letter-spacing: 0; white-space: nowrap; }

/* ── Question ───────────────────────────────────────────────────────────── */

.q__intro { max-width: var(--card-measure); }
.q__stem  { max-width: var(--card-measure); color: var(--text-primary); font-weight: 600; }
.q__list { padding-left: 1.4em; }
.q__list strong, .q__intro strong { color: var(--text-primary); font-weight: 700; }

/* Full column width: figures carry small text and must not shrink on a phone. */
.q__figure { width: 100%; max-width: 720px; background: var(--grey-white); }
.q__figure img { display: block; width: 100%; height: auto; }

/* ── Options — anatomy from templates/mcq ───────────────────────────────── */

.opts { border: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 768px) { .opts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.opt { position: relative; display: block; }

.opt input {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: pointer;
}

.opt__face {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: 100%; min-height: 60px;
  padding: 12px 16px;
  background: var(--grey-white);
  border: 1px solid var(--grey-40);
  border-radius: var(--card-radius-inner);
  box-shadow: 0 4px 0 var(--grey-40);
  transition: transform 140ms var(--btn-easing), box-shadow 140ms var(--btn-easing),
              background 160ms, border-color 160ms;
}

.opt__key {
  flex: none;
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--grey-60);
  color: var(--grey-white);
  font-family: var(--font-body); font-weight: 700; font-size: 15px; line-height: 1;
  transition: background 160ms;
}

.opt__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.opt__text { color: var(--text-primary); overflow-wrap: anywhere; }
.opt__img  { display: block; width: 100%; max-width: 200px; height: auto; margin-inline: auto; border-radius: 8px; }

/* Same bottom-anchored physics as a button: lift on hover, sink on press. */
.opt input:hover + .opt__face  { transform: translateY(-2px); box-shadow: 0 6px 0 var(--grey-40); }
.opt input:active + .opt__face { transform: translateY(2px);  box-shadow: 0 2px 0 var(--grey-40); }
.opt input:focus-visible + .opt__face { outline: 2px solid var(--teal-primary); outline-offset: 2px; }

/* Picked — purple is the reader's own answer. */
.opt input:checked + .opt__face,
.opt--mine .opt__face {
  background: var(--purple-10);
  border-color: var(--purple-30);
  box-shadow: 0 4px 0 var(--purple-60);
}
.opt input:checked:hover + .opt__face { box-shadow: 0 6px 0 var(--purple-60); }
.opt input:checked + .opt__face .opt__key,
.opt--mine .opt__key { background: var(--purple-60); }

/* Read-only option (locked in, or revealed): flat — nothing left to press. */
.opt--static .opt__face { box-shadow: none; }
.opt--static.opt--mine .opt__face { box-shadow: none; }

/* Verdict — the answer is what's judged, so the answer wears it. */
.opt--correct .opt__face { background: var(--success-10); border-color: var(--success-30); }
.opt--correct .opt__key  { background: var(--success-60); }
.opt--missed .opt__face  { border-style: dashed; border-width: 2px; }
.opt--wrong .opt__face   { background: var(--error-20); border-color: var(--error-30); }
.opt--wrong .opt__key    { background: var(--error-60); }

.opt__mark {
  position: absolute; top: -10px; right: -10px;
  display: grid; place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--grey-white);
  color: var(--grey-white);
}
.opt__mark svg { width: 12px; height: 12px; }
.opt--correct .opt__mark { background: var(--success-60); }
.opt--wrong .opt__mark   { background: var(--error-60); }

/* How everyone answered. No target, so magnitude only: grey for the field,
   purple for the reader's own bar. Track and fill always differ. */
.opt__share { display: flex; align-items: center; gap: 12px; }
.opt__track { flex: 1; height: 6px; border-radius: 99px; background: var(--grey-30); overflow: hidden; }
.opt__fill  { display: block; height: 100%; border-radius: 99px; background: var(--grey-40); }
.opt--correct .opt__track, .opt--wrong .opt__track { background: var(--grey-white); }
.opt--correct .opt__fill,  .opt--wrong .opt__fill  { background: var(--grey-60); }
.opt--mine .opt__fill { background: var(--purple-60); }
.opt__pct { flex: none; min-width: 4ch; text-align: right; color: var(--grey-90); font-weight: 500; }

/* ── Actions ────────────────────────────────────────────────────────────── */

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 8px; }

/* The view's single commit action. Size per buttons.md §4, "hero / single
   CTA": XL on mobile and tablet, L from desktop up. */
.btn--cta {
  padding: var(--btn-pad-xl); font-size: var(--btn-font-xl);
  line-height: var(--btn-lh-xl); border-radius: var(--btn-radius-xl);
  min-height: 46px; min-width: 160px;
}
.btn--quiet {
  padding: var(--btn-pad-xl); font-size: var(--btn-font-xl);
  line-height: var(--btn-lh-xl); border-radius: var(--btn-radius-xl);
  min-height: 46px;
}
@media (min-width: 1024px) {
  .btn--cta, .btn--quiet {
    padding: var(--btn-pad-l); font-size: var(--btn-font-l);
    line-height: var(--btn-lh-l); border-radius: var(--btn-radius-l);
    min-height: 42px;
  }
}
.btn--text { font-size: inherit; text-decoration: underline; text-underline-offset: 3px; }
.btn[aria-busy="true"] { pointer-events: none; }

/* ── Details form ───────────────────────────────────────────────────────── */

.picked {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--purple-10);
  border: 1px solid var(--purple-30);
  border-radius: var(--card-radius-inner);
}
.picked .opt__key { background: var(--purple-60); }
.picked__body { flex: 1; min-width: 0; }
.picked__body .t-label { color: var(--purple-70); }
.picked__body .t-body  { color: var(--text-primary); overflow-wrap: anywhere; }

.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 768px) {
  .form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field--wide { grid-column: 1 / -1; }
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; }

.input {
  width: 100%;
  padding: 12px 14px;
  background: var(--grey-white);
  border: 1px solid var(--grey-40);
  border-radius: var(--card-radius-inner);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-body);
  font-weight: 500;
  line-height: 1.4;
  transition: border-color 160ms;
}
textarea.input { min-height: 112px; resize: vertical; line-height: var(--lh-body-regular); }
.input::placeholder { color: var(--grey-50); }
.input:hover { border-color: var(--grey-50); }
.input:focus-visible { outline: 2px solid var(--teal-primary); outline-offset: 1px; border-color: var(--grey-50); }
.input[aria-invalid="true"] { border-color: var(--error-30); background: var(--grey-white); }
.field__error { color: var(--error-60); font-weight: 600; }

.form__note { max-width: var(--card-measure); }

/* ── Explanation — a nested, flat sub-tile ──────────────────────────────── */

.why { display: flex; flex-direction: column; gap: 6px; }
.why .t-body { max-width: var(--card-measure); }

/* ── Leaderboard ────────────────────────────────────────────────────────── */

.board { list-style: none; display: flex; flex-direction: column; }
.board__row {
  display: grid; grid-template-columns: 3ch minmax(0, 1fr) auto;
  align-items: center; gap: 16px;
  padding: 12px;
  border-top: 1px solid var(--grey-30);
}
.board__row:first-child { border-top: 0; }
.board__rank { color: var(--text-tertiary); text-align: right; }
.board__who .t-body  { color: var(--text-primary); font-weight: 600; overflow-wrap: anywhere; }
.board__who .t-label { overflow-wrap: anywhere; }
.board__row--me {
  background: var(--purple-10);
  border: 1px solid var(--purple-30);
  border-radius: var(--card-radius-inner);
}
.board__row--me + .board__row { border-top-color: transparent; }

/* ── Loading skeleton ───────────────────────────────────────────────────── */

.skeleton { background: var(--grey-20); border-radius: 8px; }
.skeleton--chip  { width: 96px; height: 28px; border-radius: 120px; }
.skeleton--line  { height: 20px; }
.skeleton--short { width: 62%; }
.skeleton--block { height: 220px; border-radius: var(--card-radius-inner); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Small screens ──────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  .site-head__inner, .page, .site-foot { padding-inline: 16px; }
  .site-head__inner { height: 64px; }
  .page { padding-top: 28px; padding-bottom: 40px; }
  .hero { margin-bottom: 24px; }
  #app { gap: 16px; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions .btn { width: 100%; }
  .board__row { gap: 12px; padding: 12px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  #app > * { animation: none; }
  .opt__face, .opt__key, .input { transition: none; }
  .opt input:hover + .opt__face, .opt input:active + .opt__face { transform: none; }
}
