/* ==========================================================================
   Date the Globe — map-archive reading room.
   Dark cabinet-green shell so the sepia scans glow; stamp crimson and
   graticule blue lifted from the archival stamps and CIA oceans on the
   actual source maps.
   ========================================================================== */

@font-face {
  font-family: 'Oswald';
  src: url('../assets/fonts/oswald-500.woff2') format('woff2');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: 'Oswald';
  src: url('../assets/fonts/oswald-600.woff2') format('woff2');
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: 'Source Serif 4';
  src: url('../assets/fonts/source-serif-4-400.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Source Serif 4';
  src: url('../assets/fonts/source-serif-4-600.woff2') format('woff2');
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('../assets/fonts/ibm-plex-mono-400.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('../assets/fonts/ibm-plex-mono-600.woff2') format('woff2');
  font-weight: 600; font-display: swap;
}

:root {
  --ink-950: #101613;
  --ink-900: #171f1a;
  --ink-800: #1f2a23;
  --ink-700: #2e3b32;
  --ink-600: #46564b;
  --paper: #f1e9d6;
  --paper-dim: #ded2b6;
  --paper-ink: #26221a;
  --stamp: #b5342c;
  --stamp-bright: #d04437;
  --blue: #85abcb;
  --pencil: #9caa9e;
  --text: #e9e5d8;
  --hot: #d04437;
  --warm: #d68f3c;
  --cool: #85abcb;
  --cold: #8f9c91;
  --display: 'Oswald', 'Arial Narrow', sans-serif;
  --serif: 'Source Serif 4', Georgia, serif;
  --mono: 'IBM Plex Mono', 'Courier New', monospace;
  --radius: 6px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  background:
    radial-gradient(1200px 500px at 70% -10%, rgba(133, 171, 203, 0.07), transparent 60%),
    var(--ink-950);
  color: var(--text);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--blue); text-underline-offset: 2px; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 2px; }

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

/* ---------- masthead ---------- */

.masthead {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1160px; margin: 0 auto; width: 100%;
  padding: 14px 16px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--paper); text-decoration: none;
}

.brand-mark { width: 30px; height: 30px; color: var(--stamp-bright); }

.brand-name {
  font-family: var(--display); font-weight: 600; font-size: 1.15rem;
  letter-spacing: 0.14em; text-transform: uppercase;
}

.masthead-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: var(--radius);
  border: 1px solid var(--ink-700);
  background: var(--ink-800); color: var(--pencil);
  font-family: var(--display); font-size: 1.05rem; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.icon-btn:hover { border-color: var(--ink-600); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* ---------- landing ---------- */

.landing { display: grid; place-items: center; padding: 4vh 0 6vh; }

.cartouche {
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 30px 28px;
  max-width: 560px;
  width: 100%;
  position: relative;
  border: 1px solid var(--paper-dim);
  outline: 1px solid rgba(38, 34, 26, 0.35);
  outline-offset: -8px;
}

.eyebrow {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--stamp);
}

.cartouche h1 {
  font-family: var(--display); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; font-size: clamp(1.9rem, 6vw, 2.6rem);
  line-height: 1.08; margin: 10px 0 14px;
}

.lede { margin-bottom: 18px; }

.rules { list-style: none; border-top: 1px solid var(--paper-dim); }

.rules li {
  padding: 9px 0; border-bottom: 1px solid var(--paper-dim);
  font-size: 0.93rem; line-height: 1.45;
}

.rule-key {
  font-family: var(--display); text-transform: uppercase; letter-spacing: 0.09em;
  font-size: 0.8rem; font-weight: 600; color: var(--stamp);
  display: inline-block; min-width: 106px;
}

.temp-chip {
  font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 1px 7px 2px; border-radius: 20px; color: #fff;
  white-space: nowrap;
}
.temp-hot { background: var(--hot); }
.temp-warm { background: var(--warm); }
.temp-cool { background: var(--cool); color: #14202b; }
.temp-cold { background: var(--cold); color: #17201a; }

.btn-primary {
  display: block; width: 100%; margin-top: 20px;
  background: var(--stamp); color: #fdf6ea; border: none; cursor: pointer;
  font-family: var(--display); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.12em; font-size: 1.02rem;
  padding: 14px 22px; border-radius: var(--radius);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  transition: background 0.15s, transform 0.05s, box-shadow 0.05s;
}
.btn-primary:hover { background: var(--stamp-bright); }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.25); }

.fineprint { margin-top: 14px; font-size: 0.8rem; color: rgba(38, 34, 26, 0.62); text-align: center; }

.hard-toggle {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  margin-top: 16px; padding: 10px 12px; border-radius: var(--radius);
  border: 1px dashed rgba(38, 34, 26, 0.4);
  font-size: 0.85rem; line-height: 1.45;
}
.hard-toggle input { margin-top: 3px; accent-color: var(--stamp); cursor: pointer; }
.hard-toggle strong { color: var(--stamp); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.8rem; }

.hard-chip {
  font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--stamp);
  border: 1px solid var(--stamp); border-radius: 3px; padding: 1px 6px 2px;
  vertical-align: 1px;
}

/* ---------- game layout ---------- */

.game { padding-top: 6px; }

.file-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px;
  justify-content: space-between; padding: 8px 2px 14px;
}

.file-head h2 {
  font-family: var(--display); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; font-size: clamp(1.35rem, 4.5vw, 1.8rem); color: var(--paper);
}

.file-source { font-size: 0.78rem; color: var(--pencil); }

.practice-note {
  background: rgba(133, 171, 203, 0.12); border: 1px solid rgba(133, 171, 203, 0.35);
  color: var(--blue); border-radius: var(--radius);
  font-size: 0.85rem; padding: 8px 12px; margin-bottom: 12px;
}

.link-btn {
  background: none; border: none; color: var(--blue); cursor: pointer;
  font: inherit; text-decoration: underline; text-underline-offset: 2px; padding: 0;
}

@media (min-width: 980px) {
  .game {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(340px, 5fr);
    gap: 0 28px;
    grid-template-areas:
      'head head'
      'note note'
      'map  names'
      'map  ruler'
      'map  form'
      'map  error'
      'map  ledger';
    align-items: start;
  }
  .file-head { grid-area: head; }
  .practice-note { grid-area: note; }
  .map-viewer { grid-area: map; position: sticky; top: 16px; }
  .names { grid-area: names; }
  .ruler-section { grid-area: ruler; }
  .guess-form { grid-area: form; }
  .form-error { grid-area: error; }
  .ledger-section { grid-area: ledger; }
}

/* ---------- map viewer ---------- */

.map-viewer {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
}

.map-frame {
  overflow: auto;
  border-radius: 3px;
  max-height: min(62vh, 640px);
  background: var(--paper-dim);
  cursor: grab;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  touch-action: pan-x pan-y;
}
.map-frame.dragging { cursor: grabbing; }

.map-canvas { position: relative; width: 100%; }

#map-img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }

/* hard mode: the map opens one panel at a time, Catchphrase style */
.map-cover {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
}

.cover-tile {
  display: flex; align-items: center; justify-content: center;
  background: var(--ink-800, #1c2620);
  border: 1px solid rgba(241, 233, 214, 0.14);
  font-family: var(--mono); font-size: clamp(0.9rem, 3vw, 1.6rem);
  color: rgba(241, 233, 214, 0.35);
  user-select: none;
}

.cover-tile.lifted { opacity: 0; }

@media (prefers-reduced-motion: no-preference) {
  .cover-tile { transition: opacity 0.5s ease 0.15s; }
}

.map-tools {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px 2px;
}

.map-hint { font-family: var(--mono); font-size: 0.68rem; color: rgba(38,34,26,0.55); letter-spacing: 0.04em; }

.zoom-controls { display: flex; gap: 6px; }
.zoom-controls .icon-btn {
  width: 32px; height: 32px; background: var(--paper); border-color: var(--paper-dim);
  color: var(--paper-ink); font-size: 1.2rem;
}
.zoom-controls .icon-btn:hover { border-color: var(--paper-ink); }

/* ---------- names / chips ---------- */

.section-label {
  font-family: var(--display); font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.13em; font-size: 0.78rem; color: var(--pencil);
  margin: 22px 0 10px;
}

.section-sublabel {
  font-family: var(--mono); text-transform: none; letter-spacing: 0.02em;
  font-size: 0.68rem; color: var(--ink-600); font-weight: 400;
}

.names-disclosure summary { cursor: pointer; }
.names-disclosure summary:hover { color: var(--text); }
.names-disclosure[open] summary { margin-bottom: 12px; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
  font-family: var(--mono); font-size: 0.76rem; letter-spacing: 0.02em;
  border: 1px solid var(--ink-700); color: var(--text);
  background: var(--ink-800); border-radius: 999px; padding: 4px 11px 5px;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.chip.chip-used {
  border-color: var(--stamp-bright); color: var(--paper);
  background: rgba(181, 52, 44, 0.18);
}

/* ---------- ruler ---------- */

#ruler svg { display: block; width: 100%; height: auto; }
#ruler { user-select: none; }
#ruler .tick { stroke: var(--ink-600); stroke-width: 1; }
#ruler .tick-label {
  font-family: var(--mono); font-size: 11px; fill: var(--pencil);
}
#ruler .baseline { stroke: var(--ink-600); stroke-width: 1.5; }
#ruler .window-band { fill: rgba(133, 171, 203, 0.16); stroke: rgba(133,171,203,0.5); stroke-width: 1; }
#ruler .excluded { fill: url(#hatch); }
#ruler .guess-mark { font-family: var(--mono); font-size: 12px; font-weight: 600; }
#ruler .hit-area { fill: transparent; cursor: crosshair; }

/* ---------- guess form ---------- */

.guess-form {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px; align-items: stretch; margin-top: 20px;
}

.guess-input {
  font-family: var(--mono); font-weight: 600; font-size: 2rem; letter-spacing: 0.14em;
  text-align: center; color: var(--paper);
  background: var(--ink-800); border: 1px solid var(--ink-700);
  border-radius: var(--radius); padding: 8px 12px; width: 100%; min-width: 0;
}
.guess-input::placeholder { color: var(--ink-600); }
.guess-input:focus { border-color: var(--blue); outline: none; }

.btn-stamp {
  background: var(--stamp); border: none; border-radius: var(--radius);
  cursor: pointer; padding: 0 26px;
  box-shadow: 0 5px 0 #7c221c;
  transition: transform 0.06s, box-shadow 0.06s, background 0.15s;
}
.btn-stamp:hover { background: var(--stamp-bright); }
.btn-stamp:active, .btn-stamp.stamping { transform: translateY(4px); box-shadow: 0 1px 0 #7c221c; }
.btn-stamp:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-stamp-face {
  font-family: var(--display); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.14em; color: #fdf6ea; font-size: 1rem;
}

.guesses-left {
  grid-column: 1 / -1;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--pencil);
}

.form-error { color: var(--warm); font-size: 0.85rem; min-height: 1.4em; margin-top: 6px; }

/* ---------- ledger ---------- */

.ledger { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.ledger-row {
  background: var(--paper); color: var(--paper-ink);
  border-radius: var(--radius); padding: 12px 14px;
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
}

@media (prefers-reduced-motion: no-preference) {
  .ledger-row.fresh { animation: stamp-in 0.38s cubic-bezier(0.2, 1.6, 0.35, 1); }
  @keyframes stamp-in {
    0% { transform: scale(1.5) rotate(-4deg); opacity: 0; }
    55% { transform: scale(0.97) rotate(0.6deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); }
  }
}

.ledger-year {
  font-family: var(--mono); font-weight: 600; font-size: 1.5rem;
  color: var(--stamp); border: 2.5px solid var(--stamp); border-radius: 4px;
  padding: 1px 8px; transform: rotate(-2deg); align-self: start;
  box-shadow: inset 0 0 6px rgba(181, 52, 44, 0.25);
}

.ledger-verdict {
  font-family: var(--display); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.1em; font-size: 0.82rem; align-self: center;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.ledger-verdict .arrow { font-size: 1rem; }

.ledger-evidence {
  grid-column: 1 / -1;
  border-top: 1px dashed var(--paper-dim); padding-top: 7px; margin-top: 4px;
}

.ledger-evidence summary {
  cursor: pointer; list-style-position: inside;
  font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--stamp);
}
.ledger-evidence summary:hover { color: var(--stamp-bright); }
.ledger-evidence[open] summary { margin-bottom: 4px; }

.ledger-clue { font-size: 0.9rem; line-height: 1.5; }
.ledger-clue strong { color: var(--stamp); }

.ledger-empty { color: var(--ink-600); font-size: 0.88rem; font-style: italic; }

/* ---------- result: the closing argument ---------- */

.result-bracket {
  margin-top: 18px;
  border: 1.5px solid var(--stamp);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: rgba(181, 52, 44, 0.06);
  font-size: 0.92rem;
  line-height: 1.55;
}
.result-bracket .section-label { margin: 0 0 6px; color: var(--stamp); }
.result-bracket strong { color: var(--stamp); }

/* ---------- dialogs ---------- */

.sheet {
  background: var(--paper); color: var(--paper-ink);
  border: none; border-radius: 10px; box-shadow: var(--shadow);
  padding: 28px 26px; max-width: 520px; width: calc(100vw - 32px);
  margin: auto;
}
.sheet::backdrop { background: rgba(8, 12, 10, 0.72); backdrop-filter: blur(2px); }

.dialog-title {
  font-family: var(--display); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; font-size: 1.3rem; margin-bottom: 12px;
}

.help-list { margin: 12px 0 12px 18px; display: flex; flex-direction: column; gap: 8px; font-size: 0.93rem; }

.sheet .btn-primary, .sheet .btn-quiet { margin-top: 16px; }

.btn-quiet {
  display: block; width: 100%; background: none; cursor: pointer;
  border: 1px solid rgba(38, 34, 26, 0.35); color: var(--paper-ink);
  font-family: var(--display); font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.1em; font-size: 0.9rem; padding: 11px 18px; border-radius: var(--radius);
}
.btn-quiet:hover { border-color: var(--paper-ink); }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stat-cell .stat-num { font-family: var(--mono); font-weight: 600; font-size: 1.6rem; display: block; }
.stat-cell .stat-lbl { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(38,34,26,0.6); }

.dist-chart { display: flex; flex-direction: column; gap: 5px; }
.dist-bar { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: center; font-family: var(--mono); font-size: 0.78rem; }
.dist-bar .bar { background: var(--stamp); color: #fdf6ea; border-radius: 3px; padding: 2px 7px; min-width: 22px; text-align: right; }
.dist-bar .bar.zero { background: var(--paper-dim); color: rgba(38,34,26,0.55); }

/* ---------- result ---------- */

.result-sheet { text-align: center; position: relative; }

.dialog-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; font-size: 1.5rem; cursor: pointer;
  color: rgba(38, 34, 26, 0.5); line-height: 1;
}
.dialog-close:hover { color: var(--paper-ink); }

.verdict-stamp {
  display: inline-block; margin: 6px auto 14px;
  font-family: var(--display); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.18em; font-size: 1.5rem;
  padding: 8px 22px; border: 3.5px solid; border-radius: 6px;
  transform: rotate(-3deg);
}
.verdict-stamp.won { color: var(--stamp); border-color: var(--stamp); box-shadow: inset 0 0 10px rgba(181,52,44,0.2); }
.verdict-stamp.lost { color: #3e4a42; border-color: #3e4a42; box-shadow: inset 0 0 10px rgba(62,74,66,0.2); }

@media (prefers-reduced-motion: no-preference) {
  .result-sheet[open] .verdict-stamp { animation: stamp-in 0.45s cubic-bezier(0.2, 1.6, 0.35, 1) 0.12s backwards; }
}

.result-answer { font-size: 0.9rem; color: rgba(38,34,26,0.7); }

.result-year {
  font-family: var(--mono); font-weight: 600; font-size: 3.4rem; letter-spacing: 0.08em;
  line-height: 1.1; margin-bottom: 10px;
}

.result-about { text-align: left; border-top: 1px solid var(--paper-dim); margin-top: 8px; padding-top: 4px; }
.result-about p { font-size: 0.92rem; }
.result-about .file-source { color: rgba(38,34,26,0.6); margin-top: 6px; }

.result-actions { display: grid; gap: 8px; margin-top: 14px; }
.result-actions .btn-primary, .result-actions .btn-quiet { margin-top: 0; }

.countdown { font-family: var(--mono); font-size: 0.78rem; color: rgba(38,34,26,0.65); margin-top: 12px; }

/* ---------- toast / footer ---------- */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--paper); color: var(--paper-ink);
  font-family: var(--mono); font-size: 0.82rem;
  padding: 9px 16px; border-radius: 6px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.site-footer {
  max-width: 1160px; margin: 0 auto; width: 100%;
  padding: 18px 16px 26px; font-size: 0.76rem; color: var(--ink-600);
}
.site-footer a { color: var(--pencil); }

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