:root {
  /* Layout: full-screen 3D world. HUD sits in the corners. Work card docks right, or bottom on phones. */
  --paper: #FFFFFF;
  --paper-alt: #F5F5F2;
  --ink: #111111;
  --ink-muted: #5C5C58;
  --line: #E4E4DF;
  --accent: #14342B;
  --accent-tint: #E6EFE9;
  --display: "Inter Tight", "Inter", "Helvetica Neue", Arial, sans-serif;
  --body: "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html, body, #world, .hud, .hint, .mini, .intro { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.card .body { -webkit-user-select: text; user-select: text; }
body {
  background: var(--paper-alt);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
.mono {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, #world:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* HUD */
.hud { position: fixed; z-index: 3; }
.wordmark {
  top: 16px; left: 16px;
  font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em;
}
.wordmark span { color: var(--accent); }
.topright { top: 16px; right: 16px; display: flex; gap: 12px; align-items: center; }
.count { color: var(--ink-muted); font-variant-numeric: tabular-nums; padding: 4px 10px; border-radius: 999px; transition: background .35s, color .35s; }
.count.tick { background: var(--accent); color: var(--paper); }
.btn {
  background: var(--accent); color: var(--paper);
  border: 0; border-radius: 4px; padding: 9px 14px;
  font-family: var(--body); font-weight: 600; font-size: 13px;
}
.btn.quiet { background: var(--paper); color: var(--ink); border: 1px solid var(--ink); }
a.btn { display: inline-block; text-decoration: none; text-align: center; line-height: normal; }
.hint {
  left: 200px; bottom: 16px; max-width: 300px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px;
}
.hint .mono { color: var(--ink-muted); display: block; margin-bottom: 4px; }
.hint p { margin: 0; font-size: 13px; }
.keys { display: inline-flex; gap: 4px; margin-right: 6px; vertical-align: middle; }
.keys kbd {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  border: 1px solid var(--ink); border-radius: 4px; padding: 1px 5px; background: var(--paper);
}

.zoom { right: 16px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; }
.zoom .btn { width: 36px; height: 36px; padding: 0; font-size: 18px; line-height: 1; }

/* Landmark labels */
#labels { position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 999px; padding: 3px 10px;
  will-change: transform;
}
.zone { position: absolute; left: 0; top: 0; white-space: nowrap; font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: -0.02em; color: var(--ink-muted); will-change: transform; }
.tag.unknown { color: var(--ink-muted); border-color: var(--line); }
.tag.found { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }

/* Work card */
.card {
  position: fixed; z-index: 4; top: 64px; right: 16px; bottom: 16px; width: 400px; max-width: calc(100% - 32px);
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(28px);
  transition: opacity .22s ease, transform .28s cubic-bezier(.2,.9,.3,1.2), visibility 0s linear .28s;
}
.card.open { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition: opacity .4s ease .2s, transform .5s cubic-bezier(.2,.8,.3,1) .2s, visibility 0s; }
@media (prefers-reduced-motion: reduce) { .card, .card.open, .count, .toast, .hint { transition: none; } .stage-inner { animation: none; } }
.card header { background: var(--accent); color: var(--paper); padding: 18px 20px 20px; position: relative; }
.card header .mono { color: var(--accent-tint); }
.card h2 {
  font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1.05; letter-spacing: -0.02em;
  margin: 8px 0 0; text-wrap: balance; padding-right: 40px;
}
.card .close {
  position: absolute; top: 14px; right: 14px;
  background: transparent; color: var(--paper); border: 1px solid var(--accent-tint); border-radius: 4px;
  padding: 4px 9px; font-size: 12px;
}
.card .body { padding: 18px 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
.card .body p { margin: 0; max-width: 60ch; }
.card .story { display: flex; flex-direction: column; gap: 12px; }
.card p.again { font-size: 14px; }
.card p.again a { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.cardnav { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--paper); }
.cardnav .btn { flex: 1; padding-left: 8px; padding-right: 8px; }
.card .body { flex: 1; }
.introtop { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pop { position: fixed; z-index: 12; top: 62px; right: 16px; width: 320px; max-width: calc(100% - 32px); background: var(--paper); border: 1px solid var(--ink); border-radius: 8px; padding: 14px 16px 6px; }
.pop[hidden] { display: none; }
.pop > .mono { display: block; color: var(--ink-muted); margin-bottom: 10px; }
.pop .ruled li { padding: 0; display: block; }
.pop .ruled li:last-child { border-bottom: 0; }
.pop .ruled a { display: block; padding: 11px 0; color: var(--ink); text-decoration: none; }
.pop .ruled a b { display: block; font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.pop .ruled a .mono { display: block; text-align: left; margin-top: 2px; overflow-wrap: anywhere; }
.pop .ruled a:hover b { color: var(--accent); }
.cardnav .btn.contact { flex: none; }
.cardnav .btn.ride { display: none; }
.ruled { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.ruled li {
  display: flex; justify-content: space-between; gap: 16px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.ruled li b { font-weight: 600; }
.ruled li .mono { color: var(--ink-muted); text-align: right; }
.ruled.stack li { display: block; padding: 12px 0; }
.ruled.stack li .mono { display: block; text-align: left; margin-bottom: 2px; }
.ruled.stack li b { display: block; font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; margin-bottom: 4px; }
.ruled.stack li p { color: var(--ink-muted); font-size: 14px; }
.sub { color: var(--ink-muted); margin-bottom: 8px; display: block; }
.screens { display: flex; gap: 10px; align-items: flex-end; }
.frame {
  background: var(--paper-alt); border: 1px solid var(--line); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--ink-muted); padding: 6px;
}
.shot { flex: 1; min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: 8px; display: block; }
.frame.desktop { flex: 1; aspect-ratio: 1440 / 900; }
.frame.mobile { width: 24%; aspect-ratio: 390 / 844; }
.frame .mono { font-size: 9px; letter-spacing: 0.08em; }

.shot.mob { flex: none; width: 24%; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: 50% 30%; border-radius: 8px; display: block; background: var(--paper-alt); }
.photos img:first-child { grid-column: 1 / -1; aspect-ratio: 4 / 3; }
.photos.tall img, .photos.tall img:first-child { grid-column: auto; aspect-ratio: 4 / 5; object-position: 50% 50%; border: 1px solid var(--line); }
.photos.wide img, .photos.wide img:first-child { grid-column: auto; aspect-ratio: 16 / 9; object-position: 50% 50%; border: 1px solid var(--line); }
.photos.wide img:first-child { grid-column: 1 / -1; }
.photos.wide.two img:first-child { grid-column: auto; }

.flip-tabs { display: inline-flex; border: 1px solid var(--ink); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.flip-tabs button { background: var(--paper); border: 0; padding: 6px 14px; color: var(--ink); }
.flip[data-side="before"] [data-flip="before"], .flip[data-side="after"] [data-flip="after"] { background: var(--accent); color: var(--paper); }
.flip-pane { display: none; }
.flip[data-side="before"] [data-pane="before"], .flip[data-side="after"] [data-pane="after"] { display: block; }
.flip-pane .frame.desktop { width: 100%; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.links a, .links button { text-decoration: none; display: inline-block; }
.photos img, img.shot { cursor: zoom-in; }

#fade { position: fixed; inset: 0; z-index: 2; background: var(--paper-alt); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
#fade.on { opacity: 1; }
.skip { display: flex; gap: 6px; margin-top: 6px; }
.skip .btn { flex: 1; padding: 6px 0; font-size: 12px; }
.skip .btn.wide { flex: 2.4; white-space: nowrap; }

/* Corner map */
.mini { left: 16px; bottom: 16px; width: 168px; }
.mini canvas { width: 168px; height: 168px; display: block; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.mini .mono { display: block; margin-top: 6px; color: var(--ink-muted); min-height: 1.4em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint { transition: opacity .5s, visibility 0s linear .5s; }
.hint.gone { opacity: 0; visibility: hidden; }

.tip { position: fixed; z-index: 12; left: 0; top: 0; white-space: nowrap; background: var(--ink); color: var(--paper); border-radius: 999px; padding: 4px 11px; pointer-events: none; opacity: 0; transition: opacity .12s; }
.tip.on { opacity: 1; }
.intro canvas { cursor: pointer; }

/* Toast */
.toast {
  left: 50%; top: 64px; transform: translate(-50%, -12px); background: var(--ink); color: var(--paper);
  border-radius: 999px; padding: 8px 16px; opacity: 0; visibility: hidden; transition: opacity .3s, transform .3s, visibility 0s linear .3s; max-width: calc(100% - 32px); text-align: center;
}
.hud.toast { z-index: 13; }
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity .3s, transform .3s, visibility 0s; }

/* Stage: photos and film open large, beamed up from the bottom */
.stage { position: fixed; inset: 0; z-index: 8; background: rgba(255,255,255,.94); display: none; align-items: center; justify-content: center; padding: 64px 16px 24px; }
.stage.open { display: flex; }
.stage .drag { display: none; position: fixed; top: 24px; left: 16px; color: var(--ink-muted); }
.stage.pan .drag { display: block; }
.stage.pan { background: var(--paper); padding: 60px 0 0; align-items: stretch; }
.stage.pan .stage-inner { display: block; width: 100%; max-width: none; overflow: auto; -webkit-overflow-scrolling: touch; animation: none; border-top: 1px solid var(--line); }
.stage.pan .stage-inner img { max-width: none; max-height: none; width: 260vw; border: 0; border-radius: 0; }
.stage #stageClose { position: fixed; top: 16px; right: 16px; }
.stage-inner { max-width: min(1100px, 100%); max-height: 100%; display: flex; animation: beamUp .45s cubic-bezier(.2,.8,.2,1) both; transform-origin: 50% 100%; }
.stage-inner img { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 8px; border: 1px solid var(--line); display: block; }
@keyframes beamUp { from { transform: translateY(30%) scale(.06, .02); opacity: .3; } 55% { transform: translateY(0) scale(.06, 1); opacity: 1; } to { transform: none; } }
.film { width: min(960px, 92vw); border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; background: var(--paper); }
.film-bar { padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--ink-muted); }
.film-body { aspect-ratio: 16 / 9; background: var(--paper-alt); display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; text-align: center; padding: 16px; color: var(--ink-muted); }
.film-body p { margin: 0; max-width: 46ch; }
.film-body .btn { font-size: 16px; padding: 14px 26px; text-decoration: none; }
.film-player { padding: 0; display: block; background: var(--ink); }
.film-player iframe { display: block; width: 100%; height: 100%; border: 0; }

/* Opener */
.intro { position: fixed; inset: 0; z-index: 10; background: var(--paper); display: flex; flex-direction: column; padding: 16px; overflow-y: auto; }
.intro.gone { display: none; }
.intro .wm { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }
.intro .wm span { color: var(--accent); }
.intro .mid { flex: 1; display: flex; gap: 48px; align-items: center; justify-content: center; max-width: 1100px; width: 100%; margin: 0 auto; padding: 24px 0; }
.intro .words { flex: 1; min-width: 0; }
.intro h1 { font-family: var(--display); font-weight: 700; font-size: clamp(52px, 9vw, 116px); line-height: .95; letter-spacing: -0.04em; margin: 12px 0 20px; text-wrap: balance; }
.intro p { font-size: 18px; max-width: 44ch; margin: 0 0 24px; }
.intro p.lead { max-width: 54ch; }
.intro p.small { font-size: 15px; color: var(--ink-muted); }
.intro p.does { font-size: 11px; color: var(--ink); margin: -8px 0 22px; max-width: none; line-height: 1.8; }
.intro p.does span { white-space: nowrap; }
.intro p.does i { font-style: normal; }
.intro .go { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }
.intro .go .btn { font-size: 15px; padding: 12px 20px; }
.intro .ruled { max-width: 380px; }
.intro p.skipnote { font-size: 14px; color: var(--ink-muted); margin: -12px 0 26px; }
.intro p.skipnote a { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.intro canvas { display: none; } /* the 2D map is off the opener: it added nothing */

/* List view */
.sheet {
  position: fixed; inset: 0; z-index: 6; background: var(--paper);
  display: none; overflow-y: auto; padding: 88px 16px 40px;
}
.sheet.open { display: block; }
.sheet .inner { max-width: 680px; margin: 0 auto; }
.sheet h1 {
  font-family: var(--display); font-weight: 700; font-size: clamp(36px, 7vw, 56px); line-height: 1; letter-spacing: -0.03em;
  margin: 8px 0 28px; text-wrap: balance;
}
.sheet .ruled li { padding: 0; }
.sheet .ruled button {
  width: 100%; background: none; border: 0; padding: 14px 0; text-align: left;
  display: flex; justify-content: space-between; gap: 16px; align-items: baseline;
}
.sheet .ruled button:hover b { color: var(--accent); }
.sheet .ruled b { font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.sheet .back { position: fixed; top: 0; left: 0; right: 0; z-index: 1; display: flex; gap: 8px; align-items: center; padding: 12px 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.sheet .back .wm { margin-right: auto; font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }
.sheet .back .wm span { color: var(--accent); }

@media (max-width: 640px) {
  .mini { width: auto; }
  .mini canvas { display: none; }
  .mini .skip { margin-top: 0; }
  .mini .skip .btn { flex: none; padding: 9px 16px; font-size: 13px; }
  .mini .mono { display: none; }
  .hint { bottom: 72px; }
  .intro .mid { flex-direction: column; align-items: flex-start; gap: 24px; }
  .card { top: 0; left: 0; right: 0; bottom: 0; width: auto; max-width: none; max-height: none; border: 0; border-radius: 0; transform: translateY(40%); }
  .card.open { transition: opacity .5s ease .45s, transform .7s cubic-bezier(.2,.8,.3,1) .45s, visibility 0s; }
  br.wide { display: none; }
  .intro p.does span { display: block; }
  .intro p.does i { display: none; }
  .card h2 { font-size: 24px; }
  /* On a phone the card fills the screen, so its bar leads back to the ride. The trail's own Back button covers Previous stop. */
  .cardnav .btn.ride { display: inline-block; flex: 1.25; }
  .cardnav .btn.prev { display: none; }
  .cardnav .btn.next { background: var(--paper); color: var(--ink); border: 1px solid var(--ink); }
  .hint { left: 16px; right: 16px; max-width: none; }
  .card.open ~ .hint { display: none; }
  .count { display: none; }
  .pop { top: auto; right: 10px; left: 10px; bottom: 72px; width: auto; max-width: none; }
  .sheet .back .wm { display: none; }
  .sheet .back { justify-content: flex-end; }
}
/* A phone on its side: wide but very short */
@media (max-height: 480px) and (min-width: 641px) {
  .intro .mid { align-items: flex-start; gap: 28px; padding: 8px 0 16px; }
  .intro h1 { font-size: 44px; margin: 6px 0 10px; }
  .intro h1 br { display: none; }
  .intro p { font-size: 15px; margin: 0 0 10px; max-width: none; }
  .intro p.small { font-size: 13px; }
  .intro .go { margin-bottom: 16px; }
  .intro .go .btn { padding: 10px 18px; }
  br.wide { display: none; }
  .mini { width: auto; }
  .mini canvas { display: none; }
  .mini .skip { margin-top: 0; }
  .mini .skip .btn { flex: none; padding: 9px 16px; font-size: 13px; }
  .mini .mono { display: none; }
  .count { display: none; }
  .zone { font-size: 16px; }
  .card { top: 8px; bottom: 8px; right: 8px; width: 48%; max-width: 440px; }
  .card h2 { font-size: 22px; }
  .card.open ~ .hint { display: none; }
}
/* When the page does fill a notched screen, keep the controls clear of the notch and home bar */
@supports (left: env(safe-area-inset-left)) {
  .wordmark, .mini { left: max(16px, env(safe-area-inset-left)); }
  .topright, .zoom { right: max(16px, env(safe-area-inset-right)); }
  .mini { bottom: max(16px, env(safe-area-inset-bottom)); }
  .intro { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}
@media (pointer: coarse) {
  .hint .kb, .intro .kb { display: none; } .zoom { display: none; }
  /* On touch the hint is one line in a pill: the only thing a rider needs to be told. The buttons explain themselves. */
  .hint { left: 50%; right: auto; bottom: 84px; transform: translateX(-50%); width: auto; max-width: none; padding: 9px 18px; border-radius: 999px; background: var(--ink); border-color: var(--ink); pointer-events: none; white-space: nowrap; }
  .hint > .mono { display: none; }
  .hint p.touch { display: block; margin: 0; color: var(--paper); font-size: 12px; }
}
@media (pointer: fine) { .hint .touch, .intro .touch { display: none; } }
