/* Promise Atlas: shared story components for the episode chapters (p1/, p2/, ...).
   The spine from brand/ileri_eko_identity.json, as reusable UI. Each episode keeps its own voice: it defines the
   tokens below in its own :root and this file only reads them, so P.1 stays navy and serif and P.2 stays forest
   and Archivo. Documented in web/DESIGN_SYSTEM.md.

   Tokens an episode must define: --bg --panel --rule --ink --soft --faint --accent --sans
   Optional: --map-bg (map panel background), --key-bg (legend surface)                                         */

/* ---------- accessibility atoms ---------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--bg); padding: 10px 14px;
  border-radius: 4px; font: 700 14px var(--sans); text-decoration: none; }
.skip:focus { top: 12px; }

/* ---------- chapter navigator: reading progress under the strip ---------- */
#nav { position: sticky; }
.nav-prog { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; }
.nav-prog i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
#nav a[data-ch] { min-height: 32px; display: inline-flex; align-items: center; }
#nav a[data-ch]:hover span { border-color: var(--soft); }

/* ---------- map furniture: everything drawn over the map lives in the map container ---------- */
.map-ui { position: absolute; z-index: 2; font-family: var(--sans); color: var(--ink); }

/* what the map shows right now (updates with every step; announced politely to screen readers) */
.map-head { left: 16px; top: 16px; max-width: min(420px, calc(100% - 32px)); pointer-events: none;
  display: grid; gap: 4px; padding: 10px 14px 11px; border-radius: 6px;
  background: color-mix(in srgb, var(--bg) 84%, transparent); border: 1px solid var(--rule);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: opacity .3s; }
.map-head small { font: 700 10.5px/1.2 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.map-head b { font: 600 15px/1.3 var(--sans); }
.map-head span { font: 400 13px/1.3 var(--sans); color: var(--soft); }
.map-head span:empty { display: none; }

/* legend: a stepped ramp for the 1 km squares, then the point symbols in play */
.map-key { left: 16px; bottom: 40px; width: 264px; padding: 12px 14px 10px; border-radius: 6px;
  background: color-mix(in srgb, var(--key-bg, var(--bg)) 88%, transparent); border: 1px solid var(--rule);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 12.5px; line-height: 1.3; transition: opacity .35s; }
.map-key.dim .ramp { opacity: .45; }
.map-key h4 { margin: 0 0 8px; font: 700 10.5px/1.2 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.ramp { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; margin-bottom: 4px; }
.ramp i { height: 10px; border-radius: 1px; }
.ramp i:first-child { border-radius: 3px 1px 1px 3px; } .ramp i:last-child { border-radius: 1px 3px 3px 1px; }
.ramp-l { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; font: 600 11px/1.2 var(--sans); color: var(--soft);
  font-variant-numeric: tabular-nums; }
.ramp-l span:last-child { text-align: right; }
.ramp-l span:not(:first-child):not(:last-child) { text-align: center; }
.cats { display: grid; gap: 5px; }
.cats div { display: flex; align-items: center; gap: 8px; }
.cats i { flex: none; width: 12px; height: 12px; border-radius: 2px; }
.syms { display: grid; gap: 6px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--rule); }
.syms:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.syms div { display: flex; align-items: flex-start; gap: 9px; color: var(--ink); }
.syms i { margin-top: 1px; }
.syms i { flex: none; width: 13px; height: 13px; border-radius: 50%; display: inline-block; }
.syms i.dot { border: 1.5px solid var(--bg); box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.syms i.ring { border: 3px solid currentColor; background: var(--bg); }
.syms i.model { border: 2px dashed currentColor; background: transparent; width: 15px; height: 15px; }
.syms i.line { width: 16px; height: 0; border-radius: 0; border-top: 2px dashed currentColor; }
.syms small { display: block; color: var(--faint); font-size: 11px; line-height: 1.25; }
.map-key .src { margin: 8px 0 0; font: 400 11px/1.3 var(--sans); color: var(--faint); }

/* loading and error states for the map (the access grid is ~1 MB and takes a moment on a phone) */
.map-status { inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 3;
  background: color-mix(in srgb, var(--bg) 55%, transparent); transition: opacity .5s; }
.map-status.done { opacity: 0; }
.map-status div { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--rule); font: 600 13px var(--sans); color: var(--soft); box-shadow: 0 12px 30px -12px rgba(0,0,0,.5); }
.map-status i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--rule); border-top-color: var(--accent); animation: spin .9s linear infinite; }
.map-status.err { background: var(--bg); pointer-events: auto; }
.map-status.err div { border-radius: 8px; max-width: 420px; display: block; line-height: 1.5; font-weight: 400; }
.map-status.err i { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* MapLibre controls, re-skinned to the episode (this file loads after the episode styles, so these win) */
.maplibregl-ctrl-group { background: var(--panel) !important; border: 1px solid var(--rule); box-shadow: none !important; }
.maplibregl-ctrl-group button { width: 34px !important; height: 34px !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--rule) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) brightness(1.4); }
.maplibregl-ctrl-group button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.maplibregl-ctrl-scale { background: transparent !important; border-color: var(--soft) !important; color: var(--soft) !important;
  font: 600 10.5px var(--sans) !important; }
.maplibregl-popup-content { box-shadow: 0 18px 40px -12px rgba(0,0,0,.6); }

/* ---------- story text atoms shared by every episode ---------- */
.stat { display: grid; grid-template-columns: 1fr; gap: 6px; align-items: start; }
.stat > span { max-width: 26em; }
.kbd-hint { font: 600 12px var(--sans); color: var(--faint); margin-top: 10px; }
.kbd-hint kbd { font: 600 10.5px var(--sans); border: 1px solid var(--rule); border-radius: 3px; padding: 1px 5px; color: var(--soft); }

@media (max-width: 860px) {
  .map-head { left: 10px; top: 10px; padding: 7px 10px; max-width: calc(100% - 64px); }
  .map-head small { display: none; }
  .map-head b { font-size: 13px; }
  .map-head span { font-size: 12px; }
  .map-key { left: 10px; bottom: 30px; width: min(230px, calc(100% - 70px)); padding: 8px 10px 7px; }
  .map-key h4, .map-key .syms, .map-key .src { display: none; }
  .ramp i { height: 8px; }
  .ramp-l { font-size: 10px; }
  .kbd-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .map-status i { animation: none; }
  .map-head, .map-key, .map-status { transition: none; }
}
@media (forced-colors: active) { .ramp i, .cats i, .syms i { forced-color-adjust: none; } }
.syms i.line { margin-top: 7px; }
