/* Read the Room styles. Code and style links are versioned at build (scripts/build_site.mjs). */
/* Self-hosted fonts (SIL Open Font License). Variable fonts: one file covers every weight. */
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 500 800; font-display: swap;
  src: url(fonts/fraunces-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 500 800; font-display: swap;
  src: url(fonts/fraunces-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(fonts/inter-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url(fonts/inter-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #e8f3fb;
  --ink: #1d2b3a;
  --muted: #5e7184;
  --rule: #c9dceb;
  --card: #ffffff;
  --accent: #ff6b57;
  --title: #ff6b57;
  --btn: #ff6b57;
  --btn-ink: #ffffff;
  --hit-bg: #ffe08a;
  --great: #1aa39a;
  --ok: #f2b705;
  --meh: #ff9f5a;
  --miss: #9fb0c0;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button { font: inherit; cursor: pointer; }

/* Masthead */
.masthead {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  column-gap: 8px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 16px 12px;
}
.brand { text-align: center; }
.masthead { --title-size: clamp(28px, 7vw, 40px); }
.brand h1 {
  margin: 0;
  color: var(--title);
  font: 800 var(--title-size)/1 var(--serif);
  letter-spacing: -0.02em;
}
.tagline { margin: 4px 0 0; font: 500 15px/1.3 var(--sans); color: var(--ink); }
.dateline {
  margin: 6px 0 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--ink); }
/* Buttons sit level with the title; the tagline and date use the full width below it. */
.brand { display: contents; }
.brand h1 { grid-column: 2; grid-row: 1; }
#helpBtn { grid-column: 1; grid-row: 1; }
#statsBtn { grid-column: 3; grid-row: 1; }
.masthead .tagline, .masthead .dateline { grid-column: 1 / -1; }

main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

/* Progress dots */
.progress { display: flex; gap: 6px; margin-bottom: 12px; }
.progress span {
  flex: 1; height: 4px; border-radius: 2px; background: var(--rule);
}
.progress span.done { background: var(--ink); }
.progress span.now { background: var(--accent); }

/* Photo */
.photo {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--rule);
  padding: 8px;
}
.photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  /* Short screens: leave room (~380px) for the header, guess box and button below. */
  max-height: max(200px, calc(100svh - 380px));
  object-fit: contain;
  background: var(--ink);
}
.photo figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}
.photo figcaption strong { color: var(--ink); font-weight: 600; }
.photo-credit { margin: 2px 0 0; font-size: 11px; line-height: 1.35; color: var(--muted); }
.photo-credit a, .recap .recap-credit a { color: inherit; font: inherit; text-decoration: underline; }
.recap li > div { min-width: 0; }
.recap-credit { margin: 3px 0 0; font: 11px/1.35 var(--sans); color: var(--muted); }

/* Guess */
form#guessForm { margin-top: 16px; display: grid; gap: 10px; }
.prompt { font: 500 20px/1.2 var(--serif); }
textarea {
  width: 100%;
  font: 18px/1.4 var(--serif);
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  resize: none;
}
textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; }

.primary {
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-radius: 6px;
  background: var(--btn);
  color: var(--btn-ink);
  font-weight: 600;
  font-size: 16px;
}
.primary:hover { opacity: 0.9; }
.primary:disabled { opacity: 0.4; cursor: default; }

/* Reveal */
#reveal { margin-top: 16px; }
.score-row {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 10px; margin-bottom: 8px;
}
.score-big { font: 800 48px/1 var(--serif); }
.score-big small, .total small { font-size: 0.4em; color: var(--muted); font-weight: 500; }
.verdict {
  font: 500 18px/1.2 var(--serif);
  font-style: italic;
  text-align: right;
}
/* Score meter: tier color is set by JS as the count passes each threshold. */
.scorecard { --tier: var(--miss); margin-bottom: 6px; }
.scorecard[data-tier="meh"] { --tier: var(--meh); }
.scorecard[data-tier="ok"] { --tier: var(--ok); }
.scorecard[data-tier="good"] { --tier: var(--great); }
.scorecard[data-tier="great"] { --tier: var(--great); }
.scorecard .score-row { border: 0; margin: 0; padding-bottom: 12px; position: relative; }
.score-big span {
  display: inline-block;
  color: var(--tier);
  transition: color 0.25s;
  font-variant-numeric: tabular-nums;
  min-width: 1.2ch;
}
.score-big.pop span { animation: pop 0.45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { 40% { transform: scale(1.22); } }
.verdict { opacity: 0; transform: translateY(6px); transition: opacity 0.35s, transform 0.35s; }
.verdict.show { opacity: 1; transform: none; }

.meter {
  position: relative;
  height: 14px;
  border-radius: 7px;
  background: var(--rule);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0;
  background: var(--tier);
  border-radius: 7px;
  transition: background-color 0.25s;
}
.meter i {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--paper);
  opacity: 0.8;
}
.meter-labels { position: relative; height: 18px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.meter-labels span {
  position: absolute; transform: translateX(-50%); white-space: nowrap;
  transition: color 0.25s, font-weight 0.25s;
}
.meter-labels span:last-child { transform: translateX(-70%); }
.meter-labels span.passed { color: var(--ink); font-weight: 600; }

/* Who / What / Where rows, revealed one at a time: each bar fills to the credit earned */
.fact-list { list-style: none; margin: 12px 0 4px; padding: 0; display: grid; gap: 8px; }
.fact {
  display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--card); border: 1px solid var(--rule); border-radius: 10px;
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.3s, transform 0.3s;
}
.fact.show { opacity: 1; transform: none; }
.fact-kind { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.fact-bar { height: 10px; border-radius: 5px; background: var(--rule); overflow: hidden; }
.fact-bar i {
  display: block; height: 100%; width: 0; border-radius: 5px;
  background: var(--miss);
  transition: width 0.7s cubic-bezier(.2, .8, .2, 1);
}
.fact.show .fact-bar i { width: var(--w); }
.fact[data-state="full"] .fact-bar i { background: var(--great); }
.fact[data-state="part"] .fact-bar i { background: var(--ok); }

/* Celebration for top scores */
.burst { position: absolute; left: 40px; top: 24px; pointer-events: none; }
.burst b {
  position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: var(--c);
  animation: fly 0.8s ease-out forwards;
}
@keyframes fly {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to { transform: translate(var(--x), var(--y)) scale(0.3); opacity: 0; }
}

/* Headline and the rest slide in once the score lands. */
.after-score { display: grid; gap: 4px; opacity: 0; transform: translateY(8px); transition: opacity 0.4s, transform 0.4s; }
.after-score:not(.show) { pointer-events: none; }
.after-score.show { opacity: 1; transform: none; }

/* Results: stacked bar of the three rounds */
.total-meter {
  display: flex; gap: 3px;
  height: 14px; margin: 12px auto 0; max-width: 360px;
  border-radius: 7px; background: var(--rule); overflow: hidden;
}
.total-meter span { height: 100%; width: 0; background: var(--c); transition: width 0.7s cubic-bezier(.2, .8, .2, 1); }

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

.label {
  margin: 10px 0 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.headline { margin: 2px 0 0; font: 800 24px/1.2 var(--serif); }
.your-guess { margin: 2px 0 0; font: 18px/1.35 var(--serif); color: var(--muted); }
.after-score .primary { margin-top: 18px; }

/* Results */
#results { text-align: center; }
.kicker {
  margin: 8px 0 0;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted);
}
.total { font: 800 72px/1 var(--serif); margin-top: 6px; }
.total-verdict {
  margin: 6px 0 18px; font: italic 500 20px/1.3 var(--serif);
  opacity: 0; transform: translateY(6px); transition: opacity 0.4s, transform 0.4s;
}
.total-verdict.show { opacity: 1; transform: none; }
.recap {
  list-style: none; padding: 0; margin: 0 0 18px;
  text-align: left;
  border-top: 1px solid var(--rule);
}
.recap li {
  display: grid;
  grid-template-columns: 64px 1fr 44px;
  gap: 12px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.recap img { width: 64px; height: 48px; object-fit: cover; border-radius: 3px; }
.recap a { color: inherit; text-decoration: none; font: 500 15px/1.25 var(--serif); }
.recap a:hover { text-decoration: underline; }
.recap .ext { color: var(--accent); font-family: var(--sans); font-size: 0.9em; white-space: nowrap; }
.recap b { font: 800 20px var(--serif); text-align: right; }
.streak-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px;
}
.streak-row div, .stats-grid div {
  background: var(--card); border: 1px solid var(--rule); border-radius: 6px;
  padding: 10px; display: grid;
}
.streak-row strong, .stats-grid strong { font: 800 26px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.streak-row span, .stats-grid span { font-size: 12px; color: var(--muted); }
.toast { margin: 10px 0 0; font-size: 14px; color: var(--muted); }

/* Dialogs */
dialog {
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  width: min(420px, calc(100vw - 32px));
  padding: 22px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog h2 { margin: 0 0 10px; font: 800 26px/1.1 var(--serif); }
dialog p { margin: 0 0 10px; }
dialog form { margin-top: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stats-grid strong { font-size: 22px; }
.best { font-family: var(--serif); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps li { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 12px; font-size: 16px; line-height: 1.35; }
.steps .ic {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--card));
}
.steps svg {
  width: 19px; height: 19px;
  fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
dialog .credits {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--rule);
  font-size: 12px; color: var(--muted);
}
.credits a { color: inherit; }

.site-footer {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px;
  max-width: 640px; width: 100%; margin: 0 auto;
  margin-top: 24px; padding: 16px 16px 28px;
  border-top: 1px solid var(--rule);
  font-size: 12px; color: var(--muted);
}
.site-footer a, .link-btn { color: inherit; }
.footer-about { flex-basis: 100%; margin: 0 0 4px; text-align: center; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .headline { font-size: 21px; }
}
