/* ==========================================================================
   Case Files (case.html, case.js). A reading column: the scene, the
   suspects, the evidence, the verdict. Every figure is a drawing on paper
   or on the dark of a stage, in the tokens' own colours; the page follows
   the theme.
   ========================================================================== */
.case-page { background: var(--bg); color: var(--text); }
.cf { max-width: 760px; margin: 0 auto; padding: var(--sp-md) var(--sp-lg) var(--sp-6xl); display: grid; gap: var(--sp-lg); }
.cf-top { display: flex; justify-content: space-between; gap: var(--sp-md); }
#cf-main { display: grid; gap: var(--sp-xl); }
.cf-head { display: grid; gap: var(--sp-sm); justify-items: start; }
.cf-head h1 { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: clamp(28px, 6vw, 40px); line-height: 1.1; }
.cf-lead { margin: 0; font-size: 17px; line-height: 26px; color: var(--text); text-wrap: pretty; }
.cf-cast { margin-top: var(--sp-sm); color: var(--muted); }
.cf-found { font-size: 19px; line-height: 28px; }

/* A case is frames: the row of steps at the top goes to any of them. */
.cf-steps { display: flex; flex-wrap: wrap; gap: var(--sp-xs); align-items: center; }
.cf-dot { min-height: 36px; padding: 0 var(--sp-md); border-radius: var(--r-full); border: var(--line) solid var(--border); background: var(--surface); color: var(--muted); font: 800 13px/1 var(--font-body); cursor: pointer; }
.cf-dot.num { min-width: 36px; padding: 0; }
.cf-dot.done { border-color: var(--correct); color: var(--correct-ink); }
.cf-dot.now { background: var(--amber); border-color: var(--amber); color: var(--on-bright); }
.cf-dot:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.cf-nav { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-sm); align-items: center; }
.cf-nav .cta { display: grid; place-items: center; }
.cf-nav .cta:not(.quiet) { justify-self: stretch; }
/* Who the evidence has not ruled out: a letter struck is a suspect out. */
.cf-left { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-sm); font-size: 14px; line-height: 20px; }
.cf-left span { font-weight: 800; }
.cf-left b { width: 32px; height: 32px; border-radius: var(--r-full); display: grid; place-items: center; background: var(--amber); color: var(--on-bright); font-family: var(--font-display); font-weight: 900; }
.cf-left b.out { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.cf-left small { color: var(--muted); }
.cf-suspect.out { opacity: .5; }
.cf-suspect.out b { text-decoration: line-through; }
.cf-hint { justify-self: start; }
/* The lab's chart, a question's first Hint: a cheat-sheet card under it.
   It takes the width it is given and no more (a table of five columns
   would otherwise widen the whole page by its own least width: 9px on a
   phone, seen on the Metals chart). */
.cf-chart { width: 100%; max-width: 460px; min-width: 0; justify-self: center; overflow-x: auto; }
#cf-main > *, .cf-evidence, .cf-evidence > *, .cf-step, .cf-step > * { min-width: 0; }

/* The cases, to choose from. */
.cf-cases { display: grid; gap: var(--sp-md); }
.cf-case {
  display: grid; grid-template-columns: 44px 1fr auto; gap: var(--sp-md); align-items: center; text-align: left;
  padding: var(--sp-md) var(--sp-lg); border: var(--line) solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; box-shadow: var(--card-shadow);
}
.cf-case:hover { border-color: var(--coral); }
.cf-case:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.cf-case-n { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--coral); color: var(--on-bright); font-family: var(--font-display); font-weight: 900; font-size: 20px; }
.cf-case-words { display: grid; gap: var(--sp-2xs); min-width: 0; }
.cf-case-words b { font-family: var(--font-display); font-weight: 900; font-size: 18px; line-height: 24px; }
.cf-case-words small { color: var(--muted); font-size: 13px; line-height: 18px; }
.cf-case-state { font-size: 13px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.cf-case-state.ok { color: var(--correct-ink); }

.cf-block { display: grid; gap: var(--sp-md); }
.cf-open { gap: var(--sp-xs); }
.cf-caption { margin: 0; color: var(--muted); font-size: 13px; line-height: 18px; font-weight: 700; }
.cf-block h2 { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: 22px; line-height: 28px; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-sm); }
.cf-block h2 small { font-family: var(--font-body); font-weight: 700; font-size: 13px; color: var(--muted); }

/* The scene: a sketch from above, on the dark of a stage in both themes. */
.cf-scene { width: 100%; height: auto; border-radius: var(--r-lg); background: #0D1117; display: block; }
.cf-room { fill: #131A23; stroke: #5B6B7C; stroke-width: 4; }
.cf-thing { fill: #1C2633; stroke: #3A4A5C; stroke-width: 1.5; }
.cf-room-label { fill: #9AA7B4; font-size: 9.5px; font-weight: 700; font-family: var(--font-body); letter-spacing: .02em; }
.cf-gap { stroke: #131A23; stroke-width: 6; }
.cf-swing { fill: none; stroke: #5B6B7C; stroke-width: 1.2; stroke-dasharray: 3 3; }
.cf-window { stroke: #7DD3FC; stroke-width: 5; stroke-linecap: round; }
.cf-mark { cursor: pointer; }
.cf-mark circle { fill: var(--amber); stroke: #0D1117; stroke-width: 2.5; }
.cf-mark text { fill: #1B1300; font-family: var(--font-display); font-weight: 900; font-size: 13px; pointer-events: none; }
.cf-mark.done circle { fill: var(--correct); }
/* The piece in hand: its marker is the one that beats (still for a reader who asks for less motion). */
.cf-mark.now circle { stroke: #FFFFFF; stroke-width: 3.5; animation: cf-now 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes cf-now { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.28); } }
@media (prefers-reduced-motion: reduce) { .cf-mark.now circle { animation: none; } }
.cf-scene.mini { width: min(100%, 360px); margin: 0 auto; }
/* The scene as a room (case.js, sceneFigure): on the dark of a stage in
   both themes, like the plan it is drawn from. */
.cf-scene.iso.mini { width: min(100%, 420px); }
.cf-sfloor { fill: #151D27; stroke: #2A3644; stroke-width: 1.5; }
.cf-sfloor.open { fill: #13221B; stroke: #24382C; }
.cf-sboard { stroke: #FFFFFF; stroke-opacity: .045; stroke-width: 1; fill: none; }
.cf-spool { fill: url(#cf-pool-g); }
.cf-swall { fill: #1C2734; stroke: none; }
.cf-swall.left { fill: #18212C; }
.cf-swall.glass { fill: #1B3340; fill-opacity: .78; }
.cf-swall.left.glass { fill: #173039; }
.cf-smullion { stroke: #7FD4FF; stroke-opacity: .28; stroke-width: 1.2; fill: none; }
.cf-swall-top { stroke: #5B6B7C; stroke-width: 2.5; stroke-linecap: round; fill: none; }
.cf-spane { fill: #5CC8FF; fill-opacity: .26; stroke: #9BE0FF; stroke-width: 1.5; }
.cf-spane-bar { stroke: #9BE0FF; stroke-opacity: .7; stroke-width: 1.2; fill: none; }
.cf-scrack { stroke: #FFFFFF; stroke-width: 1.4; fill: none; stroke-linejoin: round; }
.cf-sdoorway { fill: #0A0E13; stroke: #5B6B7C; stroke-width: 1.5; }
.cf-sthreshold { fill: #2B3A4B; stroke: #5B6B7C; stroke-width: 1.2; }
.cf-stop { fill: #2D3B4D; stroke: #4A5D73; stroke-width: 1.2; stroke-linejoin: round; }
.cf-sside { fill: #19222D; stroke: #33435A; stroke-width: 1.2; stroke-linejoin: round; }
.cf-sside.left { fill: #212C3A; }
.cf-scene.iso .cf-room-label { font-size: 15px; fill: #AEBBC9; }
.cf-scene.iso .cf-room-label.on { fill: #DCE5EE; paint-order: stroke; stroke: #1B2531; stroke-width: 3px; stroke-linejoin: round; }
.cf-stape-under { stroke: #0D1117; stroke-width: 7; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.cf-stape { stroke: var(--amber); stroke-width: 5; stroke-dasharray: 11 9; fill: none; stroke-linejoin: round; }
.cf-pin-shadow { fill: #000000; fill-opacity: .45; }
.cf-pin-stem { stroke: #E9EEF3; stroke-width: 2.2; stroke-linecap: round; fill: none; }
.cf-scene.iso .cf-mark text { font-size: 16px; }
.cf-mark:hover circle, .cf-mark:focus-visible circle { stroke: #FFFFFF; }
.cf-mark:focus { outline: none; }

/* The suspects. */
.cf-suspects { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-md); }
.cf-suspect { display: grid; grid-template-columns: 40px 1fr; gap: var(--sp-md); padding: var(--sp-md); border: var(--line) solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.cf-letter { width: 40px; height: 40px; border-radius: var(--r-full); display: grid; place-items: center; background: var(--surface-2); font-family: var(--font-display); font-weight: 900; font-size: 18px; }
.cf-suspect b { font-family: var(--font-display); font-weight: 900; font-size: 16px; }
.cf-suspect p { margin: var(--sp-2xs) 0 var(--sp-xs); color: var(--muted); font-size: 14px; line-height: 20px; }
.cf-suspect ul { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-2xs); font-size: 14px; line-height: 20px; }

/* A piece of evidence: what was found, its figure, what is asked of it. */
.cf-evidence { display: grid; gap: var(--sp-md); padding: var(--sp-lg); border: var(--line) solid var(--border); border-radius: var(--r-lg); background: var(--surface); scroll-margin-top: var(--sp-lg); }
.cf-evidence.done { border-color: var(--correct); }
.cf-evidence.flash { box-shadow: 0 0 0 3px var(--amber); }
.cf-evidence header { display: grid; grid-template-columns: 34px 1fr auto; gap: var(--sp-md); align-items: start; }
.cf-num { width: 34px; height: 34px; border-radius: var(--r-full); display: grid; place-items: center; background: var(--amber); color: #1B1300; font-family: var(--font-display); font-weight: 900; }
.cf-evidence.done .cf-num { background: var(--correct); color: var(--on-correct); }
.cf-evidence h3 { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: 18px; line-height: 24px; }
.cf-evidence header p { margin: var(--sp-2xs) 0 0; color: var(--muted); font-size: 14px; line-height: 20px; }
.cf-tick { color: var(--correct-ink); font-weight: 900; font-size: 18px; }
.cf-figure { display: grid; gap: var(--sp-md); justify-items: center; }
.cf-figure > svg { max-width: 100%; height: auto; }
.cf-step { display: grid; gap: var(--sp-sm); }
.cf-ask { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: 17px; line-height: 24px; }
.cf-opts.two-up { grid-template-columns: 1fr 1fr; }
.cf-fits { margin: 0; font-size: 15px; line-height: 22px; }

/* The results of a bench's tests, a row a test. */
.cf-results { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: var(--sp-2xs); }
.cf-results li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-md); padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-sm); background: var(--surface-2); font-size: 14px; line-height: 20px; }
.cf-results span { color: var(--muted); font-weight: 700; }
.cf-results b { font-weight: 800; }

/* A photograph from the microscope, with its credit under it. */
.cf-photo { margin: 0; width: 100%; max-width: 420px; }
.cf-photo img { width: 100%; height: auto; border-radius: var(--r-md); display: block; background: #0D1117; }
.cf-photo figcaption { margin-top: var(--sp-xs); color: var(--muted); font-size: 12px; line-height: 16px; }
.cf-photo a { color: inherit; }

/* The drawings. Paper is paper in both themes; ink is ink. */
.cf-paper { fill: #FBF7EC; stroke: #D8D0BC; stroke-width: 1; }
.cf-print { width: 132px; }
.cf-ridges path { fill: none; stroke: #1E2A44; stroke-width: 2.6; stroke-linecap: round; }
.cf-chroma { width: min(100%, 340px); }
.cf-ruler line { stroke: var(--muted); stroke-width: 1; }
.cf-ruler text, .cf-lane, .cf-note { fill: var(--muted); font-size: 9px; font-weight: 700; font-family: var(--font-body); }
.cf-lane { font-size: 10px; fill: var(--text); }
.cf-pencil { stroke: #8A8F98; stroke-width: 1; }
.cf-front { stroke: #7DA7D9; stroke-width: 1; stroke-dasharray: 4 3; }
.cf-origin { fill: #333842; }
.cf-gel { width: min(100%, 260px); }
.cf-gel-slab { fill: #101826; stroke: #2B3A52; stroke-width: 1.5; }
.cf-well { fill: #2B3A52; }
.cf-band { fill: #B6F7D0; }
.cf-pole { fill: var(--muted); font-size: 16px; font-weight: 900; font-family: var(--font-display); }
.cf-tray { width: min(100%, 320px); }
.cf-tray-plate { fill: #F4F6F8; stroke: #C3CBD2; stroke-width: 1.5; }
.cf-tray-well { fill: #FFFFFF; stroke: #C3CBD2; stroke-width: 1.5; }
.cf-blood { fill: #B3261E; }
.cf-serum { fill: #F1C9BD; }
.cf-clump circle { fill: #8E1B14; }
.cf-tray .cf-lane { fill: #3A4450; }
/* A hair as a light microscope shows it: a band across a pale field. */
.cf-hair { width: min(100%, 420px); display: block; }
.cf-field { fill: #E7E3DA; }
.cf-cortex { fill: #BF9A6B; stroke: #6B5236; stroke-width: 1.4; }
.cf-medulla { fill: #2B2019; }
.cf-scales path { stroke: #8A6A45; stroke-width: 1; fill: none; }
.cf-hair .cf-ink { fill: #3B3027; font-size: 10px; font-weight: 700; font-family: var(--font-body); }
.cf-hair .cf-ink .cf-num { fill: #1E1711; font-weight: 800; }
.cf-photo.cf-measured { max-width: 420px; }
.cf-dim path { stroke: var(--muted); stroke-width: 1; fill: none; }
.cf-dim text { fill: var(--muted); font-size: 10px; font-weight: 700; font-family: var(--font-body); }
.cf-dim .cf-num { fill: var(--text); font-weight: 800; }
.cf-dim-in { stroke: #FFFFFF !important; stroke-width: 1.4 !important; }
.cf-shoe { width: min(100%, 360px); }
.cf-floor { fill: #E9E3D6; stroke: #CFC7B6; }
.cf-sole { fill: #5D6B7A; opacity: .8; }
.cf-tread { stroke: #E9E3D6; stroke-width: 1.6; fill: none; }
.cf-compass circle { fill: none; stroke: var(--muted); stroke-width: 1; }
.cf-compass path { fill: var(--muted); }
.cf-compass .cf-north { fill: var(--coral); }
.cf-compass text { fill: var(--muted); font-size: 10px; font-weight: 800; font-family: var(--font-body); }

/* The verdict: the table of what fits whom. */
.cf-verdict { padding: var(--sp-lg); border: var(--line) solid var(--border); border-radius: var(--r-lg); background: var(--surface); scroll-margin-top: var(--sp-lg); }
#cf-result { display: grid; gap: var(--sp-md); }
.cf-table { overflow-x: auto; }
.cf-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cf-table th, .cf-table td { padding: var(--sp-sm) var(--sp-md); border-bottom: var(--line) solid var(--border); text-align: center; }
.cf-table tr > th:first-child { text-align: left; font-weight: 700; }
.cf-table .hit { background: var(--correct-soft); color: var(--correct-ink); font-weight: 900; }
.cf-next { display: grid; gap: var(--sp-sm); }
.cf-next .cta { display: grid; place-items: center; text-decoration: none; }

@media (max-width: 420px) {
  .cf { padding: var(--sp-md) var(--sp-md) var(--sp-5xl); }
  .cf-evidence, .cf-verdict { padding: var(--sp-md); }
  .cf-results li { grid-template-columns: 1fr; gap: 0; }
}

/* ── The real thing, once a piece of evidence is named ─────────────── */
.cf-real { display: grid; gap: var(--sp-xs); margin-top: var(--sp-sm); }
.cf-real .overline { margin: 0; color: var(--muted); }
.cf-real-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-sm); align-items: start; }
.cf-real-row .cf-photo { margin: 0; }
.cf-real-row .cf-photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.cf-real-row.prints { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cf-real-row.prints .cf-photo img { aspect-ratio: 1; }
.cf-real-row.prints .cf-photo.drawn .cf-print { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; }
.cf-real-row.prints figcaption { text-align: center; }
.cf-real-row.prints .cf-photo.hit img { outline: 3px solid var(--correct); outline-offset: 2px; }
.cf-print-real img { width: min(100%, 260px); aspect-ratio: 1; object-fit: cover; }
@media (max-width: 520px) { .cf-real-row.prints { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
