/* Layout: one column, like a ruling card on the Director's clipboard. The case
   is set in a book serif, the answers are bidding-box tabs, and the law is
   quoted the way a rulebook prints it.

   Colour: blue means right and red means wrong, and each also carries a mark
   and a word, because red against blue cannot be the only cue. Suit red is
   its own token and only ever colours ♥ and ♦. */

:root {
  --paper: #f3f5f9;
  --card: #ffffff;
  --ink: #18202e;
  --muted: #566176;
  --line: #d6dce7;
  --right: #0a66c2;
  --right-wash: #e6f0fa;
  --wrong: #b42318;
  --wrong-wash: #fbeceb;
  --suit-red: #c0281d;
  --focus: #0a66c2;

  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "IBM Plex Sans", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f141c;
    --card: #171e2a;
    --ink: #e6eaf2;
    --muted: #9ba6ba;
    --line: #2a3446;
    --right: #58a6ff;
    --right-wash: #13263d;
    --wrong: #ff7b72;
    --wrong-wash: #33191b;
    --suit-red: #ff8a80;
    --focus: #58a6ff;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0f141c;
  --card: #171e2a;
  --ink: #e6eaf2;
  --muted: #9ba6ba;
  --line: #2a3446;
  --right: #58a6ff;
  --right-wash: #13263d;
  --wrong: #ff7b72;
  --wrong-wash: #33191b;
  --suit-red: #ff8a80;
  --focus: #58a6ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
}

.page {
  max-width: 44rem;
  margin: 0 auto;
  padding-block: 1.25rem 3rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

main section { display: flex; flex-direction: column; gap: 1rem; }

a { color: var(--right); }

button { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ── Masthead ───────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.wordmark {
  margin: 0;
  font: 600 1.6rem/1.1 var(--serif);
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.link-button {
  background: none;
  border: 0;
  padding: 0.35rem 0.1rem;
  color: var(--right);
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.progress {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--ink);
  transition: width 0.25s ease;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* ── The case ───────────────────────────────────────────── */

.case {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.25rem 1.25rem 1.4rem;
}

.case-topic {
  margin: 0 0 0.5rem;
  font: 500 0.72rem/1.2 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.case-text {
  margin: 0;
  font: 400 1.25rem/1.45 var(--serif);
  text-wrap: pretty;
}

.case-text:focus { outline: none; }

.suit { font-family: var(--sans); }
.suit-red { color: var(--suit-red); }

/* ── Answers, as bidding-box tabs ───────────────────────── */

.options {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option {
  width: 100%;
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  grid-template-areas: "letter text" "letter mark";
  align-items: start;
  column-gap: 0.85rem;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 0.9rem 0.75rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.option:hover:not(:disabled) { border-color: var(--ink); }
.option:active:not(:disabled) { transform: translateY(1px); }
.option:disabled { cursor: default; }

.option-letter {
  grid-area: letter;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 500 0.95rem/1 var(--mono);
  color: var(--muted);
}

.option-text { grid-area: text; min-width: 0; padding-top: 0.45rem; }

.option-mark {
  grid-area: mark;
  font-weight: 600;
  font-size: 0.85rem;
}

.option-mark:empty { display: none; }

.option.is-answer {
  border: 2px solid var(--right);
  background: var(--right-wash);
  padding: calc(0.75rem - 1px) calc(0.9rem - 1px) calc(0.75rem - 1px) calc(0.75rem - 1px);
}
.option.is-answer .option-letter { background: var(--right); border-color: var(--right); color: var(--card); }
.option.is-answer .option-mark { color: var(--right); }

.option.is-wrong {
  border: 2px dashed var(--wrong);
  background: var(--wrong-wash);
  padding: calc(0.75rem - 1px) calc(0.9rem - 1px) calc(0.75rem - 1px) calc(0.75rem - 1px);
}
.option.is-wrong .option-letter { border-color: var(--wrong); color: var(--wrong); }
.option.is-wrong .option-mark { color: var(--wrong); }

.option.is-other { opacity: 0.6; }

/* ── Feedback and the law ───────────────────────────────── */

.feedback {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1.1rem 1.25rem 1.25rem;
  gap: 0.75rem;
}

.verdict {
  margin: 0;
  font-weight: 600;
  font-size: 1.05rem;
}
.verdict-right { color: var(--right); }
.verdict-wrong { color: var(--wrong); }

.why { margin: 0; max-width: 65ch; }

.refs-heading {
  margin: 0.4rem 0 0;
  font: 500 0.72rem/1.2 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.refs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ref {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.6rem;
  align-items: baseline;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.ref-cite {
  font: 500 0.88rem/1.3 var(--mono);
  text-decoration: none;
}
.ref-cite:hover { text-decoration: underline; }

.ref-source {
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 0;
}

.ref-text {
  grid-column: 1 / -1;
  margin: 0.3rem 0 0;
  font: 400 0.98rem/1.5 var(--serif);
  max-width: 65ch;
}

/* ── Buttons ────────────────────────────────────────────── */

.primary, .secondary {
  border-radius: 6px;
  padding: 0.8rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
}

.primary {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  align-self: flex-start;
}
.primary:disabled { opacity: 0.45; cursor: not-allowed; }

.secondary {
  background: transparent;
  border: 1px solid var(--ink);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.keys {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

@media (hover: none) { .keys { display: none; } }

/* ── Setup ──────────────────────────────────────────────── */

.section-title {
  margin: 0;
  font: 600 1.3rem/1.3 var(--serif);
}

.topic-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font: 500 0.72rem/1.2 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.topic-head .link-button { font: 500 0.85rem var(--sans); letter-spacing: 0; text-transform: none; }

.topic-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.5rem;
}

.topic {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "box name" "box meta";
  column-gap: 0.7rem;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
}
.topic:has(input:checked) { border-color: var(--ink); }
.topic input { grid-area: box; width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--ink); }
.topic-name { grid-area: name; font-weight: 500; }
.topic-meta { grid-area: meta; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.length {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}
.length legend {
  padding: 0;
  margin-bottom: 0.5rem;
  font: 500 0.72rem/1.2 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.length label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.length input { accent-color: var(--ink); width: 1.05rem; height: 1.05rem; margin: 0; }

/* ── End of round ───────────────────────────────────────── */

.final-score {
  margin: 0;
  font: 600 3rem/1 var(--serif);
  font-variant-numeric: tabular-nums;
}

.final-note { margin: 0; color: var(--muted); }

.missed-list {
  margin: 0.5rem 0 0;
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.missed-list p { margin: 0; }
.missed-q { font-family: var(--serif); font-size: 1.02rem; }
.missed-a { margin-top: 0.3rem !important; }
.missed-cite { margin-top: 0.25rem !important; font: 500 0.8rem/1.4 var(--mono); color: var(--muted); }

/* ── Colophon ───────────────────────────────────────────── */

.colophon {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.colophon p { margin: 0; max-width: 65ch; }

@media (max-width: 420px) {
  .case-text { font-size: 1.12rem; }
  .wordmark { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
