/* kva.gg — The Survey. Phase 1: flat SVG survey.
   Identity tokens from projects/kva-gg/kit/brand-tokens.css (2026-11-01).
   Curve law: border-radius 0 everywhere; curves belong to terrain contours
   and question marks only. Ember marks motion; brass dresses destinations. */

:root {
  /* kit tokens */
  --kva-iron: #0C0D10;
  --kva-basalt: #15171C;
  --kva-grain: #262B33;
  --kva-ash: #A4A9B3;
  --kva-bone: #EAE7E0;
  --kva-ember: #FF5C38;
  --kva-brass: #A98F62;
  --kva-bone-ground: #EDEAE4;
  --kva-vellum: #F5F3EE;
  --kva-grain-light: #CFCAC1;
  --kva-slate: #4E535C;
  --kva-ember-banked: #AE3517;
  --kva-bronze: #6F5C3A;

  /* semantic, dark native */
  --bg: var(--kva-iron);
  --surface: var(--kva-basalt);
  --rule: var(--kva-grain);
  --text: var(--kva-bone);
  --text-2: var(--kva-ash);
  --kinetic: var(--kva-ember);
  --dress: var(--kva-brass);
  --contour-major: var(--kva-bone);
  --contour-minor: var(--kva-ash);
  --scrim: rgba(12, 13, 16, 0.72);

  --ease: cubic-bezier(.2, .8, .15, 1);
  --t-micro: 240ms;
  --t-stroke: 480ms;
  --t-seq: 960ms;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: var(--kva-bone-ground);
    --surface: var(--kva-vellum);
    --rule: var(--kva-grain-light);
    --text: var(--kva-iron);
    --text-2: var(--kva-slate);
    --kinetic: var(--kva-ember-banked);
    --dress: var(--kva-bronze);
    --contour-major: var(--kva-iron);
    --contour-minor: var(--kva-slate);
    --scrim: rgba(237, 234, 228, 0.78);
  }
}
:root[data-theme="light"] {
  --bg: var(--kva-bone-ground);
  --surface: var(--kva-vellum);
  --rule: var(--kva-grain-light);
  --text: var(--kva-iron);
  --text-2: var(--kva-slate);
  --kinetic: var(--kva-ember-banked);
  --dress: var(--kva-bronze);
  --contour-major: var(--kva-iron);
  --contour-minor: var(--kva-slate);
  --scrim: rgba(237, 234, 228, 0.78);
}

* { box-sizing: border-box; border-radius: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.6;
}

a { color: var(--text); text-underline-offset: 3px; }
a:hover { color: var(--text-2); }

:focus-visible {
  outline: 2px solid var(--kinetic);
  outline-offset: 2px;
}

/* ---------- chrome ---------- */

.chrome {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}

.chrome-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.chrome-name {
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.chrome-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chrome-link,
.chrome-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-2);
  background: none;
  border: 1px solid var(--rule);
  padding: 8px 12px;
  line-height: 1;
  cursor: pointer;
}

.chrome-link:hover,
.chrome-btn:hover { color: var(--text); border-color: var(--text-2); }

.chrome-btn .q { font-size: 13px; }

@media (max-width: 719px) {
  .chrome-name { display: none; }
  .chrome { padding: 0 12px; }
  .chrome-nav { gap: 6px; }
  .chrome-link, .chrome-btn { padding: 8px 9px; }
}

/* ---------- map stage ---------- */

.map-stage {
  position: relative;
  display: none;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}

.map-stage.is-live {
  display: block;
  height: calc(100vh - 56px);
  height: calc(100dvh - 56px);
}

.map-stage svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
.map-stage svg.is-panning { cursor: grabbing; }

.map-stage text {
  user-select: none;
  -webkit-user-select: none;
}

.contour-major { stroke: var(--contour-major); }
.contour-minor { stroke: var(--contour-minor); }

/* cartographic halo so labels stay legible over contour lines */
.m-label, .m-desc, .m-glyph, .position-glyph {
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
  stroke-linejoin: miter;
}
.region-label, .grid-coord {
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 2px;
}

.m-label {
  font-family: var(--font-mono);
  font-weight: 500;
  fill: var(--text);
}

.m-desc {
  font-family: var(--font-mono);
  font-weight: 400;
  fill: var(--text-2);
}

.m-glyph {
  font-family: var(--font-mono);
  font-weight: 500;
  fill: var(--text);
}

.marker.is-visited .m-glyph { fill: var(--dress); }

.marker { cursor: pointer; }
.marker:hover .m-label { fill: var(--kinetic); }

@keyframes survey-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
.marker:not(.is-visited) .m-glyph {
  animation: survey-pulse 2400ms var(--ease) infinite;
}

.region-label {
  font-family: var(--font-mono);
  font-weight: 400;
  letter-spacing: 0.5em;
  fill: var(--text-2);
  opacity: 0.38;
}

.grid-line { stroke: var(--rule); stroke-width: 1; opacity: 0.5; }
.grid-coord {
  font-family: var(--font-mono);
  fill: var(--text-2);
  opacity: 0.55;
}

.trail-path {
  stroke: var(--text);
  stroke-width: 1.5;
  fill: none;
  stroke-dasharray: 7 6;
  opacity: 0.6;
}

.travel-path {
  stroke: var(--kinetic);
  stroke-width: 2;
  fill: none;
  stroke-dasharray: 7 6;
}

.position-glyph {
  font-family: var(--font-mono);
  font-weight: 500;
  fill: var(--text);
}

/* map HUD: zoom + hint */
.hud {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}
.hud button {
  width: 40px;
  height: 40px;
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--rule);
  cursor: pointer;
}
.hud button:hover { border-color: var(--text-2); }

.map-hint {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 5;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 6px 10px;
  opacity: 0.9;
}

/* ---------- content panel ---------- */

.panel[hidden], .search[hidden] { display: none; }

/* The field note: a small annotation pinned at the reached site.
   The full record (the panel) opens from its Full entry action. */
.bubble {
  position: fixed;
  z-index: 28;
  width: min(300px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 12px 16px 14px;
  animation: bubble-surface 240ms cubic-bezier(0.2, 0.8, 0.15, 1);
}
.bubble[hidden] { display: none; }
@keyframes bubble-surface {
  from { opacity: 0; translate: 0 6px; }
  to   { opacity: 1; translate: 0 0; }
}
.bubble-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 6px;
}
.bubble-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-2);
}
.bubble-close {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
  padding: 3px 7px;
  background: none;
  border: 1px solid var(--rule);
  color: var(--text);
  cursor: pointer;
}
.bubble-name {
  margin: 0 0 2px;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 600;
}
.bubble-desc {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
}
.bubble-excerpt {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.55;
}
.bubble-excerpt[hidden] { display: none; }
.bubble-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
}
.bubble-actions:empty { display: none; }
.bubble-actions a,
.bubble-more {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.panel {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(440px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
}

.panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--rule);
}

.panel-bearing {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-2);
}

.panel-close {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  background: none;
  border: 1px solid var(--rule);
  padding: 8px 12px;
  cursor: pointer;
}
.panel-close:hover { border-color: var(--text-2); }

.panel-body {
  padding: 20px;
  overflow-y: auto;
}

.panel-body .entry-kicker { margin-top: 0; }
.panel-body h2 { margin: 4px 0 8px; font-size: 24px; }

@media (max-width: 720px) {
  .panel {
    top: auto;
    left: 0;
    width: 100%;
    height: min(62vh, 520px);
    border-left: none;
    border-top: 1px solid var(--rule);
  }
}

/* ---------- search ---------- */

.search {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--scrim);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 96px 16px 16px;
}

.search-box {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 16px;
}

.search-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 8px;
}
.search-glyph { color: var(--text); margin-right: 8px; }

.search-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 10px 12px;
}
.search-input:focus-visible { outline-offset: 0; }

.search-results {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}

.search-results li { border-top: 1px solid var(--rule); }

.search-hit {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: left;
  color: var(--text);
  background: none;
  border: none;
  padding: 10px 4px;
  cursor: pointer;
  text-decoration: none;
}
.search-hit:hover { background: var(--bg); }
.search-hit .hit-bearing { color: var(--text-2); white-space: nowrap; }
.search-empty {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  padding: 10px 4px;
}

/* ---------- index + entries (the document under the map) ---------- */

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 16px 64px;
}

.index-title {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 4px;
}

.index-sub {
  color: var(--text-2);
  margin: 0 0 24px;
}

.index-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.index-list li {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--rule);
}

.index-list a {
  font-weight: 500;
  text-decoration: none;
}
.index-list a:hover { text-decoration: underline; }

.idx-desc {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
}

.index-list-essays { margin-top: 32px; }
.index-list-essays li a { font-weight: 400; }

.entries { margin-top: 64px; }

.entry {
  border-top: 1px solid var(--rule);
  padding: 32px 0;
}

.entry-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 0 0 8px;
}

.entry h2 { margin: 0 0 4px; font-size: 28px; }

.entry-desc {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  margin: 0 0 16px;
}

.entry-essays {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}
.entry-essays li {
  padding: 8px 0;
  border-top: 1px solid var(--rule);
}

/* ---------- footer ---------- */

.footer {
  border-top: 1px solid var(--rule);
  padding: 32px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-2);
}

.footer-nav { display: flex; gap: 24px; }
.footer-nav a {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  text-decoration: none;
}
.footer-nav a:hover { color: var(--text); }

.footer-line {
  font-family: var(--font-mono);
  font-size: 11px;
  margin: 0;
  opacity: 0.7;
}

/* ---------- motion discipline ---------- */

@media (prefers-reduced-motion: reduce) {
  .marker:not(.is-visited) .m-glyph { animation: none; }
  * { transition: none !important; animation: none !important; }
}
/* the ?static test override mirrors the reduced-motion rules exactly */
:root.static { scroll-behavior: auto; }
:root.static .marker:not(.is-visited) .m-glyph { animation: none; }
:root.static * { transition: none !important; animation: none !important; }

/* Far zoom (whole-territory views): glyph and name only. The desc line
   returns on descent, and the field note carries it at arrival. */
.lod-far .m-desc { display: none; }
