:root {
  --paper: #f5f1e8;
  --paper-2: #ebe5d8;
  --ink: #1c1a16;
  --ink-soft: #5b564c;
  --ink-faint: rgba(28, 26, 22, 0.28);
  --line: rgba(28, 26, 22, 0.14);
  --accent: #a3341d;
  --accent-ink: #fff;
  --night: #12100e;
  --glass: rgba(16, 14, 12, 0.66);
  --glass-line: rgba(255, 255, 255, 0.16);
  --light: #f6f1e7;
  --light-soft: rgba(246, 241, 231, 0.76);
  --focus: #2f6fde;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: 16px;
  --head: 236px;            /* height of the card's top part; tour.js measures it when the card changes */
  --peek: min(calc(var(--head) + 24px), 55svh);   /* how much of the card shows over the picture */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1d1b18;
    --paper-2: #26231f;
    --ink: #f1ece2;
    --ink-soft: #b4ad9f;
    --ink-faint: rgba(241, 236, 226, 0.28);
    --line: rgba(241, 236, 226, 0.14);
    --accent: #e0754f;
    --accent-ink: #1a0f0a;
    --focus: #7aa7ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* touch-action: manipulation turns off double-tap-to-zoom (quick taps on Back zoomed the page). Pinch zoom still works. */
html { -webkit-text-size-adjust: 100%; background: var(--night); overscroll-behavior-y: none; touch-action: manipulation; }
body { margin: 0; background: var(--night); color: var(--ink); font-family: var(--sans); overflow-x: hidden; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 50; padding: 10px 14px; background: var(--paper); color: var(--ink); border-radius: 8px; }
.skip-link:focus { top: 8px; }

/* ---------- layout ----------
   Phones: the picture is a full-screen layer that never changes size. The card starts near the
   bottom and slides up over it as you scroll (like a bottom sheet). Nothing re-lays out while
   scrolling, so it stays smooth. Wide screens: picture left, card right. */
.tour { position: relative; }
.media {
  position: sticky;
  top: 0;
  z-index: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--night);
  color: var(--light);
  contain: strict;
}
.panel {
  position: relative;
  z-index: 1;
  margin-top: calc(-1 * var(--peek));
  /* Arriving: the card glides up and settles (ease-out). */
  transition: opacity 0.2s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.tour.is-walking .panel {
  opacity: 0;
  transform: translateY(calc(var(--peek) + 40px));
  pointer-events: none;
  /* Leaving: the card drops away quickly (ease-in), and fades only at the end. */
  transition: opacity 0.2s ease 0.15s, transform 0.35s cubic-bezier(0.4, 0, 1, 1);
}

/* Darkens the picture as the card slides up. Runs on the browser's scroll timeline, not in JS. */
.shade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
@supports (animation-timeline: scroll()) {
  .shade, .topbar {
    animation-timing-function: linear;
    animation-fill-mode: both;
    animation-timeline: scroll(root);
    animation-range: 0 50svh;
  }
  .shade { animation-name: shade; }
  .topbar { animation-name: topbar-fade; }
  @keyframes shade { to { opacity: 0.6; } }
  @keyframes topbar-fade { to { opacity: 0; } }
}

/* ---------- picture layers ---------- */
/* The frame fits the space above the card. It grows to full screen during a walk and shrinks back on arrival,
   in step with the card. This only animates when moving between stops, never while scrolling. */
.frame {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: var(--peek);
  overflow: hidden;
  transition: bottom 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.tour.is-walking .frame { bottom: 0; transition: bottom 0.35s cubic-bezier(0.4, 0, 1, 1); }
.fill, .still, #clip { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame { cursor: zoom-in; }
.tour.is-walking .frame, .tour.is-cover.has-plan .frame { cursor: default; }
.zoom-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(16, 14, 12, 0.72);
  color: var(--light);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tour.is-walking .zoom-btn, .tour.is-cover.has-plan .zoom-btn { display: none; }
.fill { display: none; transform: scale(1.15); filter: blur(28px) brightness(0.55); }
.media.contain .fill { display: block; }
.media.contain .still, .media.contain #clip { object-fit: contain; }
.still { opacity: 0; transition: opacity 0.45s ease; }
.still.on { opacity: 1; }
.still.instant { transition: none; }
/* The video appears at once (after its first frame is ready) and fades out over the destination still.
   Outside a walk it is hidden from painting once the fade is done. */
#clip { opacity: 0; pointer-events: none; visibility: hidden; transition: opacity 0.35s ease, visibility 0s linear 0.35s; }
.tour.is-walking #clip { visibility: visible; transition: opacity 0.35s ease; }
#clip.on, .tour.is-walking #clip.on { opacity: 1; transition: none; }

/* ---------- plan sheet (cover, when the tour has a plan) ---------- */
.sheet { position: absolute; inset: 0; background: var(--paper); will-change: transform, opacity; }
.sheet-plan { position: absolute; inset: 56px var(--gutter) calc(var(--peek) + 12px); }
#plan-art { width: 100%; height: 100%; display: block; overflow: visible; }
#plan-art .ink, .minimap .ink { fill: none; stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#plan-art .ink *, .minimap .ink * { vector-effect: non-scaling-stroke; }
#plan-art .wall, .minimap .wall, #plan-art .solid, .minimap .solid { fill: var(--ink); stroke: none; }
#plan-art .cut, .minimap .cut { fill: var(--paper); stroke: none; }
#plan-art .thin { stroke-width: 0.75; }
#plan-art .hidden-lines line { stroke: var(--ink-faint); stroke-width: 0.75; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
#plan-art .labels text { font: 600 0.62px var(--sans); letter-spacing: 0.12px; fill: var(--ink-soft); text-anchor: middle; dominant-baseline: middle; }
#plan-art .dims path { fill: none; stroke: var(--ink-soft); stroke-width: 0.75; vector-effect: non-scaling-stroke; }
#plan-art .dims text { font: 0.6px var(--sans); fill: var(--ink-soft); text-anchor: middle; dominant-baseline: middle; }
.route-line { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.route-stop circle { fill: var(--paper); stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.route-stop text { font: 700 0.58px var(--sans); fill: var(--accent); text-anchor: middle; dominant-baseline: central; }

.minimap {
  position: absolute;
  top: calc(60px + env(safe-area-inset-top));
  right: 12px;
  width: 58px;
  padding: 4px;
  background: var(--paper);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.4s;
}
.minimap.on { opacity: 1; }
.minimap svg { display: block; width: 100%; height: auto; }
.minimap .labels, .minimap .dims, .minimap .hidden-lines, .minimap .thin, .minimap .route-stop text { display: none; }
.minimap .route-line, .minimap .route-stop circle { stroke-width: 1; }
.minimap .you { fill: var(--accent); }
.minimap .cone { fill: var(--accent); opacity: 0.3; }

/* ---------- top bar and walking controls (on the picture) ---------- */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(rgba(0, 0, 0, 0.5), transparent);
}
.tour.is-cover.has-plan .topbar { background: none; }
.count { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5); }
.tour.is-cover.has-plan .count { color: var(--ink-soft); text-shadow: none; }
.pill {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(16, 14, 12, 0.72);
  color: var(--light);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Slim bar during a walk: where you are going, a speed button, and Skip. */
.walking {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 52px;
  padding: 6px 6px 6px 16px;
  overflow: hidden;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  /* Rises in just after the card has left. */
  transition: opacity 0.3s ease 0.2s, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.2s;
}
.walking.away {
  opacity: 0;
  transform: translateY(24px);
  /* Sinks away at once, while the card slides up over it. */
  transition: opacity 0.25s ease, transform 0.3s ease;
}
.walking[hidden] { display: none; }
.walking-to {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, 0.15); }
.progress-bar { height: 100%; width: 0; background: var(--light); }
.walk-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  min-width: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--light);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.walk-btn-light { background: var(--light); color: #1c1a16; }

.loader {
  position: absolute;
  left: 50%;
  top: calc(64px + env(safe-area-inset-top));
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--glass);
  color: var(--light-soft);
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

/* ---------- the card ---------- */
.card {
  position: relative;
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
  min-height: 100svh;
  padding: 26px var(--gutter) calc(40px + env(safe-area-inset-bottom));
}
.card::before {             /* grab handle: says "this slides up" */
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  width: 40px;
  height: 4px;
  margin-left: -20px;
  border-radius: 2px;
  background: var(--line);
}
.card-head { padding-bottom: 16px; max-width: 40em; }
.kicker { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.card h1 { margin: 0; font: 600 clamp(26px, 7vw, 38px)/1.1 var(--serif); }
/* Focus moves to the title on each stop so screen readers read it out. It is not a control,
   so it gets no focus ring. */
.card h1:focus, .card h1:focus-visible { outline: none; }
.lede { margin: 8px 0 0; font-size: 17px; line-height: 1.45; color: var(--ink-soft); }

.nav { display: flex; gap: 10px; margin-top: 16px; }
/* "More about …" under the buttons: says there is more to read, and scrolls to it. */
.more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.more[hidden] { display: none; }
.more .arrow { display: inline-block; animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(3px); } }
.btn {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
.btn-primary { flex: 1; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-light { background: var(--light); color: #1c1a16; border-color: transparent; }
.btn-quiet { background: transparent; }
.btn[disabled] { opacity: 0.4; cursor: default; }

.card-body { border-top: 1px solid var(--line); padding-top: 18px; max-width: 40em; }
.card-body p { margin: 0 0 1em; font: 18px/1.6 var(--serif); }
.card-body h2 { margin: 1.4em 0 0.4em; font: 600 20px/1.25 var(--serif); }
.facts { margin: 1.2em 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; padding: 14px 16px; border-radius: 12px; background: var(--paper-2); }
.facts dt { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.facts dd { margin: 0; font-size: 15px; }

.card-foot { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; gap: 20px; max-width: 40em; }
.end-note { padding: 16px; border-radius: 12px; background: var(--paper-2); }
.end-note h2 { margin: 0 0 6px; font: 600 22px/1.2 var(--serif); }
.end-note p { margin: 0; line-height: 1.5; color: var(--ink-soft); }
.small { font-size: 13px; color: var(--ink-soft); margin: 0; }

/* ---------- walk setting (radio buttons that look like a segmented control) ---------- */
.walks { border: 0; margin: 0; padding: 0; min-width: 0; }
.walks legend { padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 700; }
.walks .hint { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); }
.segments { display: flex; border-radius: 12px; background: var(--paper-2); padding: 3px; border: 1px solid var(--line); }
.segments label { flex: 1; position: relative; }
.segments input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segments span {
  display: flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 0 8px; border-radius: 9px;
  font-size: 15px; font-weight: 600; color: var(--ink-soft);
}
.segments input:checked + span { background: var(--paper); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
.segments input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -2px; }

/* ---------- all stops dialog ---------- */
.stops-dialog {
  width: min(480px, calc(100% - 2 * var(--gutter)));
  max-height: 80svh;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
}
.stops-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); }
.dialog-head h2 { margin: 0; font: 600 22px var(--serif); }
.stops-list { list-style: none; margin: 0; padding: 8px; }
.stops-list button {
  width: 100%; min-height: 52px; padding: 8px 12px; border: 0; border-radius: 10px;
  background: none; text-align: left; cursor: pointer; display: flex; gap: 12px; align-items: center; font-size: 16px;
}
.stops-list button:hover { background: var(--paper-2); }
.stops-list .num {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--accent); color: var(--accent); font-size: 13px; font-weight: 700;
}
.stops-list [aria-current] { background: var(--paper-2); font-weight: 700; }
.stops-list [aria-current] .num { background: var(--accent); color: var(--accent-ink); }

.noscript { padding: var(--gutter); }

/* ---------- wide screens: picture left, card right ---------- */
@media (min-width: 900px) {
  :root { --gutter: 32px; }
  .tour { display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 38%); }
  .panel { margin-top: 0; }
  .frame, .tour.is-walking .frame { bottom: 0; }
  .sheet-plan { bottom: 12px; }
  .card { border-radius: 0; box-shadow: none; min-height: 100svh; padding-top: 40px; }
  .card::before { display: none; }
  .shade, .topbar { animation: none; }
  .tour.is-walking .panel { opacity: 0.35; transform: none; }
  .minimap { width: 92px; right: 20px; top: 72px; }
  .walking { left: 50%; right: auto; width: min(520px, calc(100% - 64px)); transform: translateX(-50%); }
  .walking.away { transform: translate(-50%, 24px); }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .tour.is-walking .panel, .walking, .walking.away, .still, .minimap, .loader, #clip, .tour.is-walking #clip,
  .frame, .tour.is-walking .frame { transition: none; }
  .more .arrow { animation: none; }
}

/* ---------- picture viewer (zoom) ---------- */
.viewer {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  color: var(--light);
  overflow: hidden;
}
.viewer::backdrop { background: #000; }
.viewer-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.viewer-stage:active { cursor: grabbing; }
#viewer-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.viewer-hint {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 14, 12, 0.72);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.4s;
}
.viewer-bar {
  position: absolute;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(16, 14, 12, 0.72);
}
.viewer-bar .walk-btn { min-width: 48px; justify-content: center; font-size: 18px; }
.viewer-bar .walk-btn-light { font-size: 15px; }
html.viewing { overflow: hidden; }
