/* Staten Island Data Viewer — chrome.
   Tokens are the ones written down in docs/VISUAL_IDENTITY.md. If you change a
   value here, change it there too; that doc is the contract. */

:root {
  /* chrome — cool gunmetal */
  --chrome-900: #0d1520;
  --chrome-800: #16212f;
  --chrome-700: #223143;
  --chrome-600: #33475e;
  --chrome-500: #4a637f;
  --chrome-100: #c6d4e4;
  --chrome-000: #eef4fb;

  --accent-amber: #f0a830;
  --accent-amber-hi: #ffd177;
  --accent-cyan: #4fd0e0;
  --accent-red: #e2564a;
  --accent-green: #63c46a;

  /* world */
  --world-water: #1c4f6e;
  --world-land: #3f4a35;
  --world-park: #4a6b38;

  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --panel-radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--chrome-900);
  font-family: var(--sans);
  color: var(--chrome-100);
  -webkit-font-smoothing: antialiased;
}

#map { position: absolute; inset: 0; }

/* Vignette: a CSS-only post-process pass (PLAN.md §2.1), no images. */
#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(ellipse at 50% 45%,
    rgba(0,0,0,0) 52%, rgba(0,0,0,0.12) 80%, rgba(0,0,0,0.30) 100%);
}

/* ------------------------------------------------------------------ panels */

.panel {
  background: linear-gradient(180deg, var(--chrome-700), var(--chrome-800));
  border: 1px solid var(--chrome-900);
  border-radius: var(--panel-radius);
  box-shadow:
    inset 0 1px 0 var(--chrome-600),
    inset 0 -1px 0 var(--chrome-900),
    0 6px 18px rgba(0,0,0,0.45);
}

.panel-title {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--chrome-500);
  padding: 7px 10px 5px;
  border-bottom: 1px solid var(--chrome-900);
  box-shadow: inset 0 -1px 0 var(--chrome-600);
}

/* --------------------------------------------------------- top readout bar */

#hud-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  align-items: stretch;
  gap: 10px;
  pointer-events: none;
}
#hud-top > * { pointer-events: auto; }

#brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}
#brand .mark {
  width: 22px; height: 22px;
  border-radius: 2px;
  border: 1px solid var(--chrome-900);
  background: linear-gradient(150deg, var(--accent-amber), #b9761b);
  box-shadow: inset 0 1px 0 var(--accent-amber-hi);
  flex: none;
}
#brand h1 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--chrome-000);
  font-weight: 600;
  white-space: nowrap;
}
#brand .sub {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chrome-500);
  white-space: nowrap;
}

#readouts {
  display: flex;
  gap: 1px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.readout {
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.readout .label {
  font-size: 9.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--chrome-500);
  white-space: nowrap;
}
.readout .value {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--accent-amber);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  white-space: nowrap;
}
.readout .value.small { font-size: 12px; }

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

#camera-tools {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.btn {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chrome-100);
  background: linear-gradient(180deg, var(--chrome-700), var(--chrome-800));
  border: 1px solid var(--chrome-900);
  border-radius: var(--panel-radius);
  box-shadow:
    inset 0 1px 0 var(--chrome-600),
    inset 0 -1px 0 var(--chrome-900),
    0 3px 10px rgba(0,0,0,0.4);
  padding: 7px 11px;
  cursor: pointer;
  transition: box-shadow 90ms ease-out, color 90ms ease-out;
  user-select: none;
}
.btn:hover {
  color: var(--chrome-000);
  box-shadow:
    inset 0 0 0 1px var(--accent-cyan),
    inset 0 1px 0 var(--chrome-600),
    0 3px 10px rgba(0,0,0,0.4);
}
.btn:active { box-shadow: inset 0 2px 6px rgba(0,0,0,0.5); }
.btn.is-active {
  color: var(--accent-amber-hi);
  box-shadow:
    inset 0 0 0 1px var(--accent-amber),
    inset 0 1px 0 var(--chrome-600),
    0 0 12px rgba(240,168,48,0.25);
}

#compass {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  cursor: grab;
}
#compass svg { display: block; }

/* ------------------------------------------------------ view switcher + legend */

#hud-left {
  position: absolute;
  left: 12px;
  top: 68px;
  z-index: 10;
  width: 214px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 200px);
  min-height: 0;
}

#view-switcher {
  display: flex;
  flex-direction: column;
  padding: 4px;
  gap: 2px;
  flex: none;
}

.view-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 7px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  text-align: left;
  font-family: var(--sans);
  transition: background 120ms ease-out, box-shadow 90ms ease-out;
}
.view-tab .vl {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--chrome-100);
}
.view-tab .vh {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--chrome-500);
}
.view-tab:hover { background: rgba(79, 208, 224, 0.07); box-shadow: inset 0 0 0 1px var(--accent-cyan); }
.view-tab.is-active {
  background: linear-gradient(180deg, rgba(240,168,48,0.16), rgba(240,168,48,0.05));
  box-shadow: inset 0 0 0 1px var(--accent-amber);
}
.view-tab.is-active .vl { color: var(--accent-amber-hi); }
.view-tab.is-loading .vh::after { content: " …"; }

/* min-height:0 is what actually lets a flex child shrink and scroll — without
   it the legend grows past the viewport and its last swatches are unreachable. */
#legend { overflow-y: auto; min-height: 0; flex: 0 1 auto; }
.lg-body { padding: 8px 10px 10px; }
.lg-blurb {
  margin: 0 0 9px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--chrome-500);
}
.lg-row { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; }
.lg-sw {
  width: 12px; height: 12px;
  border-radius: 2px;
  border: 1px solid var(--chrome-900);
  flex: none;
}
.lg-lb { font-size: 10.5px; color: var(--chrome-100); }
.lg-note {
  margin: 9px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--chrome-900);
  box-shadow: inset 0 1px 0 var(--chrome-600);
  font-size: 10px;
  line-height: 1.5;
  color: var(--chrome-500);
}
.lg-types { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 9px; }
.lg-type {
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--chrome-100);
  background: var(--chrome-800);
  border: 1px solid var(--chrome-900);
  border-radius: 2px;
  padding: 4px 6px;
  cursor: pointer;
}
.lg-type:hover { box-shadow: inset 0 0 0 1px var(--accent-cyan); }
.lg-type.is-active {
  color: var(--accent-amber-hi);
  box-shadow: inset 0 0 0 1px var(--accent-amber);
}

/* ------------------------------------------------------------------ popups */

.sc-popup .maplibregl-popup-content {
  background: linear-gradient(180deg, var(--chrome-700), var(--chrome-800));
  border: 1px solid var(--chrome-900);
  border-radius: var(--panel-radius);
  box-shadow:
    inset 0 1px 0 var(--chrome-600),
    0 8px 22px rgba(0,0,0,0.5);
  padding: 0;
  color: var(--chrome-100);
}
.sc-popup .maplibregl-popup-tip { border-top-color: var(--chrome-800); border-bottom-color: var(--chrome-700); }
.sc-popup .maplibregl-popup-close-button {
  color: var(--chrome-500);
  font-size: 16px;
  padding: 2px 7px;
  background: transparent;
  border: 0;
}
.sc-popup .maplibregl-popup-close-button:hover { color: var(--accent-amber); background: transparent; }
.pc { padding: 9px 11px 10px; min-width: 190px; }
.pt {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-amber);
  margin-bottom: 7px;
  padding-right: 16px;
}
.pr { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.pk { font-size: 10.5px; color: var(--chrome-500); }
.pv { font-family: var(--mono); font-size: 11px; color: var(--chrome-000); text-align: right; }
.pn {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--chrome-900);
  box-shadow: inset 0 1px 0 var(--chrome-600);
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--chrome-500);
}

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

#data-footer {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 10;
  max-width: 46ch;
  padding: 7px 11px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--chrome-500);
}
#data-footer strong { color: var(--chrome-100); font-weight: 500; }
#data-footer a { color: var(--accent-cyan); text-decoration: none; }
#data-footer a:hover { text-decoration: underline; }

/* ------------------------------------------------------------- city chip */

#city-chip {
  position: absolute;
  right: 12px;
  top: 68px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--chrome-100);
  transition: opacity 700ms ease-out;
}
#city-chip.fade { opacity: 0; }
#city-chip .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
  animation: pulse 1.1s ease-in-out infinite;
}
#city-chip .dot.ok { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); animation: none; }
#city-chip .dot.bad { background: var(--accent-red); box-shadow: 0 0 8px var(--accent-red); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.35 } }

/* --------------------------------------------------------------- loading */

#boot {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: var(--chrome-900);
  transition: opacity 400ms ease-out;
}
#boot.done { opacity: 0; pointer-events: none; }
#boot .inner { text-align: center; }
#boot .title {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--chrome-100);
  margin-bottom: 14px;
}
#boot .bar {
  width: 220px; height: 4px;
  background: var(--chrome-800);
  border: 1px solid var(--chrome-900);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto;
}
#boot .bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-amber), var(--accent-amber-hi));
  transition: width 200ms ease-out;
}
#boot .step {
  margin-top: 10px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--chrome-500);
}

/* hide MapLibre's own chrome — this project brings its own */
.maplibregl-ctrl-attrib, .maplibregl-ctrl-logo { display: none !important; }

@media (max-width: 860px) {
  #brand .sub { display: none; }
  .readout { padding: 6px 10px; }
  #data-footer { max-width: 30ch; left: auto; right: 12px; bottom: 64px; }
  #hud-left { width: 168px; max-height: calc(100vh - 150px); }
  .view-tab .vh { display: none; }
}
