:root {
  --bg: #0f1418;
  --panel-glass: rgba(16, 22, 28, 0.52);
  --border-glass: rgba(255, 255, 255, 0.12);
  --text-main: #f5f7fa;
  --text-muted: #a6b0bc;
  --accent: #f5a623;

  --risk-very-high: #d7342a;
  --risk-high: #f36a2d;
  --risk-moderate: #f3b43c;
  --risk-emerging: #55b06f;
  --risk-lower: #4f9ad9;

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-pill: 999px;
}

/* Global layout */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #222a31 0%, #0b1014 40%, #050708 100%);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
}

#app {
  height: 100vh;
  width: 100vw;
  display: flex;
  padding: 10px;
  gap: 10px;
}

/* Map + dashboard responsive split */

#map-panel,
#dashboard {
  position: relative;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.35));
  border: 1px solid var(--border-glass);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  overflow: hidden;
}

/* Mobile first: stacked layout */

#app {
  flex-direction: column;
}

#map-panel {
  flex: 0.55;
  min-height: 0;
  padding: 8px 8px 32px;
}

#dashboard {
  flex: 0.45;
  min-height: 0;
  padding: 10px;
}

/* Larger screens: side-by-side */

@media (min-width: 768px) {
  #app {
    flex-direction: row;
  }
  #map-panel {
    flex: 0.6;
    padding: 12px 12px 40px;
  }
  #dashboard {
    flex: 0.4;
    padding: 14px;
  }
}

/* Map styles */

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

/* Map tooltip */

#map-tooltip {
  position: absolute;
  pointer-events: none;
  padding: 6px 9px;
  font-size: 11px;
  border-radius: 10px;
  color: var(--text-main);
  background: rgba(5, 10, 16, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  transform: translate(-50%, -110%);
  z-index: 2;
}

#map-tooltip .tooltip-title {
  font-weight: 600;
}

#map-tooltip .tooltip-sub {
  color: var(--text-muted);
}

.state {
  stroke: rgba(15, 15, 20, 0.78);
  stroke-width: 0.8;
  cursor: pointer;
  transition: fill 160ms ease-out, transform 120ms ease-out, stroke-width 120ms;
}

.state:hover {
  stroke-width: 1.3;
  transform: translateY(-0.5px);
}

.state.selected {
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 1.6;
}

/* Legend */

#legend {
  position: absolute;
  left: 12px;
  bottom: 10px;
  display: flex;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: linear-gradient(120deg, rgba(5, 10, 16, 0.92), rgba(11, 18, 25, 0.85));
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(5, 5, 5, 0.6);
}

.legend-swatch.risk-very-high {
  background: var(--risk-very-high);
}
.legend-swatch.risk-high {
  background: var(--risk-high);
}
.legend-swatch.risk-moderate {
  background: var(--risk-moderate);
}
.legend-swatch.risk-emerging {
  background: var(--risk-emerging);
}
.legend-swatch.risk-lower {
  background: var(--risk-lower);
}

/* Dashboard */

#dashboard-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#risk-pill {
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-main);
  background: linear-gradient(120deg, rgba(245, 166, 35, 0.18), rgba(245, 68, 35, 0.08));
  border: 1px solid rgba(245, 166, 35, 0.5);
}

#risk-pill[data-risk="very-high"] {
  background: linear-gradient(120deg, rgba(215, 52, 42, 0.24), rgba(245, 166, 35, 0.12));
  border-color: rgba(215, 52, 42, 0.85);
}

#risk-pill[data-risk="high"] {
  background: linear-gradient(120deg, rgba(243, 106, 45, 0.24), rgba(245, 166, 35, 0.12));
  border-color: rgba(243, 106, 45, 0.85);
}

#risk-pill[data-risk="moderate"] {
  background: linear-gradient(120deg, rgba(243, 180, 60, 0.23), rgba(245, 166, 35, 0.12));
  border-color: rgba(243, 180, 60, 0.9);
}

#risk-pill[data-risk="emerging"] {
  background: linear-gradient(120deg, rgba(85, 176, 111, 0.23), rgba(107, 196, 139, 0.1));
  border-color: rgba(85, 176, 111, 0.9);
}

#risk-pill[data-risk="lower"] {
  background: linear-gradient(120deg, rgba(79, 154, 217, 0.23), rgba(92, 174, 233, 0.1));
  border-color: rgba(79, 154, 217, 0.9);
}

#region-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

#region-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Metrics grid */

#metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metric-card {
  background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.09), rgba(5, 10, 14, 0.9));
  border-radius: var(--radius-md);
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
}

.metric-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.metric-footnote {
  font-size: 10px;
  color: var(--text-muted);
}

/* Insight */

#insight {
  margin-top: auto;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, rgba(7, 14, 18, 0.9), rgba(10, 18, 24, 0.85));
}

#insight-title {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#insight-body {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

/* Metric modal */

#metric-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 10, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

#metric-modal-overlay[hidden] {
  display: none !important;
}

#metric-modal {
  position: relative;
  width: min(640px, 92vw);
  max-height: 90vh;
  padding: 14px 14px 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(
    145deg,
    rgba(14, 20, 26, 0.96),
    rgba(3, 7, 12, 0.94)
  );
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#metric-modal-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 24px;
}

#metric-modal-pill {
  align-self: flex-start;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

#metric-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

#metric-modal-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

#metric-modal-body {
  margin-top: 4px;
  padding-right: 4px;
  overflow-y: auto;
  scrollbar-width: thin;
}

#metric-modal-body::-webkit-scrollbar {
  width: 4px;
}
#metric-modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.modal-section {
  margin-bottom: 8px;
}

.modal-section h3 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.modal-section p {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.modal-section ul {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  color: var(--text-muted);
}

.modal-section li + li {
  margin-top: 2px;
}

#metric-modal-sources a {
  color: var(--accent);
  text-decoration: none;
}
#metric-modal-sources a:hover {
  text-decoration: underline;
}

#metric-modal-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
#metric-modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

@media (min-width: 768px) {
  #metric-modal-title {
    font-size: 18px;
  }
}

#lsu-logo {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  border-radius: 999px;
  background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.2), rgba(5, 10, 16, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
}

#lsu-logo img {
  display: block;
  height: 22px;
  width: auto;
}

/* Larger text on tablets / desktop */

@media (min-width: 768px) {
  #region-title {
    font-size: 20px;
  }
  #region-subtitle {
    font-size: 13px;
  }
  .metric-value {
    font-size: 18px;
  }
}