/* Jerusalem at Passover: viewer styles.
   Warm stone-and-ink palette; translucent dark panels over the 3D view. */

:root {
  --ink: #14110e;
  --panel: rgba(24, 20, 16, 0.82);
  --panel-solid: #1d1915;
  --panel-raised: rgba(44, 37, 29, 0.9);
  --line: rgba(233, 220, 196, 0.16);
  --line-strong: rgba(233, 220, 196, 0.32);
  --text: #f0e7d8;
  --muted: #bdb09a;
  --accent: #dcb670;
  --accent-ink: #1b150d;
  --stone: #cbbd9f;
  --attested: #9cc79a;
  --reconstructed: #dcb670;
  --traditional: #94b8d6;
  --conjectural: #c3a4ee;
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --radius: 10px;
  --gap: 16px;
  --top: 64px;
  --left-inset: var(--gap);
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.38);
  /* notches and home indicators: the chrome keeps inside them, the picture runs underneath */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
/* Keyboard focus on the view is shown on the mode switch, not as a frame round the picture. */
#view:focus-visible { outline: none; }
body:has(#view:focus-visible) .modes { box-shadow: 0 0 0 2px var(--accent); }

#fade { position: fixed; inset: 0; background: #0b0907; opacity: 0; pointer-events: none; transition: opacity 0.28s ease; z-index: 3; }
#fade.on { opacity: 1; }

#reticle { position: fixed; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: rgba(240, 231, 216, 0.75); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45); opacity: 0; pointer-events: none; z-index: 2; transition: opacity 0.2s; }
body.mode-walk.locked #reticle, body.mode-fly.locked #reticle { opacity: 1; }

/* ------------------------------------------------------------------ labels in the view */

#labels { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
body.is-loading #labels, body.is-opening #labels, body.labels-off #labels { display: none; }

.label {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  /* the pointer goes through to the view, which works out what was clicked (see Places.hitLabel):
     a wheel or a drag that starts on a label must zoom and turn the view like any other */
  pointer-events: none;
  transition: opacity 0.25s ease;
  color: var(--text);
}
/* Hidden always wins: a label that is both hidden and dimmed must not linger as a ghost.
   A label goes at once (it comes with a fade): one that is fading out is, for that quarter
   of a second, a name lying across whatever the camera has just turned to, and where frames
   come slowly it lies there for as long as the next frame takes. */
.label[data-hidden] { opacity: 0; visibility: hidden; pointer-events: none; transition: none; }
.label:not([data-hidden]) { will-change: transform; }
.label[data-occluded]:not([data-hidden]) { opacity: 0.42; }
.label[data-below] { flex-direction: column-reverse; }
.label[data-below] .label-stem { transform: scaleY(-1); }
.label[data-focus] .label-text { border-color: var(--accent); background: rgba(58, 43, 20, 0.92); box-shadow: 0 0 0 1px rgba(220, 182, 112, 0.35); }
.label[data-focus] .label-dot { width: 9px; height: 9px; box-shadow: 0 0 0 1.5px rgba(20, 17, 14, 0.85), 0 0 10px 2px rgba(255, 210, 122, 0.7); }
.label .label-text {
  padding: 3px 9px 4px; border-radius: 999px;
  background: rgba(20, 17, 14, 0.74); border: 1px solid var(--line);
  font: 500 12px/1.2 var(--sans); letter-spacing: 0.02em; white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.label .label-stem { width: 1px; height: 14px; background: linear-gradient(rgba(240, 231, 216, 0.75), rgba(240, 231, 216, 0.15)); }
.label .label-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--accent)); box-shadow: 0 0 0 1.5px rgba(20, 17, 14, 0.85); }
.label[data-hover] .label-text, .label:focus-visible .label-text, .label[aria-current="true"] .label-text { background: var(--accent); color: var(--accent-ink); border-color: transparent; text-shadow: none; }
#view.over-label, body.mode-walk #view.over-label, body.mode-fly #view.over-label { cursor: pointer; }
.label:focus-visible { outline: none; }

/* the name of an optional line that is switched on: it hangs under a point of the line, and
   is squared off and edged in the line's colour so that it is not taken for a place */
.line-label {
  position: absolute; left: 0; top: 0;
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 9px 4px 8px; border-radius: 6px;
  background: rgba(20, 17, 14, 0.8); border: 1px solid color-mix(in srgb, var(--line-colour) 70%, transparent);
  color: var(--text); font: 500 12px/1.2 var(--sans); letter-spacing: 0.02em; white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); pointer-events: none; transition: opacity 0.25s ease; will-change: transform;
}
.line-label i { flex: none; width: 16px; height: 0; border-top: 2px solid var(--line-colour); }
.line-label[data-hint="later"] i { border-top-style: dashed; }
.line-label[data-hidden] { opacity: 0; visibility: hidden; transition: none; }

/* ------------------------------------------------------------------ chrome */

#ui { position: fixed; inset: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); pointer-events: none; z-index: 2; transition: opacity 0.4s ease; }
#ui > * { pointer-events: auto; }
body.is-loading #ui, body.is-opening #ui { opacity: 0; pointer-events: none; }
body.is-loading #ui > *, body.is-opening #ui > * { pointer-events: none; }

.glass {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px) saturate(1.1); backdrop-filter: blur(14px) saturate(1.1);
}

#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 12px var(--gap);
  background: linear-gradient(rgba(14, 11, 9, 0.62), rgba(14, 11, 9, 0));
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.brand { display: flex; flex-direction: column; align-items: flex-start; text-align: left; line-height: 1.05; margin-right: 6px; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }
.brand-title { font: 600 21px/1.05 var(--serif); letter-spacing: 0.01em; }
.brand-sub { font: 500 10.5px/1.4 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }

.modes, .tools {
  display: flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.tools { margin-left: auto; }
.modes button, .tools button {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 34px; padding: 0 13px; border-radius: 999px;
  font-weight: 500; font-size: 13px; color: var(--muted); white-space: nowrap;
  transition: background 0.18s, color 0.18s;
}
.modes button:hover, .tools button:hover { color: var(--text); background: rgba(233, 220, 196, 0.08); }
.modes button[aria-pressed="true"], .tools button[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); }
.tools-sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 4px; }
.tools button#btn-settings, .tools button#btn-help { padding: 0 9px; }

/* drawer */
#drawer {
  position: absolute; top: var(--top); left: var(--gap); bottom: var(--gap); width: 328px;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  animation: slide-in 0.22s ease both;
}
@keyframes slide-in { from { opacity: 0; transform: translateX(-10px); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } }

.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font: 600 22px/1.1 var(--serif); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--muted); transition: background 0.18s, color 0.18s; }
.icon-btn:hover { background: rgba(233, 220, 196, 0.1); color: var(--text); }

.panel { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 18px; scrollbar-width: thin; scrollbar-color: rgba(233, 220, 196, 0.25) transparent; }
.panel h3 { margin: 18px 0 8px; font: 600 11px/1.3 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.panel-intro, .panel-note { color: var(--muted); font-size: 13px; }
.panel-note { margin: 4px 0 10px 26px; }
.panel-actions { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(233, 220, 196, 0.05);
  font-weight: 500; font-size: 13px; white-space: nowrap;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.btn:hover { background: rgba(233, 220, 196, 0.13); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #e9c98a; }
.btn.quiet { border-color: transparent; background: none; color: var(--muted); }
.btn.quiet:hover { color: var(--text); background: rgba(233, 220, 196, 0.08); }
.btn.large { min-height: 44px; padding: 0 22px; font-size: 14.5px; }
.btn:disabled { opacity: 0.4; cursor: default; }
.link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 13.5px; }
.link:hover { color: #efd197; }

.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; cursor: pointer; }
.check.strong { font-weight: 600; font-size: 14px; }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 17px; height: 17px; margin: 1px 0 0; border: 1.5px solid var(--line-strong); border-radius: 4px; background: rgba(0, 0, 0, 0.25); display: grid; place-items: center; cursor: pointer; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { content: ""; width: 9px; height: 5px; border: 2px solid var(--accent-ink); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]:checked { background: rgba(0, 0, 0, 0.25); }
.check input[type="radio"]:checked::after { width: 9px; height: 9px; border: 0; border-radius: 50%; background: var(--accent); transform: none; }
.check input:disabled { opacity: 0.45; cursor: default; }
.check:has(input:disabled) { cursor: default; }

/* tour list */
.tour-list { margin-top: 14px; }
.tour-day { margin: 16px 0 6px; font: 600 11px/1.3 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.tour-list button { display: grid; grid-template-columns: 22px 1fr; gap: 2px 8px; width: 100%; text-align: left; padding: 8px 8px; border-radius: 8px; transition: background 0.18s; }
.tour-list button:hover { background: rgba(233, 220, 196, 0.08); }
.tour-list button[aria-current="step"] { background: rgba(220, 182, 112, 0.16); }
.tour-list .n { grid-row: span 2; font: 600 17px/1.2 var(--serif); color: var(--muted); font-variant-numeric: tabular-nums; }
.tour-list button[aria-current="step"] .n { color: var(--accent); }
.tour-list .t { font-weight: 500; }
.tour-list .w { color: var(--muted); font-size: 12px; }

/* places */
.search { position: relative; margin-bottom: 12px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; height: 38px; padding: 0 12px 0 36px; border-radius: 999px; border: 1px solid var(--line-strong); background: rgba(0, 0, 0, 0.25); }
.search input::placeholder { color: var(--muted); }
.place-list { margin-top: 12px; }
.place-list button { display: grid; grid-template-columns: 12px 1fr; align-items: baseline; gap: 2px 9px; width: 100%; text-align: left; padding: 8px 8px; border-radius: 8px; transition: background 0.18s; }
.place-list button:hover { background: rgba(233, 220, 196, 0.08); }
.place-list button[aria-current="true"] { background: rgba(220, 182, 112, 0.16); }
.place-list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); transform: translateY(-1px); }
.place-list .name { font-weight: 500; overflow-wrap: anywhere; }
.place-list .meta { grid-column: 2; color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 12px 8px; }
#place-more { margin: 10px 0 0 4px; }

/* layers */
.legend { display: grid; grid-template-columns: 14px 1fr; gap: 6px 9px; align-items: center; margin: 0 0 4px 26px; font-size: 12px; color: var(--muted); }
.swatch { width: 14px; height: 14px; border-radius: 3px; }
.swatch.conj { background: var(--conjectural); }
.swatch.firm { background: var(--stone); }
.layer-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.layer-list .check { flex: 1; }
.layer-list .tag { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--conjectural); border: 1px solid currentColor; border-radius: 999px; padding: 1px 7px; white-space: nowrap; }
.layer-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.layer-tags:empty { display: none; }
.layer-list .tag.stop { color: var(--accent); white-space: nowrap; }
.layer-list .tris { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.layer-list .failed { color: #e7a08e; font-size: 12px; white-space: nowrap; }
.layer-list li.off { opacity: 0.55; }
.layer-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.layer-desc { color: var(--muted); font-size: 12px; line-height: 1.4; }
/* layers that are alternatives to one another: one boxed group of radio buttons */
.layer-list li.variant { display: block; margin: 6px 0; padding: 8px 10px 5px; border: 1px solid var(--line); border-radius: 8px; background: rgba(0, 0, 0, 0.16); }
.variant-name { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 3px; font-weight: 600; font-size: 13px; }
.variant-hint { font: 500 10.5px/1.3 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.variant-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
/* optional lines: a sample of the line in its colour stands at the end of each row */
.panel-note.flush { margin-left: 0; }
.hint-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.hint-key { display: inline-flex; align-items: center; gap: 6px; }
.line-swatch { flex: none; display: inline-block; width: 22px; height: 0; border-top: 3px solid var(--line-colour); filter: drop-shadow(0 0 3px color-mix(in srgb, var(--line-colour) 60%, transparent)); }
.line-swatch[data-hint="later"] { border-top-style: dashed; }
.layer-list li.overlay { align-items: flex-start; }
.layer-list li.overlay .line-swatch { margin-top: 9px; }
.layer-list li.overlay:not([data-on]) .layer-desc { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.problems { margin-top: 18px; padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(201, 111, 90, 0.5); background: rgba(201, 111, 90, 0.1); color: #f1c3b6; font-size: 12.5px; }
.problems b { display: block; color: #ffd9cd; margin-bottom: 4px; }
.problems li + li { margin-top: 4px; }

/* info card: the title and the two actions stay put; only the text between them scrolls */
#infocard {
  position: absolute; top: var(--top); right: var(--gap); width: 348px; max-height: calc(100% - var(--top) - 356px);
  min-height: 180px; display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  animation: rise-in 0.22s ease both;
}
.info-head { position: relative; flex: none; padding: 16px 20px 10px; }
#infocard .close { position: absolute; top: 10px; right: 10px; }
.kicker { font: 600 10.5px/1.4 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
#infocard h2 { font: 600 24px/1.12 var(--serif); margin: 4px 30px 0 0; overflow-wrap: anywhere; }
.info-sub { margin: 5px 30px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.info-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 20px 12px; scrollbar-width: thin; scrollbar-color: rgba(233, 220, 196, 0.25) transparent; }
.evidence { display: flex; flex-direction: column; gap: 4px; padding: 9px 11px; border-radius: 8px; background: rgba(0, 0, 0, 0.24); border-left: 3px solid var(--dot, var(--accent)); margin-bottom: 12px; }
.evidence .level { font-weight: 600; font-size: 12.5px; letter-spacing: 0.04em; color: var(--dot, var(--accent)); }
.evidence .what { font-size: 12.5px; color: var(--muted); }
.evidence .raw { font-size: 11.5px; color: var(--muted); }
.evidence .link { align-self: flex-start; margin-top: 2px; font-size: 12.5px; }
.info-body .see { color: var(--muted); }
.info-body .see .link { font-size: 13px; }
.info-body h3 { margin: 14px 0 4px; font: 600 10.5px/1.4 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.info-body h3:first-child { margin-top: 2px; }
.info-body p { font-size: 13.5px; }
.info-body ul { padding-left: 16px; list-style: disc; color: var(--muted); font-size: 12.5px; }
.info-body li + li { margin-top: 2px; }
.info-body a { color: var(--accent); text-underline-offset: 2px; }
.card-actions { flex: none; display: flex; gap: 8px; padding: 10px 20px 14px; border-top: 1px solid var(--line); }

/* bottom stack */
#bottom {
  position: absolute; left: var(--left-inset); right: 300px; bottom: var(--gap);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none; transition: left 0.22s ease;
}
#bottom > * { pointer-events: auto; width: 100%; max-width: 760px; }

#timebar { padding: 9px 14px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.time-row { display: flex; align-items: center; gap: 12px; }
#time-readout { font: 600 20px/1 var(--serif); font-variant-numeric: tabular-nums; min-width: 52px; }
.time-name { min-width: 92px; text-align: right; color: var(--muted); font-size: 12.5px; }
input[type="range"] { -webkit-appearance: none; appearance: none; flex: 1; height: 22px; background: none; cursor: pointer; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #232a45 0%, #e09a62 13%, #f1e2b6 26%, #f6efd6 50%, #f1e2b6 74%, #e58e53 88%, #232a45 100%); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #232a45 0%, #e09a62 13%, #f1e2b6 26%, #f6efd6 50%, #f1e2b6 74%, #e58e53 88%, #232a45 100%); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--text); border: 2px solid var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--text); border: 2px solid var(--ink); }
.settings input[type="range"]::-webkit-slider-runnable-track { background: var(--line-strong); }
.settings input[type="range"]::-moz-range-track { background: var(--line-strong); }
.presets { display: flex; gap: 4px; margin-top: 7px; overflow-x: auto; scrollbar-width: none; }
.presets::-webkit-scrollbar { display: none; }
.presets button { flex: 1 0 auto; min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--muted); border: 1px solid transparent; transition: background 0.18s, color 0.18s; white-space: nowrap; }
.presets button:hover { color: var(--text); background: rgba(233, 220, 196, 0.08); }
.presets button[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: rgba(220, 182, 112, 0.14); }
.time-note { margin-bottom: 8px; padding-bottom: 7px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.45; }

/* tour caption card */
#tourcard { position: relative; display: flex; flex-direction: column; max-height: calc(100dvh - var(--top) - 170px); padding: 14px 18px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); animation: rise-in 0.25s ease both; overflow: hidden; }
/* the card's text scrolls where it is too long for the screen; the stops above it and the
   controls below it stay where they are. A text with more below fades out at its foot. */
.tour-text { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(233, 220, 196, 0.25) transparent; }
.tour-text.more-below { -webkit-mask-image: linear-gradient(#000 calc(100% - 30px), transparent); mask-image: linear-gradient(#000 calc(100% - 30px), transparent); }
.tour-progress { flex: none; display: flex; align-items: center; gap: 5px; margin: -5px 0 4px; flex-wrap: wrap; }
.tour-progress button { width: 22px; height: 24px; display: grid; place-items: center; }
.tour-progress button::after { content: ""; width: 100%; height: 3px; border-radius: 2px; background: var(--line-strong); transition: background 0.2s, height 0.2s; }
.tour-progress button.done::after { background: rgba(220, 182, 112, 0.55); }
.tour-progress button[aria-current="step"]::after { background: var(--accent); height: 5px; }
.tour-progress .gap { width: 6px; }
#tourcard h2 { font: 600 26px/1.14 var(--serif); margin: 2px 0 4px; text-wrap: balance; }
.refs { color: var(--stone); font-size: 12.5px; font-style: italic; font-family: var(--serif); font-size: 15.5px; }
.lead { margin: 2px 0 6px; color: var(--text); font-size: 14px; max-width: 72ch; }
.note { margin-top: 6px; color: var(--muted); font-size: 13px; max-width: 72ch; }
/* a long note is folded to its first lines so the card does not take the view; "Read the note" opens it */
.note.folded { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.link.more { margin-top: 3px; font-size: 12.5px; }
.tour-progress.dense { gap: 0; flex-wrap: nowrap; }
.tour-progress.dense button { flex: 1 1 0; min-width: 2px; max-width: 24px; width: auto; padding: 0 1.5px; }
.tour-progress.dense .gap { flex: 0 1 5px; width: 5px; min-width: 2px; }
.tour-controls { flex: none; display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
/* the last stop: where to go from here */
.tour-finish { flex: none; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.tour-finish .link { margin-left: 10px; font-size: 13px; }
.tour-controls .btn.quiet { gap: 0.28em; }
.tour-count { margin: 0 auto 0 6px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
/* while walking, the card shrinks to its title and controls so it does not hide the street */
body.mode-walk #tourcard :is(.note, .more, .lead, .refs, .tour-progress, .layer-note, .tour-finish), body.mode-fly #tourcard :is(.note, .more, .lead, .refs, .tour-progress, .layer-note, .tour-finish) { display: none; }
/* which layers the stop on show has switched on or off */
.layer-note { margin: 5px 0 0; font-size: 12px; color: var(--accent); }
body.mode-walk #tourcard h2, body.mode-fly #tourcard h2 { font-size: 20px; }
#tour-play .i-pause { display: none; }
#tour-play[aria-pressed="true"] .i-pause { display: block; }
#tour-play[aria-pressed="true"] .i-play { display: none; }
.tour-dwell { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; }
.tour-dwell i { display: block; height: 100%; width: 0; background: var(--accent); }

/* minimap + hud (right column) */
#minimap { position: absolute; right: var(--gap); bottom: var(--gap); width: 268px; padding: 7px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
#minimap canvas { display: block; width: 252px; height: 235px; border-radius: 6px; cursor: crosshair; }
#minimap .icon-btn { position: absolute; top: 9px; right: 9px; width: 24px; height: 24px; background: rgba(20, 17, 14, 0.7); }
#minimap.collapsed { width: auto; padding: 4px; }
#minimap.collapsed canvas { display: none; }
#minimap.collapsed .icon-btn { position: static; width: 32px; height: 32px; background: none; transform: rotate(180deg); }

#hud { position: absolute; right: var(--gap); bottom: 278px; width: 268px; display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
body.map-collapsed #hud { bottom: 68px; }
.compass { width: 40px; height: 40px; flex: none; border-radius: 50%; }
.compass:hover .ring { stroke: var(--accent); }
/* "whole city": tucked into the corner of the readout, beside the heading (which is short) */
#hud-home { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; }
#hud-home svg { width: 15px; height: 15px; }
#hud .readout div:first-child { padding-right: 24px; }
.compass svg { width: 100%; height: 100%; stroke-width: 1; }
.compass .ring { stroke: var(--line-strong); fill: rgba(0, 0, 0, 0.25); }
.compass .north { fill: var(--accent); stroke: none; }
.compass .south { fill: rgba(233, 220, 196, 0.35); stroke: none; }
.compass .n { fill: var(--text); stroke: none; font: 600 8px var(--sans); text-anchor: middle; display: none; }
.compass .lubber { stroke: var(--text); stroke-width: 2; }
#compass-rose { transform-origin: 32px 32px; }
.readout { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.readout div { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.readout dt { color: var(--muted); flex: none; }
.readout dd { flex: 1; min-width: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#hint { position: absolute; left: 50%; top: calc(var(--top) + 6px); transform: translateX(-50%); padding: 7px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; color: var(--text); white-space: nowrap; pointer-events: none !important; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
/* the hint is for the bare view: it steps aside for an open panel or place card */
body.drawer-open #hint, body.info-open #hint { display: none; }
#notice { position: absolute; left: var(--gap); top: calc(var(--top) + 2px); max-width: 300px; padding: 7px 12px; border-radius: 8px; background: rgba(60, 44, 20, 0.86); border: 1px solid rgba(220, 182, 112, 0.4); font-size: 12px; color: #f0deb8; pointer-events: none !important; }
body.drawer-open #notice, body.mode-walk #notice, body.mode-fly #notice, body.tour-on #notice { display: none; }
#toast { position: absolute; left: 50%; top: calc(var(--top) + 46px); transform: translateX(-50%); max-width: calc(100% - 24px); padding: 8px 16px; border-radius: 999px; background: var(--panel-solid); border: 1px solid var(--line-strong); font-size: 13px; opacity: 0; transition: opacity 0.25s; pointer-events: none !important; white-space: nowrap; }
#toast.on { opacity: 1; }

#joystick { position: absolute; left: 22px; bottom: 150px; width: 112px; height: 112px; border-radius: 50%; background: rgba(20, 17, 14, 0.45); border: 1px solid var(--line-strong); touch-action: none; }
#joystick i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(240, 231, 216, 0.8); }

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

dialog { padding: 0; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--panel-solid); color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55); max-width: min(760px, calc(100vw - 28px)); max-height: calc(100dvh - 40px); width: 100%; overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; animation: rise-in 0.28s ease both; }
dialog::backdrop { background: rgba(10, 8, 6, 0.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 12px 26px; border-bottom: 1px solid var(--line); }
.dialog-head h1 { font: 600 28px/1.1 var(--serif); }
.dialog-body { overflow-y: auto; padding: 18px 26px 26px; scrollbar-width: thin; scrollbar-color: rgba(233, 220, 196, 0.25) transparent; }

#opening { max-width: min(640px, calc(100vw - 28px)); padding: 34px 38px 26px; background: rgba(26, 22, 18, 0.9); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); overflow-y: auto; }
#opening::backdrop { background: radial-gradient(ellipse at center, rgba(10, 8, 6, 0.25), rgba(10, 8, 6, 0.7)); -webkit-backdrop-filter: none; backdrop-filter: none; }
#opening h1 { font: 600 clamp(32px, 6vw, 46px)/1.04 var(--serif); margin: 8px 0 14px; letter-spacing: -0.005em; }
#opening p { color: var(--muted); font-size: 14.5px; margin-top: 10px; max-width: 58ch; }
#opening p.lede { color: var(--text); font: 500 20px/1.35 var(--serif); }
#opening p.kicker { margin: 0; color: var(--accent); font-size: 10.5px; }
#opening .fixture-note { color: #f0deb8; font-size: 13px; padding: 8px 12px; border-radius: 8px; background: rgba(220, 182, 112, 0.12); border: 1px solid rgba(220, 182, 112, 0.3); }
.opening-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 26px 0 18px; }

.about-nav { display: flex; gap: 4px 18px; flex-wrap: wrap; padding: 10px 26px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.about-nav a { color: var(--accent); text-decoration: none; }
.about-nav a:hover { text-decoration: underline; text-underline-offset: 3px; }
#about-body h2 { font: 600 25px/1.15 var(--serif); margin: 26px 0 8px; scroll-margin-top: 8px; }
#about-body h2:first-child { margin-top: 0; }
#about-body h3 { font: 600 14.5px/1.3 var(--sans); margin: 18px 0 4px; color: var(--text); }
#about-body p { margin-top: 8px; color: #e2d8c6; max-width: 70ch; }
#about-body ul { list-style: none; margin-top: 8px; }
#about-body li { position: relative; padding-left: 16px; margin-top: 6px; color: #e2d8c6; max-width: 70ch; }
#about-body li::before { content: ""; position: absolute; left: 2px; top: 0.72em; width: 5px; height: 1px; background: var(--accent); }
#about-body li b, #about-body p b { color: var(--text); font-weight: 600; }
#about-body .levels { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin-top: 10px; }
#about-body .levels dt { font-weight: 600; }
#about-body .levels dd { color: #e2d8c6; }
#about-body .date { color: var(--muted); }
#about-body .small { font-size: 12.5px; color: var(--muted); }
#about-body cite { font-style: italic; }

.help-grid { columns: 2 270px; column-gap: 38px; }
.help-grid section { break-inside: avoid; padding-bottom: 6px; }
.help-grid section h2 { font: 600 11px/1.3 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin: 14px 0 6px; }
.help-grid dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; align-items: baseline; }
.help-grid dt { white-space: nowrap; }
.help-grid dd { color: var(--muted); }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; background: rgba(0, 0, 0, 0.3); font: 500 11.5px/1.5 var(--sans); text-align: center; }

.settings fieldset { border: 0; padding: 0; margin: 0 0 20px; }
.settings legend { font: 600 11px/1.3 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; padding: 0; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line-strong); border-radius: 999px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 5px 16px; border-radius: 999px; font-weight: 500; font-size: 13px; color: var(--muted); }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 13px; }
.field output { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.field-note { color: var(--muted); font-size: 12.5px; margin-top: 8px; max-width: 60ch; }
.stats { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ loading */

#loading { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 40%, rgba(38, 31, 24, 0.9), rgba(13, 11, 9, 0.97)); transition: opacity 0.34s ease, visibility 0.34s; }
#loading.done { opacity: 0; visibility: hidden; pointer-events: none; }
#loading.gone { transition: none; }
.loading-inner { width: min(460px, 100%); text-align: center; }
#loading h1 { font: 600 clamp(34px, 7vw, 50px)/1.05 var(--serif); margin: 8px 0 2px; }
.loading-sub { font: 500 11px/1.4 var(--sans); letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
.bar { height: 2px; margin: 30px 0 12px; background: var(--line); border-radius: 1px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s ease; }
.loading-stage { color: var(--muted); font-size: 13px; min-height: 1.5em; }
.load-list { margin-top: 16px; display: grid; gap: 5px; text-align: left; font-size: 12.5px; color: var(--muted); }
.load-list li { display: grid; grid-template-columns: 1fr 90px 64px; align-items: center; gap: 10px; }
.load-list .lb { height: 2px; background: var(--line); border-radius: 1px; overflow: hidden; }
.load-list .lb i { display: block; height: 100%; width: 0; background: var(--stone); transition: width 0.2s; }
.load-list .sz { text-align: right; font-variant-numeric: tabular-nums; }
/* loaded: the bars are full and still (no animation left to be caught halfway through) */
#loading.settled .bar i, #loading.settled .load-list .lb i { transition: none; }
#loading.settled .load-list li:not(.failed) .lb i { width: 100% !important; }
.load-list li.done { color: var(--text); }
.load-list li.done .lb i { background: var(--accent); }
.load-list li.failed { color: #e7a08e; }
.load-list li.failed .lb i { background: #c96f5a; width: 100% !important; }
.load-error { margin-top: 18px; padding: 12px 14px; text-align: left; border-radius: 8px; border: 1px solid rgba(201, 111, 90, 0.5); background: rgba(201, 111, 90, 0.1); color: #f1c3b6; font-size: 13px; }
.load-error b { display: block; color: #ffd9cd; margin-bottom: 2px; }
.load-action { margin-top: 10px; }
.settings .link { display: inline-block; margin-bottom: 14px; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; z-index: 20; background: var(--ink); }

/* ------------------------------------------------------------------ states */

body.drawer-open { --left-inset: 360px; }
body.mode-walk #view, body.mode-fly #view { cursor: crosshair; }
body.locked #view { cursor: none; }

/* ------------------------------------------------------------------ narrower screens */

@media (max-width: 1180px) {
  .brand { display: none; }
}

@media (max-width: 1100px) {
  body.drawer-open #bottom { display: none; }
}

@media (max-height: 880px) and (min-width: 981px) {
  body.info-open #hud { display: none; }
  #infocard { max-height: calc(100% - var(--top) - 296px); }
}

@media (max-width: 980px) {
  #bottom { right: var(--gap); bottom: var(--gap); }
  #minimap { bottom: auto; top: var(--top); }
  #minimap canvas { width: 150px; height: 140px; }
  #minimap { width: 166px; }
  #hud { bottom: auto; top: calc(var(--top) + 164px); width: 166px; padding: 8px; gap: 8px; }
  body.map-collapsed #hud { bottom: auto; top: calc(var(--top) + 50px); }
  .compass { width: 36px; height: 36px; }
  .readout dt, .readout .up { display: none; }
  .readout dd { text-align: left; }
  #infocard { top: auto; bottom: var(--gap); left: var(--gap); right: var(--gap); width: auto; max-height: 52dvh; z-index: 3; }
  body.info-open #bottom { display: none; }
}

/* the toolbar keeps its words only while there is room for all of them on one line */
@media (max-width: 860px) {
  .modes button, .tools button { padding: 0 9px; min-height: 36px; min-width: 36px; justify-content: center; }
  .modes button span, .tools button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .tools-sep { display: none; }
  .tools button, .tools button#btn-settings, .tools button#btn-help { padding: 0; min-width: 38px; }
  .modes button { padding: 0; min-width: 40px; }
}

@media (max-width: 720px) {
  :root { --gap: 8px; --top: 54px; }
  #topbar { gap: 6px; padding: 8px; }
  .modes, .tools { gap: 0; padding: 2px; }
  .tools button, .tools button#btn-settings, .tools button#btn-help { min-width: 35px; }
  .modes button { min-width: 38px; }
  #drawer { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 64dvh; border-radius: 14px 14px 0 0; border-bottom: 0; z-index: 4; animation-name: rise-in; }
  #infocard { left: 0; right: 0; bottom: 0; border-radius: 14px 14px 0 0; }
  #timebar { padding: 7px 10px 8px; }
  .time-name { display: none; }
  #time-readout { font-size: 17px; min-width: 44px; }
  .presets button { flex: 0 0 auto; }
  /* the tour sets the light itself: on a small screen its card takes the time bar's place,
     and the compass gives way to the picture (the map can be folded with its own button) */
  body.tour-on #timebar { display: none; }
  body.tour-on.mode-orbit #hud { display: none; }
  #tourcard { padding: 12px 14px 10px; max-height: 46dvh; }
  #tourcard h2 { font-size: 22px; }
  .tour-controls { margin-top: 9px; gap: 4px; row-gap: 4px; }
  .tour-controls .btn.quiet { padding: 0 6px; min-width: 0; }
  .tour-count { margin-left: 2px; font-size: 12px; white-space: nowrap; }
  #hud-home { display: none; }
  #hud .readout div:first-child { padding-right: 0; }
  .note { font-size: 13px; }
  .tour-controls .btn span { display: none; }
  .tour-controls .btn.quiet { display: inline-flex; }
  .tour-controls .btn { padding: 0 8px; min-width: 36px; }
  #tour-next { padding: 0 10px; }
  #tour-next span { display: inline; }
  .tour-progress.dense button { padding: 0 0.5px; }
  #minimap canvas { width: 112px; height: 104px; }
  #minimap { width: 124px; padding: 5px; }
  #hud { top: calc(var(--top) + 120px); width: 124px; padding: 6px 8px; gap: 8px; }
  .compass { width: 30px; height: 30px; }
  .readout { font-size: 11px; }
  body.mode-walk #timebar .presets { display: none; }
  #opening { padding: 24px 20px 18px; }
  #opening p.lede { font-size: 18px; }
  .opening-actions .btn { flex: 1 1 100%; }
  .dialog-head { padding: 14px 12px 10px 18px; }
  .dialog-head h1 { font-size: 23px; }
  .dialog-body { padding: 14px 18px 20px; }
  .about-nav { padding: 8px 18px; }
  .field { grid-template-columns: 1fr 44px; }
  .field span { grid-column: 1 / -1; }
  #joystick { bottom: 96px; left: 14px; }
  body.tour-on #joystick { bottom: 150px; }
  #hint { left: var(--gap); transform: none; max-width: calc(100% - 150px); white-space: normal; border-radius: 14px; }
  #notice { display: none; }
  .load-list li { grid-template-columns: 1fr 60px 56px; }
}

/* the narrowest phones: Help gives way so that About still fits */
@media (max-width: 380px) {
  #btn-help { display: none; }
  .tools button, .tools button#btn-settings { min-width: 33px; }
  .modes button { min-width: 36px; }
}

/* short screens (a phone on its side): the picture needs the room more than the instruments do */
@media (max-height: 480px) {
  #hud { display: none; }
  body.tour-on #minimap, body.info-open #minimap { display: none; }
  body.tour-on #timebar { display: none; }
  #tourcard { max-height: 55dvh; padding: 10px 14px 8px; }
  #tourcard h2 { font-size: 20px; }
  #timebar .presets { margin-top: 4px; }
  #infocard { max-height: 70dvh; }
  #drawer { max-height: none; }
  #joystick { bottom: 70px; width: 96px; height: 96px; }
}

@media (max-height: 620px) and (min-width: 981px) {
  #hud { display: none; }
  #infocard { max-height: calc(100% - var(--top) - 296px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  /* the one exception: a camera move becomes a cut through this fade, which must stay a fade */
  #fade { transition-duration: 0.26s !important; }
}

@media (forced-colors: active) {
  .modes button[aria-pressed="true"], .tools button[aria-expanded="true"], .btn.primary { outline: 2px solid Highlight; }
}
