/* Ophtho Case of the Day · page styles. Values come from tokens.css. See case/DESIGN.md. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.5;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; z-index: 10; background: var(--accent); color: var(--on-accent); padding: var(--space-2) var(--space-4); }
.skip-link:focus { left: var(--space-4); top: var(--space-4); }

.wrap {
  max-width: calc(var(--w-column) + 2 * var(--space-6));
  margin: 0 auto;
  padding: var(--space-3) var(--space-6) var(--space-9);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Top bar: way home, and the status line */
.masthead { display: flex; flex-direction: column; gap: var(--space-5); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); }
.quiet { display: inline-flex; align-items: center; min-height: var(--tap); font-size: var(--fs-sm); text-decoration: none; }
.quiet:hover { text-decoration: underline; text-underline-offset: 3px; }
.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Snellen masthead: the title, set as the top of an eye chart */
.chart { display: grid; gap: var(--space-1); justify-items: center; padding-block: var(--space-2) var(--space-1); font-weight: normal; }
.chart .row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline; width: 100%; }
.chart .ltr {
  grid-column: 2;
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: 0.12em;
  line-height: 1.05;
  white-space: nowrap;
  color: var(--heading);
}
.chart .va { grid-column: 3; justify-self: end; font-family: var(--display); font-size: var(--fs-xs); color: var(--muted); }
.chart .r1 .ltr { font-size: var(--fs-chart-1); }
.chart .r2 .ltr { font-size: var(--fs-chart-2); }
.chart .r3 .ltr { font-size: var(--fs-chart-3); }

/* Without JavaScript the game cannot run, so it stays out of the way */
.game { display: none; flex-direction: column; gap: var(--space-5); }
.js .game { display: flex; }
.noscript { max-width: var(--measure); padding-top: var(--space-4); border-top: 1px solid var(--border); color: var(--muted); }

/* Status line above the case */
.meta { display: flex; flex-wrap: wrap; gap: 0 var(--space-3); align-items: center; justify-content: space-between; }
.status { font-size: var(--fs-sm); color: var(--muted); }
.linkbtn {
  min-height: var(--tap);
  padding: 0 var(--space-1);
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linkbtn:hover { color: var(--accent-hover); }

/* Case card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.card-head h2, .stats h2 { font-family: var(--display); font-weight: 700; font-size: var(--fs-lg); line-height: 1.3; color: var(--heading); }
.count { font-size: var(--fs-sm); color: var(--muted); }
.clues { list-style: none; }
.clue { display: grid; grid-template-columns: 6.5rem 1fr; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--border); }
.clue:last-child { border-bottom: 0; }
.clue .k { font-size: var(--fs-sm); color: var(--muted); line-height: 1.7; }
.clue .t { min-width: 0; }
.clue.new .t { animation: rise 420ms ease-out both; }
.clue.locked .t { display: flex; align-items: center; }
.clue.locked .bar { height: var(--space-2); width: 70%; border-radius: var(--radius); background: var(--chip); }
@keyframes rise { from { opacity: 0.2; transform: translateY(var(--space-1)); } to { opacity: 1; transform: none; } }

/* Attempts: a symbol as well as a color, so they read without red-green vision */
.steps-row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; justify-content: space-between; }
.steps { display: flex; gap: var(--space-2); }
.step {
  display: grid;
  place-items: center;
  width: var(--space-6);
  height: var(--space-6);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1;
}
.step.wrong { background: var(--wrong); border-color: var(--wrong); color: var(--on-status); }
.step.right { background: var(--right); border-color: var(--right); color: var(--on-status); }
.step.skip { background: var(--chip); color: var(--text); }
.steps-legend { font-size: var(--fs-sm); color: var(--muted); }

/* Guess */
.guess { display: flex; flex-direction: column; gap: var(--space-3); }
.field { position: relative; scroll-margin-top: var(--space-2); }
.field label { display: block; font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--space-2); }
#guessInput {
  width: 100%;
  min-height: var(--tap);
  font: inherit;
  font-size: var(--fs-lg);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
}
#guessInput::placeholder { color: var(--muted); opacity: 1; }
.sugg {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: var(--space-1);
  z-index: 5;
  list-style: none;
  max-height: 16rem;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.sugg li { min-height: var(--tap); padding: var(--space-2) var(--space-3); cursor: pointer; display: flex; align-items: center; }
.sugg li[aria-selected="true"], .sugg li:hover { background: var(--chip); }

.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.btn {
  min-height: var(--tap);
  padding: var(--space-2) var(--space-5);
  font: inherit;
  font-weight: 700;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--border-strong); }
.btn.ghost:hover { background: transparent; color: var(--accent-hover); border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.feedback { min-height: 1.5em; font-size: var(--fs-sm); color: var(--muted); }
.feedback.bad { color: var(--wrong); }

/* Result */
.result { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); }
.verdict { font-size: var(--fs-sm); font-weight: 700; }
.verdict.win { color: var(--right); }
.verdict.lose { color: var(--wrong); }
.dx:focus { outline: none; }
.dx { font-family: var(--display); font-weight: 800; font-size: var(--fs-dx); line-height: 1.15; color: var(--heading); text-wrap: balance; }
.pearl { max-width: var(--measure); }
.pearl b { font-weight: 700; }
.next { font-size: var(--fs-sm); color: var(--muted); }
#shareFallback {
  width: 100%;
  padding: var(--space-2);
  font-family: var(--sans);
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

/* Record: a ruled block, not a card, because nothing in it can be opened or used */
.stats { padding-top: var(--space-5); border-top: 1px solid var(--border); }
.stats h2 { margin-bottom: var(--space-3); }
.nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); margin-bottom: var(--space-4); }
.num { display: flex; flex-direction: column-reverse; justify-content: flex-end; }
.num dd { font-family: var(--display); font-weight: 800; font-size: var(--fs-num); line-height: 1.1; color: var(--heading); }
.num dt { font-size: var(--fs-sm); color: var(--muted); }
.dist { display: grid; gap: var(--space-2); }
.dist .r { display: grid; grid-template-columns: var(--space-4) 1fr var(--space-7); gap: var(--space-2); align-items: center; font-size: var(--fs-sm); }
.dist .lbl, .dist .n { color: var(--muted); }
.dist .n { text-align: right; font-family: var(--display); }
.dist .track { height: var(--space-4); background: var(--chip); border-radius: var(--radius); overflow: hidden; }
.dist .fill { height: 100%; background: var(--bar); }
.dist .r.hit .fill { background: var(--right); }
.dist .r.miss .fill { background: var(--wrong); }

.foot { display: grid; gap: var(--space-1); padding-top: var(--space-5); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--muted); }

@media (max-width: 460px) {
  .wrap { padding-inline: var(--space-4); }
  .clue { grid-template-columns: 1fr; gap: 0; padding-inline: var(--space-4); }
  .clue.locked { grid-template-columns: 6.5rem 1fr; gap: var(--space-3); padding-block: var(--space-2); }
  .card-head { padding-inline: var(--space-4); }
  .result { padding: var(--space-4); }
}
@media (prefers-reduced-motion: reduce) {
  .clue.new .t { animation: none; }
}
@media print {
  .topbar, .meta, .guess, .actions { display: none; }
}
