:root {
  color-scheme: light;
  --paper: #faf8f3;
  --paper-2: #f1eee5;
  --card: #ffffff;
  --ink: #1d1b16;
  --ink-2: #57534a;
  --ink-3: #8a8578;
  --line: #e4dfd2;
  --focus: #1f5fbf;

  /* Category colours: validated as a set for colour-blind separation. */
  --cat-b: #c8501e;
  --cat-p: #2a78d6;
  --cat-e: #108a66;
  --cat-h: #6b2f8f;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --panel-w: 408px;
  --radius: 10px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr);
  grid-template-areas: "panel map";
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ------------------------------------------------------------------ map */
#map { grid-area: map; position: relative; height: 100%; background: #f3f1ea; }
#map .maplibregl-canvas { outline: none; }

.maplibregl-ctrl-group {
  border-radius: 8px !important;
  box-shadow: 0 1px 3px rgba(29, 27, 22, .18), 0 0 0 1px rgba(29, 27, 22, .06) !important;
  overflow: hidden;
}
.maplibregl-ctrl-attrib { font: 11px/1.4 var(--sans); background: rgba(250, 248, 243, .8) !important; }
.maplibregl-ctrl button.home-ctrl svg { width: 17px; height: 17px; fill: none; stroke: #333; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.tip.maplibregl-popup { pointer-events: none; z-index: 3; }
.tip .maplibregl-popup-content {
  padding: 5px 9px; border-radius: 6px; background: rgba(29, 27, 22, .92); color: #fff;
  font: 600 12.5px/1.3 var(--sans); box-shadow: 0 2px 8px rgba(0, 0, 0, .2); max-width: 240px;
}
.tip .maplibregl-popup-content span { display: block; font-weight: 400; opacity: .78; }
.tip .maplibregl-popup-tip { border-top-color: rgba(29, 27, 22, .92) !important; border-width: 5px; }

.map-note {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 2;
  padding: 7px 14px; border-radius: 999px; background: rgba(29, 27, 22, .9); color: #fff;
  font-size: 13px; box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
  opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap;
}
.map-note.show { opacity: 1; }

/* ---------------------------------------------------------------- panel */
#panel {
  grid-area: panel; display: flex; flex-direction: column; min-height: 0; height: 100%;
  background: var(--paper); border-right: 1px solid var(--line);
  box-shadow: 2px 0 14px rgba(29, 27, 22, .06); z-index: 2;
}

.masthead { padding: 20px 22px 14px; }
.masthead h1 { font: 600 25px/1.1 var(--serif); letter-spacing: -.01em; }
.masthead p { margin-top: 5px; color: var(--ink-2); font-size: 13.5px; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view[hidden] { display: none; }

.controls { padding: 0 22px 12px; }

.search {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(31, 95, 191, .14); }
.search svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--ink-3); stroke-width: 1.8; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 15px; }
.search input::placeholder { color: var(--ink-3); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search kbd {
  flex: none; padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px;
  color: var(--ink-3); font: 12px/1.5 var(--sans); background: var(--paper);
}
.search:focus-within kbd { display: none; }

.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.cat {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 7px; min-height: 36px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  font-size: 13.5px; font-weight: 550; text-align: left; white-space: nowrap;
  transition: background .15s, opacity .15s, border-color .15s;
}
.cat:hover { border-color: #cfc9b9; }
.cat .mark { width: 22px; height: 22px; flex: none; }
.cat .count { margin-left: auto; color: var(--ink-3); font-weight: 400; font-size: 12px; font-variant-numeric: tabular-nums; }
.cat[aria-pressed="false"] { background: transparent; color: var(--ink-3); }
.cat[aria-pressed="false"] .mark { filter: grayscale(1); opacity: .4; }
.cat[aria-pressed="false"] .label { text-decoration: line-through; text-decoration-color: rgba(138, 133, 120, .6); }

.list-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 10px 22px 8px; border-top: 1px solid var(--line);
}
.list-head h2 { font: 600 12px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }

.quiet {
  padding: 3px 0; border: 0; background: none; color: var(--ink-2); font-size: 13px;
  text-decoration: underline; text-decoration-color: #cfc9b9; text-underline-offset: 3px;
}
.quiet:hover { color: var(--ink); text-decoration-color: var(--ink); }

.list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 16px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #d5cfbf transparent; }
.list:focus { outline: none; }

.group-label {
  margin: 14px 10px 4px; color: var(--ink-3);
  font: 600 11.5px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase;
}

.row {
  display: flex; gap: 12px; width: 100%; padding: 10px; border: 0; border-radius: var(--radius);
  background: none; text-align: left; align-items: flex-start;
}
.row:hover, .row.is-hover { background: var(--paper-2); }
.row .thumb {
  flex: none; width: 64px; height: 64px; border-radius: 8px; object-fit: cover;
  background: var(--paper-2); color: transparent;
}
.row .thumb.blank { display: grid; place-items: center; }
.row .thumb.blank svg { width: 30px; height: 30px; }
.row .body { min-width: 0; flex: 1; }
.row .name { display: block; font: 600 16px/1.25 var(--serif); }
.row .meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--ink-2); font-size: 12.5px; }
.row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.row .snip {
  margin-top: 4px; color: var(--ink-2); font-size: 13px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.row.small { padding: 7px 10px; gap: 10px; align-items: center; }
.row.small .thumb { width: 40px; height: 40px; border-radius: 6px; }
.row.small .name { font: 550 14px/1.3 var(--sans); }
.row.small .meta { margin-top: 1px; }
.row.small .meta span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.tiny { padding: 6px 10px; gap: 10px; align-items: baseline; }
.row.tiny .dot { position: relative; top: -1px; }
.row.tiny .name { font: 500 14px/1.3 var(--sans); display: inline; }
.row.tiny .sub { color: var(--ink-3); font-size: 12.5px; margin-left: 6px; }

.empty, .hint { margin: 14px 10px; color: var(--ink-2); font-size: 13.5px; }
.hint { padding: 10px 12px; border-radius: 8px; background: var(--paper-2); }

.skeleton { margin: 10px; height: 64px; border-radius: var(--radius); background: linear-gradient(90deg, var(--paper-2) 25%, #f7f5ee 37%, var(--paper-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

/* --------------------------------------------------------------- detail */
#detail { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #d5cfbf transparent; animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.back {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 10px 22px; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: rgba(250, 248, 243, .94); backdrop-filter: blur(6px); color: var(--ink-2); font-size: 13.5px; text-align: left;
}
.back:hover { color: var(--ink); }
.back svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back kbd { margin-left: auto; padding: 0 6px; border: 1px solid var(--line); border-radius: 5px; font: 11.5px/1.6 var(--sans); color: var(--ink-3); }

.photo { margin: 0; background: var(--paper-2); }
.photo img { display: block; width: 100%; height: 230px; object-fit: cover; object-position: 50% 35%; opacity: 0; transition: opacity .3s; }
.photo img.ready { opacity: 1; }
.photo figcaption { padding: 5px 22px 0; background: var(--paper); color: var(--ink-3); font-size: 11.5px; line-height: 1.4; }
.photo figcaption a { text-decoration-color: #cfc9b9; text-underline-offset: 2px; }

.story { padding: 16px 22px 8px; }
.tag { display: flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 12.5px; font-weight: 550; letter-spacing: .02em; }
.tag .mark { width: 20px; height: 20px; }
.tag .when { color: var(--ink-3); font-weight: 400; }
.tag .when::before { content: "·"; margin-right: 7px; }
.story h2 { margin-top: 8px; font: 600 26px/1.15 var(--serif); letter-spacing: -.01em; text-wrap: balance; }
.story .sub { margin-top: 6px; color: var(--ink-2); font-size: 14px; }
.story .text { margin-top: 12px; font: 17px/1.55 var(--serif); text-wrap: pretty; }
.story .text.plain { font: 15px/1.55 var(--sans); color: #2d2a24; }
.story blockquote {
  margin: 14px 0 0; padding: 12px 16px; border-left: 3px solid var(--cat, var(--line)); border-radius: 0 8px 8px 0;
  background: var(--card); font: 16px/1.5 var(--serif);
}
.story .source { margin-top: 8px; color: var(--ink-3); font-size: 12px; }
.story .loading { margin-top: 14px; height: 70px; border-radius: 8px; }

.quote {
  margin: 0 0 8px; padding: 11px 15px; border-left: 3px solid var(--cat, var(--line)); border-radius: 0 8px 8px 0;
  background: var(--card); font: 15.5px/1.5 var(--serif);
}
.quote footer { margin-top: 5px; color: var(--ink-3); font: 12px/1.4 var(--sans); }
.quote-head { margin: 0 0 8px; color: var(--ink-3); font: 600 11.5px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase; }
.story blockquote + blockquote { margin-top: 8px; }
[data-extras] section { padding: 14px 22px 4px; }
[data-extras] h3 { margin-bottom: 8px; color: var(--ink-3); font: 600 11.5px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase; }
.notes { margin-top: 8px; border-top: 1px solid var(--line); }
.note + .note { margin-top: 12px; }
.note h4 { margin: 0 0 2px; font: 600 15px/1.3 var(--serif); }
.note p { color: #2d2a24; font-size: 14.5px; line-height: 1.5; text-wrap: pretty; }

/* What Joolz Guides tells about the place on his walks. */
.told { margin-top: 8px; border-top: 1px solid var(--line); }
.told p { color: #2d2a24; font: 15.5px/1.55 var(--serif); text-wrap: pretty; }
.told p + p { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.told-mark {
  width: 11px; height: 11px; margin-left: 6px; vertical-align: -1px; flex: none;
  fill: none; stroke: var(--ink-3); stroke-width: 1.3; stroke-linejoin: round;
}
.video {
  display: flex; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); text-decoration: none; transition: border-color .15s;
}
.video + .video, .player + .video, .video + .player { margin-top: 8px; }
.video:hover { border-color: var(--ink-3); }
.video img { flex: none; width: 112px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--paper-2); }
.video .vt { min-width: 0; }
.video b { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.video small { display: block; margin-top: 3px; color: var(--ink-2); font-size: 12px; }
.video small::before { content: "\25B6\FE0E"; margin-right: 5px; font-size: 9px; }
.player iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius); background: #000; }
.player a { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; color: var(--ink-2); font-size: 12.5px; }
.player svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sources ul { margin: 0; padding: 0; list-style: none; }
.sources li { margin-top: 4px; font-size: 12.5px; line-height: 1.4; }
.sources a { color: var(--ink-2); text-decoration-color: #cfc9b9; text-underline-offset: 2px; }
.sources a:hover { color: var(--ink); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 22px 6px; }
.actions a {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); font-size: 13.5px; font-weight: 550; text-decoration: none;
  transition: border-color .15s, background .15s;
}
.actions a:hover { border-color: var(--ink-3); }
.actions a.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.actions a.primary:hover { background: #000; }
.actions svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.nearby { margin-top: 12px; padding: 4px 12px 18px; border-top: 1px solid var(--line); }
.nearby .row .dist { margin-left: auto; padding-left: 8px; flex: none; color: var(--ink-3); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.foot { padding: 9px 22px calc(9px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.foot .quiet { font-size: 12.5px; color: var(--ink-3); }

/* ---------------------------------------------------------------- about */
dialog#about {
  width: min(560px, calc(100vw - 32px)); max-height: min(86vh, 720px); padding: 26px 28px 22px;
  border: 0; border-radius: 14px; background: var(--paper); color: var(--ink);
  box-shadow: 0 20px 60px rgba(29, 27, 22, .3);
}
dialog#about::backdrop { background: rgba(29, 27, 22, .42); }
dialog#about h2 { font: 600 24px/1.2 var(--serif); }
dialog#about h3 { margin-top: 18px; font: 600 12px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
dialog#about p { margin-top: 10px; }
dialog#about ul { margin: 8px 0 0; padding-left: 18px; }
dialog#about li { margin-top: 7px; font-size: 14px; }
dialog#about a { text-underline-offset: 2px; }
dialog#about .fine { color: var(--ink-3); font-size: 12.5px; }
dialog#about .close {
  position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: none; font-size: 24px; line-height: 1; color: var(--ink-2);
}
dialog#about .close:hover { background: var(--paper-2); }

/* --------------------------------------------------------------- narrow */
@media (max-width: 760px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 52dvh; grid-template-areas: "map" "panel"; }
  #panel { border-right: 0; border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(29, 27, 22, .1); }
  .masthead { padding: 12px 16px 8px; }
  .masthead h1 { font-size: 20px; }
  .masthead p, .search kbd, .back kbd { display: none; }
  .controls { padding: 0 16px 10px; }
  .list-head { padding: 8px 16px 6px; }
  .list { padding: 0 6px 12px; }
  .back, .photo figcaption, .story, .actions { padding-left: 16px; padding-right: 16px; }
  .photo img { height: 170px; }
  .story h2 { font-size: 22px; }
  .foot { display: none; }
  body.has-detail { grid-template-rows: minmax(0, 1fr) 62dvh; }
  body.has-detail .masthead { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
