/* Paradise Valley from space — Grizzly Systems dark operator UI.
   Five colors, tone not hue for state, no shadows, no emoji, 4 px spacing scale. */
:root {
  --ink: #121212;          /* the ground */
  --ink-2: #1b1b1b;        /* raised surface */
  --ink-3: #262626;        /* control */
  --line: #333333;
  --text: #e8e6e3;
  --text-dim: #9a9793;
  --gold: #d99e30;
  --gold-dim: rgba(217, 158, 48, 0.32);
  --r: 3px;
  --pad: 12px;
  font-synthesis-weight: none;
}

@font-face { font-family: 'Inter Tight'; src: local('Inter Tight'), local('Inter'); font-display: swap; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--ink); }
body {
  font-family: 'Inter Tight', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#map, #map-after { position: absolute; inset: 0; }
/* The compare map stays in the layout always and is hidden by CLIPPING, never display:none —
   a WebGL map in a display:none container never finishes loading its style, so hiding it that
   way deadlocks the page against its own "wait until both maps are ready". */
#map-after { pointer-events: none; clip-path: inset(0 0 0 100%); }

/* ---- the compare divider ---- */
#swipe { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
#swipe-line {
  position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px;
  background: var(--gold); left: 50%;
}
#swipe-grip {
  position: absolute; top: 50%; left: 50%;
  width: 34px; height: 34px; margin: -17px 0 0 -17px; padding: 0;
  border: 1px solid var(--gold); border-radius: 50%;
  background: var(--ink); color: var(--gold);
  display: flex; align-items: center; justify-content: center; gap: 3px;
  cursor: ew-resize; pointer-events: auto;
}
#swipe-grip span { display: block; width: 2px; height: 12px; background: currentColor; }
#swipe-grip:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.frame-label {
  /* The credit runs down the centre and the labels sit in the corners, all three sharing one
     baseline: this `bottom` matches #credit-block's, so their bottom edges line up exactly. */
  position: absolute; bottom: 10px; z-index: 4;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(18, 18, 18, 0.86); color: var(--text);
  font-size: 12px; letter-spacing: 0.02em; white-space: nowrap;
  pointer-events: none;
}
.frame-label b { color: var(--gold); font-weight: 600; }
.frame-label { left: 16px; }
.frame-label.is-right { left: auto; right: 16px; }

/* ---- the control panel ---- */
#panel {
  position: absolute; top: 16px; left: 16px; z-index: 6;
  width: 296px; max-width: calc(100vw - 32px);
  background: rgba(20, 20, 20, 0.93);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: var(--r);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 32px);
}
#panel header {
  display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap;
  padding: var(--pad); border-bottom: 1px solid var(--line);
}
/* The three icon buttons travel together. With the header wrapping, each was free to wrap on its
   own, so a narrow panel broke them onto a second line one at a time. Grouped, they either all
   fit beside the title or all move together -- and they always fit, because the title shrinks. */
.hdr-actions { display: flex; gap: 8px; flex: 0 0 auto; align-items: flex-start; }
/* The subtitle takes a row of its own BELOW the icon buttons. Nested beside the title it had to
   share the width with three buttons and wrapped into a narrow three-line column. */
#subtitle {
  flex: 1 0 100%; order: 10; margin: 3px 0 0;
  font-size: 11px; color: var(--text-dim); line-height: 1.4;
}
/* flex-basis 0, not auto: with  the brand claims the full width of its content before the
   buttons get a say, so in a 280px panel the three icons wrapped to a row of their own. At 0 the
   title yields first and wraps within itself, which is what should give. */
.brand { display: flex; gap: 10px; align-items: flex-start; flex: 1 1 0; min-width: 0; }
.brand h1 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.01em;
             overflow-wrap: break-word; }
.brand p { margin: 2px 0 0; font-size: 11px; color: var(--text-dim); line-height: 1.35; }
#panel-toggle, #fullscreen, #method-btn {
  flex: 0 0 auto; width: 24px; height: 24px; padding: 0; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: var(--r);
  color: var(--text-dim); display: flex; align-items: center; justify-content: center;
}
#panel-toggle:hover, #fullscreen:hover, #method-btn:hover { color: var(--text); border-color: var(--line); }
#panel-toggle:focus-visible, #fullscreen:focus-visible, #method-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
/* one icon, two states: the arrows point out to enter and in to leave */
#fullscreen .fs-out { display: none; }
body.is-fullscreen #fullscreen .fs-in { display: none; }
body.is-fullscreen #fullscreen .fs-out { display: block; }
#fullscreen[hidden] { display: none; }
body.is-collapsed #panel-body, body.is-collapsed #panel footer { display: none; }
body.is-collapsed #panel-toggle svg { transform: rotate(-90deg); }

#panel-body { padding: var(--pad); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
/* The footer carries only TRANSIENT news -- buffering, playing, an error -- so it exists only
   while there IS news. It used to restate the two dropdowns ("1972 against 2014 - drag the
   divider"), which is the one thing on this page the reader can already see, and it charged a
   permanent rule across the panel for saying it. Nothing to say now means gone, rule and all. */
#panel footer {
  padding: 8px var(--pad); border-top: 1px solid var(--line);
  font-size: 11px; color: var(--text-dim); min-height: 30px; display: flex; align-items: center;
}
#panel footer.is-quiet { display: none; }

.row { display: flex; flex-direction: column; gap: 6px; }
.row.two { flex-direction: row; align-items: center; gap: 10px; }
.row.two label { flex: 0 0 52px; font-size: 12px; color: var(--text-dim); }
.row.two select { flex: 1 1 auto; min-width: 0; }
.row-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.hint { margin: 0; font-size: 11px; color: var(--text-dim); line-height: 1.4; }
.hint.spaced { margin-top: 10px; }   /* breathing room under the Before/After pair */

/* Zoom-to-a-town. They are <button>s, not <a>s -- nothing navigates, the camera moves -- but
   they read as links, because that is what a place name in a line of text looks like. The dot
   between them is its own inert <span> rather than a ::before on the button: a ::before would
   sit INSIDE the button's hit area, so clicking the punctuation between two towns would silently
   pick the one on the right. */
#places { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 0; min-width: 0; }
#places .place {
  appearance: none; background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--gold);
  border-bottom: 1px solid transparent; line-height: 1.3;
}
#places .place:hover, #places .place:focus-visible { border-bottom-color: currentColor; }
#places .place:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
#places .sep { color: var(--text-dim); font-size: 12px; margin: 0 7px; user-select: none; }

.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg-btn {
  flex: 1 1 0; padding: 7px 8px; cursor: pointer;
  background: var(--ink-2); color: var(--text-dim);
  border: 0; border-right: 1px solid var(--line);
  font: inherit; font-size: 12px; letter-spacing: 0.01em;
}
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { color: var(--text); }
.seg-btn.is-on { background: var(--gold-dim); color: var(--text); }
.seg-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

select, input[type="range"] { font: inherit; }
select {
  appearance: none; -webkit-appearance: none;
  padding: 6px 26px 6px 8px; font-size: 12px;
  background: var(--ink-3) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%239a9793' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 6px center / 14px;
  color: var(--text); border: 1px solid var(--line); border-radius: var(--r);
}
select:focus-visible { outline: 2px solid var(--gold); outline-offset: -1px; }

.slider-wrap { flex: 1 1 auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.slider-wrap output { flex: 0 0 auto; font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
input[type="range"] {
  flex: 1 1 auto; min-width: 0; height: 18px; appearance: none; -webkit-appearance: none; background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--line); }
input[type="range"]::-moz-range-track { height: 2px; background: var(--line); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px;
  border-radius: 50%; background: var(--gold); border: 0; cursor: pointer;
}
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--gold); border: 0; cursor: pointer; }
input[type="range"]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.scrub-row { flex-direction: row; align-items: center; gap: 8px; }
.scrub-year { font-size: 12px; color: var(--gold); font-variant-numeric: tabular-nums; flex: 0 0 auto; min-width: 34px; text-align: right; }

.row.buttons { flex-direction: row; gap: 8px; }
.btn {
  flex: 1 1 0; padding: 7px 10px; cursor: pointer;
  background: var(--ink-3); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r);
  font: inherit; font-size: 12px;
}
.btn:hover { border-color: #444; }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: -1px; }
.btn-primary { background: var(--gold-dim); border-color: var(--gold); }
.btn[disabled] { opacity: 0.5; cursor: default; }

#toast {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 8;
  max-width: min(460px, calc(100vw - 32px));
  padding: 9px 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(20, 20, 20, 0.95); color: var(--text); font-size: 12px; line-height: 1.4;
}
#toast.is-bad { border-color: var(--gold); }

/* The mark and the credit share one centre line along the bottom of the map. */
#credit-block {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; z-index: 4;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
/* the block ignores the pointer so it never steals a drag from the map; the link takes it back */
#credit-link { pointer-events: auto; display: block; border-radius: var(--r); line-height: 0; }
#credit-link:hover #credit-mark { opacity: 1; }
#credit-link:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
#credit-mark { display: block; height: 30px; width: auto; opacity: 0.85; transition: opacity 120ms; }
#credit {
  margin: 0; padding: 3px 10px;
  font-size: 10px; letter-spacing: 0.03em; color: var(--text-dim);
  background: rgba(18, 18, 18, 0.7); border-radius: var(--r);
  white-space: nowrap;
}

/* MapLibre chrome, restyled to match. Zoom and scale stack in the bottom right DIRECTLY ABOVE
   the "after" label: the label is 16px from the bottom and about 27px tall, so the stack starts
   clear of it. The credit runs down the centre. One owner per place, nothing overlapping. */
.maplibregl-ctrl-bottom-right { right: 16px; bottom: 51px; }
.maplibregl-ctrl-bottom-right .maplibregl-ctrl { margin: 0 0 8px 0; }
.maplibregl-ctrl-bottom-right .maplibregl-ctrl:last-child { margin-bottom: 0; }
.maplibregl-ctrl-bottom-left { bottom: 6px; }

.maplibregl-ctrl-group { background: rgba(20,20,20,0.93) !important; border: 1px solid var(--line) !important; border-radius: var(--r) !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
.maplibregl-ctrl-group button { background: transparent !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(88%); }
.maplibregl-ctrl-attrib { background: rgba(20,20,20,0.8) !important; color: var(--text-dim) !important; font-size: 10px !important; }
.maplibregl-ctrl-attrib a { color: var(--text-dim) !important; }
.maplibregl-ctrl-scale { background: rgba(20,20,20,0.8) !important; border-color: var(--line) !important; color: var(--text-dim) !important; font-size: 10px !important; }

@media (max-width: 640px) {
  #panel { top: 8px; left: 8px; right: 8px; width: auto; }
  .frame-label { font-size: 11px; bottom: 6px; }   /* same baseline as #credit-block below */
  #credit { font-size: 9px; }
  #credit-block { bottom: 6px; gap: 4px; }
  #credit-mark { height: 22px; }
  .maplibregl-ctrl-bottom-right { bottom: 67px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }


/* ---- How-this-was-made dialog -------------------------------------------------------------
   Opened from the ? beside the full-screen control. Sized for reading rather than for the panel:
   a method description that needs scrolling in a 280px column will not be read. */
#method {
  border: 1px solid var(--line); border-radius: var(--r); padding: 0; max-width: 620px;
  width: min(92vw, 620px); max-height: 86vh; color: var(--text);
  /* 25% see-through, with a blur behind it. Transparency ALONE would put body text over moving
     satellite imagery and destroy legibility; the backdrop blur flattens whatever is underneath
     into a soft wash, so the map still reads as present without competing with the words. */
  background: color-mix(in srgb, var(--ink-2) 75%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(115%);
  backdrop-filter: blur(14px) saturate(115%);
  /* overflow:hidden on the DIALOG so only the article scrolls. Both had a height cap, so both
     grew a scrollbar and the reader got two side by side -- an outer one that moved nothing and
     an inner one that did. The dialog is the frame; the article is the content. */
  overflow: hidden;
}
#method::backdrop { background: rgba(0, 0, 0, 0.42); }   /* lighter, so the map shows */
#method article { padding: 22px 26px 20px; overflow-y: auto; max-height: 86vh; }
#method h2 { margin: 0 0 14px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
#method h3 {
  margin: 18px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--gold);
}
#method p, #method li { margin: 0 0 9px; font-size: 13px; line-height: 1.6; color: var(--text-dim); }
#method b { color: var(--text); font-weight: 600; }
#method ul { margin: 0 0 9px; padding-left: 18px; }
#method .fine { margin-top: 16px; font-size: 11px; opacity: 0.75; }
/* The close affordance is an X in the corner, not a button in the flow: a long method note ends
   far below the fold, and a footer button there is a control you have to go looking for. The X
   stays put while the prose scrolls under it. */
#method article { position: relative; }
#method .dialog-x {
  position: absolute; top: 14px; right: 16px; width: 26px; height: 26px; padding: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: var(--r);
  color: var(--text-dim);
}
#method .dialog-x:hover { color: var(--text); border-color: var(--line); }
#method .dialog-x:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
#method h2 { padding-right: 34px; }   /* never let the title run under the X */


/* Year-by-year instrument table in the method note. Generated from the frames actually loaded,
   never hand-written: a hand-typed era table drifts the moment a year is dropped. */
#era-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 4px 0 2px; }
#era-table th {
  text-align: left; font-weight: 600; color: var(--text-dim); font-size: 10.5px;
  letter-spacing: 0.07em; text-transform: uppercase; padding: 0 0 5px; border-bottom: 1px solid var(--line);
}
#era-table td { padding: 5px 0; border-bottom: 1px solid var(--line); color: var(--text-dim); }
#era-table tr:last-child td { border-bottom: 0; }
#era-table td:first-child { color: var(--text); font-weight: 600; white-space: nowrap; width: 8.5em; }
#era-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Buffer-then-play progress. Determinate on purpose: the reader is told how long is left,
   not merely that something is happening. Same goldenrod as the primary action, thin enough
   not to compete with the controls above it. */
#buffer { margin: 2px 0 6px; }
.bufbar { height: 4px; background: #262626; border-radius: 2px; overflow: hidden; }
.bufbar > i { display: block; height: 100%; width: 0; background: var(--gold, #d99e30);
              transition: width .18s linear; }
#buffer-text { margin-top: 5px; font-variant-numeric: tabular-nums; }
