/* Dashboard chrome overrides.
   Top band: P&I site nav (matches policiesandindustries.com header).
   Body chrome (drilldown, tuner, modals) retains the original palette.
   Map colorway (RdYlBu_r) is set in figures.py — do NOT override here. */

html, body, #react-entry-point {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Source Sans 3', Arial, sans-serif;
  color: #0E1A2E;
  background-color: #F4F2EB;
}

.app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ---- P&I site nav band ---------------------------------------------------
   Replicates src/components/Layout.tsx from the policies-and-industries-site
   repo. Cream paper background with backdrop blur, thin border-bottom,
   DM Serif Display wordmark left, Inter nav links right. Active link uses
   the P&I primary color pill (navy on cream).
   Updated 2026-06-03 — P&I brand v6 lock (cream + navy + teal + silver).
*/
.pi-site-header {
  background-color: rgba(244, 242, 235, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid #CFCCC0;
  flex-shrink: 0;
}
.pi-site-header-inner {
  /* Flush-left padding matches .control-bar (24px) so the wordmark, the
     "US Water Risk Dashboard" title below, and the "Spatial unit:" label
     of the control bar all line up on the same left edge. The parent P&I
     site uses max-width 72rem here, but the dashboard is a full-width
     tool, so we drop the centered narrow band. */
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.pi-wordmark {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: #0A2540;
  text-decoration: none;
  white-space: nowrap;
}
.pi-wordmark:hover {
  color: #0A2540;
  text-decoration: none;
}
.pi-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.pi-nav-link {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 0.125rem;
  color: #4F5870;
  text-decoration: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.pi-nav-link:hover {
  background-color: #E2DFD5;
  color: #0A2540;
  text-decoration: none;
}
.pi-nav-link-active,
.pi-nav-link-active:hover {
  background-color: transparent;
  color: #0A2540;
  border-radius: 0;
  border-bottom: 2px solid #8B95A8;
  padding-bottom: calc(0.5rem - 2px);
}
@media (max-width: 640px) {
  .pi-nav {
    display: none;
  }
}

/* ---- Page-title strip (under the P&I site nav) --------------------------
   Inverted color scheme — navy-deep background, cream foreground.
   Visually rhymes with the active "Data" nav pill in the band above and
   breaks up the cream-on-cream-on-gray stack so the page has real
   structure. Uses the P&I site's navy-deep (#051630) so the band reads as
   the parent brand, just inverted. 2px silver bottom border per the v6
   architectural-divider convention.
*/
.app-header {
  background-color: #051630;
  color: #F4F2EB;
  padding: 16px 24px 14px;
  border-bottom: 2px solid #A8B0BD;
  flex-shrink: 0;
}
.app-header-inner {
  /* No max-width — see .pi-site-header-inner. */
}
.app-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: #F4F2EB;
  margin: 0;
}
.app-subtitle {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 400;
  color: rgba(244, 242, 235, 0.78);
  margin-top: 4px;
}

/* Control bar — light grey, below header. Wraps to multiple rows on
   narrower viewports so the highlight-flag radio never gets clipped. */
.control-bar {
  background-color: #FAF8F3;
  border-bottom: 1px solid #CFCCC0;
  padding: 10px 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
}

/* Dimension toggle — pill row */
.dimension-toggle {
  display: flex;
  align-items: center;
}
.dimension-pills {
  display: inline-flex;
  gap: 6px;
}
.dimension-pill {
  background-color: #FFFEFA !important;
  color: #0E1A2E !important;
  border: 1px solid #CFCCC0 !important;
  border-radius: 999px !important;
  padding: 6px 16px !important;
  font-size: 0.85rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.dimension-pill:hover {
  border-color: #216C7C !important;
  color: #216C7C !important;
}
.dimension-pill-active {
  background-color: #0A2540 !important;
  color: #F4F2EB !important;
  border-color: #0A2540 !important;
}

/* Map container — fills remaining space */
.map-container {
  flex: 1 1 auto;
  position: relative;
  width: 100%;
  min-height: 0;
  display: flex;
}
/* Make the dcc.Loading wrapper (NOT the legend!) fill the container.
   Earlier `> div { height:100% }` was applying to the legend too and
   confusing its absolute positioning. */
.map-container > .dash-loading-callback,
.map-container > .dash-spinner,
.map-container > div:not(.coverage-legend):not(.map-graph-wrapper) {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
}

/* Session 14 — two stacked map wrappers (risk-map for heatmap/flag,
   source-basin-map for the imported-water overlay). Absolute positioning
   so they overlay each other; visibility toggled by display:block/none
   in the _toggle_map_visibility callback. Each wrapper takes the full
   container so Plotly inside computes correct dimensions. */
.map-graph-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}

/* Suppress dash undo/redo bar that appears on graph click */
._dash-undo-redo {
  display: none !important;
}

/* Header row: title + methodology link */
.app-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.methodology-link {
  font-family: 'Inter', system-ui, sans-serif;
  color: #F4F2EB;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: #4DB8CB;
  text-underline-offset: 3px;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0.95;
}
.methodology-link:hover {
  color: #FFFEFA;
  text-decoration-color: #F4F2EB;
  opacity: 1;
}

/* Region picker — session 8 (geography expansion). Sits leftmost in the
   control bar; "what region am I looking at" frames everything else. */
.region-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
.region-picker-label {
  color: #0E1A2E;
  font-weight: 500;
  white-space: nowrap;
}
.region-picker-dropdown {
  min-width: 180px;
  font-size: 0.85rem;
}

/* View picker — session 9 (converted from radio pills to dropdown).
   Sits between the region picker and the horizon picker; selects which
   composite/dimension drives the choropleth. */
.view-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  margin-left: 12px;
}
.view-picker-label {
  color: #0E1A2E;
  font-weight: 500;
  white-space: nowrap;
}
.view-picker-dropdown {
  min-width: 160px;
  font-size: 0.85rem;
}

/* Spatial-unit picker — session 10 (HUC12 toggle). Leftmost in the control
   bar; switches between county and HUC12 watershed views. */
.spatial-unit-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  margin-right: 12px;
}
.spatial-unit-picker-label {
  color: #0E1A2E;
  font-weight: 500;
  white-space: nowrap;
}
.spatial-unit-picker-dropdown {
  min-width: 170px;
  font-size: 0.85rem;
}

/* Time-horizon picker — session 9 (projection feature). Sits to the right
   of the view pills; switches between current snapshot and 2036 projection. */
.horizon-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  margin-left: 12px;
}
.horizon-picker-label {
  color: #0E1A2E;
  font-weight: 500;
  white-space: nowrap;
}
.horizon-picker-dropdown {
  min-width: 200px;
  font-size: 0.85rem;
}

/* Composite + overlay controls in the bar */
.control-spacer {
  flex: 1 1 auto;
}
.composite-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #0E1A2E;
}
.composite-toggle .form-check-label {
  font-size: 0.85rem;
  color: #0E1A2E;
}
.composite-switch {
  margin-bottom: 0;
}
.overlay-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
.overlay-label {
  color: #0E1A2E;
  font-weight: 500;
  white-space: nowrap;
}
.overlay-dropdown {
  min-width: 280px;
  font-size: 0.85rem;
}

/* Radio picker (M3 — replaces the M2 multi-select dropdown). Inline horizontal
   radio with subtle padding; the active option highlights via Bootstrap's
   form-check-input checked state. */
.overlay-radio {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 0.82rem;
  margin-bottom: 0;
}
.overlay-radio .form-check {
  margin-right: 0;
  padding-left: 1.5rem;
}
.overlay-radio-label {
  color: #0E1A2E;
  cursor: pointer;
  user-select: none;
}
.overlay-radio .form-check-input:checked {
  background-color: #C61D1D;
  border-color: #C61D1D;
}

/* Coverage legend — pinned to viewport bottom-left so it stays put
   regardless of the Loading wrapper's positioning context. */
.coverage-legend {
  position: fixed !important;
  left: 14px;
  bottom: 14px;
  top: auto !important;
  right: auto !important;
  background-color: rgba(255, 255, 255, 0.92);
  border: 1px solid #CFCCC0;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.4;
  max-width: 320px;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.coverage-legend-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: #216C7C;
}
.coverage-legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}
.coverage-swatch {
  width: 16px;
  height: 12px;
  border: 1px solid #CFCCC0;
  flex-shrink: 0;
  display: inline-block;
}
.swatch-decile {
  background: linear-gradient(
    90deg,
    #4575b4 0%,
    #abd9e9 25%,
    #ffffbf 50%,
    #fdae61 75%,
    #d73027 100%
  );
  border-color: transparent;
}
.coverage-legend-note {
  margin-top: 6px;
  color: #4F5870;
  font-size: 0.7rem;
  font-style: italic;
}

/* Drill-down offcanvas — bottom-anchored (M3 refactor from right-anchored).
   Width is full viewport; height ~40vh for content breathing room without
   eating the map. Bootstrap's bs-offcanvas-height var controls offcanvas-bottom. */
.drilldown-panel {
  --bs-offcanvas-height: 40vh;
  font-size: 0.85rem;
}

/* 2-column landscape grid for the bottom-anchored content.
   Left col: header + dim scores + composite + chips (stable height, ~360px).
   Right col: factor breakdown (scrollable per-dim collapsible groups). */
.drilldown-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) 1.2fr;
  gap: 24px;
  height: 100%;
}
.drilldown-col-left,
.drilldown-col-right {
  min-width: 0;  /* allow grid children to shrink below content size */
  overflow-y: auto;
}
.drilldown-col-right .factor-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
  align-content: start;
}
.drilldown-empty {
  color: #8B8B8B;
  padding: 12px 0;
}
.drilldown-header {
  border-bottom: 2px solid #8B95A8;
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.drilldown-county {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  color: #216C7C;
}
.drilldown-fips {
  font-size: 0.75rem;
  color: #4F5870;
}
.drilldown-small-county-note {
  margin-top: 6px;
  padding: 6px 8px;
  background-color: #FFF8E1;
  border-left: 3px solid #B8860B;
  font-size: 0.72rem;
  color: #6A4C00;
  line-height: 1.35;
}
.section-title {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: #216C7C;
  letter-spacing: 0.04em;
  margin: 14px 0 6px 0;
}

/* Dimension score rows */
.dim-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dim-row, .composite-row {
  display: grid;
  grid-template-columns: 110px 40px 1fr;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid #E2DFD5;
}
.composite-row {
  border-bottom: none;
  border-top: 1px solid #8B95A8;
  margin-top: 8px;
  padding-top: 8px;
}
.composite-name {
  font-weight: 600;
  color: #216C7C;
}
.composite-score {
  font-weight: 600;
}
.dim-name { color: #0E1A2E; }
.dim-score {
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.dim-coverage {
  color: #8B8B8B;
  font-size: 0.75rem;
}

/* Chip badges */
.chips-section {
  margin-top: 12px;
}
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chip {
  display: inline-block;
  background-color: #FFF3E0;
  color: #6A2C00;
  border: 1px solid #E07B00;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
}
.chips-empty {
  color: #8B8B8B;
  font-size: 0.78rem;
  font-style: italic;
}

/* Factor breakdown */
.factor-groups {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.factor-group {
  border: 1px solid #E2DFD5;
  border-radius: 4px;
  padding: 4px 8px;
}
.factor-group summary {
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  color: #0E1A2E;
}
.factor-group summary:hover {
  color: #216C7C;
}
.factor-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}
.factor-line {
  font-size: 0.78rem;
  padding: 6px 0;
  border-bottom: 1px dotted #E2DFD5;
}
.factor-line-head {
  display: grid;
  grid-template-columns: 28px 1fr 50px;
  gap: 6px;
  align-items: baseline;
}
.factor-line-body {
  margin-left: 34px;
  margin-top: 2px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.factor-id {
  color: #8B8B8B;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.factor-name {
  color: #0E1A2E;
  white-space: normal;
  line-height: 1.25;
}
.factor-pct {
  font-weight: 600;
  text-align: right;
  color: #216C7C;
  font-variant-numeric: tabular-nums;
}
.factor-val-plain {
  color: #0E1A2E;
  font-size: 0.74rem;
  font-style: italic;
}
.factor-cov {
  font-size: 0.7rem;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.factor-cov-full { color: #2A8E4A; }
.factor-cov-partial { color: #B8860B; }
.factor-cov-insufficient { color: #8B8B8B; font-style: italic; }

/* Methodology modal — readability tweaks */
.methodology-body h5 {
  font-family: 'Source Serif 4', Georgia, serif;
  color: #216C7C;
  font-size: 1rem;
  margin-top: 18px;
  margin-bottom: 6px;
}
.methodology-body h5:first-child { margin-top: 0; }
.methodology-body p, .methodology-body li {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #0E1A2E;
}
.methodology-body ul {
  padding-left: 1.2rem;
}

/* Coverage legend — slightly smaller, anchored bottom-left */
.coverage-legend {
  font-size: 0.74rem;
  padding: 8px 10px;
  max-width: 280px;
}
.coverage-legend-title {
  font-size: 0.78rem;
}

/* ----------------------------------------------------------------------
   Sensitivity tuner panel (session 7)
   ---------------------------------------------------------------------- */

/* Top-bar "Tune weights" button — sits between view pills and overlays */
.tune-weights-btn {
  margin-right: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Right-anchored offcanvas — wider than the drilldown to fit slider rows */
.sensitivity-panel {
  width: 460px !important;
  font-size: 0.88rem;
}

.sensitivity-intro {
  font-size: 0.82rem;
  color: #4F5870;
  margin-bottom: 14px;
  line-height: 1.4;
}

.sensitivity-controls {
  margin-bottom: 12px;
}

.preset-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.preset-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #0E1A2E;
}
.preset-dropdown {
  font-size: 0.85rem;
}

.reset-row {
  display: flex;
  justify-content: flex-end;
}

/* Apply-row hosts the dim-multipliers sum indicator + Reset + Apply buttons */
.apply-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 8px;
  background-color: #FAF8F3;
  border-radius: 4px;
  border: 1px solid #CFCCC0;
}
.dim-sum-top {
  flex-grow: 1;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4F5870;
}
.reset-btn {
  flex-shrink: 0;
}
.run-btn {
  flex-shrink: 0;
  font-weight: 600;
}
.run-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Warn state — sums diverging from 100% */
.dim-sum-warn {
  color: #C0392B !important;
  font-weight: 700;
}

/* Accordion — the 5 dimension blocks. dbc.Accordion handles base styling;
   we add brand-aligned tints. */
.sensitivity-accordion .accordion-button {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 14px;
  background-color: #FAF8F3;
}
.sensitivity-accordion .accordion-button:not(.collapsed) {
  background-color: #D6E8EC;
  color: #216C7C;
  box-shadow: none;
}
.sensitivity-accordion .accordion-button:focus {
  box-shadow: none;
  border-color: transparent;
}

.accordion-dim-name {
  font-weight: 600;
}
.accordion-dim-sep {
  color: #8B8B8B;
  margin: 0 4px;
}
.accordion-dim-sum {
  font-weight: 400;
  font-size: 0.8rem;
  color: #4F5870;
  font-family: 'Source Sans 3', Arial, sans-serif;
}

/* Body of each accordion item */
.dim-multiplier-block {
  background-color: #FAF8F3;
  padding: 8px 10px;
  border-left: 3px solid #8B95A8;
  margin-bottom: 8px;
}
.dim-multiplier-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4F5870;
  margin-bottom: 6px;
}

.accordion-divider {
  margin: 6px 0 10px 0;
  border-top: 1px dashed #CFCCC0;
}

.factor-sliders-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.factor-slider-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.factor-slider-label {
  font-size: 0.8rem;
  color: #0E1A2E;
}
.factor-slider-control {
  /* slider container — pad to match dcc.Slider's internal margin */
  padding: 0 8px;
}

/* Disabled (placeholder) slider — visually grayed */
.weight-slider-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.weight-slider-disabled + * {
  /* no-op; reserved for future placeholder badge */
}

/* Decile preview — bottom of panel */
.decile-preview-block {
  margin-top: 10px;
}
.decile-preview-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4F5870;
  margin-bottom: 4px;
}

/* Imported-water source-basin section — only renders for curated CRB
   importer counties (Maricopa, LA, Denver, etc.). The drilldown wrap
   stacks the existing 2-col grid above this row; both fit inside the
   bottom-anchored offcanvas (40vh). Visual treatment uses Carolina blue
   border to mark it as a distinct overlay context. */
.drilldown-content-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 12px;
}
.drilldown-content-wrap > .drilldown-grid {
  flex: 1 1 auto;
  min-height: 0;
}
.source-basin-section {
  flex-shrink: 0;
  border-top: 2px solid #8B95A8;
  padding-top: 10px;
  margin-top: 4px;
}
.source-basin-head {
  margin-bottom: 8px;
}
.source-basin-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #216C7C;
}
.source-basin-subtitle {
  font-size: 0.72rem;
  color: #4F5870;
  margin-top: 2px;
  line-height: 1.4;
}
.source-basin-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-color: #FAF8F3;
  border: 1px solid #CFCCC0;
  border-radius: 4px;
  padding: 6px 10px;
}
.source-basin-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.8fr) minmax(60px, 0.6fr) minmax(110px, 0.9fr) minmax(80px, 0.7fr) minmax(90px, 0.8fr);
  gap: 10px;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px solid #E2DFD5;
  font-size: 0.82rem;
}
.source-basin-row:last-child {
  border-bottom: none;
}
.source-basin-row-head .source-basin-cell {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #216C7C;
}
.source-basin-row-agg {
  border-top: 2px solid #8B95A8;
  margin-top: 2px;
  padding-top: 6px;
  font-weight: 600;
}
.source-basin-cell-label {
  color: #4F5870;
}
.source-basin-cell-v {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.source-basin-footer {
  font-size: 0.7rem;
  color: #8B8B8B;
  font-style: italic;
  margin-top: 6px;
  line-height: 1.45;
}
