:root {
  --paper: #efebe4;
  --paper-2: #e4dfd5;
  --ink: #1b1a17;
  --muted: #8a857b;
  --signal: #e2522b; /* drone nav-light orange */
  /* Azonix (Mixo, free for personal use) lives in fonts/; Michroma is the look-alike fallback until it's there */
  --display: 'Azonix', 'Michroma', sans-serif;
  /* Lemon Milk (MARSNEV, donationware) — caps-only, no lowercase glyphs, so it renders as capitals wherever text-transform: lowercase is set below */
  --sans: 'Lemon Milk', 'Helvetica Neue', Helvetica, sans-serif;
}
@font-face {
  font-family: 'Azonix';
  src: url('fonts/Azonix.otf') format('opentype'), url('fonts/Azonix.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Lemon Milk';
  src: url('fonts/LemonMilk-Light.otf') format('opentype');
  font-weight: 300;
  font-display: swap;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; } /* hidden always wins, even over display:flex rules */
html, body { height: 100%; overflow: hidden; }
body {
  background: radial-gradient(120% 90% at 50% 45%, var(--paper) 40%, var(--paper-2) 100%);
  color: var(--ink);
  font: 300 14px/1.4 var(--sans);
  letter-spacing: .04em; /* Lemon Milk renders all-caps, wants more air between letters than a lowercase sans did */
  text-transform: lowercase;
  -webkit-font-smoothing: antialiased;
}

.grain {
  position: fixed; inset: 0; pointer-events: none; opacity: .09; mix-blend-mode: multiply; z-index: 5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- header ---------- */
header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40; padding: 22px 28px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; pointer-events: none;
}
header > * { pointer-events: auto; }
.mark { grid-column: 1; font: 17px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; }
.mark span { display: block; margin-top: 8px; font: 300 13px/1 var(--sans); letter-spacing: .04em; text-transform: lowercase; color: var(--muted); }
.compass { grid-column: 2; position: relative; width: min(280px, 44vw); text-align: center; }
.controls { grid-column: 3; justify-self: end; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  background: none; border: 1px solid currentColor; border-radius: 999px; padding: 7px 13px;
  font: inherit; font-size: 13px; letter-spacing: inherit; text-transform: inherit; color: inherit; cursor: pointer;
  opacity: .7; transition: opacity .25s, background .25s, color .25s;
}
.pill:hover { opacity: 1; }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); opacity: 1; }
body.inside .pill[aria-pressed="true"] { background: #fff; color: var(--ink); border-color: #fff; }

.search {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid currentColor; border-radius: 999px; padding: 7px 8px 7px 13px;
  opacity: .7; transition: opacity .25s;
}
.search:focus-within { opacity: 1; }
.search input {
  background: none; border: none; outline: none; color: inherit; font: inherit;
  font-size: 13px; letter-spacing: inherit; text-transform: inherit; width: 200px; max-width: 32vw;
}
.search input::placeholder { color: currentColor; opacity: .6; }
#searchCount { font-size: 11px; color: var(--muted); white-space: nowrap; }
#searchCount.empty { color: var(--signal); }
.clear { background: none; border: none; color: inherit; opacity: .55; cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; }
.clear:hover { opacity: 1; }

.zoom { display: flex; gap: 4px; }
.zoom .pill { width: 34px; padding: 7px 0; text-align: center; font-size: 15px; line-height: 1; }

/* compass tape: ticks every 5°, taller every 45°; slides as you look around */
.tape {
  height: 12px; opacity: .55;
  background:
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 8px) bottom / 100% 5px no-repeat,
    repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 72px) bottom / 100% 12px no-repeat;
  -webkit-mask: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent);
          mask: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent);
}
.compass::before { content: ''; position: absolute; left: 50%; top: -4px; width: 1px; height: 18px; background: var(--signal); }
.hdg { margin-top: 6px; }

/* ---------- browse: sortable list on the left, photo + map on the right ---------- */
#browse { position: fixed; inset: 0; padding-top: 96px; display: flex; z-index: 1; }
.list {
  flex: 1 1 380px; max-width: 460px; min-width: 280px; display: flex; flex-direction: column;
  border-right: 1px solid rgba(27, 26, 23, .14);
}
.sortbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 28px 14px;
  border-bottom: 1px solid rgba(27, 26, 23, .14);
}
.sortLabel { color: var(--muted); font-size: 12px; margin-right: 4px; }
.sort, .dir {
  background: none; border: 1px solid transparent; border-radius: 999px; padding: 5px 11px; cursor: pointer;
  font: inherit; font-size: 12px; letter-spacing: inherit; text-transform: inherit; color: inherit; opacity: .6;
  transition: opacity .2s, background .2s, color .2s;
}
.sort:hover, .dir:hover { opacity: 1; }
.sort[aria-pressed="true"] { background: var(--ink); color: var(--paper); opacity: 1; }
.dir { margin-left: auto; color: var(--muted); opacity: 1; padding-right: 0; }
.dir:hover { color: var(--ink); }
.sort:focus-visible, .dir:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

#entries { flex: 1; overflow-y: auto; list-style: none; padding: 0 0 40px; }
#entries li[hidden] { display: none; }
#entries li.group {
  padding: 22px 28px 8px; font-size: 11px; color: var(--muted); letter-spacing: .08em;
  border-bottom: 1px solid rgba(27, 26, 23, .12);
}
#entries li.row { border-bottom: 1px solid rgba(27, 26, 23, .12); }
.entry {
  all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 13px 28px; cursor: pointer; position: relative;
}
.entry:hover { background: var(--paper-2); }
.entry[aria-current="true"] { background: var(--paper-2); }
.entry[aria-current="true"]::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; background: var(--signal); }
.entry:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
.entry img { width: 52px; height: 68px; object-fit: cover; border-radius: 3px; flex: none; background: var(--paper-2); }
.entryText { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.entryText strong {
  font: 15px/1.2 var(--sans); font-weight: 300; letter-spacing: inherit; text-transform: inherit;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.entryText em {
  font-style: normal; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.detail {
  flex: 1 1 auto; min-width: 0; overflow-y: auto; padding: 4px 32px 32px;
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto minmax(240px, 1fr);
  column-gap: 28px; row-gap: 24px;
}
/* the photo is a porthole: dark rim, a hairline ring outside it, curved glass on top */
.photo {
  all: unset; position: relative; display: block; cursor: zoom-in; border-radius: 50%; overflow: hidden;
  height: min(40vh, 360px); aspect-ratio: 1; background: var(--ink);
  outline: 1px solid rgba(27, 26, 23, .3); outline-offset: 9px;
}
.photo::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; z-index: 1;
  box-shadow: inset 0 0 0 7px var(--ink), inset 0 0 50px rgba(0, 0, 0, .55);
  background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .28), transparent 38%);
}
.photo[hidden] { display: none; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s cubic-bezier(.22, .68, 0, 1); }
.photo:hover img, .photo:focus-visible img { transform: scale(1.04); }
.photo:focus-visible { outline: 2px solid var(--signal); outline-offset: 9px; }
.photoHint {
  position: absolute; left: 50%; bottom: 22%; z-index: 2; transform: translate(-50%, 6px); padding: 7px 14px; border-radius: 999px;
  background: rgba(27, 26, 23, .72); color: var(--paper); font-size: 12px; white-space: nowrap;
  opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none;
}
.photo:hover .photoHint, .photo:focus-visible .photoHint { opacity: 1; transform: translate(-50%, 0); }
@media (hover: none) { .photoHint { opacity: 1; transform: translate(-50%, 0); } }

.detailText { align-self: stretch; min-width: 0; display: flex; flex-direction: column; }
.facts {
  margin-top: auto; padding-top: 22px; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  column-gap: 24px; row-gap: 18px;
}
.fact { border-top: 1px solid rgba(27, 26, 23, .18); padding-top: 9px; }
.fact h3 { font: 300 11px/1 var(--sans); letter-spacing: .08em; color: var(--signal); margin-bottom: 8px; }
.fact p { font-size: 12.5px; line-height: 1.45; }
.detail h2 { font: 400 clamp(24px, 3.2vw, 44px)/1.05 var(--display); letter-spacing: .02em; text-transform: uppercase; overflow-wrap: anywhere; }
.detail .meta { margin-top: 14px; color: var(--ink); opacity: .75; display: flex; flex-wrap: wrap; row-gap: 4px; }
.detail .meta span { white-space: nowrap; }
.detail .meta span + span::before { content: '·'; margin: 0 .9em; }

.map {
  grid-column: 1 / -1; border-radius: 4px; border: 1px solid rgba(27, 26, 23, .14); overflow: hidden;
  background: var(--paper-2);
}
.map .leaflet-tile-pane { filter: sepia(.15) saturate(.9) contrast(1.08); } /* warm the gray basemap toward the site's paper */
.leaflet-container { font: inherit; font-size: 12px; }
.map .leaflet-control-attribution { background: rgba(239, 235, 228, .85); color: var(--muted); font-size: 10px; text-transform: none; letter-spacing: 0; }
.map .leaflet-control-attribution a { color: inherit; }
.map .leaflet-bar a { background: var(--paper); color: var(--ink); border-color: rgba(27, 26, 23, .14); }
.map .leaflet-bar a:hover { background: var(--paper-2); }
.map .leaflet-tooltip {
  background: var(--ink); color: var(--paper); border: none; border-radius: 999px; padding: 5px 11px;
  box-shadow: none; font-size: 12px; letter-spacing: .04em;
}
.map .leaflet-tooltip-top::before { border-top-color: var(--ink); }
.map .leaflet-interactive:focus { outline: none; }

/* pin popup: every 360 from that town */
.townPopup .leaflet-popup-content-wrapper { background: var(--paper); color: var(--ink); border-radius: 6px; box-shadow: 0 8px 28px rgba(27, 26, 23, .22); }
.townPopup .leaflet-popup-tip { background: var(--paper); }
.townPopup .leaflet-popup-content { margin: 12px; font: inherit; font-size: 12px; }
.townPop strong { display: block; font-weight: 300; margin-bottom: 10px; }
.townGrid { display: grid; grid-template-columns: repeat(auto-fill, 72px); gap: 10px; max-width: 290px; }
.townGrid button {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 5px;
  font-size: 10px; line-height: 1.25; color: var(--muted); text-align: center;
}
.townGrid img { width: 72px; height: 96px; object-fit: cover; border-radius: 3px; outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .2s; }
.townGrid button:hover img, .townGrid button:focus-visible img { outline-color: rgba(27, 26, 23, .35); }
.townGrid button[aria-current="true"] img { outline-color: var(--signal); }
.townGrid button[aria-current="true"] { color: var(--ink); }

/* ---------- the shared-element flyer that morphs a thumb into the full pano ---------- */
.flyer {
  position: fixed; z-index: 70; object-fit: cover; border-radius: 3px; pointer-events: none;
  transition: left .6s cubic-bezier(.22, .68, 0, 1), top .6s cubic-bezier(.22, .68, 0, 1),
              width .6s cubic-bezier(.22, .68, 0, 1), height .6s cubic-bezier(.22, .68, 0, 1), border-radius .6s;
}
.flyer.full { left: 0; top: 0; width: 100vw; height: 100vh; border-radius: 0; }
@media (prefers-reduced-motion: reduce) { .flyer { transition: none; } }

/* ---------- the full-screen 360 viewer ---------- */
#viewer { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#viewer .back { pointer-events: auto; }
/* one canvas, two jobs: a faint 360 printed onto the paper behind the list, then the full viewer when you step in */
#scene {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab;
  z-index: 0; pointer-events: none; opacity: .2; mix-blend-mode: multiply; filter: saturate(.6) contrast(.9);
  transition: opacity .7s ease, filter .7s ease;
}
#scene.dip { opacity: 0; }
body.viewing #scene { opacity: 1; mix-blend-mode: normal; filter: none; pointer-events: auto; }
#scene:active { cursor: grabbing; }

.back {
  position: fixed; top: 76px; left: 28px; background: none; border: 1px solid currentColor; border-radius: 999px;
  padding: 7px 13px; font: inherit; font-size: 13px; letter-spacing: inherit; text-transform: inherit; color: inherit; cursor: pointer;
  transition: background .3s, color .3s;
}
.back:hover { background: #fff; color: var(--ink); }

#caption {
  position: fixed; left: 0; right: 0; bottom: 26px; text-align: center; pointer-events: none; padding: 0 20px;
}
.count { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.count #idx { color: var(--signal); }
.count i { width: 28px; height: 1px; background: currentColor; opacity: .6; }
#caption h1 {
  font: 400 clamp(26px, 4.4vw, 58px)/1.05 var(--display); letter-spacing: .02em; text-transform: uppercase;
  margin: 12px 0 12px; min-height: 1em;
}
#caption .meta { color: var(--ink); opacity: .75; display: flex; flex-wrap: wrap; justify-content: center; row-gap: 4px; }
#caption .meta span { white-space: nowrap; }
#caption .meta span + span::before { content: '·'; margin: 0 .9em; }
#caption .hint { margin-top: 14px; color: var(--muted); font-size: 12px; }

body.inside { color: #fff; }
body.inside .count, body.inside .mark span { color: rgba(255, 255, 255, .7); }
body.inside #caption .meta { color: #fff; opacity: .9; }
body.inside #caption .hint { color: rgba(255, 255, 255, .75); }
body.inside header, body.inside #caption, body.inside .back { text-shadow: 0 1px 12px rgba(0, 0, 0, .45); }
body.inside .grain { opacity: 0; }
#caption::before, header::before {
  content: ''; position: fixed; left: 0; right: 0; height: 240px; z-index: -1; pointer-events: none; opacity: 0; transition: opacity .8s;
}
#caption::before { bottom: 0; background: linear-gradient(transparent, rgba(0, 0, 0, .5)); }
header::before { top: 0; height: 140px; background: linear-gradient(rgba(0, 0, 0, .35), transparent); }
body.inside #caption::before, body.inside header::before { opacity: 1; }
body.inside #scene { cursor: grab; }

/* hide-text mode: the words step aside while you look around, the controls stay put */
.mark, .compass, #caption { transition: opacity .45s; }
body.quiet .mark, body.quiet .compass, body.quiet #caption { opacity: 0; }

@media (max-width: 780px) {
  header { grid-template-columns: 1fr auto; padding: 16px 16px; }
  .compass { display: none; }
  .controls { grid-column: 2; }
  .pill { font-size: 12px; padding: 6px 11px; }
  .zoom { display: none; } /* phones pinch instead */
  #quiet { max-width: 9.5em; white-space: normal; text-align: center; line-height: 1.15; }
  .search input { width: 120px; max-width: 40vw; }
  .back { top: 64px; left: 16px; }
  #caption { bottom: 20px; }

  #browse { padding-top: 84px; }
  .detail { display: none; }
  .list { max-width: none; min-width: 0; border-right: none; }
  .sortbar { padding: 4px 20px 12px; }
  #entries li.group { padding: 20px 20px 8px; }
  .entry { padding: 13px 20px; }
  .entry img { width: 60px; height: 78px; }
}

/* mid-size screens: stack photo, text, and map in the right pane */
@media (min-width: 781px) and (max-width: 1100px) {
  .detail { grid-template-columns: 1fr; grid-template-rows: auto auto minmax(240px, 1fr); }
  .photo { height: min(34vh, 300px); }
  .detailText { align-self: start; }
  .facts { margin-top: 0; }
}
