/* Paras v3 — Premium Light-Themed Editorial Stylesheet
   Focus: Water Transit Lines, Narrative-first UI, Clean Data Typography
*/

:root {
  --bg-slate: #f8fafc;
  --bg-white: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  
  /* Status Colors (Premium Light Palette) */
  --color-normal: #10b981;    /* Emerald */
  --color-alert: #eab308;     /* Amber */
  --color-warning: #f97316;   /* Orange */
  --color-danger: #ef4444;    /* Crimson */
  --color-stale: #94a3b8;     /* Slate */
  --color-rain: #2563eb;      /* Blue */
  --color-teal: #0d9488;      /* Teal */
  
  --font-serif: 'Lora', Georgia, serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
  
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08);
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body, html {
  height: 100%;
  width: 100%;
  font-family: var(--font-sans);
  color: var(--text-main);
  background-color: var(--bg-slate);
  overflow: hidden;
}

/* Flex Split Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Left Pane: Narrative & Transit Maps */
.story-pane {
  width: 55%;
  height: 100%;
  flex-shrink: 0;
  background-color: var(--bg-white);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.02);
}

/* Right Pane: Map */
.map-pane {
  flex: 1;
  height: 100%;
  position: relative;
  background-color: #e5e9f0;
}

#map {
  width: 100%;
  height: 100%;
}

/* Header */
.site-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
}

.brand span {
  font-family: var(--font-sans);
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.text-btn:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* National Pulse Board */
.pulse-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 20px 24px;
  background-color: var(--bg-slate);
  border-bottom: 1px solid var(--border-color);
}

.pulse-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.pulse-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.pulse-card .count {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.pulse-card .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pulse-card.danger { border-top: 3px solid var(--color-danger); }
.pulse-card.danger .count { color: var(--color-danger); }
.pulse-card.warning { border-top: 3px solid var(--color-warning); }
.pulse-card.warning .count { color: var(--color-warning); }
.pulse-card.rain { border-top: 3px solid var(--color-rain); }
.pulse-card.rain .count { color: var(--color-rain); }
.pulse-card.reservoirs { border-top: 3px solid var(--color-teal); }
.pulse-card.reservoirs .count { color: var(--color-teal); }

/* State Filter Bar */
.state-filter-bar {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-white);
}

.state-select {
  width: 100%;
  background: var(--bg-slate) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5' /%3E%3C/svg%3E") no-repeat right 12px center;
  background-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 36px 10px 14px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  transition: var(--transition);
}

.state-select:hover {
  background-color: var(--border-light);
  border-color: #cbd5e1;
}

.state-select:focus {
  outline: none;
  border-color: var(--color-rain);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Warnings Strip */
.met-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 12px 24px 0;
  border: 1px solid #fef08a;
  border-left: 4px solid var(--color-alert);
  background-color: #fef9c3;
  color: #854d0e;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.met-strip:hover {
  background-color: #fef08a;
}

.met-strip svg {
  flex-shrink: 0;
}

.met-strip .met-n {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 800;
  background-color: #854d0e;
  color: #fff;
  padding: 1px 7px;
  border-radius: 20px;
}

/* Basin / Mode Tabs */
.basin-tabs {
  display: flex;
  gap: 4px;
  padding: 16px 24px 0;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none;
}

.basin-tabs::-webkit-scrollbar {
  display: none;
}

.basin-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.basin-tab:hover {
  color: var(--text-main);
}

.basin-tab.active {
  color: var(--color-rain);
  border-bottom-color: var(--color-rain);
  font-weight: 700;
}

.basin-tab.special {
  margin-left: auto;
  color: var(--color-teal);
}

.basin-tab.special.active {
  border-bottom-color: var(--color-teal);
}

/* River Transit Line Section */
.transit-section {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}

.transit-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}

.basin-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
}

.transit-caption {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.transit-scroll-wrapper {
  width: 100%;
  overflow-x: auto;
  padding: 10px 0;
  border-radius: var(--radius-md);
  background-color: var(--bg-slate);
  border: 1px solid var(--border-color);
  scrollbar-width: thin;
}

.transit-map-container {
  height: 320px;
  position: relative;
  display: block;
  width: max-content;
  min-width: 100%;
}

.transit-map-container.dams-mode {
  height: auto;
  min-height: 320px;
  width: 100%;
  display: block;
}

.tide-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--bg-slate);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  vertical-align: middle;
  margin-left: 12px;
  font-family: var(--font-sans);
  cursor: help;
  text-transform: none;
  letter-spacing: normal;
}

.tide-badge b {
  color: var(--text-main);
}

/* SVG River Transit Elements */
.transit-line {
  stroke-linecap: round;
  stroke-linejoin: round;
}

.transit-node {
  cursor: pointer;
  transition: r 0.2s, stroke-width 0.2s;
}

.transit-node:hover {
  r: 9;
  stroke-width: 3.5px;
}

.transit-node.active {
  r: 10;
  stroke-width: 4px;
  stroke: var(--text-main);
}

.transit-dam-node {
  cursor: pointer;
  transition: transform 0.2s;
  transform-origin: center;
}

.transit-dam-node:hover {
  stroke-width: 3px;
  stroke: var(--text-main);
}

.transit-label {
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  fill: var(--text-main);
  user-select: none;
}

.transit-label-meta {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 500;
  fill: var(--text-muted);
  user-select: none;
}

/* Active Station Spotlight & Catchment Ecosystem */
.spotlight-section {
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ecosystem-summary {
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.ecosystem-summary:hover {
  box-shadow: var(--shadow-md);
}

.ecosystem-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  text-transform: capitalize;
}

.ecosystem-p {
  font-family: var(--font-serif);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
}

.ecosystem-p b {
  color: var(--text-main);
}

.ecosystem-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.ecosystem-stat-item {
  background-color: var(--bg-slate);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ecosystem-stat-item span {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 2px;
  text-transform: none;
}

.spotlight-detail {
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.spotlight-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.spotlight-name {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
}

.spotlight-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.spotlight-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #ffffff;
}

.pill.normal { background-color: var(--color-normal); }
.pill.alert { background-color: var(--color-alert); color: #854d0e; }
.pill.warning { background-color: var(--color-warning); }
.pill.danger { background-color: var(--color-danger); }
.pill.stale { background-color: var(--color-stale); }

.reading {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
}

.trend-arrow {
  display: flex;
  align-items: center;
}

.trend-arrow.up { color: var(--color-danger); }
.trend-arrow.down { color: var(--color-normal); }

.spotlight-narrative {
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 24px;
  padding: 14px 16px;
  background-color: var(--bg-slate);
  border-left: 3px solid var(--border-color);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.spotlight-narrative b {
  color: var(--text-main);
}

/* Chart */
.chart-wrapper {
  width: 100%;
  height: 240px;
  position: relative;
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.spotlight-updated {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  text-transform: uppercase;
}

/* Footer */
.site-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  background-color: var(--bg-slate);
}

.refresh-stamp {
  font-weight: 600;
}

/* Map Controls */
.map-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  background-color: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
}

.layer-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.layer-toggles label {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.layer-toggles input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--color-rain);
  cursor: pointer;
}

.legend-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.legend-colors {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.legend-item {
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.dot.normal { background-color: var(--color-normal); }
.dot.alert { background-color: var(--color-alert); }
.dot.warning { background-color: var(--color-warning); }
.dot.danger { background-color: var(--color-danger); }

/* Locate Button */
.btn-locate {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 15;
  width: 44px;
  height: 44px;
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
}

.btn-locate:hover {
  background-color: var(--bg-slate);
  transform: scale(1.05);
}

.btn-locate svg {
  color: var(--text-main);
}

/* Maplibre popups styling (light theme override) */
.maplibregl-popup-content {
  background: rgba(255, 255, 255, 0.98) !important;
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 16px !important;
  color: var(--text-main);
  min-width: 260px;
}

.maplibregl-popup-close-button {
  font-size: 18px;
  padding: 6px 10px;
  color: var(--text-muted);
  transition: var(--transition);
}

.maplibregl-popup-close-button:hover {
  color: var(--text-main);
  background: transparent;
}

/* Map Popup Details Card */
.map-popup-card h3 {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 2px;
}

.map-popup-card .where {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.map-popup-card .statusline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.map-popup-card .reading {
  font-size: 18px;
  font-weight: 800;
}

.map-popup-card .meta {
  font-size: 9.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 6px;
  margin-top: 8px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background-color: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease-out;
}

.modal-card {
  position: relative;
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: scaleUp 0.15s ease-out;
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-card h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 12px;
}

.modal-card h3 {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-teal);
  margin: 18px 0 6px;
  letter-spacing: 0.5px;
}

.modal-card p, .modal-card li {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.modal-card a {
  color: var(--color-rain);
  text-decoration: none;
  font-weight: 600;
}

.modal-card a:hover {
  text-decoration: underline;
}

.warn-item {
  border-left: 3px solid var(--color-warning);
  padding: 8px 12px;
  margin: 10px 0;
  background-color: #fffbeb;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}

.warn-item .wt {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}

/* Custom Visual Beaker/Cylinder icons for Dams (V3 style) */
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.bar-label {
  font-size: 12px;
  font-weight: 600;
  width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-place {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-main);
}

.bar-place:hover {
  color: var(--color-rain);
  text-decoration: underline;
}

.bar-track {
  flex: 1;
  height: 6px;
  background-color: var(--bg-slate);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.bar-val {
  font-size: 12px;
  font-weight: 700;
  width: 45px;
  text-align: right;
}

/* Reservoir grid mode */
.dams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  padding: 16px;
}

.dam-card {
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dam-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.dam-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
}

.dam-card-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.dam-card-fill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.dam-card-fill-txt {
  font-size: 18px;
  font-weight: 800;
}

/* Screen Readers Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- Mobile Responsive ---------- */
@media (max-width: 992px) {
  .app-container {
    flex-direction: column-reverse;
  }
  .story-pane {
    width: 100%;
    height: 55%;
    border-right: none;
    border-top: 1px solid var(--border-color);
  }
  .map-pane {
    height: 45%;
  }
  .pulse-board {
    padding: 14px 16px;
    gap: 8px;
  }
  .pulse-card {
    padding: 8px 10px;
  }
  .pulse-card .count {
    font-size: 20px;
  }
  .pulse-card .label {
    font-size: 9px;
  }
  .met-strip {
    margin: 10px 16px 0;
  }
  .basin-tabs {
    padding: 10px 16px 0;
  }
  .transit-section {
    padding: 16px;
  }
  .spotlight-section {
    padding: 16px;
  }
  .chart-wrapper {
    height: 200px;
    padding: 10px;
  }
}
