/* Spatial evidence explorer: a field guide of places. Nautoguide proof of concept. */
:root {
  color-scheme: light;
  --page: #eef4f5;
  --plate: #ffffff;
  --plate-2: #f5f9fa;
  --ink: #13232a;
  --muted: #4b616b;
  --line: #d6e1e5;
  --keyline: #b4c6cc;
  --teal: #1a89b4;
  --teal-ink: #126a8c;
  --teal-wash: #e2f1f7;
  --select: #13232a;
  --halo: #ffffff;
  --sea: #dae7ec;
  --caveat-bg: #fbf3e2;
  --caveat-ink: #5a4210;
  --worse-bg: #fbe2da; --worse-ink: #8f260c;
  --better-bg: #dcf0e3; --better-ink: #1c6536;
  --flat-bg: #e6edf0; --flat-ink: #36464d;
  --hatch-bg: #e3eaed; --hatch-line: #9fb1b8;
  --shadow: 0 1px 2px rgba(19, 35, 42, .06), 0 6px 18px rgba(19, 35, 42, .06);
  --font: Mulish, Muli, "Segoe UI", system-ui, sans-serif;
  --r: 2px;
  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px; --s6: 48px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #23292e; --plate: #2b3237; --plate-2: #323a40; --ink: #ecf0f2; --muted: #aab5bb;
    --line: #3c454c; --keyline: #535e66; --teal: #2fa9d0; --teal-ink: #70c7e4; --teal-wash: #1d3b47;
    --select: #ffffff; --halo: #10171b; --sea: #10171b;
    --caveat-bg: #2c2412; --caveat-ink: #f0d9a6;
    --worse-bg: #3d1d14; --worse-ink: #f6b4a1; --better-bg: #13321f; --better-ink: #9fdcb3; --flat-bg: #22333a; --flat-ink: #c6d4d9;
    --hatch-bg: #2c3a42; --hatch-line: #64777f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #23292e; --plate: #2b3237; --plate-2: #323a40; --ink: #ecf0f2; --muted: #aab5bb;
  --line: #3c454c; --keyline: #535e66; --teal: #2fa9d0; --teal-ink: #70c7e4; --teal-wash: #1d3b47;
  --select: #ffffff; --halo: #10171b; --sea: #10171b;
  --caveat-bg: #2c2412; --caveat-ink: #f0d9a6;
  --worse-bg: #3d1d14; --worse-ink: #f6b4a1; --better-bg: #13321f; --better-ink: #9fdcb3; --flat-bg: #22333a; --flat-ink: #c6d4d9;
  --hatch-bg: #2c3a42; --hatch-line: #64777f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--page); line-height: 1.45; font-size: 15px; }
::selection { background: var(--teal-wash); color: var(--ink); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 2px; }
a { color: var(--teal-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
td, output, .num, .measure dd { font-variant-numeric: tabular-nums; }
* { scrollbar-width: thin; scrollbar-color: var(--keyline) transparent; }
.sub { color: var(--muted); font-size: 13px; }
.hatch-bg { fill: var(--hatch-bg); } .hatch-line { stroke: var(--hatch-line); stroke-width: 1.4; }

/* ---------- header ---------- */
header.site { display: flex; align-items: center; gap: var(--s4); padding: 0 var(--s4); min-height: 64px; background: var(--plate); border-bottom: 1px solid var(--line); }
.logo { display: block; line-height: 0; flex: none; }
.logo img { height: 25px; width: auto; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-light { display: none; } :root:not([data-theme="light"]) .logo-dark { display: block; } }
.titles { position: relative; padding-left: var(--s4); min-width: 0; }
.titles::before { content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 1px; background: var(--line); }
.titles h1 { font-size: 15px; font-weight: 800; letter-spacing: -0.005em; }
.tag { margin: 0; font-size: 12.5px; color: var(--muted); }
nav { display: flex; gap: var(--s1); margin-left: auto; align-self: stretch; }
nav button { font: inherit; font-size: 14px; font-weight: 700; color: var(--muted); background: none; border: 0; cursor: pointer;
  padding: 0 var(--s3); position: relative; transition: color .15s ease-out; }
nav button::after { content: ""; position: absolute; left: var(--s3); right: var(--s3); bottom: -1px; height: 2px; background: var(--teal);
  transform: scaleX(0); transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
nav button:hover { color: var(--ink); }
nav button[aria-selected="true"] { color: var(--ink); }
nav button[aria-selected="true"]::after { transform: scaleX(1); }
.theme { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--plate); color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.theme:hover { border-color: var(--keyline); background: var(--plate-2); }
.theme svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme .i-sun { display: none; }
.theme[aria-pressed="true"] .i-sun { display: block; }
.theme[aria-pressed="true"] .i-moon { display: none; }

/* ---------- loading / error ---------- */
main { padding: var(--s4); max-width: 1600px; margin: 0 auto; }
.status { display: none; }
.is-loading .status, .status.error { display: grid; place-items: center; align-content: center; gap: var(--s3); min-height: 60vh; text-align: center; color: var(--muted); }
.is-loading .tab { display: none !important; }
.status-plates { display: flex; gap: var(--s2); }
.status-plates i { width: 72px; height: 96px; border-radius: var(--r); background: linear-gradient(100deg, var(--line) 30%, var(--plate-2) 50%, var(--line) 70%); background-size: 300% 100%; animation: shimmer 1.6s ease-out infinite; }
.status-plates i:nth-child(2) { animation-delay: .15s; } .status-plates i:nth-child(3) { animation-delay: .3s; }
.status.error .status-plates { display: none; }
.status.error p { max-width: 60ch; color: var(--ink); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.tab { display: none; }
.tab.active { display: block; animation: settle .35s cubic-bezier(.2, .8, .2, 1); }
.tab[hidden] { display: none !important; }
@keyframes settle { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::after { animation: none !important; transition: none !important; } }

/* ---------- toolbar ---------- */
.toolbar { display: grid; grid-template-columns: minmax(200px, 1.1fr) minmax(240px, 1.6fr) auto minmax(200px, 1fr); gap: var(--s3); align-items: start; margin-bottom: var(--s3); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child, #geoLabel { font-size: 12px; font-weight: 700; color: var(--muted); }
.field output { color: var(--ink); font-weight: 800; margin-left: 4px; }
select, input[type="search"] { font: inherit; font-size: 14px; color: var(--ink); background: var(--plate); border: 1px solid var(--keyline); border-radius: var(--r); height: 40px; padding: 0 12px; width: 100%; }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
select:hover, input[type="search"]:hover { border-color: var(--muted); }
select option, select optgroup { background: var(--plate); color: var(--ink); }
.search { position: relative; display: block; }
.search svg { position: absolute; left: 11px; top: 11px; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search input { padding-left: 36px; }
input::placeholder { color: var(--muted); opacity: 1; }
.segmented { display: inline-flex; height: 40px; border: 1px solid var(--keyline); border-radius: var(--r); background: var(--plate); padding: 3px; gap: 3px; }
.segmented button { font: inherit; font-size: 13.5px; font-weight: 700; border: 0; border-radius: 4px; padding: 0 14px; color: var(--muted); background: none; cursor: pointer; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--teal-wash); color: var(--ink); box-shadow: inset 0 0 0 1px var(--teal); }
input[type="range"] { width: 100%; margin: 9px 0 0; accent-color: var(--teal); height: 18px; }
.range-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- workspace ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s3); align-items: start; }
.map-col { display: grid; gap: var(--s3); min-width: 0; }
.plate { margin: 0; background: var(--plate); border: 1px solid var(--keyline); border-radius: var(--r); overflow: hidden; }
.plate.main { padding: var(--s2); }
.plate.main .mapwrap { border: 1px solid var(--line); }
.mapwrap { position: relative; height: clamp(440px, 62vh, 640px); background: var(--sea); }
#map, #map2 { position: absolute; inset: 0; }

/* legend reads as a plate caption, keyed beneath */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); padding: 12px var(--s3); border-top: 1px solid var(--line); font-size: 12.5px; }
.legend .cap { flex: 1 1 220px; min-width: 0; }
.legend .cap strong { display: block; font-size: 13px; }
.legend .cap span { color: var(--muted); }
.legend .key { display: flex; flex-wrap: wrap; gap: 2px; }
.legend .k { display: grid; grid-template-rows: 12px auto auto; gap: 3px; min-width: 64px; }
.legend .sw { height: 12px; border-radius: 2px; }
.legend .k b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend .k em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.sw.hatched { background: repeating-linear-gradient(45deg, var(--hatch-bg) 0 3px, var(--hatch-line) 3px 4.4px); }

/* ---------- goal plates: the signature ---------- */
.plates-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s2); }
.plates-head h2 { font-size: 15px; font-weight: 800; }
.plates-head .sub { margin: 0; max-width: 60ch; }
.plates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.goal { font: inherit; text-align: left; color: inherit; cursor: pointer; padding: 0; background: var(--plate); border: 1px solid var(--keyline); border-radius: var(--r); overflow: hidden; margin: 0; transition: border-color .15s ease-out, transform .2s cubic-bezier(.2, .8, .2, 1); }
.goal:hover { border-color: var(--muted); transform: translateY(-1px); }
.goal[aria-pressed="true"] { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.goal svg { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; background: var(--sea); }
.goal figcaption, .goal .cap { display: block; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.goal .g { display: block; font-weight: 800; font-size: 14px; }
.goal .m { display: block; color: var(--muted); font-size: 12.5px; }
.goal .v { display: block; margin-top: 4px; font-size: 13px; font-variant-numeric: tabular-nums; }
.goal .v b.worst { color: var(--worse-ink); }
svg .d { stroke: var(--plate); stroke-width: .35; vector-effect: non-scaling-stroke; }
svg .sel-ring { fill: none; stroke: var(--halo); stroke-width: 4.5; vector-effect: non-scaling-stroke; }
svg .sel-line { fill: none; stroke: var(--teal); stroke-width: 2; vector-effect: non-scaling-stroke; }

/* ---------- the place account ---------- */
.account { background: var(--plate); border: 1px solid var(--keyline); border-radius: var(--r); padding: var(--s4); }
.account h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.account h3 { font-size: 13.5px; font-weight: 800; margin: var(--s5) 0 var(--s2); padding-top: var(--s3); border-top: 1px solid var(--line); }
.acc-head { display: flex; justify-content: space-between; align-items: start; gap: var(--s2); }
.code { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; font-style: italic; }
.place-line { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.measure { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--s3); margin: var(--s3) 0 0; padding: var(--s3) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.measure dt { font-size: 12.5px; color: var(--muted); font-weight: 600; padding-top: 2px; }
.measure dd { margin: 0; font-size: 14px; }
.measure dd.value { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.1; }
.measure dd.value small { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.badge.worse { background: var(--worse-bg); color: var(--worse-ink); }
.badge.better { background: var(--better-bg); color: var(--better-ink); }
.badge.flat { background: var(--flat-bg); color: var(--flat-ink); }
.caveat { margin: var(--s3) 0 0; padding: 10px 12px; background: var(--caveat-bg); color: var(--caveat-ink); border-radius: var(--r); font-size: 12.5px; }
.note { margin: var(--s2) 0 0; font-size: 12.5px; color: var(--muted); }
.chart-wrap { margin-top: var(--s3); }
.link-btn { font: inherit; font-size: 13px; font-weight: 700; color: var(--teal-ink); background: none; border: 0; padding: 4px 0; cursor: pointer; white-space: nowrap; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link-btn:hover { text-decoration-thickness: 2px; }
.compare { margin-top: var(--s3); display: flex; gap: var(--s2); align-items: end; }
.compare .field { flex: 1; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 700; font-size: 12px; color: var(--muted); }
td.n, th.n { text-align: right; white-space: nowrap; }
.pick { font: inherit; font-size: 13px; text-align: left; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-decoration-color: var(--keyline); text-underline-offset: 3px; }
.pick:hover { color: var(--teal-ink); text-decoration-color: currentColor; }
.bar { display: inline-block; height: 6px; background: var(--teal); border-radius: 2px; vertical-align: middle; margin-right: 6px; }
tr.small td { color: var(--muted); }
.roster { list-style: none; padding: 0; margin: 0; counter-reset: r; }
.roster li { counter-increment: r; display: grid; grid-template-columns: 28px 1fr; gap: 2px var(--s2); padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.roster li::before { content: counter(r); grid-row: span 2; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.roster .sub { font-size: 12px; }
.strip { display: grid; grid-template-columns: 1fr auto; gap: 10px var(--s3); margin: var(--s3) 0 var(--s1); align-items: center; }
.cells { display: inline-flex; gap: 2px; }
.cells i { width: 14px; height: 14px; border-radius: 2px; background: var(--plate-2); box-shadow: inset 0 0 0 1px var(--line); }
.goal-name { font-weight: 700; display: block; }
.goal-val { display: block; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---------- cross-cutting ---------- */
.finding { margin: 0 0 var(--s3); padding: var(--s2) 0 0; }
.finding h2 { font-size: clamp(22px, 2.1vw, 30px); line-height: 1.22; letter-spacing: -0.015em; max-width: 44ch; font-weight: 800; }
.lede { margin: var(--s2) 0 0; max-width: 72ch; color: var(--muted); font-size: 15.5px; }
.equation { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr) 28px) minmax(0, 1fr); align-items: stretch; gap: var(--s2); margin-bottom: var(--s3); }
.equation .op { align-self: center; text-align: center; font-size: 22px; font-weight: 800; color: var(--muted); }
.equation .goal { cursor: default; display: flex; flex-direction: column; margin: 0; }
.tab.active .equation > * { animation: settle .5s cubic-bezier(.2, .8, .2, 1) both; }
.tab.active .equation > :nth-child(3) { animation-delay: .08s; } .tab.active .equation > :nth-child(5) { animation-delay: .16s; }
.tab.active .equation > :nth-child(6), .tab.active .equation > :nth-child(7) { animation-delay: .32s; }
.equation .goal .cap { flex: 1; }
.equation .goal:hover { transform: none; }
.equation .goal svg { aspect-ratio: 1 / 1; }
.equation .result { border-color: var(--keyline); }
.method { font-size: 14px; background: var(--plate); border: 1px solid var(--keyline); border-radius: var(--r); padding: 12px var(--s3); }
.method summary { cursor: pointer; color: var(--teal-ink); font-weight: 700; }
.method ul { margin: var(--s2) 0 0; padding-left: 18px; max-width: 75ch; }
.method li { margin: 4px 0; }

/* ---------- about ---------- */
.about { background: var(--plate); border: 1px solid var(--keyline); border-radius: var(--r); padding: var(--s5); max-width: 880px; margin: 0 auto; line-height: 1.6; }
.about p, .about li { max-width: 72ch; }
.about h2 { font-size: 15px; margin: var(--s5) 0 var(--s2); }
.about h2:first-child { margin-top: 0; }
.signoff { margin-top: var(--s5); padding: var(--s4); background: var(--teal-wash); border-radius: var(--r); display: grid; grid-template-columns: auto 1fr; gap: var(--s2) var(--s4); align-items: center; }
.signoff img { height: 22px; width: auto; }
.signoff p { margin: 0; }

/* map chrome */
.maplibregl-popup-content { font-family: var(--font); font-size: 13px; padding: 8px 10px; border-radius: var(--r); background: var(--plate); color: var(--ink); box-shadow: var(--shadow); }
.maplibregl-popup-tip { border-top-color: var(--plate) !important; border-bottom-color: var(--plate) !important; }
.maplibregl-ctrl-group { background: var(--plate) !important; border: 1px solid var(--line); box-shadow: var(--shadow) !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
:root[data-theme="dark"] .maplibregl-ctrl-icon, :root[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .maplibregl-ctrl-icon, :root:not([data-theme="light"]) .maplibregl-ctrl-attrib-button { filter: invert(1); } }
.maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--plate) 85%, transparent) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted); }
.maplibregl-ctrl button:focus-visible { outline: 2px solid var(--teal); outline-offset: 0; box-shadow: none; }

@media (max-width: 1100px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .workspace { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  header.site { flex-wrap: wrap; gap: var(--s2) var(--s3); padding: 12px var(--s3) 0; }
  .titles::before { display: none; }
  .titles { padding-left: 0; flex: 1 1 100%; order: 3; }
  .theme { margin-left: auto; }
  nav { order: 4; flex: 1 1 100%; margin: 0 calc(var(--s3) * -1); padding: 0 var(--s2); overflow-x: auto; min-height: 44px; }
  nav button { padding: 0 12px; white-space: nowrap; }
  nav button::after { left: 12px; right: 12px; }
  main { padding: var(--s3); }
  .toolbar { grid-template-columns: 1fr; }
  .segmented { width: 100%; } .segmented button { flex: 1; }
  .mapwrap { height: 420px; }
  .plates { gap: var(--s2); }
  .goal .cap { padding: 8px; } .goal .m { display: none; }
  .equation { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
  .equation .op { display: none; }
  .equation .op.eq { display: block; grid-column: 1 / -1; font-size: 22px; }
  .equation .result { grid-column: 1 / -1; width: 66%; justify-self: center; }
  .equation .goal .cap { padding: 6px; } .equation .goal .g { font-size: 11.5px; }
  .account, .about { padding: var(--s3); }
  .signoff { grid-template-columns: 1fr; }
}

.toolbar.single { grid-template-columns: minmax(0, 360px); margin-bottom: 0; }
.nw { white-space: nowrap; }
.tables { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s3); align-items: start; margin-top: var(--s3); }
.plate.pad { padding: var(--s3) var(--s4) var(--s4); }
.plate.pad h3 { font-size: 14px; font-weight: 800; margin: 0 0 var(--s2); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px var(--s3); margin: var(--s3) 0 0; padding: 0; list-style: none; font-size: 12px; }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend svg { width: 22px; height: 8px; overflow: visible; }
@media (max-width: 1100px) { .tables { grid-template-columns: 1fr; } }
