/* Taua map: blog.lewisbrewer.com/map/
   Builds on site.css tokens (black, off-white, red; BN Romaine and Inter). */
:root {
  --tm-panel: rgba(8, 8, 9, 0.94);
  --tm-card: #0f0f10;
  --tm-line: rgba(240, 240, 240, 0.14);
  --tm-line-strong: rgba(240, 240, 240, 0.28);
  --tm-amber: #e5c48a;
  --tm-top: 56px;
  --tm-radius: 6px;
}
html, body.tm { height: 100%; overflow: hidden; }
body.tm { display: flex; flex-direction: column; font-size: 0.9375rem; line-height: 1.5; }
.tm-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tm button { font: inherit; color: inherit; }
.tm-link { background: none; border: 0; padding: 0; color: var(--head); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--tm-line-strong); cursor: pointer; }
.tm-link:hover { color: var(--red-text); text-decoration-color: currentColor; }
.tm-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--tm-line); border-radius: var(--tm-radius); background: var(--tm-panel); color: var(--head); cursor: pointer; }
.tm-icon svg { width: 18px; height: 18px; }
.tm-icon:hover { border-color: var(--tm-line-strong); color: #fff; }

/* ── top bar ── */
.tm-top { flex: none; height: var(--tm-top); display: flex; align-items: center; gap: 20px; padding: 0 var(--gutter); border-bottom: 1px solid var(--tm-line); background: var(--bg); position: relative; z-index: 1200; }
.tm-brand { font-size: 0.8125rem; line-height: 1; text-transform: uppercase; letter-spacing: -0.03em; text-decoration: none; white-space: nowrap; display: inline-flex; gap: 0.6em; }
.tm-brand span { color: var(--muted); }
.tm-brand:hover { color: var(--red-text); }
.tm-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; padding-left: 20px; border-left: 1px solid var(--tm-line); }
.tm-title h1 { margin: 0; font: 400 1.5rem/1 var(--display); color: var(--red); letter-spacing: 0.01em; white-space: nowrap; }
.tm-title p { margin: 0; font-size: 0.75rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.tm-search { position: relative; margin-left: auto; width: min(340px, 34vw); }
.tm-search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.tm-search input { width: 100%; height: 36px; padding: 0 12px 0 34px; border: 1px solid var(--tm-line); border-radius: var(--tm-radius); background: var(--tm-card); color: var(--head); font: inherit; font-size: 0.875rem; }
.tm-search input::placeholder { color: var(--faint); }
.tm-search input:focus { outline: none; border-color: var(--red-text); }
#tm-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: var(--tm-panel); border: 1px solid var(--tm-line-strong); border-radius: var(--tm-radius); max-height: min(420px, 60vh); overflow: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); }
#tm-results li { padding: 7px 10px; border-radius: 4px; cursor: pointer; display: flex; flex-direction: column; }
#tm-results li b { font-weight: 600; color: var(--head); }
#tm-results li span { font-size: 0.75rem; color: var(--muted); }
#tm-results li[aria-selected="true"], #tm-results li:hover { background: rgba(255, 90, 95, 0.14); }
#tm-results .tm-none { color: var(--muted); cursor: default; font-size: 0.8125rem; }
.tm-search-open { display: none; }
.tm-about-link { font-size: 0.8125rem; white-space: nowrap; }

/* ── stage ── */
.tm-stage { flex: 1; position: relative; min-height: 0; }
.tm-map { position: absolute; inset: 0; background: #2e526c; font: inherit; }
.leaflet-container { font: inherit; background: #2e526c; outline: none; }
.leaflet-container a { color: inherit; }
.whenua-tiles img, .leaflet-pane.leaflet-whenua-pane img { image-rendering: pixelated; }
.leaflet-whenua-pane .leaflet-tile { image-rendering: pixelated; }
.tm-hover { position: absolute; left: 0; top: 0; z-index: 900; pointer-events: none; padding: 5px 9px; border-radius: 4px; background: rgba(0, 0, 0, 0.82); border: 1px solid var(--tm-line); font-size: 0.75rem; line-height: 1.3; display: flex; flex-direction: column; max-width: 240px; }
.tm-hover[hidden] { display: none; }
.tm-hover b { font-weight: 600; color: #fff; }
.tm-hover span { color: var(--muted); }
.tm-tip { background: rgba(0, 0, 0, 0.85); color: var(--head); border: 1px solid var(--tm-line); box-shadow: none; border-radius: 4px; font-size: 0.75rem; padding: 4px 8px; }
.tm-tip::before { display: none; }
.tm-wheel-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1000; margin: 0; padding: 10px 16px; border-radius: var(--tm-radius); background: rgba(0, 0, 0, 0.8); font-size: 0.875rem; pointer-events: none; }

/* ── controls ── */
.tm-controls { position: absolute; top: 14px; right: 14px; z-index: 1000; display: flex; flex-direction: column; gap: 6px; }
.has-panel .tm-controls { right: calc(var(--tm-panel-w) + 28px); }
.tm-open-full, .tm-embed-note { display: none; }

/* ── layers ── */
.tm-layers { position: absolute; top: 14px; left: 14px; z-index: 1000; width: 290px; max-height: calc(100% - 28px); display: flex; flex-direction: column; background: var(--tm-panel); border: 1px solid var(--tm-line); border-radius: var(--tm-radius); backdrop-filter: blur(6px); }
.tm-layers-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: 0; background: none; cursor: pointer; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.75rem !important; color: var(--head); }
.tm-layers-toggle svg { width: 18px; height: 18px; }
.tm-layers-toggle::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform 0.15s; }
.tm-layers.is-open .tm-layers-toggle::after { transform: rotate(-135deg) translateY(-2px); }
.tm-layers:not(.is-open) .tm-layers-body { display: none; }
.tm-layers:not(.is-open) { width: auto; }
.tm-layers-body { overflow: auto; padding: 4px 14px 14px; border-top: 1px solid var(--tm-line); overscroll-behavior: contain; }
.tm-layers fieldset { border: 0; padding: 6px 0 0; margin: 0; }
.tm-check { display: flex; align-items: center; gap: 9px; padding: 6px 0; cursor: pointer; font-weight: 500; color: var(--head); font-size: 0.875rem; }
.tm-check input { accent-color: #d12229; width: 15px; height: 15px; margin: 0; flex: none; }
.tm-check.sm { font-weight: 400; font-size: 0.8125rem; padding: 3px 0; color: var(--text); }
.tm-hint { color: var(--faint); font-weight: 400; font-size: 0.75rem; }
.tm-count { margin-left: auto; color: var(--faint); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.tm-sub { padding: 0 0 6px 24px; }
.tm-sub[hidden] { display: none; }
.tm-select, .tm-range { display: flex; align-items: center; gap: 10px; font-size: 0.8125rem; color: var(--muted); }
.tm-select select { flex: 1; height: 30px; padding: 0 8px; background: var(--tm-card); color: var(--head); border: 1px solid var(--tm-line); border-radius: 4px; font: inherit; }
.tm-range input { flex: 1; accent-color: #d12229; }
.tm-glyph { width: 16px; height: 16px; flex: none; }
.tm-legend { margin-top: 8px; }
.tm-lg-sec { padding-top: 12px; margin-top: 10px; border-top: 1px solid var(--tm-line); }
.tm-lg-sec h4 { margin: 0 0 8px; font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.tm-key, .tm-swatches { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 0.78rem; color: var(--text); }
.tm-key li, .tm-swatches li { display: flex; align-items: center; gap: 8px; line-height: 1.3; }
.tm-swatches { grid-template-columns: 1fr 1fr; column-gap: 10px; margin-bottom: 8px; }
.tm-swatches.tm-wide { grid-template-columns: 1fr; }
.tm-swatches span { width: 12px; height: 12px; border-radius: 2px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35); }
.tm-swatches i { margin-left: auto; font-style: normal; color: var(--faint); font-size: 0.7rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tm-legend details { margin: 4px 0; }
.tm-legend summary { cursor: pointer; font-size: 0.78rem; color: var(--head); padding: 3px 0; }
.tm-legend details ul { margin: 4px 0 6px 14px; }
.tm-fine { font-size: 0.72rem; color: var(--faint); line-height: 1.45; margin: 8px 0 0; }

/* ── details panel ── */
.tm { --tm-panel-w: 390px; }
.tm-panel { position: absolute; top: 14px; right: 14px; bottom: 14px; width: var(--tm-panel-w); z-index: 1001; display: flex; flex-direction: column; background: var(--tm-panel); border: 1px solid var(--tm-line); border-radius: var(--tm-radius); box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px); }
.tm-panel[hidden] { display: none; }
.tm-panel-handle { display: none; }
.tm-panel-close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 32px; height: 32px; }
.tm-panel-body { overflow: auto; padding: 18px 20px 20px; overscroll-behavior: contain; }
.tm-kind { margin: 0 0 4px; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--red-text); font-weight: 600; padding-right: 40px; }
.tm-panel h2, .tm-about h2 { margin: 0; font: 400 1.85rem/1.05 var(--display); color: var(--head); letter-spacing: 0.01em; padding-right: 40px; overflow-wrap: anywhere; }
.tm-aka { margin: 6px 0 0; color: var(--muted); font-size: 0.8125rem; }
.tm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.tm-chips:empty { display: none; }
.tm-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; line-height: 1.5; border: 1px solid var(--tm-line-strong); color: var(--head); white-space: nowrap; }
.tm-chip.is-unconf { border-style: dashed; border-color: rgba(229, 196, 138, 0.7); color: var(--tm-amber); }
.tm-chip.is-approx { color: var(--muted); }
.tm-chip.is-consult { border-color: #ff5a5f; color: #ffb3b5; background: rgba(209, 34, 41, 0.16); }
.tm-chip.is-ok { border-color: rgba(143, 196, 230, 0.5); color: #b9d6e6; }
.tm-lede { margin: 12px 0 0; color: var(--text); }
.tm-panel h3, .tm-about h3 { margin: 0 0 6px; font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.tm-occ, .tm-facts, .tm-src, .tm-list { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--tm-line); }
.tm-occ.is-unconf { border-top-style: dashed; border-top-color: rgba(229, 196, 138, 0.45); }
.tm-occ-name { margin: 0 0 8px; font-size: 1.05rem; font-weight: 600; color: #fff; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; }
.tm-occ-name a { text-decoration-color: var(--tm-line-strong); text-underline-offset: 3px; }
.tm-occ-name a:hover { color: var(--red-text); }
.tm-occ-name span { font-size: 0.8125rem; font-weight: 400; color: var(--muted); }
.tm-occ.is-empty p { margin: 0; color: var(--muted); }
.tm-panel dl { margin: 0; display: grid; gap: 6px; }
.tm-kv { display: grid; grid-template-columns: 92px 1fr; gap: 10px; font-size: 0.8125rem; line-height: 1.45; }
.tm-kv dt { color: var(--faint); }
.tm-kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.tm-kv i, .tm-panel i { color: var(--faint); font-style: normal; }
.tm-panel details { margin-top: 10px; font-size: 0.8125rem; }
.tm-panel details summary { cursor: pointer; color: var(--head); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 4px 0; }
.tm-panel details p { margin: 6px 0 0; color: var(--text); line-height: 1.55; overflow-wrap: anywhere; }
.tm-notes { padding-top: 12px; border-top: 1px solid var(--tm-line); margin-top: 16px !important; }
.tm-src ul, .tm-list ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 0.8125rem; }
.tm-list li { display: flex; justify-content: space-between; gap: 10px; }
.tm-list li span { color: var(--faint); font-size: 0.75rem; white-space: nowrap; }
.tm-list ul.tm-inline { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.tm-panel a { text-underline-offset: 3px; text-decoration-color: var(--tm-line-strong); }
.tm-panel a:hover { color: var(--red-text); text-decoration-color: currentColor; }
.tm-note { margin: 16px 0 0; font-size: 0.78rem; color: var(--muted); line-height: 1.5; }
.tm-panel-foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--tm-line); font-size: 0.78rem; color: var(--muted); }
.tm-panel-foot p { margin: 0 0 8px; }

/* ── about ── */
.tm-about { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.7); }
.tm-about[hidden] { display: none; }
.tm-about-card { position: relative; width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 26px 28px; background: var(--tm-card); border: 1px solid var(--tm-line-strong); border-radius: 8px; font-size: 0.9rem; line-height: 1.6; }
.tm-about-card p, .tm-about-card ul { color: var(--text); }
.tm-about-card ul { padding-left: 1.1em; }
.tm-about-card li { margin: 4px 0; }
.tm-about-card h3 { margin-top: 18px; }
.tm-about-card a { color: var(--head); text-underline-offset: 3px; }
.tm-about-close { position: absolute; top: 14px; right: 14px; }
.tm-noscript { padding: 2rem var(--gutter); }

/* ── loading ── */
.tm-map::after { content: "Loading the map"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: rgba(255, 255, 255, 0.7); font-size: 0.875rem; letter-spacing: 0.05em; text-transform: uppercase; }
.is-ready .tm-map::after { display: none; }

/* ── phones ── */
@media (max-width: 900px) {
  .tm-title p { display: none; }
  .tm-about-link { display: none; }
}
@media (max-width: 719px) {
  :root { --tm-top: 52px; }
  .tm-brand { display: none; }
  .tm-title { border-left: 0; padding-left: 0; flex: 1; }
  .tm-title h1 { font-size: 1.35rem; }
  .tm-search { display: none; position: absolute; left: var(--gutter); right: var(--gutter); top: 8px; width: auto; margin: 0; }
  .search-open .tm-search { display: block; }
  .search-open .tm-title, .search-open .tm-search-open { visibility: hidden; }
  .tm-search-open { display: inline-grid; margin-left: auto; }
  .tm-layers { top: auto; bottom: 14px; left: 12px; width: calc(100% - 24px); max-height: 62%; }
  .tm-layers:not(.is-open) { width: auto; }
  .tm-layers.is-open { z-index: 1002; }
  .tm-controls { top: 12px; right: 12px; }
  .has-panel .tm-controls { right: 12px; }
  .tm-icon { width: 40px; height: 40px; }
  .tm-panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 86%; border-radius: 12px 12px 0 0; border-bottom: 0; transition: height 0.2s ease; padding-bottom: env(safe-area-inset-bottom); }
  .tm-panel[data-sheet="peek"] { height: 42%; }
  .tm-panel[data-sheet="full"] { height: 86%; }
  .tm-panel-handle { display: block; flex: none; height: 22px; border: 0; background: none; cursor: grab; touch-action: none; }
  .tm-panel-handle span { display: block; width: 40px; height: 4px; margin: 9px auto; border-radius: 2px; background: var(--tm-line-strong); }
  .tm-panel-body { padding: 4px 18px 18px; }
  .tm-panel-close { top: 14px; }
  .tm-panel h2 { font-size: 1.6rem; }
  .has-panel .tm-layers { display: none; }
}

/* ── embedded in a post ── */
.is-embed .tm-top { display: none; }
.is-embed .tm-open-full { display: inline-flex; align-items: center; gap: 7px; position: absolute; top: 12px; right: 58px; z-index: 1000; height: 36px; padding: 0 12px; border: 1px solid var(--tm-line); border-radius: var(--tm-radius); background: var(--tm-panel); font-size: 0.78rem; text-decoration: none; color: var(--head); }
.is-embed .tm-embed-note { display: block; position: absolute; left: 12px; bottom: 10px; z-index: 1000; margin: 0; padding: 4px 9px; border-radius: 4px; background: rgba(0, 0, 0, 0.72); font-size: 0.72rem; color: #f3dcdc; }
.is-embed.has-panel .tm-embed-note { display: none; }
.is-embed .tm-open-full svg { width: 14px; height: 14px; }
.is-embed .tm-open-full:hover { color: var(--red-text); }
.is-embed .tm-layers { top: 12px; left: 12px; bottom: auto; width: auto; max-width: 270px; max-height: calc(100% - 24px); }
.is-embed .tm-layers.is-open { width: 270px; }
.is-embed.has-panel .tm-open-full, .tm-embed-note { display: none; }
.is-embed .tm-panel { --tm-panel-w: min(360px, 62vw); }
.is-embed .tm-panel-foot .tm-link { display: none; }
@media (max-width: 719px) {
  .is-embed .tm-open-full { right: 60px; }
  .is-embed .tm-panel[data-sheet="peek"] { height: 55%; }
  .is-embed .tm-layers { bottom: auto; }
}
@media (prefers-reduced-motion: reduce) { .tm-panel { transition: none; } }
