:root {
  color-scheme: dark;
  --bg: #05090b;
  --ink: #eef2ee;
  --text: #d9e2de;
  --muted: #9fb0aa;
  --accent: #ffb347;
  --others: #9fccd9;
  --card: rgb(6 12 14 / .8);
  --line: rgb(255 255 255 / .09);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); }
body { margin: 0; }
.map { position: fixed; inset: 0; z-index: 0; }
.noscript { position: fixed; inset: auto 1rem 50% 1rem; text-align: center; color: var(--muted); }
a { color: inherit; }

/* ------------------------------------------------------------ top bar and counter */
.top {
  position: fixed; z-index: 3; inset: 0 0 auto 0;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: max(.7rem, env(safe-area-inset-top)) 1rem .7rem;
  background: linear-gradient(rgb(5 9 11 / .75), transparent);
  font-size: .78rem; letter-spacing: .06em;
}
.brand { color: var(--accent); text-decoration: none; text-transform: uppercase; font-weight: 600; }
.langs { display: flex; gap: .15rem; align-items: center; }
.langs a { padding: .3rem .45rem; border-radius: 6px; text-decoration: none; color: var(--muted); text-transform: uppercase; }
.langs a[aria-current="page"] { color: var(--ink); background: rgb(255 255 255 / .1); }
.langs .to-explorer { margin-inline-start: .5rem; color: var(--ink); border: 1px solid var(--line); text-transform: none; letter-spacing: 0; }
.langs a:hover { color: var(--ink); }
:is(a, button):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hud {
  position: fixed; z-index: 2; top: calc(max(.7rem, env(safe-area-inset-top)) + 2.4rem); left: 50%; translate: -50% 0;
  margin: 0; display: flex; align-items: center; gap: .6rem; white-space: nowrap;
  padding: .35rem .85rem; border-radius: 999px; background: rgb(6 12 14 / .62); border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.hud time { color: var(--ink); }
.hud b { color: var(--accent); font-weight: 600; }
.hud .sep { inline-size: 1px; block-size: .9em; background: var(--line); }
html:not([data-chapter]) .hud, html[data-chapter="intro"] .hud, html[data-chapter="credits"] .hud { opacity: 0; }
.hud { transition: opacity .4s; }

/* ------------------------------------------------------------ chapters */
.story { position: relative; z-index: 1; }
.chapter {
  min-block-size: 125svh;
  display: flex; align-items: flex-end;
  padding: 0 .75rem 10svh;
  pointer-events: none;
}
.chapter-intro { min-block-size: 100svh; padding-block-end: 6svh; }
.chapter-credits { min-block-size: 100svh; padding-block-end: 4rem; }
.card {
  pointer-events: auto;
  inline-size: 100%; max-inline-size: 27rem; margin-inline: auto;
  padding: .95rem 1.1rem 1rem;
  background: var(--card);
  backdrop-filter: blur(12px) saturate(1.15);
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 20px 50px -20px rgb(0 0 0 / .7);
  transition: opacity .5s;
}
.chapter:not(.is-active) .card { opacity: .55; }
.kicker { margin: 0 0 .25rem; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
h1, h2 { font-family: var(--serif); font-weight: 600; color: var(--ink); margin: 0 0 .6rem; line-height: 1.1; }
h1 { font-size: clamp(2.8rem, 12vw, 4.2rem); letter-spacing: -.01em; }
h2 { font-size: 1.45rem; }
.card p { margin: 0 0 .6rem; color: var(--text); font-size: .9rem; line-height: 1.5; text-wrap: pretty; }
.card p:last-child { margin-block-end: 0; }
.chapter-intro .card p:nth-of-type(3) { color: var(--ink); font-variant-numeric: tabular-nums; }

.legend { list-style: none; margin: .9rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-size: .8rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: .45rem; }
.legend li::before { content: ""; inline-size: 1.5rem; block-size: 3px; border-radius: 2px; }
.legend-bird::before { background: linear-gradient(90deg, rgb(255 179 71 / .5), #fff3d6); box-shadow: 0 0 8px rgb(255 179 71 / .8); }
.legend-others::before { background: rgb(159 204 217 / .55); block-size: 1px !important; }
.hint { margin-top: 1rem !important; font-size: .8rem !important; color: var(--muted) !important; display: flex; align-items: center; gap: .5rem; }
.hint::after { content: "↓"; color: var(--accent); }

.credits { margin: 0; padding: 0 0 0 1rem; font-size: .8rem; line-height: 1.5; color: var(--muted); }
.credits li { margin-block-end: .5rem; }
.made { font-size: .8rem; color: var(--muted); margin-block: .5rem 1rem; }
.made a { color: var(--text); text-decoration-color: rgb(255 255 255 / .3); text-underline-offset: 2px; }
.credits a { color: var(--text); text-decoration-color: rgb(255 255 255 / .3); text-underline-offset: 2px; }
.cta {
  display: inline-block; margin-top: .6rem; padding: .6rem 1rem; border-radius: 999px;
  background: var(--accent); color: #1b1200; text-decoration: none; font-weight: 600; font-size: .92rem;
}

@media (min-width: 900px) {
  .chapter { align-items: center; padding: 0 0 0 max(2.5rem, 5vw); }
  .chapter-intro, .chapter-credits { padding-block-end: 0; }
  .card { margin-inline: 0; max-inline-size: 26rem; padding: 1.5rem 1.7rem 1.6rem; }
  .card p { font-size: 1rem; line-height: 1.6; margin-block-end: .75rem; }
  h2 { font-size: 1.65rem; }
  .hud { top: auto; bottom: 2.6rem; left: auto; right: 1.5rem; translate: none; }
}

/* ------------------------------------------------------------ map markers */
.bird { pointer-events: none; display: flex; align-items: center; gap: .45rem; }
.bird .dot {
  position: relative; inline-size: 11px; block-size: 11px; border-radius: 50%; background: #fff6e0;
  box-shadow: 0 0 0 3px rgb(255 179 71 / .35), 0 0 18px 6px rgb(255 179 71 / .55);
}
.bird .dot::after {
  content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 1px solid rgb(255 214 150 / .7);
  animation: pulse 2.4s ease-out infinite;
}
.bird .name {
  position: absolute; left: 16px; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: #fff3d6;
  text-shadow: 0 0 6px #000, 0 0 2px #000;
}
@keyframes pulse { from { scale: .5; opacity: 1; } to { scale: 1.6; opacity: 0; } }
.place {
  pointer-events: none; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase;
  color: rgb(235 240 236 / .85); text-shadow: 0 0 6px #000, 0 0 2px #000;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
}
.place::before { content: ""; inline-size: 5px; block-size: 5px; border-radius: 50%; background: rgb(235 240 236 / .8); margin-block-start: -12px; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* Cards rise as they scroll in (progressive enhancement). */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .card { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
    @keyframes rise { from { translate: 0 3rem; scale: .97; } }
  }
}
@media (prefers-reduced-motion: reduce) {
  .bird .dot::after { animation: none; display: none; }
  .card, .hud { transition: none; }
}
