/* Layout: the model fills the screen under a harmattan haze; the chrome floats over it in three bands. A top bar
   (brand, the explore nav, search), a card stack on the left for whatever the nav has open, and a full-width time
   strip along the bottom. Danfo yellow and black as the one loud pair. */
:root {
  --haze: #ebe6dc; --land: #f6f2ea; --paper: #fffdf8; --ink: #17140f; --muted: #6b655b; --rule: #ddd5c6;
  --lagoon: #9cc1c0; --accent: #f5b800; --accent-2: #17140f; --soft: #fff4cf;
  --glass: rgba(255,253,248,.86); --glass-line: rgba(221,213,198,.75); --blur: saturate(1.3) blur(14px);
  --shadow-1: 0 1px 2px rgba(40,30,10,.06), 0 2px 10px rgba(40,30,10,.08);
  --shadow-2: 0 2px 6px rgba(40,30,10,.06), 0 14px 36px rgba(40,30,10,.14);
  --glass-soft: rgba(255,253,248,.55); --line-soft: rgba(221,213,198,.55); --blur-soft: blur(8px); --shadow-soft: 0 1px 6px rgba(40,30,10,.06);
  /* type scale: caption, small, body, title, display */
  --fs-1: 11px; --fs-2: 12px; --fs-3: 13px; --fs-4: 18px; --fs-5: 26px;
  --pad: 15px; --radius-sm: 10px;
  --radius: 16px; --gutter: 16px; --control: 32px; --stack-w: 304px; --dock-h: 76px;
  --top: calc(env(safe-area-inset-top, 0px) + var(--gutter));
  --bottom: calc(env(safe-area-inset-bottom, 0px) + var(--gutter));
  /* every details card is the same height, capped by the room between the top bar and the time strip */
  --sheet-h: 520px; --sheet-max: calc(100vh - (var(--top) + var(--control) + 24px) - (var(--bottom) + var(--dock-h) + 52px));
  --display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
  font: 400 var(--fs-3)/1.5 var(--body);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--haze); color: var(--ink); overflow: hidden; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
#scene { position: fixed; top: 0; bottom: 0; right: 0; left: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.haze { position: fixed; left: 0; right: 0; top: 0; height: 120px; pointer-events: none; background: linear-gradient(var(--haze) 10%, rgba(235,230,220,0)); }
.glass { background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--glass-line); }
svg { stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top bar: slim and see-through, so the map stays the loudest thing on screen ---------- */
.topbar { position: fixed; z-index: 20; top: var(--top); left: max(var(--gutter), env(safe-area-inset-left, 0px)); right: max(var(--gutter), env(safe-area-inset-right, 0px));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { justify-self: start; display: flex; flex-direction: column; gap: 5px; color: inherit; text-decoration: none; padding: 2px 4px; border-radius: 8px; }
.wordmark { margin: 0; display: flex; align-items: baseline; gap: 6px; font-family: var(--display); font-weight: 800; font-size: 22px; line-height: .9; letter-spacing: -0.03em; }
.wordmark small { font-size: var(--fs-2); font-weight: 600; letter-spacing: 0; color: var(--muted); }
.stripe { display: block; height: 4px; width: 56px; background: repeating-linear-gradient(90deg, var(--accent) 0 11px, var(--ink) 11px 15px); border-radius: 2px; }

.topnav { justify-self: center; display: flex; gap: 1px; padding: 2px; border-radius: 999px; background: var(--glass-soft); -webkit-backdrop-filter: var(--blur-soft); backdrop-filter: var(--blur-soft); border: 1px solid var(--line-soft); box-shadow: var(--shadow-soft); }
.topnav button { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 11px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: var(--fs-2); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color .15s ease, color .15s ease, box-shadow .15s ease; }
.topnav svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; flex: none; }
.topnav button:hover { color: var(--ink); }
.topnav button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(40,30,10,.14); }
.topnav button[aria-pressed="true"] svg { stroke: #b07f00; }

.topbar-end { justify-self: end; display: flex; align-items: center; gap: 6px; }
/* search folds to an icon until it's used, so it doesn't hold a wide box open over the map */
.find { position: relative; display: flex; justify-content: flex-end; }
.find input { width: var(--control); height: var(--control); border: 1px solid var(--line-soft); border-radius: 999px; background-color: var(--glass-soft); -webkit-backdrop-filter: var(--blur-soft); backdrop-filter: var(--blur-soft); box-shadow: var(--shadow-soft); padding: 0 0 0 var(--control); font: inherit; font-size: var(--fs-2); color: var(--ink); -webkit-appearance: none; appearance: none; min-width: 0; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='6.8' cy='6.8' r='4.6' fill='none' stroke='%2317140f' stroke-width='1.6'/%3E%3Cpath d='M10.2 10.2 14 14' stroke='%2317140f' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 50% 50%; background-size: 13px; transition: width .25s ease, background-position .25s ease; }
.find input::placeholder { color: transparent; }
.find input:focus, .find input:not(:placeholder-shown) { width: 240px; padding: 0 12px 0 30px; background-position: 11px 50%; background-color: var(--paper); cursor: text; }
.find input:focus::placeholder { color: var(--muted); }
.find input:hover { border-color: var(--rule); }
.find input:focus { outline: 2px solid var(--ink); outline-offset: 0; }
.find-results { position: absolute; right: 0; width: 240px; top: calc(var(--control) + 6px); z-index: 5; list-style: none; margin: 0; padding: 4px; background: var(--paper); border-radius: 12px; box-shadow: var(--shadow-2); max-height: min(50vh, 420px); overflow-y: auto; }
.find-results li { padding: 7px 10px; border-radius: 8px; cursor: pointer; display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.find-results li[aria-selected="true"], .find-results li:hover { background: var(--haze); }
.find-results b { font-weight: 600; }
.find-results span { color: var(--muted); font-size: var(--fs-2); }
.find-results .none { color: var(--muted); cursor: default; }
.find-sel { position: absolute; right: 0; width: 240px; top: calc(var(--control) + 6px); display: flex; align-items: center; gap: 6px; background: var(--paper); border-radius: 999px; padding: 3px 3px 3px 12px; box-shadow: var(--shadow-1); font-size: var(--fs-2); }
.find-sel span { font-weight: 600; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.find-sel button { min-width: 24px; min-height: 24px; border: 0; background: none; border-radius: 999px; padding: 2px 8px; cursor: pointer; font-size: 15px; font-weight: 600; color: var(--muted); }
.find-sel[hidden], .find-results[hidden] { display: none; }
.about-open { height: var(--control); padding: 0 13px; border-radius: 999px; border: 1px solid var(--line-soft); background: var(--glass-soft); -webkit-backdrop-filter: var(--blur-soft); backdrop-filter: var(--blur-soft); box-shadow: var(--shadow-soft); font-size: var(--fs-2); font-weight: 600; cursor: pointer; transition: border-color .15s ease; }
.about-open:hover { border-color: var(--rule); }

/* ---------- Card stack: details for the open nav item, plus tour, quest and focus ---------- */
.stack { position: fixed; z-index: 10; left: max(var(--gutter), env(safe-area-inset-left, 0px)); top: calc(var(--top) + var(--control) + 24px); bottom: calc(var(--bottom) + var(--dock-h) + 52px); width: var(--stack-w);
  display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.sheet { position: relative; pointer-events: auto; flex: 0 1 auto; min-height: 0; overflow-y: auto; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--glass-line); border-radius: var(--radius); box-shadow: var(--shadow-2); font-size: var(--fs-3); }
.sheet[hidden] { display: none; }
.panel { display: flex; flex-direction: column; overflow: hidden; }
.stack > .sheet:not(.focusbox) { height: min(var(--sheet-h), 100%); }
.stack > .sheet.collapsed { height: auto; }
.walkcard.collapsed > :not(header):not(.q-close):not(.q-toggle), .questcard.collapsed > :not(header):not(.q-close):not(.q-toggle) { display: none; }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; padding: 13px 12px 12px var(--pad); }
.sheet-head > div { flex: 1; min-width: 0; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-size: var(--fs-4); font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
.sheet-dek { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-2); line-height: 1.45; }
.sheet-toggle { flex: none; width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(23,20,15,.06); display: grid; place-items: center; cursor: pointer; transition: background-color .15s ease; }
.sheet-toggle:hover { background: rgba(23,20,15,.12); }
.sheet-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .2s ease; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 4px var(--pad) var(--pad); border-top: 1px solid rgba(221,213,198,.6); }
.panel.collapsed .sheet-body, .panel.collapsed .sheet-dek { display: none; }
.panel.collapsed .sheet-head { align-items: center; padding-top: 12px; padding-bottom: 12px; }
.panel.collapsed .sheet-toggle svg { transform: rotate(180deg); }
.sheet-body h2 { margin: 0 0 8px; font-size: var(--fs-2); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.swatches { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.swatch { display: grid; grid-template-columns: 5px 1fr auto; gap: 10px; align-items: stretch; background: none; border: 0; text-align: left; padding: 6px 5px; font-size: var(--fs-3); cursor: pointer; border-radius: 8px; transition: background-color .15s ease, opacity .15s ease; }
.swatch:hover { background: rgba(23,20,15,.05); }
.swatch i { width: 5px; border-radius: 3px; }
.swatch > span:nth-child(2) { display: flex; flex-direction: column; line-height: 1.3; font-weight: 600; }
.swatch .era { color: var(--muted); font-weight: 400; font-size: var(--fs-1); }
.swatch .n { font-family: var(--mono); color: var(--ink); font-size: var(--fs-1); align-self: center; font-variant-numeric: tabular-nums; }
.swatch[aria-pressed="false"] > span { color: var(--muted); }
.swatch[aria-pressed="false"] i, .swatch[aria-pressed="false"] .fbar { opacity: .25; }
.swatch.total { cursor: default; border-top: 1px solid var(--rule); margin-top: 6px; padding-top: 10px; border-radius: 0; }
.swatch.total:hover { background: none; }
.swatch.total { grid-template-columns: 1fr auto; }
.swatch.total > span:first-child { font-weight: 600; line-height: 1.3; }
.floors .swatch > span:nth-child(2) { gap: 3px; }
.fbar { display: block; height: 3px; border-radius: 2px; margin-top: 3px; }
.note { color: var(--muted); font-size: var(--fs-1); margin: 12px 0 0; line-height: 1.5; }
.ramp { height: 10px; border-radius: 2px; margin: 4px 0 6px; }
.ramp-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: var(--fs-2); font-family: var(--mono); }
.icon { width: 16px; height: 16px; flex: none; }
.jump { margin: 0 -15px 6px; position: sticky; top: -4px; background: rgba(255,253,248,.96); padding: 10px 15px 8px; z-index: 1; }
/* one row: icons share the width and shrink a little rather than wrap */
.jump-icons { display: flex; justify-content: space-between; gap: 2px; }
.jump-icons button { flex: 0 1 26px; min-width: 24px; height: auto !important; aspect-ratio: 1; }
.jump-label { margin: 6px 0 0; font-size: var(--fs-1); color: var(--muted); }
.jump-label.on { color: var(--ink); font-weight: 600; }
.jump button { width: 26px; height: 26px; border: 1px solid var(--rule); border-radius: 50%; background: var(--paper); display: grid; place-items: center; cursor: pointer; color: var(--ink); transition: background-color .15s ease, border-color .15s ease; }
.jump button:hover { background: var(--accent); border-color: var(--accent); }
.sheet-body h2.section { display: flex; align-items: center; gap: 7px; margin: 16px 0 4px; font-size: var(--fs-1); scroll-margin-top: 76px; }
.layers { display: flex; flex-direction: column; margin: 0 -6px; }
.layer { display: grid; grid-template-columns: 1fr auto auto; align-items: baseline; gap: 0 10px; background: none; border: 0; text-align: left; padding: 6px; border-radius: 8px; cursor: pointer; font-size: var(--fs-2); }
.layer:hover { background: rgba(23,20,15,.05); }
.layer b { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer .era { font-size: var(--fs-1); color: var(--muted); white-space: nowrap; }
.layer .n { font-family: var(--mono); font-size: var(--fs-1); color: var(--ink); min-width: 3.6em; text-align: right; font-variant-numeric: tabular-nums; }
.panel .back { position: sticky; top: -4px; z-index: 2; display: block; width: calc(100% + 30px); margin: -4px -15px 10px; padding: 10px 15px; font-size: var(--fs-2); text-align: left; background: rgba(255,253,248,.96); border: 0; border-bottom: 1px solid var(--rule); color: var(--ink); font-weight: 600; cursor: pointer; }
.panel .back::before { content: "← "; }
.sheet-body h2.layer-title { display: flex; align-items: center; gap: 8px; letter-spacing: -0.02em; font-family: var(--display); font-size: var(--fs-4) !important; font-weight: 800 !important; letter-spacing: -0.02em; margin: 0 0 4px !important; line-height: 1.05; color: var(--ink) !important; text-transform: none !important; }
.layer-title .icon { width: 18px; height: 18px; }
.layer-era { margin: 0 0 8px; color: var(--muted); font-family: var(--mono); font-size: var(--fs-1); }
.layer-detail p { margin: 0 0 10px; line-height: 1.5; }
.stories { list-style: none; margin: 6px -8px 0; padding: 0; counter-reset: s; }
.story { display: grid; grid-template-columns: 20px 1fr; gap: 0 8px; align-items: start; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 8px; cursor: pointer; }
.story::before { grid-row: span 2; counter-increment: s; content: counter(s); width: 20px; height: 20px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: var(--fs-1); }
.story:hover { background: rgba(23,20,15,.05); }
.story b { display: block; font-weight: 600; grid-column: 2; }
.story span { display: block; grid-column: 2; color: var(--muted); font-size: var(--fs-1); line-height: 1.45; margin-top: 2px; }
.w-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.w-list button { width: 100%; text-align: left; border: 1px solid var(--rule); background: var(--paper); border-radius: var(--radius-sm); padding: 9px 12px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; transition: border-color .15s ease; }
.w-list button:hover { border-color: var(--ink); }
.w-list b { font-size: var(--fs-3); }
.w-list span { color: var(--muted); font-size: var(--fs-1); grid-column: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.w-list em { font-style: normal; font-size: var(--fs-1); font-weight: 600; grid-row: 1 / 3; grid-column: 2; align-self: center; font-family: var(--mono); white-space: nowrap; }

/* ---------- Time dock: full width along the bottom ---------- */
.dock { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: auto auto auto 1fr; align-items: center; gap: 20px;
  padding: 56px max(calc(var(--gutter) + 8px), env(safe-area-inset-right, 0px)) var(--bottom) max(var(--gutter), env(safe-area-inset-left, 0px));
  background: linear-gradient(to top, rgba(235,230,220,.97) 0%, rgba(235,230,220,.9) 45%, rgba(235,230,220,0) 100%); pointer-events: none; }
/* the faded top of the strip is decoration only, so clicks fall through to the map */
.dock > * { pointer-events: auto; }
.play { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--accent); box-shadow: 0 2px 8px rgba(40,30,10,.18); color: var(--ink); cursor: pointer; display: grid; place-items: center; transition: transform .15s ease; }
.play:hover { transform: scale(1.05); }
.play svg { width: 16px; height: 16px; fill: currentColor; }
.tally { display: flex; flex-direction: column; min-width: 136px; padding-right: 20px; border-right: 1px solid var(--rule); }
.tally-year { font-family: var(--display); font-size: var(--fs-5); font-weight: 800; letter-spacing: -0.03em; line-height: .95; font-variant-numeric: tabular-nums; }
.tally-count { color: var(--muted); font-family: var(--mono); font-size: var(--fs-1); margin-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dock canvas:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 4px; }
.dock canvas { width: 100%; min-width: 0; height: 56px; cursor: ew-resize; touch-action: none; display: block; }
/* reads as a sibling of the tally: small stacked lines closed off by the same divider */
.howto { display: flex; flex-direction: column; gap: 1px; margin: 0; padding-right: 20px; border-right: 1px solid var(--rule); font-size: var(--fs-1); line-height: 1.35; color: var(--muted); white-space: nowrap; }
.howto b { color: var(--ink); font-weight: 600; }
.status { position: fixed; z-index: 9; left: 50%; transform: translateX(-50%); white-space: nowrap; bottom: calc(var(--bottom) + var(--dock-h) + 12px); margin: 0; padding: 4px 12px; border-radius: 999px; font-size: var(--fs-2); color: var(--muted); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); pointer-events: none; }
.status[hidden] { display: none; }
.loading { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--muted); background: rgba(235,230,220,.9); padding: 6px 12px; border-radius: 6px; }

/* ---------- Building card ---------- */
.card { position: fixed; z-index: 13; pointer-events: none; background: var(--paper); border-radius: var(--radius); width: var(--stack-w); max-height: min(var(--sheet-h), var(--sheet-max)); overflow-y: auto; box-shadow: 0 10px 30px rgba(40,30,10,.18); font-size: var(--fs-2); border-top: 4px solid var(--accent); }
.card.pinned { pointer-events: auto; }
.card-close { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(255,255,255,.92); cursor: pointer; font-size: 18px; line-height: 1; z-index: 1; }
.card a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.card .photo { margin: 0; }
.card .photo .frame { position: relative; }
.card .photo img { display: block; width: 100%; height: 180px; object-fit: cover; background: var(--haze); }
.card .photo .year { position: absolute; left: 10px; bottom: 8px; background: var(--accent); color: var(--ink); font-size: var(--fs-2); font-weight: 700; padding: 2px 7px; border-radius: 4px; font-family: var(--mono); }
.card .photo .prev, .card .photo .next { position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(255,255,255,.92); cursor: pointer; font-size: 20px; line-height: 1; }
.card .photo .prev { left: 8px; } .card .photo .next { right: 8px; }
.card .photo .years { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px var(--pad) 0; }
.card .photo .years button { min-height: 24px; border: 1px solid var(--rule); background: none; border-radius: 4px; padding: 2px 7px; font-size: var(--fs-2); cursor: pointer; font-family: var(--mono); }
.card .photo .years button[aria-current] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.card .photo figcaption { font-size: var(--fs-1); color: var(--muted); padding: 5px var(--pad) 0; }
.card .sv { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px var(--pad); background: var(--haze); font-size: var(--fs-2); }
.card .sv a { font-weight: 600; }
.card .sv span:first-child { color: var(--muted); }
.card .sv.flat { margin-top: 8px; }
.card-head { padding: 12px var(--pad) 10px; }
.card .place-kind { margin: -2px 0 8px; color: var(--muted); font-size: var(--fs-2); }
.card-head h2 { margin: 0 0 6px; font-family: var(--display); font-size: var(--fs-4); font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; padding-right: 26px; }
.card .when { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card .y { font-family: var(--display); font-size: var(--fs-5); font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.card .y.approx { color: #3e3a33; }
.card .period { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.card .period i, .card .chips i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.card section { padding: 10px var(--pad); border-top: 1px solid var(--rule); }
.card h3 { margin: 0 0 6px; font-size: var(--fs-1); font-weight: 600; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.card .chips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.card .chips li { display: flex; gap: 8px; align-items: flex-start; }
.card .chips li i { margin-top: 5px; }
.card .chips b { font-weight: 600; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; }
.card dt { color: var(--muted); }
.card dd { margin: 0; text-align: right; font-family: var(--mono); font-size: var(--fs-2); font-variant-numeric: tabular-nums; }
.card .why { margin: 0; color: var(--muted); font-size: var(--fs-2); line-height: 1.45; }
.card .story-sec { background: var(--soft); border-top-color: #efdca0; }
.card .story-sec p { margin: 0 0 6px; line-height: 1.55; }
.card .extract { margin: 0 0 6px; line-height: 1.55; }
.card .hint { margin: 0; padding: 8px var(--pad) 12px; color: var(--muted); font-size: var(--fs-2); border-top: 1px solid var(--rule); }

/* ---------- About drawer ---------- */
dialog.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; border: 0; padding: 0; width: min(440px, 100vw); height: 100%; max-height: 100%; max-width: 100vw; overflow-y: auto; background: var(--paper); color: var(--ink); box-shadow: -24px 0 60px rgba(40,30,10,.18); }
dialog.drawer[open] { animation: drawer-in .32s cubic-bezier(.2,.8,.2,1); }
dialog.drawer::backdrop { background: rgba(23,20,15,.28); }
dialog.drawer[open]::backdrop { animation: fade-in .32s ease; }
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes fade-in { from { opacity: 0; } }
.about article { padding: 22px 24px 40px; font-size: var(--fs-3); }
.about h2 { margin: 0 0 14px; font-family: var(--display); font-size: var(--fs-5); font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
.about h2::after { content: ""; display: block; height: 4px; width: 56px; margin-top: 10px; background: repeating-linear-gradient(90deg, var(--accent) 0 11px, var(--ink) 11px 15px); border-radius: 2px; }
.about h3 { margin: 22px 0 6px; font-size: var(--fs-1); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.about p, .about li { line-height: 1.6; max-width: 64ch; margin: 0 0 10px; }
.about ul { padding-left: 18px; margin: 6px 0 0; }
.about li { margin-bottom: 6px; }
.about a { color: var(--ink); text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.about .credit { color: var(--muted); }
.about .notice { border-left: 3px solid var(--accent); padding-left: 12px; font-weight: 500; }
.about-close { position: sticky; float: right; top: 14px; margin: 14px 14px 0 0; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(23,20,15,.06); cursor: pointer; font-size: 16px; line-height: 1; z-index: 1; transition: background-color .15s ease; }
.about-close:hover { background: rgba(23,20,15,.12); }

/* ---------- Tour, quest and focus cards (inside the stack) ---------- */
.walkcard header, .questcard header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 10px; padding: 10px 72px 9px var(--pad); background: var(--ink); color: var(--paper); }
.walkcard header b, .questcard header b { font-size: var(--fs-2); }
.walkcard header .w-meta, .questcard header .w-meta { margin-left: auto; white-space: nowrap; font-size: var(--fs-1); font-family: var(--mono); color: var(--accent); }
.walkcard .q-close, .questcard .q-close { position: absolute; z-index: 2; top: 5px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; cursor: pointer; font-size: 18px; color: var(--paper); }
.q-toggle { position: absolute; z-index: 2; top: 5px; right: 36px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; cursor: pointer; color: var(--paper); display: grid; place-items: center; }
.q-toggle:hover, .walkcard .q-close:hover, .questcard .q-close:hover { background: rgba(255,253,248,.14); }
.q-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .2s ease; }
.collapsed > .q-toggle svg { transform: rotate(180deg); }
.walkcard :focus-visible, .questcard header ~ button:focus-visible { outline-color: var(--accent); }
.walkcard .w-actions { display: flex; gap: 6px; padding: 10px var(--pad); border-bottom: 1px solid var(--rule); }
.walkcard .w-actions button, .questcard .q-actions button { border: 1px solid var(--rule); background: var(--paper); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: var(--fs-2); font-weight: 600; }
.walkcard .w-actions .primary, .questcard .q-actions .primary { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.w-stops { list-style: none; margin: 6px 0 8px; padding: 0; }
.w-stops button { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px var(--pad); cursor: pointer; }
.w-stops button:hover, .w-stops button[aria-current="true"] { background: rgba(23,20,15,.05); }
.w-num { flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--ink); display: grid; place-items: center; font-size: var(--fs-2); font-weight: 800; margin-top: 1px; }
.w-stops b { display: block; font-size: var(--fs-2); }
.w-stops em { display: block; font-style: normal; font-size: var(--fs-1); color: var(--muted); }
.focusbox { flex: none; padding: 12px var(--pad); font-size: var(--fs-3); border-top: 4px solid #d4380d; }
.focusbox b { display: block; margin-bottom: 4px; }
.focusbox p { margin: 0 0 8px; color: var(--muted); font-size: var(--fs-2); }
.focusbox button { border: 1px solid var(--rule); background: var(--paper); border-radius: 999px; padding: 4px 11px; font-size: var(--fs-2); font-weight: 600; cursor: pointer; margin-right: 6px; }
.questcard input { background: rgba(255,255,255,.8); }

/* Quest */
.q-body { padding: 12px var(--pad) var(--pad); display: flex; flex-direction: column; gap: 10px; }
.q-dots { display: flex; gap: 3px; flex-wrap: wrap; }
.q-dots i { width: 12px; height: 4px; border-radius: 2px; background: var(--rule); }
.q-dots i.ok { background: #2f8f4f; } .q-dots i.miss { background: #d4380d; } .q-dots i.now { background: var(--ink); }
.q-text { margin: 0; font-size: var(--fs-3); line-height: 1.45; font-weight: 500; }
.q-form { display: flex; gap: 6px; }
.q-form input { flex: 1; min-width: 0; font: inherit; font-size: var(--fs-3); padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--paper); }
.q-form input:focus { outline: 2px solid var(--ink); outline-offset: 0; }
.q-form button { border: 0; background: var(--accent); border-radius: var(--radius-sm); padding: 0 14px; font-weight: 700; cursor: pointer; }
.q-hints { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.q-hints li { font-size: var(--fs-3); padding-left: 10px; border-left: 3px solid var(--accent); }
.q-feedback { margin: 0; font-size: var(--fs-3); min-height: 1.3em; color: var(--muted); }
.q-feedback.right { color: #2f6f3f; font-weight: 600; } .q-feedback.wrong { color: #b0300a; font-weight: 600; }
.q-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.q-score { margin-left: auto; font-family: var(--mono); font-size: var(--fs-2); color: var(--muted); }
.q-score b { color: var(--ink); font-size: var(--fs-3); }
.q-shake { animation: qshake .32s; }
@keyframes qshake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.q-intro p { margin: 0 0 8px; line-height: 1.5; }
.q-levels { display: flex; flex-direction: column; gap: 6px; }
.q-levels button { text-align: left; border: 1px solid var(--rule); background: var(--paper); border-radius: var(--radius-sm); padding: 9px 12px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.q-levels button:hover { border-color: var(--ink); }
.q-levels span { color: var(--muted); font-size: var(--fs-2); }
.q-levels em { font-style: normal; font-family: var(--mono); font-size: var(--fs-2); grid-row: 1 / 3; grid-column: 2; align-self: center; }

/* Graph */
.graph { position: fixed; z-index: 5; inset: 0; background: var(--haze); }
#g-svg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
.g-panel { position: absolute; left: var(--gutter); top: calc(var(--top) + var(--control) + 24px); height: min(var(--sheet-h), var(--sheet-max)); width: min(var(--stack-w), calc(100% - 32px)); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--glass-line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: var(--pad); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.g-head { display: flex; align-items: flex-start; gap: 10px; }
.g-head > div { flex: 1; min-width: 0; }
.g-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.g-panel.collapsed { height: auto !important; }
.g-panel.collapsed .g-body, .g-panel.collapsed .g-lede { display: none; }
.g-panel.collapsed .g-head { align-items: center; }
.g-panel.collapsed .sheet-toggle svg { transform: rotate(180deg); }
.g-panel h2 { margin: 0; font-family: var(--display); font-size: var(--fs-4); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; text-wrap: balance; }
.g-lede { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-2); line-height: 1.45; }
.g-panel input { width: 100%; font: inherit; font-size: var(--fs-3); padding: 7px 10px; border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.g-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.g-kinds button { min-height: 26px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule); background: var(--paper); border-radius: 999px; padding: 3px 10px; font-size: var(--fs-2); font-weight: 600; cursor: pointer; }
.g-kinds button span { color: var(--muted); font-weight: 500; font-family: var(--mono); }
.g-kinds button i { width: 8px; height: 8px; border-radius: 50%; }
.g-kinds button[aria-pressed="false"] { color: var(--muted); border-style: dashed; }
.g-kinds button[aria-pressed="false"] i { opacity: .3; }
.g-chips { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--rule); padding-top: 10px; }
.g-chip { min-height: 26px; border: 0; background: #b52f0a; color: #fff; border-radius: 999px; padding: 3px 10px; font-size: var(--fs-2); font-weight: 600; cursor: pointer; }
.g-show { border: 0; background: var(--accent); color: var(--ink); border-radius: 999px; padding: 9px 14px; font-size: var(--fs-3); font-weight: 700; cursor: pointer; width: 100%; }
.g-clear { border: 0; background: none; color: var(--muted); font-size: var(--fs-2); text-decoration: underline; cursor: pointer; padding: 0; align-self: flex-start; }
.g-ent h3 { margin: 6px 0 6px; font-size: var(--fs-3); }
.g-ent h3 span { color: var(--muted); font-weight: 500; font-size: var(--fs-2); }
.g-bld { display: grid; grid-template-columns: 34px 1fr; gap: 8px; margin-bottom: 9px; font-size: var(--fs-2); line-height: 1.45; }
.g-bld i { width: 34px; height: 34px; border-radius: 4px; background: #c9c2b4; display: grid; place-items: center; color: #fff; font-style: normal; font-weight: 800; font-size: var(--fs-1); }
.g-bld b { display: block; font-size: var(--fs-3); }
.g-bld a { color: var(--muted); }
.g-foot { margin-top: auto; color: var(--muted); font-size: var(--fs-2); }
.g-tip { position: absolute; pointer-events: none; background: var(--paper); border-radius: 6px; padding: 5px 8px; font-size: var(--fs-2); box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.g-tip b { display: block; }
.g-tip span { color: var(--muted); }


@media (max-width: 960px) {
  .topnav svg { display: none; }
  .wordmark small { display: none; }
}

@media (max-width: 860px) {
  :root { --gutter: 10px; --control: 34px; --dock-h: 60px; }
  .topbar { grid-template-columns: auto 1fr; gap: 8px 10px; }
  .brand { gap: 4px; }
  .wordmark { font-size: 22px; }
  .stripe { width: 44px; }
  .topbar-end { justify-self: stretch; grid-row: 1; grid-column: 2; }
  .find { flex: 1; }
  .find input, .find input:focus, .find input:not(:placeholder-shown) { width: 100%; padding: 0 12px 0 30px; background-position: 11px 50%; cursor: text; }
  .find input::placeholder { color: var(--muted); }
  .find-results, .find-sel { left: 0; width: auto; }
  .topnav { grid-row: 2; grid-column: 1 / -1; justify-self: stretch; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent); mask-image: linear-gradient(90deg, #000 82%, transparent); }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav svg { display: block; }
  .topnav button { flex: none; padding: 0 12px; height: 30px; }
  .stack { top: auto; left: var(--gutter); right: var(--gutter); width: auto; bottom: calc(var(--bottom) + var(--dock-h) + 8px); max-height: 48vh; justify-content: flex-end; }
  .sheet-head { padding: 12px 12px 12px 16px; }
  .stack > .sheet:not(.focusbox) { height: auto; }
  .sheet-head h2 { font-size: var(--fs-4); }
  .dock { gap: 12px; padding-top: 40px; grid-template-columns: auto auto 1fr; }
  .play { width: 40px; height: 40px; }
  .tally { min-width: 0; padding-right: 12px; }
  .tally-year { font-size: 22px; }
  .tally-count { display: none; }
  .dock canvas { height: 44px; }
  .howto, .status { display: none; }
  .card, .card.pinned { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto; max-height: 62vh; border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .graph { bottom: 0; }
  .g-panel { top: auto !important; bottom: var(--gutter); left: var(--gutter); right: var(--gutter); width: auto; height: 46%; }
  .about article { padding: 24px 20px 32px; }
}

/* ---------- Navigation kit: right edge, centred between the top bar and the dock ---------- */
.navkit { --nk: 28px; position: fixed; z-index: 11; right: max(var(--gutter), env(safe-area-inset-right, 0px)); bottom: calc(var(--bottom) + 72px);
  display: grid; grid-template-columns: repeat(3, var(--nk)); grid-template-rows: repeat(3, var(--nk)); gap: 1px; padding: 3px; border-radius: 11px;
  background: var(--glass-soft); -webkit-backdrop-filter: var(--blur-soft); backdrop-filter: var(--blur-soft); border: 1px solid var(--line-soft); box-shadow: var(--shadow-soft); }
.navkit button { width: var(--nk); height: var(--nk); font: inherit; cursor: pointer; color: var(--ink); border: 0; background: none; border-radius: 7px; padding: 0; display: grid; place-items: center; touch-action: none; transition: background-color .15s ease; }
.navkit button:hover { background: rgba(23,20,15,.08); }
.navkit svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; }
/* turn and tilt around the compass; spin and the zoom pair fill the free corners */
.navkit [data-nk="rot-left"] { grid-area: 1 / 1; }
.navkit [data-nk="tilt-up"] { grid-area: 1 / 2; }
.navkit [data-nk="rot-right"] { grid-area: 1 / 3; }
.navkit .compass { grid-area: 2 / 2; border-radius: 50%; background: rgba(255,253,248,.85); box-shadow: inset 0 0 0 1px var(--glass-line); }
.navkit .compass svg { width: 20px; height: 20px; stroke: none; }
.navkit [data-nk="zoom-in"] { grid-area: 2 / 3; }
.navkit #nk-spin { grid-area: 3 / 1; font-size: var(--fs-1); font-weight: 700; letter-spacing: -0.02em; }
.navkit #nk-spin[aria-pressed="true"] { background: var(--accent); }
.navkit [data-nk="tilt-down"] { grid-area: 3 / 2; }
.navkit [data-nk="zoom-out"] { grid-area: 3 / 3; }
/* finger-sized targets on touch screens */
@media (pointer: coarse) { .navkit { --nk: 36px; } }
body.graphing .dock, body.graphing .howto, body.graphing .status, body.graphing .find, body.graphing .navkit, body.graphing .stack { display: none; }
@media (max-width: 860px) {
  .navkit { top: calc(var(--top) + 2 * var(--control) + 26px); bottom: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Card links: Google Maps and Panorama ---------- */
.card .go { display: flex; gap: 8px; padding: 10px var(--pad); background: var(--haze); }
.card .go.flat { margin-top: 8px; }
/* with no photo the link row is the card's top edge, so leave room for the close button */
.card-close + .go { padding-right: 52px; }
.card .go a, .card .go button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 10px; border-radius: 999px; font: 600 var(--fs-2)/1.2 var(--body); text-decoration: none; cursor: pointer; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); }
.card .go button { background: var(--accent); border-color: var(--accent); }
.card .go a:hover { border-color: var(--ink); }
.card .go svg { width: 14px; height: 14px; }

/* ---------- Panorama: street level in front of the building ---------- */
.pano-bar { position: fixed; z-index: 14; bottom: calc(env(safe-area-inset-bottom, 0px) + 28px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 16px; border-radius: 999px; background: rgba(23,20,15,.82); color: var(--paper); font-size: var(--fs-3); box-shadow: 0 6px 20px rgba(40,30,10,.2); max-width: calc(100vw - 200px); }
.pano-bar[hidden] { display: none; }
.pano-bar b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pano-bar span { color: rgba(255,253,248,.7); font-size: var(--fs-2); white-space: nowrap; }
.pano-bar button { border: 0; border-radius: 999px; padding: 7px 14px; background: var(--accent); color: var(--ink); font-weight: 700; font-size: var(--fs-2); cursor: pointer; white-space: nowrap; }
body.pano .howto, body.pano .dock, body.pano #status, body.pano .questcard, body.pano .walkcard, body.pano .focusbox { display: none !important; }
body.pano #scene { cursor: grab; }
body.pano #scene:active { cursor: grabbing; }
@media (max-width: 860px) {
  .pano-bar { left: 50%; max-width: calc(100vw - 24px); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }
  .pano-bar span { display: none; }
  body.pano .stack { display: none; }
}


/* ---------- Opening animation ---------- */
#loading.intro { position: fixed; inset: 0; left: 0; top: 0; transform: none; z-index: 60; padding: 24px; border-radius: 0; background: #0b0b0c; color: #f3eee4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; transition: opacity .7s ease; }
#loading.intro.out { opacity: 0; pointer-events: none; }
.intro-art { height: min(52vh, 440px); aspect-ratio: 48 / 100; }
.intro-art canvas { width: 100%; height: 100%; display: block; }
.intro-count { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.intro-count b { display: flex; font-family: var(--mono); font-size: clamp(32px, 6vw, 56px); font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
/* each character has its own fixed cell; leading zeros sit dim until the count reaches them */
.intro-count i { font-style: normal; width: 1ch; text-align: center; color: #3a3833; transition: color .2s ease; }
.intro-count i.on { color: #f3eee4; }
.intro-count span { color: #a39c8f; font-size: var(--fs-3); }
