/* Wild Thames: placeholder styling.
   All colours, fonts and shapes live in the tokens below, including the map palette,
   so the final design can be dropped in here without touching the code. */

:root {
  /* Type */
  --font-heading: "Boldonse", "Arial Black", sans-serif;   /* map name and site names, set in capitals */
  --font-display: "General Sans", system-ui, sans-serif;
  --font-body: "General Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  /* Interface */
  --panel: #fbf7e8;
  --panel-edge: rgba(40, 52, 30, 0.12);
  --ink: #4c4c4c;             /* all body text */
  --fill-dark: #23301c;       /* dark button fills */
  --heading-ink: #4c4c4c;     /* smaller medium-weight headings */
  --display-ink: #0c007d;     /* Boldonse headings: title, site names, How to visit */
  --ink-soft: #6e6e6e;        /* labels and secondary text (same grey, lighter) */
  --accent: #f0f493;          /* selected marker and text highlight */
  --accent-ink: #4c4c4c;
  --focus: #1b5fd1;
  --radius: 4px;
  --radius-small: 4px;
  --shadow: none;
  --gap: 14px;
  --ease: 180ms ease;

  /* Map palette (read by app.js) */
  --map-land: #dfe3c9;
  --map-urban: #e7e2cf;
  --map-green: #b4bd86;
  --map-park: #c5cc9b;
  --map-water: #87b8a7;
  --map-water-label: #2f5d50;
  --map-building: #d6cfb8;
  --map-road: #f8f4e4;
  --map-road-casing: #cfc8ae;
  --map-rail: #b9b29a;
  --map-label: #4a5440;
  --map-label-halo: #f3f0de;
}

* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.5 var(--font-body);
  color: var(--ink);
  background: var(--map-land);
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--panel); padding: 10px 14px; border-radius: var(--radius-small); box-shadow: var(--shadow); transition: top var(--ease); }
.skip:focus { top: 12px; }

/* Map fills the screen */
#map { position: fixed; inset: 0; }

/* Shared panel look */
.panel {
  background: var(--panel);
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Left rail: search, list, site details */
.rail {
  position: fixed; z-index: 10;
  top: var(--gap); left: var(--gap); bottom: var(--gap);
  width: auto; max-width: calc(100vw - 2 * var(--gap));
  display: flex; flex-direction: column; gap: var(--gap);
  pointer-events: none;
}
.rail > * { pointer-events: auto; }
.top-row { display: flex; align-items: stretch; gap: var(--gap); }

/* Title ticker: letters flip between Boldonse and hand-drawn versions.
   The incoming letter drops in from above and pushes the old one down (positions set in app.js).
   Boldonse caps sit 0.13em above the line box and are 1.19em tall (from the font metrics). */
.ch { position: relative; display: inline-block; clip-path: inset(-0.16em -0.6em -0.14em -0.6em); }
.ty { display: inline-block; transform: translateY(var(--y, 0%)); }
.hand {
  position: absolute; left: 50%; top: -0.13em; height: 1.19em; width: auto; pointer-events: none;
  transform: translate(-50%, var(--y, -140%));
}
.ty, .hand { transition: transform 560ms cubic-bezier(.3, 1.35, .5, 1); }
.top-row .zoom { align-items: center; }

.brand { padding: 24px; display: flex; align-items: center; }
.brand h1 { font: 400 44px/1 var(--font-heading); color: var(--display-ink); white-space: nowrap; text-transform: uppercase; margin: 0; letter-spacing: 0.01em; text-box: trim-both cap alphabetic; }

.search { display: flex; gap: 8px; }
.field { position: relative; flex: 1; display: flex; }
.search input {
  flex: 1; padding-right: 44px; height: 44px; padding: 0 14px; font-size: 16px;
  background: #fff; border: 1px solid var(--panel-edge); border-radius: 999px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.search input:hover { border-color: rgba(40, 52, 30, 0.3); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: transparent; color: var(--ink-soft); cursor: pointer;
  transition: background-color var(--ease), color var(--ease);
}
.clear[hidden] { display: none; }
.clear:hover { background: #efe9d2; color: var(--ink); }
.clear svg { width: 18px; height: 18px; }
.btn {
  height: 44px; min-width: 44px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: #fff; border: 1px solid var(--panel-edge); border-radius: 999px;
  cursor: pointer; font-weight: 500;
  transition: background-color var(--ease), border-color var(--ease), transform var(--ease);
}
.btn:hover { background: #f1edd9; border-color: rgba(40, 52, 30, 0.3); }
.btn:active { transform: translateY(1px); }
.btn[aria-pressed="true"], .btn.primary { background: var(--fill-dark); color: var(--panel); border-color: var(--fill-dark); }
.btn[aria-pressed="true"]:hover, .btn.primary:hover { background: #3a4a30; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* List view */
.list { flex: 1 1 auto; min-height: 0; overflow: hidden; }
.list[hidden] { display: none; }
.list-head { display: flex; align-items: center; gap: 8px; padding: 4px 28px 14px; border-bottom: 1px solid var(--drawer-line); }
.list h2 { flex: 1; font: 500 15px/1.2 var(--font-display); margin: 0; }
.list h2:focus { outline: none; }
.list ol { list-style: none; margin: 0; padding: 12px; overflow-y: auto; }
.list li button {
  width: 100%; text-align: left; display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 16px; border: 0; background: none; border-radius: var(--radius-small); cursor: pointer;
  transition: background-color var(--ease);
}
.list li button:hover, .list li button[aria-current="true"] { background: var(--drawer-hover); }
.list .dot { width: 12px; height: 12px; border-radius: 50%; }
.list .nm { font-weight: 500; }
.list .sub { display: block; font-size: 13px; color: inherit; opacity: .75; font-weight: 400; }
.list .km { font: 13px var(--font-mono); color: inherit; opacity: .75; white-space: nowrap; }
.list .empty { padding: 20px; }

/* Site details card: horizontal, anchored bottom left.
   Left column (type, name, art, summary) stays put; right column scrolls. */
:root { --card-h: min(500px, 62vh); }
.card {
  position: fixed; z-index: 11; left: var(--gap); bottom: var(--gap);
  width: min(820px, calc(100vw - 3 * var(--gap) - 320px));
  height: var(--card-h);
  display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  overflow: hidden;
}
.card[hidden] { display: none; }
.card .close { position: absolute; top: 24px; right: 24px; z-index: 1; background: var(--accent); color: var(--display-ink); border: 0;
  transition: background-color var(--ease), color var(--ease), transform var(--ease); }
.card .close:hover, .card .close:focus-visible { background: var(--display-ink); color: var(--panel); }
.card-intro { padding: 32px; overflow-y: auto; border-right: 1px solid var(--panel-edge); }
.card-more { padding: 36px 36px 32px; overflow-y: auto; }
.card-more:focus-visible { outline-offset: -3px; }
.card-more > .facts:first-child { margin: 0 56px 8px 0; }
.card-intro p { line-height: 1.6; }
.card .kind { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-soft); margin: 0 0 16px; }
.card .kind .dot { width: 10px; height: 10px; border-radius: 50%; }
.card h2 { font: 400 24px/1.54 var(--font-heading); color: var(--display-ink); text-transform: uppercase; margin: 0 0 24px; letter-spacing: 0.01em; overflow-wrap: break-word; text-wrap: balance; }
.card h2:focus { outline: none; }
.type-art { display: block; width: 100%; height: auto; aspect-ratio: 584 / 329; border-radius: var(--radius); margin: 0 0 24px; background: var(--panel-edge); }
/* Make room above the card for the search and list */
@media (max-width: 1000px) { body.has-card .corner, body.has-card .foot { display: none; } body.has-card .card { width: calc(100vw - 2 * var(--gap)); } }
.card h3 { font: 500 13px/1.2 var(--font-body); text-transform: none; color: var(--ink-soft); margin: 24px 0 8px; }
.card p { margin: 0 0 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 4px; padding: 0; list-style: none; }
.tag {
  font: 12px/1 var(--font-mono); padding: 6px 8px; border-radius: var(--radius-small);
  background: #e6ecd3; color: var(--ink);
}
.tag.SSSI, .tag.MCZ { background: #d8e6f0; }
.tag.NONE { background: #ece7d6; }
.protect { margin: 24px 0 0; display: grid; gap: 16px; }
.protect dt { font-weight: 500; color: var(--heading-ink); }
.protect dd { margin: 2px 0 0; color: var(--ink); line-height: 1.6; }
.card .section-title { font: 400 18px/1.3 var(--font-heading); color: var(--display-ink); text-transform: uppercase; letter-spacing: 0.01em; margin: 32px 0 24px; }
.rows { margin: 0; }
.rows > div { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--panel-edge); }
.rows > div:first-child { padding-top: 0; }
.rows > div:last-child { border-bottom: 0; padding-bottom: 0; }
.rows dt { color: var(--ink-soft); }
.rows dd { margin: 0; font-weight: 500; }
/* Welcome panel */
.card .section-title-first { margin-top: 0; margin-right: 56px; }
.card.welcome { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); width: min(980px, calc(100vw - 3 * var(--gap) - 320px)); }
.card.welcome h2 { font-size: 38px; line-height: 1.54; margin-bottom: 24px; }
.card.welcome .card-intro { padding: 40px; }
.card.welcome .rows > div { grid-template-columns: 6.5em minmax(0, 1fr); gap: 12px; }
.card.welcome .type-key { flex-direction: column; gap: 6px; }
.welcome-intro { margin-right: 56px; }
.welcome-intro p { margin: 0 0 12px; line-height: 1.6; }
.card.welcome .type-art { margin-bottom: 0; }
.type-key { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-weight: 400; }
.type-key li { display: flex; align-items: center; gap: 8px; }
.type-key .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
/* Accent buttons: Start exploring, site website link, About this map */
.btn.start { margin-top: 28px; }
.btn.start, .card .more, #about-open, .zoom .btn { background: var(--accent); color: var(--display-ink); border: 0; padding: 0 22px;
  transition: background-color var(--ease), color var(--ease), transform var(--ease); }
.btn.start:hover, .btn.start:focus-visible, .card .more:hover, .card .more:focus-visible, #about-open:hover, #about-open:focus-visible, .zoom .btn:hover, .zoom .btn:focus-visible { background: var(--display-ink); color: var(--panel); }
.small-print { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--panel-edge); font-size: 13px; color: var(--ink-soft); }
.small-print p { margin: 0 0 8px; line-height: 1.55; }
.small-print a { color: var(--display-ink); }
.card .more { display: inline-flex; margin-top: 32px; text-decoration: none; }

/* Top right: zoom and filters */
.corner {
  position: fixed; z-index: 10; top: var(--gap); right: var(--gap); bottom: calc(2 * var(--gap) + 84px);
  width: 320px; display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  pointer-events: none;
}
.corner > * { pointer-events: auto; }

/* Right-hand drawers: deep blue panels with cream text */
:root { --drawer-bg: var(--display-ink); --drawer-ink: var(--panel); --drawer-hover: #1d1099; --drawer-line: rgba(251, 247, 232, .2); }
.drawer { background: var(--drawer-bg); color: var(--drawer-ink); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; flex: none; }
.drawer :focus-visible { outline-color: var(--accent); }
.drawer-head {
  display: flex; align-items: center; gap: 16px; width: 100%; padding: 16px 28px;
  background: none; border: 0; border-radius: var(--radius); color: inherit; text-align: left; cursor: pointer;
  font: 500 15px/1.2 var(--font-body); transition: background-color var(--ease);
}
.drawer-head:hover { background: var(--drawer-hover); }
.drawer-head svg { width: 22px; height: 19px; flex: none; }
.drawer-body { padding: 4px 28px 24px; }
[hidden] { display: none !important; }
.drawer-list { flex: 0 1 auto; }
.drawer-list .list { display: flex; flex-direction: column; min-height: 0; padding: 0; }
.search-msg { margin: 12px 0 0; font-size: 14px; }
.search-msg:empty { display: none; }
.drawer input { color: var(--ink); }
.drawer .btn.primary { background: var(--drawer-ink); color: var(--drawer-bg); border-color: var(--drawer-ink); }
.drawer .btn.primary:hover { background: #fff; }
.drawer .btn.primary svg { width: 20px; height: 20px; }
.zoom { display: flex; gap: 6px; padding: 0; }
.zoom .btn { border-radius: 999px; width: 44px; padding: 0; }
.zoom .btn svg { width: 16px; height: 16px; }
.filters { padding-top: 0; }
.filters fieldset { border: 0; margin: 0; padding: 0; }
.filters legend { font: 500 14px var(--font-display); padding: 0; margin-bottom: 8px; opacity: .8; }
.filters label {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 6px; margin: 0 -6px;
  border-radius: var(--radius-small); cursor: pointer; font-size: 14px; transition: background-color var(--ease);
}
.filters label:hover { background: var(--drawer-hover); }
.filters input {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 22px; height: 22px; border: 0; border-radius: var(--radius-small); background: var(--panel);
  display: grid; place-items: center; transition: background-color var(--ease);
}
.filters input::after {
  content: ""; width: 12px; height: 7px; margin-top: -3px;
  border-left: 2.5px solid var(--display-ink); border-bottom: 2.5px solid var(--display-ink);
  transform: rotate(-45deg) scale(0); transition: transform 160ms ease;
}
.filters input:checked { background: var(--accent); }
.filters input:checked::after { transform: rotate(-45deg) scale(1); }
.filters .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.filters .count { margin-left: auto; font: 12px var(--font-mono); color: inherit; opacity: .75; }
.facts { list-style: none; margin: 10px 0 4px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.facts li { font-size: 13px; padding: 5px 10px; border-radius: 999px; background: #e6ecd3; }
.facts li.no { background: #efe6d6; }

/* Bottom right: about */
.foot { position: fixed; z-index: 10; right: var(--gap); bottom: calc(var(--gap) + 40px); display: flex; align-items: center; gap: var(--gap); }

/* Markers */
.marker {
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none;
  display: grid; place-items: center; cursor: pointer; color: var(--c, #4f7a3a);
  transition: width var(--ease), height var(--ease), transform var(--ease), color var(--ease);
}
.marker svg { width: 100%; height: 100%; display: block; overflow: visible; }
.marker .pin-bg { fill: var(--panel); transition: fill var(--ease); }
.marker:hover, .marker:focus-visible { transform: scale(1.12); color: var(--panel); }
.marker:hover .pin-bg, .marker:focus-visible .pin-bg { fill: var(--display-ink); }
.marker[aria-pressed="true"]:hover, .marker[aria-pressed="true"]:focus-visible { color: var(--display-ink); }
.marker[aria-pressed="true"]:hover .pin-bg, .marker[aria-pressed="true"]:focus-visible .pin-bg { fill: var(--accent); }
.marker[aria-pressed="true"] { width: 58px; height: 58px; color: var(--display-ink); z-index: 2; }
.marker[aria-pressed="true"] .pin-bg { fill: var(--accent); }
.you { width: 18px; height: 18px; border-radius: 50%; background: var(--focus); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(27, 95, 209, .2); }


/* Map attribution: keep it legible on the textured map */
.maplibregl-ctrl-attrib { font-size: 11px; background: rgba(251, 247, 232, .85) !important; }

/* Phones */
@media (max-width: 640px) {
  :root { --gap: 10px; }
  .rail { bottom: auto; max-height: calc(100dvh - 2 * var(--gap)); }
  .brand { padding: 16px; flex-wrap: wrap; gap: 12px; }
  .brand h1 { font-size: 28px; }
  .list-head { padding: 8px 12px 8px 20px; }
  .card { left: var(--gap); right: var(--gap); width: auto; height: auto; max-height: 62dvh; display: block; overflow-y: auto; }
  .card-intro { padding: 24px 20px 0; border-right: 0; overflow: visible; }
  .card-more { padding: 8px 20px 20px; overflow: visible; }
  .rows > div { grid-template-columns: 1fr; gap: 4px; padding: 12px 0; }
  .card .close { top: 12px; right: 12px; }
  .card h2 { margin-right: 48px; }
  .card.welcome { width: auto; }
  .card.welcome h2 { font-size: 28px; }
  .card.welcome .card-intro { padding: 24px 20px 0; }
  body.has-card .rail { bottom: auto; }
  .corner { top: auto; left: var(--gap); right: var(--gap); width: auto; bottom: calc(var(--gap) + 98px); }
  .drawer-head { padding: 14px 20px; font-size: 15px; gap: 14px; }
  .drawer-body { padding: 4px 20px 18px; }
  .drawer-list .list { max-height: 50dvh; }
  .zoom { display: none; }
  .foot { right: auto; left: var(--gap); }
  body.has-card .corner, body.has-card .foot { display: none; }
}

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