/* © 2026 Radha Prabhakaran. All rights reserved. See LICENSE. */
/* ChainReaction: home page, page guide, glossary pop-ups and field notes.
   Every colour comes from the tokens in styles.css. Class prefixes:
   g- = page guide (all pages), h- = home page, gl = glossary term. */

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/Fraunces-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/Fraunces-Italic-latin.woff2") format("woff2");
}

:root {
  --font-quirk: "Fraunces", var(--font-display);
  --chrome-offset: 180px;
}
html { scroll-padding-top: var(--chrome-offset); }

/* ---------- page guide (inside the sticky topbar) ---------- */
.g-guide { border-top: 1px solid var(--border-soft); }
.g-inner { max-width: 1360px; margin: 0 auto; padding: 10px 44px 12px; display: grid; gap: 8px; }
.g-what { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; max-width: 920px; margin: 0; }
.g-word { font: italic 600 24px/1.1 var(--font-quirk); font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 72; color: var(--accent); letter-spacing: -0.01em; }
.g-ipa { font: 13px var(--font-mono); color: var(--text-faint); }
.g-pos { font: italic 14px var(--font-quirk); color: var(--text-dim); }
.g-def { flex-basis: 100%; font: 16px/1.45 var(--font-quirk); font-variation-settings: "SOFT" 50, "opsz" 24; color: var(--text); }
.g-def em { font-style: italic; color: var(--accent); }
.g-page { font-size: 14px; color: var(--text-dim); margin: 0; max-width: 80ch; }
.g-page b { color: var(--text); }
.g-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.g-lbl { font: 600 11px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-right: 4px; }
.g-step { display: inline-flex; gap: 8px; align-items: center; background: none; border: 1px solid var(--border-soft); border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; font: inherit; font-size: 13px; color: var(--text-dim); transition: border-color 0.15s, color 0.15s, background 0.15s; }
.g-step-n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-elevated); font: 700 11px var(--font-mono); color: var(--text-faint); }
.g-step:hover { color: var(--text); border-color: var(--border); }
.g-step[aria-current="step"] { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.g-step[aria-current="step"] .g-step-n { background: var(--accent); color: var(--on-accent); }
.g-step.done .g-step-n { background: var(--success-soft); color: var(--success); }
.g-step:disabled { opacity: 0.45; cursor: not-allowed; }
.g-step:disabled:hover { color: var(--text-dim); border-color: var(--border-soft); }
.g-toggle { margin-left: auto; background: none; border: 0; color: var(--text-faint); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; }
.g-toggle:hover { color: var(--text); }
.g-show { display: none; }
.g-guide.collapsed .g-inner > :not(.g-show) { display: none; }
.g-guide.collapsed .g-show { display: inline-block; justify-self: start; margin-left: 0; }
.topbar.compact .g-what { display: none; }

/* ---------- glossary terms ---------- */
.gl { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: help; text-decoration: underline dotted var(--border); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.gl:hover, .gl[aria-expanded="true"] { text-decoration-color: var(--accent); color: var(--text); }
.gl-pop { position: absolute; z-index: 60; max-width: 280px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5; color: var(--text-dim); box-shadow: 0 10px 30px var(--shadow-soft); }
.gl-pop b { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }

/* ---------- field notes (all pages) ---------- */
.fnote { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: baseline; margin-top: 28px; padding-top: 10px; border-top: 1px dotted var(--border); font-size: 13px; line-height: 1.55; color: var(--text-dim); max-width: 760px; }
.fnote b { font: 700 11px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--success); white-space: nowrap; }
.fnote a { color: var(--text-faint); font-family: var(--font-mono); font-size: 12px; text-underline-offset: 3px; }
.fnote a:hover { color: var(--text); }

/* ---------- home page ---------- */
.h-wrap { max-width: 1180px; margin: 0 auto; padding-left: 44px; padding-right: 44px; }
.h-kicker { font: 600 12px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.h-hero { padding-block: 44px 52px; }
.h-head { max-width: 720px; display: grid; gap: 12px; margin-bottom: 22px; }
.h-head h1 { font-family: var(--font-display); font-size: clamp(30px, 4.2vw, 46px); line-height: 1.12; margin: 0; text-wrap: balance; }
.h-head p { color: var(--text-dim); max-width: 64ch; margin: 0; line-height: 1.6; }

.h-picker { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.h-pick { display: flex; gap: 10px; align-items: center; text-align: left; background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: 12px; padding: 8px 14px 8px 8px; cursor: pointer; font: inherit; color: var(--text); min-width: 0; }
.h-pick svg { width: 44px; height: 44px; flex: none; }
.h-pick strong { display: block; font-size: 15px; }
.h-pick small { display: block; font-size: 12px; color: var(--text-faint); }
.h-pick:hover { border-color: var(--border); }
.h-pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.h-tag { display: inline-block; margin-top: 4px; font: 600 10px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 1px 6px; }

.h-game { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.h-term { background: var(--term-bg); border: 1px solid var(--border-soft); border-radius: 12px; overflow: hidden; font: 14px/1.55 var(--font-mono); color: var(--term-fg); }
.h-term-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border-soft); background: var(--bg-elevated); color: var(--text-faint); font-size: 12px; }
.h-term-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--border); display: block; }
.h-term-bar span { margin-left: 6px; }
.h-out { padding: 14px 16px; height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.h-out p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.h-out .cmd { margin-top: 8px; }
.h-out .cmd::before { content: "recon@chainreaction:~$ "; color: var(--success); }
.h-out .res::before { content: "> "; color: var(--text-faint); }
.h-out .why { color: var(--accent); }
.h-out .meh { color: var(--text-faint); }
.h-out .ok { color: var(--success); font-weight: 700; }
.h-out .bad { color: var(--accent); font-weight: 700; }
.h-cmds { border-top: 1px solid var(--border-soft); padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 8px; background: var(--bg-elevated); }
.h-cmds-label { width: 100%; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.h-cmd { font: 13px var(--font-mono); background: var(--term-bg); color: var(--term-fg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.h-cmd::before { content: "$ "; color: var(--success); }
.h-cmd:hover:not(:disabled) { border-color: var(--success); }
.h-cmd:disabled { opacity: 0.45; cursor: default; text-decoration: line-through; }
.h-cmd.go { border-color: var(--accent); }
.h-cmd.fix { border-color: var(--success); color: var(--success); }

.h-board { background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: 12px; padding: 18px; display: grid; gap: 12px; }
.h-board-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.h-board-top h3 { font-family: var(--font-display); font-size: 17px; margin: 0; }
.h-count { font: 600 13px var(--font-mono); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.h-meter { height: 6px; border-radius: 3px; background: var(--bg-elevated); overflow: hidden; }
.h-meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.4s ease; }
.h-slots { list-style: none; margin: 0; padding: 0; display: grid; }
.h-slot { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; }
.h-rail { display: flex; flex-direction: column; align-items: center; }
.h-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px dashed var(--border); display: grid; place-items: center; font: 700 11px var(--font-mono); color: var(--text-faint); flex: none; background: var(--bg-card); }
.h-stem { width: 2px; flex: 1; min-height: 12px; background: repeating-linear-gradient(var(--border) 0 4px, transparent 4px 8px); }
.h-slot:last-child .h-stem { display: none; }
.h-slot-body { padding-bottom: 12px; font-size: 14px; color: var(--text-faint); }
.h-slot-body strong { display: block; font-weight: 600; }
.h-slot.on .h-dot { border-style: solid; border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.h-slot.on .h-stem { background: var(--accent); }
.h-slot.on .h-slot-body strong { color: var(--text); }
.h-slot.on .h-slot-body span { color: var(--text-dim); }
.h-slot.on { animation: hPop 0.35s ease; }
.h-slot.broken .h-dot { background: var(--success); border-color: var(--success); color: var(--on-success); }
.h-slot.broken .h-slot-body strong { text-decoration: line-through; color: var(--text-faint); }
@keyframes hPop { from { opacity: 0.4; transform: translateY(4px); } }
.h-foot { display: grid; gap: 10px; border-top: 1px solid var(--border-soft); padding-top: 12px; font-size: 14px; color: var(--text-dim); }
.h-foot p { margin: 0; }
.h-foot b { color: var(--text); }

.h-block { padding-block: 52px; border-top: 1px solid var(--border-soft); }
.h-block-head { display: grid; gap: 8px; margin-bottom: 26px; max-width: 660px; }
.h-block-head h2 { font-family: var(--font-display); font-size: clamp(24px, 3vw, 32px); margin: 0; text-wrap: balance; }
.h-block-head p { color: var(--text-dim); margin: 0; }
.h-handoff { margin-top: 26px; display: flex; gap: 12px; flex-wrap: wrap; }
.h-next-btn { background: none; border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px; cursor: pointer; font: inherit; font-size: 14px; color: var(--text); }
.h-next-btn:hover { border-color: var(--accent); }
.h-next-btn::after { content: "  \2193"; color: var(--accent); }
.h-next-btn.side::after { content: "  \2192"; }

.h-comic { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch; }
.h-panel { display: grid; gap: 10px; align-content: start; padding: 0 14px; position: relative; }
.h-panel + .h-panel { border-left: 1px dashed var(--border); }
.h-panel svg { width: 100%; max-width: 170px; height: auto; aspect-ratio: 4 / 3; }
.h-panel h3 { font-size: 17px; font-weight: 700; display: flex; gap: 8px; align-items: baseline; margin: 0; }
.h-panel h3 small { font: 700 11px var(--font-mono); color: var(--accent); }
.h-panel p { font-size: 14px; color: var(--text-dim); margin: 0; }
.h-jargon { font-size: 12px; color: var(--text-faint); font-family: var(--font-mono); }
.h-panel.stop::before { content: "2FA stops it here"; position: absolute; top: 34%; left: -1px; transform: translate(-50%, -50%) rotate(-90deg); white-space: nowrap; font: 700 11px var(--font-mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--success); background: var(--bg); padding: 2px 8px; border: 1px solid var(--success); border-radius: 999px; }

.h-mapgrid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.h-map { width: 100%; height: auto; display: block; background: var(--bg-elevated); border-radius: 14px; border: 1px solid var(--border-soft); }
.h-district { cursor: pointer; }
.h-district rect.lot { fill: var(--bg-card); stroke-width: 2; transition: fill 0.15s; }
.h-district:hover rect.lot, .h-district:focus-visible rect.lot, .h-district.active rect.lot { fill: var(--bg); }
.h-district.active rect.lot { stroke-width: 3.5; }
.h-district text { font: 600 13px var(--font-sans); fill: var(--text); }
.h-district text.sub { font: 400 11px var(--font-mono); fill: var(--text-faint); }
.h-district:focus { outline: none; }
.h-district:focus-visible rect.lot { stroke-dasharray: 6 4; }
.h-road { stroke: var(--border-soft); stroke-width: 10; stroke-linecap: round; fill: none; }
.h-road-dash { stroke: var(--border); stroke-width: 1.5; stroke-dasharray: 6 8; fill: none; }
.h-mapinfo { background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: 14px; padding: 20px; display: grid; gap: 10px; }
.h-mapinfo .tag { font: 700 11px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.h-mapinfo h3 { font-family: var(--font-display); font-size: 22px; margin: 0; }
.h-mapinfo p { color: var(--text-dim); font-size: 15px; margin: 0; }
.h-mapinfo ul { margin: 0; padding-left: 18px; color: var(--text-dim); font-size: 14px; display: grid; gap: 2px; }
.h-mapinfo .ex { font-size: 14px; border-left: 3px solid var(--border); padding-left: 10px; color: var(--text); }

.h-ways { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--border-soft); }
.h-ways li { border-bottom: 1px solid var(--border-soft); }
.h-ways button { width: 100%; background: none; border: 0; display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 18px 4px; text-align: left; cursor: pointer; font: inherit; color: var(--text); }
.h-ways button:hover h3 { color: var(--accent); }
.h-ways svg { width: 48px; height: 48px; }
.h-ways h3 { font-size: 19px; font-weight: 700; margin: 0; }
.h-ways p { color: var(--text-dim); font-size: 14px; margin: 0; }
.h-time { font: 600 12px var(--font-mono); color: var(--text-faint); white-space: nowrap; }

.h-ink { fill: none; stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.h-ink-thin { fill: none; stroke: var(--text-dim); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 1080px) {
  .g-inner, .h-wrap { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 860px) {
  :root { --chrome-offset: 150px; }
  .h-game, .h-mapgrid { grid-template-columns: minmax(0, 1fr); }
  .h-comic { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 28px; }
  .h-panel:nth-child(3) { border-left: 0; }
  .h-panel.stop::before { position: static; transform: none; display: inline-block; justify-self: start; }
  .g-lbl { display: none; }
}
@media (max-width: 720px) {
  :root { --chrome-offset: 190px; }
  /* Pre-existing: the nav sat beside the actions and ran off-screen. Give it its own row. */
  .topbar-inner .sitenav { order: 3; flex: 1 0 100%; width: 100%; min-width: 0; justify-content: space-between; overflow-x: auto; scrollbar-width: none; }
  .topbar-inner .sitenav::-webkit-scrollbar { display: none; }
  .topbar-inner .navlink { padding-left: 10px; padding-right: 10px; }
  .g-inner { padding-top: 8px; padding-bottom: 8px; gap: 6px; }
  .g-word { font-size: 19px; }
  .g-ipa { display: none; }
  .g-def { font-size: 14px; line-height: 1.4; }
  .g-page { font-size: 13px; }
  .g-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .g-row::-webkit-scrollbar { display: none; }
  .g-step { flex: none; white-space: nowrap; }
  .g-toggle { flex: none; white-space: nowrap; margin-left: 4px; }
}
@media (max-width: 480px) {
  .g-inner, .h-wrap { padding-left: 16px; padding-right: 16px; }
  .h-comic { grid-template-columns: minmax(0, 1fr); }
  .h-panel + .h-panel { border-left: 0; border-top: 1px dashed var(--border); padding-top: 20px; }
  .h-ways button { grid-template-columns: 40px minmax(0, 1fr); }
  .h-time { grid-column: 2; }
  .h-ways svg { width: 36px; height: 36px; }
  .g-step { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .h-slot.on { animation: none; }
  .h-meter i, .g-step { transition: none; }
}
@media print {
  .g-guide, .gl-pop { display: none !important; }
}
