/* =========================================================
   Louisiana Megaproject Real Estate Impact Dashboard — CSS
   ========================================================= */

/* ---------- Design tokens ---------- */
:root, [data-theme='light'] {
  /* Surfaces */
  --color-bg: #F5F6F7;
  --color-surface: #FFFFFF;
  --color-surface-2: #FBFCFD;
  --color-surface-offset: #EEF1F3;
  --color-surface-offset-2: #E6EAED;
  --color-border: #DCE1E5;
  --color-divider: #E4E8EB;

  /* Text */
  --color-text: #131A22;
  --color-text-muted: #5B6673;
  --color-text-faint: #93A0AB;
  --color-text-inverse: #F5F6F7;

  /* Primary (deep navy) */
  --color-primary: #12324F;
  --color-primary-hover: #0C2438;
  --color-primary-active: #081826;
  --color-primary-highlight: #D6E0E8;

  /* Accent (amber / Louisiana gold) */
  --color-accent: #C2761B;
  --color-accent-hover: #A15F10;
  --color-accent-active: #7C4A0C;
  --color-accent-highlight: #F3DFC0;

  --color-success: #2E7D4F;
  --color-success-highlight: #D7EADC;
  --color-error: #A13F3F;
  --color-error-highlight: #EAD6D6;
  --color-warning: #C2761B;
  --color-warning-highlight: #F3DFC0;

  /* Region colors */
  --region-nw: #2C7A7B;
  --region-ne: #2E8B57;
  --region-sw: #C2761B;
  --region-capital: #5B4B8A;
  --region-se: #A13F3F;
  --region-other: #6B7280;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(19,26,34,0.06);
  --shadow-md: 0 4px 14px rgba(19,26,34,0.08);
  --shadow-lg: 0 14px 32px rgba(19,26,34,0.14);

  --transition-interactive: 160ms cubic-bezier(0.16, 1, 0.3, 1);

  --font-display: 'Cabinet Grotesk', 'General Sans', 'Segoe UI', sans-serif;
  --font-body: 'Satoshi', 'Inter', 'Segoe UI', sans-serif;

  --text-xs: clamp(0.72rem, 0.68rem + 0.2vw, 0.8rem);
  --text-sm: clamp(0.82rem, 0.78rem + 0.25vw, 0.9rem);
  --text-base: clamp(0.92rem, 0.88rem + 0.25vw, 1rem);
  --text-lg: clamp(1.05rem, 0.95rem + 0.5vw, 1.3rem);
  --text-xl: clamp(1.35rem, 1.1rem + 1vw, 1.9rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem;
  --space-12: 3rem; --space-16: 4rem;
}

[data-theme='dark'] {
  --color-bg: #0E1318;
  --color-surface: #151B22;
  --color-surface-2: #191F27;
  --color-surface-offset: #1B222A;
  --color-surface-offset-2: #222932;
  --color-border: #2B333C;
  --color-divider: #232B33;

  --color-text: #E4E8EB;
  --color-text-muted: #9AA6B2;
  --color-text-faint: #5E6A76;
  --color-text-inverse: #131A22;

  --color-primary: #6FA0BE;
  --color-primary-hover: #8FB7CF;
  --color-primary-active: #A9C8DC;
  --color-primary-highlight: #24333D;

  --color-accent: #E29A44;
  --color-accent-hover: #EDB06B;
  --color-accent-active: #F4C48C;
  --color-accent-highlight: #3B2E1C;

  --color-success: #6FBF8B;
  --color-success-highlight: #1E3327;
  --color-error: #D08787;
  --color-error-highlight: #3A2626;
  --color-warning: #E29A44;
  --color-warning-highlight: #3B2E1C;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.35);
  --shadow-lg: 0 14px 32px rgba(0,0,0,0.45);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; scroll-behavior: smooth; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-body), sans-serif;
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}
h1, h2, h3, h4 { font-family: var(--font-display), sans-serif; text-wrap: balance; line-height: 1.2; color: var(--color-text); }
p, li { text-wrap: pretty; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.tabular { font-variant-numeric: tabular-nums lining-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  grid-template-rows: 64px 1fr;
  height: 100dvh;
}
.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand svg { width: 30px; height: 30px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-family: var(--font-display); font-weight: 700; font-size: var(--text-sm); letter-spacing: 0.01em; }
.brand-sub { font-size: var(--text-xs); color: var(--color-text-muted); }
.topbar-right { display: flex; align-items: center; gap: var(--space-4); }
.updated-tag { font-size: var(--text-xs); color: var(--color-text-muted); }
.theme-toggle {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full); color: var(--color-text-muted);
  transition: background var(--transition-interactive), color var(--transition-interactive);
}
.theme-toggle:hover { background: var(--color-surface-offset); color: var(--color-text); }

.sidebar {
  grid-row: 2; grid-column: 1;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto; overscroll-behavior: contain;
  padding: var(--space-4) var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-1);
}
.nav-group-label { font-size: var(--text-xs); color: var(--color-text-faint); text-transform: uppercase; letter-spacing: 0.06em; padding: var(--space-4) var(--space-3) var(--space-2); }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 500; color: var(--color-text-muted);
  text-align: left; width: 100%;
  transition: background var(--transition-interactive), color var(--transition-interactive);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--color-surface-offset); color: var(--color-text); }
.nav-item.active { background: var(--color-primary-highlight); color: var(--color-primary); font-weight: 600; }
[data-theme='dark'] .nav-item.active { color: var(--color-text); background: var(--color-surface-offset-2); }

.main {
  grid-row: 2; grid-column: 2;
  overflow-y: auto; overscroll-behavior: contain;
  padding: var(--space-8) var(--space-10) var(--space-16);
}
.view { display: none; animation: fadein 220ms ease; }
.view.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.view-header { margin-bottom: var(--space-6); }
.view-title { font-size: var(--text-xl); font-weight: 700; margin-bottom: var(--space-1); }
.view-desc { color: var(--color-text-muted); font-size: var(--text-sm); max-width: 68ch; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-8); }
.kpi-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); }
.kpi-label { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: var(--space-2); }
.kpi-value { font-size: var(--text-xl); font-weight: 700; font-family: var(--font-display); }
.kpi-delta { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); font-weight: 600; margin-top: var(--space-2); }
.kpi-delta.up { color: var(--color-success); }
.kpi-delta.down { color: var(--color-error); }
.kpi-delta.flat { color: var(--color-text-faint); }
.kpi-note { font-size: var(--text-xs); color: var(--color-text-faint); margin-top: var(--space-2); }

/* ---------- Panels / cards ---------- */
.panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow-sm); margin-bottom: var(--space-6); }
.panel-title { font-size: var(--text-lg); font-weight: 700; margin-bottom: var(--space-1); }
.panel-sub { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-4); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.grid-2-even { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; }
@media (max-width: 980px) { .grid-2, .grid-2-even { grid-template-columns: 1fr; } }
.chart-wrap { position: relative; width: 100%; }
.chart-wrap.h-260 { height: 260px; }
.chart-wrap.h-300 { height: 300px; }
.chart-wrap.h-340 { height: 340px; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-6); padding: var(--space-3); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.filter-label { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-right: var(--space-1); }
.pill-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.pill {
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted);
  background: var(--color-surface-offset); border: 1px solid transparent;
  transition: background var(--transition-interactive), color var(--transition-interactive), border-color var(--transition-interactive);
}
.pill:hover { background: var(--color-surface-offset-2); color: var(--color-text); }
.pill.active { background: var(--color-primary); color: #fff; }
.pill .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: var(--space-2); vertical-align: middle; }
.select-input {
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--color-border);
  background: var(--color-surface); font-size: var(--text-sm); color: var(--color-text);
}
.search-input { padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--color-border); background: var(--color-surface); font-size: var(--text-sm); min-width: 200px; color: var(--color-text); }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
table.data-table { min-width: 720px; }
.data-table thead { position: sticky; top: 0; background: var(--color-surface-offset); z-index: 1; }
.data-table th { text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-muted); padding: var(--space-3) var(--space-4); font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none; }
.data-table th:hover { color: var(--color-text); }
.data-table td { padding: var(--space-3) var(--space-4); font-size: var(--text-sm); border-top: 1px solid var(--color-divider); vertical-align: top; }
.data-table tbody tr { transition: background var(--transition-interactive); }
.data-table tbody tr:hover { background: var(--color-surface-offset); }
.region-tag { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); font-weight: 600; padding: 2px var(--space-2); border-radius: var(--radius-full); white-space: nowrap; }
.region-tag .dot { width: 7px; height: 7px; border-radius: 50%; }

/* ---------- Badges / status ---------- */
.badge { display: inline-block; font-size: var(--text-xs); font-weight: 600; padding: 2px var(--space-2); border-radius: var(--radius-sm); background: var(--color-surface-offset); color: var(--color-text-muted); }
.badge.status-construction { background: var(--color-success-highlight); color: var(--color-success); }
.badge.status-announced { background: var(--color-warning-highlight); color: var(--color-warning); }
.badge.status-fid { background: var(--color-primary-highlight); color: var(--color-primary); }

/* ---------- Map ---------- */
.map-wrap { position: relative; }
#la-map { width: 100%; height: 560px; }
#la-map svg { width: 100%; height: 100%; }
.parish-shape { stroke: var(--color-surface); stroke-width: 0.6; transition: opacity var(--transition-interactive); cursor: pointer; }
.parish-shape.dim { opacity: 0.35; }
.project-dot { stroke: var(--color-surface); stroke-width: 1.4; cursor: pointer; transition: r var(--transition-interactive), opacity var(--transition-interactive); }
.project-dot.dim { opacity: 0.25; }
.spinoff-dot { stroke: var(--color-surface); stroke-width: 1.2; cursor: pointer; fill-opacity: 0.95; }
.spinoff-dot.dim { opacity: 0.2; }
.distance-ring { fill: none; stroke-width: 1.1; stroke-dasharray: 4 3; opacity: 0.75; pointer-events: none; }
.distance-ring.ring-10 { stroke-dasharray: none; stroke-width: 1.4; }
.distance-ring.ring-50 { opacity: 0.5; }
.distance-ring.dim, .ring-label.dim { opacity: 0.08; }
.ring-label { font-size: 10px; fill: var(--color-text-muted); pointer-events: none; }
.map-legend-item .dot.diamond { border-radius: 1px; transform: rotate(45deg); width: 8px; height: 8px; background: var(--color-text-muted); }
.ring-swatch { width: 14px; height: 14px; border-radius: 50%; border: 1.5px dashed var(--color-text-muted); display: inline-block; }
.toggle-input { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--color-text-muted); margin-left: var(--space-4); cursor: pointer; white-space: nowrap; }
.toggle-input input { accent-color: var(--color-primary); width: 16px; height: 16px; }
.chart-empty { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--color-text-faint); font-size: var(--text-sm); text-align: center; }
#spinoff-table { min-width: 1080px; }
#commercial-market-table { min-width: 860px; }
#commercial-market-table td.tabular, #spinoff-table td.tabular { white-space: nowrap; }
.grid-2-even + .panel, .panel + .grid-2-even { margin-top: 0; }
.map-tooltip {
  position: absolute; pointer-events: none; background: var(--color-primary-active, #081826);
  color: #fff; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  font-size: var(--text-xs); max-width: 240px; box-shadow: var(--shadow-lg); z-index: 30;
  opacity: 0; transition: opacity 120ms ease; line-height: 1.4;
}
.map-tooltip.show { opacity: 1; }
.map-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-top: var(--space-4); font-size: var(--text-xs); color: var(--color-text-muted); }
.map-legend-item { display: flex; align-items: center; gap: var(--space-2); }
.map-legend-item .dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- Timeline (infrastructure Gantt-ish) ---------- */
.timeline-row { display: grid; grid-template-columns: 1fr auto; gap: var(--space-4); align-items: center; padding: var(--space-3) 0; border-top: 1px solid var(--color-divider); }
.timeline-row:first-child { border-top: none; }
.timeline-name { font-size: var(--text-sm); font-weight: 600; }
.timeline-meta { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 2px; }
.timeline-amount { font-size: var(--text-base); font-weight: 700; font-family: var(--font-display); text-align: right; white-space: nowrap; }

/* ---------- Synthesis callout ---------- */
.callout { background: var(--color-surface-offset); border-radius: var(--radius-lg); padding: var(--space-5); font-size: var(--text-sm); color: var(--color-text); }
.callout strong { color: var(--color-primary); }
[data-theme='dark'] .callout strong { color: var(--color-text); }

/* ---------- Sources ---------- */
.source-list { display: grid; gap: var(--space-2); }
.source-item { font-size: var(--text-sm); padding: var(--space-2) 0; border-top: 1px solid var(--color-divider); display: flex; justify-content: space-between; gap: var(--space-4); }
.source-item:first-child { border-top: none; }
.source-name { color: var(--color-text); }
.source-link { color: var(--color-accent); font-size: var(--text-xs); white-space: nowrap; }

/* ---------- Footer note ---------- */
.footnote { font-size: var(--text-xs); color: var(--color-text-faint); margin-top: var(--space-3); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .topbar { grid-column: 1; padding: var(--space-3) var(--space-4); flex-wrap: wrap; gap: var(--space-2); row-gap: var(--space-1); }
  .brand-sub, .updated-tag { display: none; }
  .sidebar { grid-row: 2; grid-column: 1; flex-direction: row; overflow-x: auto; overflow-y: hidden; white-space: nowrap; padding: var(--space-2); }
  .nav-group-label { display: none; }
  .nav-item { flex-shrink: 0; }
  .main { grid-row: 3; grid-column: 1; padding: var(--space-5); }
  .grid-2, .grid-2-even { grid-template-columns: 1fr; }
}
