/* Hallmark · app-shell · genre: modern-minimal · theme: custom (water-data, light)
 * tone: technical/scientific · accent hue: cool blue-teal
 * pre-emit critique: P5 H5 E5 S4 R5 V4
 * DFR data ramp is domain-locked in app.js CLASS_COLORS — not themed here.
 * contrast: pass
 */
@import "tokens.css";

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: clip; }
body {
  font-family: var(--font-sans);
  color: var(--c-ink);
  background: var(--c-paper-2);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Shell: full-bleed map + floating card ---- */
#app { position: relative; width: 100%; height: 100vh; height: 100dvh; }
#map-wrap { position: absolute; inset: 0; }
#map, #map2 { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
#map2 { display: none; }

/* Globe mode: real-star backdrop sits behind the (transparent-space) globe.
   The map canvas is transparent outside the sphere, so #space shows through;
   the opaque Earth correctly hides the stars behind it. */
#space { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; display: none; }
body.globe-on { background: #070b16; }
body.globe-on #map-wrap { background: #070b16; }
body.globe-on #space { display: block; }

#panel {
  position: absolute; top: var(--space-4); left: var(--space-4); z-index: 10;
  width: 336px; max-width: calc(100vw - var(--space-6));
  max-height: calc(100dvh - var(--space-8));
  overflow-y: auto; overscroll-behavior: contain;
  padding: var(--space-5) var(--space-5) var(--space-4);
  background: var(--c-glass);
  -webkit-backdrop-filter: blur(var(--blur-card)) saturate(1.35);
  backdrop-filter: blur(var(--blur-card)) saturate(1.35);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
#panel::-webkit-scrollbar { width: 9px; }
#panel::-webkit-scrollbar-thumb { background: var(--c-line-2); border-radius: var(--radius-pill);
  border: 3px solid transparent; background-clip: content-box; }

/* ---- Header / wordmark ---- */
/* Grid: wordmark + toggle share row 1 (vertically centered); subtitle spans row 2. */
#panel header { display: grid; grid-template-columns: 1fr auto; align-items: center;
  column-gap: var(--space-3); padding-bottom: var(--space-4); border-bottom: 1px solid var(--c-line); }
#panel h1 {
  grid-column: 1; grid-row: 1; margin: 0;
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--text-2xl); letter-spacing: -0.02em; line-height: 1;
  color: var(--c-asu-maroon); display: flex; align-items: center; gap: 0.34em;
  overflow-wrap: anywhere; min-width: 0;
}
#panel h1 .ver { font-family: var(--font-mono); font-weight: 700; font-size: 0.46em;
  line-height: 1; letter-spacing: 0; color: var(--c-asu-gold);
  background: var(--c-asu-maroon); padding: 0.28em 0.42em; border-radius: 5px; }
#panel .sub { grid-column: 1 / -1; grid-row: 2; margin: var(--space-2) 0 0;
  font-size: var(--text-sm); color: var(--c-ink-3); line-height: 1.42; }

/* ---- Collapse toggle ---- */
#panel-toggle { grid-column: 2; grid-row: 1;
  width: 28px; height: 28px; display: grid; place-items: center;
  font-family: var(--font-sans); font-size: 15px; line-height: 1; color: var(--c-ink-2);
  background: var(--c-paper-2); border: 1px solid var(--c-line); border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out); }
#panel-toggle:hover { background: var(--c-accent-soft); color: var(--c-accent-strong); }
#panel-toggle:active { transform: translateY(1px); }
#panel-toggle:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }

/* Collapsed: card shrinks to a compact wordmark + expand button row */
#panel.is-collapsed { width: auto; max-width: max-content; padding: var(--space-3) var(--space-4);
  overflow: visible; }
#panel.is-collapsed > :not(header) { display: none; }
#panel.is-collapsed header { display: flex; align-items: center; gap: var(--space-3);
  padding: 0; border-bottom: none; }
#panel.is-collapsed .sub { display: none; }
#panel.is-collapsed h1 { order: 1; }
#panel.is-collapsed #panel-toggle { order: 2; }

/* ---- Control groups ---- */
.ctrl { margin-top: var(--space-5); }
.ctrl-label { display: block; margin: 0 0 var(--space-3);
  font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.085em; color: var(--c-ink-3); }

/* segmented control */
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px;
  padding: 3px; background: var(--c-paper-2); border: 1px solid var(--c-line);
  border-radius: var(--radius-md); }
#proj-seg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg button { font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 500;
  padding: 7px 0; border: 0; background: transparent; color: var(--c-ink-2);
  border-radius: calc(var(--radius-md) - 4px); cursor: pointer;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out); }
.seg button:hover { background: var(--c-white-50); color: var(--c-ink); }
.seg button.active { background: var(--c-accent-strong); color: #fff;
  box-shadow: 0 1px 2px rgba(106, 21, 48, 0.5); }
.seg button.active:hover { background: var(--c-accent-strong); }
.seg button:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }

/* month slider + play */
#month-label { font-family: var(--font-mono); font-weight: 700; color: var(--c-ink);
  letter-spacing: -0.01em; }
#month-slider { width: 100%; height: 22px; margin: 0; accent-color: var(--c-accent);
  cursor: pointer; }
#month-slider:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 3px;
  border-radius: var(--radius-sm); }
.play { margin-top: var(--space-3); display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 500;
  color: var(--c-accent-strong); background: var(--c-accent-soft);
  border: 1px solid transparent; border-radius: var(--radius-pill);
  padding: 6px 14px; cursor: pointer;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out); }
.play:hover { background: var(--c-accent); color: #fff; }
.play:active { transform: translateY(1px); }
.play:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }

/* compare selects */
.cmp-row { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.cmp-row span { width: 38px; flex: 0 0 auto; font-size: var(--text-sm); color: var(--c-ink-3); }
.cmp-row select { flex: 1; min-width: 0; font-family: var(--font-sans); font-size: var(--text-sm);
  color: var(--c-ink); padding: 7px 30px 7px 11px; appearance: none; cursor: pointer;
  background-color: var(--c-paper); border: 1px solid var(--c-line-2); border-radius: var(--radius-sm);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" fill="none" stroke="%23667085" stroke-width="1.7"><path d="M1 1.7 6 6.5 11 1.7"/></svg>');
  background-repeat: no-repeat; background-position: right 11px center;
  transition: border-color var(--dur) var(--ease-out); }
.cmp-row select:hover { border-color: var(--c-ink-3); }
.cmp-row select:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 1px;
  border-color: var(--c-accent); }

/* layer toggles */
.chk { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-1) 0;
  font-size: var(--text-base); color: var(--c-ink); cursor: pointer; }
.chk input { flex: 0 0 auto; width: 16px; height: 16px; accent-color: var(--c-accent); cursor: pointer; }
.chk input:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; border-radius: 3px; }

/* ---- Legend ---- */
.legend-note { margin: 0 0 var(--space-3); font-size: var(--text-xs); color: var(--c-ink-3);
  line-height: 1.45; }
.legend { list-style: none; margin: 0; padding: 0; }
.legend li { display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center; gap: var(--space-2); margin-bottom: var(--space-1);
  font-family: var(--font-mono); font-size: var(--text-sm); color: var(--c-ink-2); }
.legend li.head { font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-ink-3);
  margin-bottom: var(--space-2); }
.legend .sw { width: 24px; height: 11px; border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.09); }
.legend li.unaff { display: flex; align-items: center; gap: var(--space-2);
  margin-top: var(--space-3); font-family: var(--font-sans); font-size: var(--text-sm);
  color: var(--c-ink-2); }
.legend .dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto;
  margin-left: 6px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }

/* ---- Downloads ---- */
.dl-note { margin: 0 0 var(--space-3); font-size: var(--text-xs);
  color: var(--c-ink-3); line-height: 1.45; }
.dl-list { list-style: none; margin: 0; padding: 0; }
.dl-list li { display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding: var(--space-2) 0; }
.dl-list li + li { border-top: 1px solid var(--c-line); }
.dl-title { display: flex; flex-direction: column; min-width: 0;
  font-size: var(--text-sm); color: var(--c-ink); }
.dl-title small { margin-top: 2px; font-family: var(--font-mono); font-size: 10px;
  color: var(--c-ink-3); letter-spacing: 0.02em; text-transform: uppercase; }
.dl-links { display: inline-flex; gap: 6px; flex: 0 0 auto; }
.dl-links a { font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 600;
  letter-spacing: 0.02em; color: var(--c-accent-strong); background: var(--c-accent-soft);
  padding: 4px 10px; border-radius: var(--radius-pill);
  text-decoration: none; border: 1px solid transparent;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out); }
.dl-links a:hover { background: var(--c-accent); color: #fff; }
.dl-links a:active { transform: translateY(1px); }
.dl-links a:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }

/* footer note */
#panel footer p { margin: var(--space-4) 0 0; padding-top: var(--space-3);
  border-top: 1px solid var(--c-line); font-size: var(--text-xs); color: var(--c-ink-3);
  line-height: 1.45; }

/* ---- Loading pill ---- */
#loading { position: absolute; top: var(--space-4); left: 50%; transform: translateX(-50%);
  z-index: 20; display: flex; align-items: center; gap: var(--space-2);
  padding: 7px 15px; background: var(--c-glass);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--c-line); border-radius: var(--radius-pill);
  box-shadow: var(--shadow-pop); font-family: var(--font-mono); font-size: var(--text-sm);
  color: var(--c-ink-2); letter-spacing: -0.01em; }
/* the JS hides the pill via the hidden attribute; without this rule the
   `display: flex` above outranks the UA's [hidden]{display:none} and the
   pill never disappears */
#loading[hidden] { display: none; }
#loading::before { content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-accent); animation: pulse 1.1s var(--ease-in-out) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.6); } }

/* ---- Swipe-compare divider ---- */
.compare-divider { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px;
  background: rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 1px rgba(25, 25, 25, 0.22);
  z-index: 3; cursor: ew-resize; }
.compare-divider::after { content: "\2194"; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); width: 32px; height: 32px; line-height: 32px;
  text-align: center; font-family: var(--font-sans); font-size: 15px;
  color: var(--c-accent-strong); background: rgba(255, 255, 255, 0.95);
  border-radius: 50%; box-shadow: var(--shadow-pop); }

/* ---- MapLibre chrome (themed to match) ---- */
.maplibregl-ctrl-group { border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-pop) !important; border: 1px solid var(--c-line) !important;
  overflow: hidden; background: var(--c-paper) !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--c-line) !important; }
.maplibregl-ctrl-scale { background: var(--c-glass); border: 1px solid var(--c-line);
  border-top: none; color: var(--c-ink-2); font-family: var(--font-mono);
  font-size: 10px; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.maplibregl-ctrl-attrib { font-family: var(--font-sans); font-size: 10px;
  border-radius: var(--radius-sm) 0 0 0 !important; }
.maplibregl-ctrl-attrib a { color: var(--c-ink-3); }

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  #loading::before { animation: none; }
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* ---- Mobile ---- */
@media (max-width: 640px) {
  #panel { top: var(--space-2); left: var(--space-2); right: var(--space-2);
    width: auto; max-width: none; max-height: 54dvh; padding: var(--space-4); }
  #panel h1 { font-size: var(--text-xl); }
}

/* Official Unity header is fixed; reserve its measured height above the map. */
:root { --asu-header-h: 122px; }
html, body { height: auto; overflow-x: clip; }
#asu-header { height: var(--asu-header-h); background: #fff; }
#app { height: max(360px, calc(100dvh - var(--asu-header-h))); }
#panel { max-height: calc(100% - var(--space-8)); }
#skip-to-content { position: absolute; top: 0; scroll-margin-top: var(--asu-header-h); }
.asu-skip {
  position: fixed; left: -9999px; top: 0; z-index: 1100;
  background: #8c1d40; color: #fff; padding: 12px 16px;
}
.asu-skip:focus { left: 0; }
@media (max-width: 991px) { :root { --asu-header-h: 96px; } }
@media (max-width: 640px) {
  #panel { max-height: min(54dvh, calc(100% - var(--space-4))); }
}
.maplibregl-map,
.maplibregl-ctrl,
.maplibregl-ctrl-attrib,
.maplibregl-popup-content { font-family: var(--font-asu) !important; }

/* Demo fallback for the Unity privacy control until ASU consent is configured. */
#privacy-settings { width: min(32rem, calc(100% - 2rem)); padding: 2rem; border: 0;
  background: #fff; color: #191919; font: 1rem/1.5 Arial, sans-serif; }
#privacy-settings::backdrop { background: rgb(0 0 0 / 55%); }
#privacy-settings h2 { margin-top: 0; font-size: 1.5rem; }
#privacy-settings a { color: #8c1d40; text-decoration: underline; }
#privacy-settings button { border: 0; border-radius: 2rem; padding: 1rem 2rem;
  background: #ffc627; color: #191919; font: bold 1rem Arial, sans-serif; cursor: pointer; }
#privacy-settings :focus-visible { outline: 2px solid #191919; outline-offset: 4px; }
