/* Styles for docs/index.html (the full-screen-map page). */

:root {
  --lichen:   #DDE1DA;
  --chalk:    #F1F3EE;
  --ink:      #171E1B;
  --weir:     #3D6152;
  --oxide:    #BC431C;
  --amber:    #E0912F;
  --silt:     #7E8B82;
  --hairline: #C3C9BF;

  /* 90-day strip */
  --day-dry:    #93C0A9;
  --day-nodata: #C7CBBF;

  /* map */
  --pin-dry:  #2FB84C;
  --water:    #A9D0E6;
  --water-line: #2F80B4;

  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, sans-serif;
  --data: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--lichen);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- The map fills the viewport --- */

#overflow-map {
  position: fixed;
  inset: 0;
  background: var(--lichen);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

#overflow-map.is-panning { cursor: grabbing; }

#overflow-map.is-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: 17px;
  color: var(--silt);
  padding: 24px;
  text-align: center;
}

#overflow-map svg { display: block; width: 100%; height: 100%; }

/* Basemap layers. Non-scaling strokes so line weights hold as you zoom. */
.bm path { fill: none; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.bm--water  path { fill: var(--water); stroke: var(--water-line); stroke-width: 0.6; }
.bm--stream path { stroke: #6FAAD0; stroke-width: 1.3; }
.bm--river  path { stroke: var(--water-line); stroke-width: 2.8; }
.bm--minor  path { stroke: #D0D3CB; stroke-width: 1; }
.bm--mid    path { stroke: #C1C4BB; stroke-width: 1.6; }
.bm--major  path { stroke: #ADB1A6; stroke-width: 2.6; }

.map-bg { fill: var(--chalk); }
.map-frame { fill: none; stroke: var(--hairline); stroke-width: 1; vector-effect: non-scaling-stroke; }

.label-layer { position: absolute; inset: 0; pointer-events: none; }

.map-label {
  position: absolute;
  display: none;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  text-shadow: 0 0 3px var(--chalk), 0 0 3px var(--chalk), 0 0 7px var(--chalk);
}

.map-label.is-shown { display: block; }

.map-label--town,
.map-label--village,
.map-label--suburb,
.map-label--hamlet { font-family: var(--display); color: var(--ink); }

.map-label--town    { font-weight: 800; font-size: 14px; letter-spacing: 0.01em; }
.map-label--village { font-weight: 700; font-size: 11.5px; }
.map-label--suburb  { font-weight: 600; font-size: 10.5px; color: #3B443F; }
.map-label--hamlet  { font-weight: 400; font-size: 10px; color: var(--silt); }
.map-label--road    { font-family: var(--data); font-size: 10px; letter-spacing: 0.02em; color: #58685F; }

.pin-layer { position: absolute; inset: 0; pointer-events: none; }

.mappin {
  position: absolute;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 2px solid var(--chalk);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(23, 30, 27, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
}

.pin-layer .mappin { display: none; }
.pin-layer .mappin.is-shown { display: block; }
.mappin:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.mappin--discharging { background: var(--oxide); }
.mappin--recent      { background: var(--amber); }
.mappin--dry         { background: var(--pin-dry); }
.mappin--offline     { background: var(--silt); }

.mappin.is-edge { border-radius: 2px; width: 12px; height: 12px; box-shadow: none; opacity: 0.9; }

@media (prefers-reduced-motion: no-preference) {
  .mappin--discharging.is-shown:not(.is-edge) { animation: pinpulse 2.1s ease-in-out infinite; }
  @keyframes pinpulse { 50% { box-shadow: 0 0 0 7px rgba(188, 67, 28, 0.16); } }
}

.map-ctrl {
  position: absolute;
  left: 16px;
  bottom: 46px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 4px rgba(23, 30, 27, 0.25);
}

.map-ctrl button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--hairline);
  background: var(--chalk);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.map-ctrl button:first-child { border-bottom: 0; }
.map-ctrl button:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; z-index: 1; }

.map-attr {
  position: absolute;
  left: 16px;
  bottom: 18px;
  padding: 1px 6px;
  background: rgba(241, 243, 238, 0.85);
  font-size: 10px;
  color: var(--silt);
}
.map-attr a { color: inherit; }

.map-popup {
  position: absolute;
  z-index: 18;
  width: min(230px, calc(100vw - 24px));
  padding: 12px 14px;
  background: var(--chalk);
  border: 1px solid var(--ink);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: auto;
  /* left / top are set in px by placePopup() so it stays on screen near edges */
}

.map-popup h3 { margin: 0 0 4px; font-family: var(--display); font-weight: 700; font-size: 15px; }
.map-popup p { margin: 0 0 6px; }
.map-popup a { color: var(--weir); }
.map-popup .pop-state { font-family: var(--data); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.map-popup .pop-state.is-discharging { color: var(--oxide); }
.map-popup .pop-state.is-recent      { color: #A9631A; }
.map-popup .pop-state.is-dry         { color: var(--weir); }
.map-popup .pop-state.is-offline     { color: var(--silt); }

.map-popup .pop-close {
  position: absolute;
  top: 4px;
  right: 6px;
  border: 0;
  background: none;
  font-size: 15px;
  line-height: 1;
  color: var(--silt);
  cursor: pointer;
}

/* --- Floating furniture over the map --- */

.titlecard {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 15;
  max-width: min(270px, calc(100vw - 96px));
  padding: 11px 14px;
  background: rgba(241, 243, 238, 0.92);
  border: 1px solid var(--hairline);
}

.tc-eyebrow {
  margin: 0 0 3px;
  font-family: var(--data);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--silt);
}

.tc-verdict {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-stretch: 88%;
  font-size: 16px;
  line-height: 1.25;
}

.tc-verdict.is-clear { color: var(--weir); }

.legend {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px 15px;
  margin: 0;
  padding: 7px 13px;
  list-style: none;
  max-width: calc(100vw - 140px);
  background: rgba(241, 243, 238, 0.92);
  border: 1px solid var(--hairline);
  font-size: 12px;
}

.legend li { display: flex; align-items: center; gap: 7px; }

.legend .mappin {
  position: static;
  width: 13px;
  height: 13px;
  flex: none;
  transform: none;
  box-shadow: 0 0 0 1px rgba(23, 30, 27, 0.25);
}

.fab {
  position: fixed;
  z-index: 20;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--weir);
  color: var(--chalk);
  box-shadow: 0 2px 12px rgba(23, 30, 27, 0.32);
  cursor: pointer;
  transition: opacity 0.2s, background 0.15s;
}

.fab:hover { background: var(--ink); }
.fab:focus-visible { outline: 2px solid var(--weir); outline-offset: 2px; }
.fab svg { width: 22px; height: 22px; }
.fab--clock { top: 16px; right: 16px; }
.fab--info  { bottom: 16px; right: 16px; }

body.panel-open .fab { opacity: 0; pointer-events: none; }

/* --- Slide-in panels --- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(23, 30, 27, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.scrim.is-open { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: 500px;
  max-width: 100%;
  height: 100%;
  background: var(--lichen);
  border-left: 1px solid var(--hairline);
  box-shadow: -8px 0 30px rgba(23, 30, 27, 0.18);
  transform: translateX(100%);
  transition: transform 0.28s ease;
}

.panel.is-open { transform: none; }

.panel-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 2px solid var(--ink);
}

.panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-stretch: 90%;
  font-size: 18px;
}

.panel-close {
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--silt);
  cursor: pointer;
}

.panel-close:focus-visible { outline: 2px solid var(--weir); outline-offset: 2px; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px 40px;
}

.stamp { font-family: var(--data); font-size: 11px; color: var(--silt); margin: 0 0 4px; }
.standfirst { margin: 8px 0 20px; color: #414A45; font-size: 14px; }

.prose p { margin: 0 0 12px; }
.prose h3 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  margin: 22px 0 6px;
}
.prose h3:first-child { margin-top: 0; }
.prose a { color: var(--weir); }

/* --- Overflow list (the timeline panel) --- */

.overflows { display: flex; flex-direction: column; gap: 10px; }

.o-card {
  padding: 14px 16px 15px;
  background: var(--chalk);
  border-left: 3px solid var(--hairline);
}

.o-card.is-discharging { border-left-color: var(--oxide); }
.o-card.is-dry         { border-left-color: var(--weir); }
.o-card.is-offline     { border-left-color: var(--silt); }

.o-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  flex-wrap: wrap;
}

.o-head h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-stretch: 88%;
  font-size: 16px;
}

.o-state {
  font-family: var(--data);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.o-card.is-discharging .o-state { color: var(--oxide); font-weight: 500; }
.o-card.is-dry .o-state         { color: var(--weir); }
.o-card.is-offline .o-state     { color: var(--silt); }

.o-meta { margin: 3px 0 0; font-size: 12.5px; color: var(--silt); }

.o-strip {
  display: flex;
  gap: 1px;
  width: 100%;
  max-width: 450px;
  height: 32px;
  margin: 11px 0 0;
}

.o-day { flex: 1 1 0; min-width: 0; border-radius: 1px; background: var(--day-dry); }
.o-day--nodata { background: var(--day-nodata); }
.o-day--recent { background: var(--amber); }
.o-day--spill  { background: var(--oxide); }

.o-scale {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 450px;
  margin: 5px 0 0;
  font-family: var(--data);
  font-size: 10px;
  color: var(--silt);
}

.o-geo { margin: 10px 0 0; font-family: var(--data); font-size: 11.5px; }
.o-geo a { color: var(--weir); text-decoration: none; white-space: nowrap; }
.o-geo a:hover { text-decoration: underline; }
.o-geo .pin { vertical-align: -1.5px; margin-right: 4px; }

.empty { padding: 24px; background: var(--chalk); font-family: var(--display); font-size: 17px; }

@media (max-width: 560px) {
  .panel { width: 100%; border-left: 0; }
  .map-ctrl { display: none; }
  .legend { max-width: calc(100vw - 32px); bottom: 74px; }
  .map-attr { bottom: 14px; }
}
