/* =========================================================================
   Mobile Source Exposure — redesign stylesheet
   UVM TRC × Environmental Defense Fund
   -------------------------------------------------------------------------
   Everything is class/id driven. Set the active theme on <body>:
     <body class="theme-inferno">   (default)
     <body class="theme-daylight">
     <body class="theme-classic">
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,500;12..96,600;12..96,700;12..96,800&family=Public+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ----------------------------------------------------------------- THEMES */
:root,
.theme-inferno {
  --bg:        #100D1C;
  --bg-2:      #17122A;
  --surface:   #1C1636;
  --panel:     rgba(15, 11, 26, 0.88);
  --line:      rgba(255, 255, 255, 0.12);
  --ink:       #F3EFFA;
  --muted:     #9F99B4;
  --accent:    #E8175D;   /* magenta — the brand pull from the magma ramp */
  --accent-2:  #F4A02A;   /* amber   — "benefit / output" accent          */
  --good:      #FEC98D;
  --map-fade:  rgba(16, 12, 26, 0.55);
  --on-accent: #ffffff;
}

.theme-daylight {
  --bg:        #F4F1EC;
  --bg-2:      #ECE7DF;
  --surface:   #FFFFFF;
  --panel:     rgba(255, 255, 255, 0.92);
  --line:      rgba(20, 16, 30, 0.13);
  --ink:       #1A1626;
  --muted:     #6B6577;
  --accent:    #C8123F;
  --accent-2:  #B5631A;
  --good:      #C2701A;
  --map-fade:  rgba(244, 241, 236, 0.30);
  --on-accent: #ffffff;
}

.theme-classic {
  --bg:        #181818;
  --bg-2:      #202020;
  --surface:   #262626;
  --panel:     rgba(0, 0, 0, 0.82);
  --line:      rgba(255, 255, 255, 0.14);
  --ink:       #F5F5F5;
  --muted:     #a7a4a4;
  --accent:    #E8175D;
  --accent-2:  #f1a226;
  --good:      #FEC98D;
  --map-fade:  rgba(0, 0, 0, 0.5);
  --on-accent: #ffffff;
}

/* the inferno colour ramp used by the legend + tool cards, as a token */
:root {
  --ramp-inferno: linear-gradient(90deg,#0D0829,#4A0F61,#6A176E,#9E2D71,#B73779,#D44A57,#DD513A,#F07A4F,#FEC98D,#FCFDBF);
  --ramp-purple:  linear-gradient(90deg,#330066,#550099,#7300cc,#8f00ff,#a633ff,#bf66ff,#d399ff,#e0c0ff,#f4e5ff);
}

/* --------------------------------------------------------------- GLOBALS  */
* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Public Sans', system-ui, sans-serif;
  scrollbar-width: thin;
}

.container-fluid { padding: 0; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

a { color: var(--accent); }

.font-display { font-family: 'Bricolage Grotesque', sans-serif; }
.font-mono    { font-family: 'JetBrains Mono', monospace; }

.kicker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ============================================================== HEADER === */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: radial-gradient(circle at 30% 30%, var(--accent-2), var(--accent) 55%, #4A0F61 100%);
  box-shadow: 0 0 16px rgba(232,23,93,0.45);
}
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-title { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-sub   { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; margin-top: 3px; }

.header-meta { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--muted); text-align: right; line-height: 1.5; letter-spacing: 0.03em; }
.header-meta .accent { color: var(--accent); }

/* ---- top navigation (styles the radioGroupButtons #tab) ---------------- */
.main-nav {
  display: inline-flex;
  gap: 4px;
  background: var(--surface);
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
/* radioGroupButtons renders .btn-group > .btn; flatten it */
.main-nav .btn-group,
.main-nav .btn-group-container-sw { display: inline-flex; gap: 4px; }
.main-nav .btn {
  border: none !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: var(--muted) !important;
  font-family: 'Public Sans', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 15px;
  box-shadow: none !important;
  transition: all .15s;
}
.main-nav .btn:hover { color: var(--ink) !important; }
.main-nav .btn.active,
.main-nav .btn:active {
  background: var(--accent) !important;
  color: var(--on-accent) !important;
}

/* ============================================================== LAYOUT === */
.page { min-height: calc(100vh - 62px); }
.map-page { position: relative; height: calc(100vh - 62px); overflow: hidden; }

/* ============================================================ OVERVIEW === */
.hero {
  position: relative;
  min-height: 600px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.9; }
.hero::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(16,12,26,0.6) 0%, rgba(16,12,26,0.2) 34%, var(--bg) 100%);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--bg) 0%, rgba(16,12,26,0.08) 80%, transparent 72%)
}

.hero-inner { position: relative; padding: 0 60px 56px; max-width: 880px; z-index: 99999}

.dev-banner {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 14px; border-radius: 999px;
  background: rgba(232,23,93,0.16); border: 1px solid rgba(232,23,93,0.4);
  margin-bottom: 24px; font-size: 12.5px; color: #FFD7E4; backdrop-filter: blur(4px);
}
.dev-banner .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dev-banner code { font-family: 'JetBrains Mono', monospace; font-size: 11px; }

.hero h1 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800; font-size: 58px; line-height: 1.0;
  letter-spacing: -0.025em; margin: 0 0 20px; text-wrap: balance;
}
.hero p { font-size: 18px; line-height: 1.55; color: #D9D4E6; max-width: 600px; margin: 0 0 30px; text-wrap: pretty; }

.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

/* buttons */
.btn-primary-cta,
.btn-ghost-cta {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 15px 24px; border-radius: 12px; cursor: pointer;
  font-family: 'Public Sans', sans-serif; font-size: 15px; font-weight: 700;
  border: none; text-decoration: none;
}
.btn-primary-cta { background: var(--accent); color: #fff; box-shadow: 0 8px 30px rgba(232,23,93,0.4); }
.btn-ghost-cta   { background: rgba(255,255,255,0.06); color: var(--ink); border: 1px solid var(--line); font-weight: 600; backdrop-filter: blur(6px); }

/* stat strip */
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg-2); }
.stat-strip .stat { padding: 26px 28px; border-right: 1px solid var(--line); }
.stat-strip .stat:last-child { border-right: none; }
.stat .num { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 34px; color: var(--accent-2); line-height: 1; }
.stat .cap { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.4; }

/* section + tool cards */
.section { padding: 64px 60px 40px; }
.section h2 { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 36px; letter-spacing: -0.02em; margin: 10px 0 36px; max-width: 640px; }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.tool-card { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; cursor: pointer; background: var(--surface); transition: transform .2s, border-color .2s; text-decoration: none; color: inherit; display: block; }
.tool-card:hover { transform: translateY(-4px); border-color: rgba(232,23,93,0.5); }
.tool-card .thumb { height: 150px; position: relative; }
.tool-card .thumb.ed       { background: linear-gradient(120deg,#0D0829,#6A176E 45%,#DD513A 80%,#FEC98D); }
.tool-card .thumb.forecast { background: linear-gradient(120deg,#330066,#7300cc 45%,#a633ff 75%,#e0c0ff); }
.tool-card .thumb::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 70% 120%, transparent, var(--surface) 90%); }
.tool-card .body { padding: 24px 26px 26px; }
.tool-card .tags { display: flex; gap: 10px; margin-bottom: 12px; }
.tag { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.12em; color: var(--muted); border: 1px solid var(--line); padding: 3px 8px; border-radius: 6px; }
.tag.new { color: var(--accent-2); border-color: rgba(244,160,42,0.4); }
.tool-card h3 { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 24px; margin: 0 0 10px; }
.tool-card p { font-size: 14.5px; line-height: 1.55; color: var(--muted); margin: 0 0 16px; }
.tool-card .more { color: var(--accent); font-weight: 600; font-size: 14px; }

.method-band { margin: 30px 60px 70px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg-2); padding: 30px 34px; display: flex; gap: 40px; align-items: center; flex-wrap: wrap; }
.method-band .copy { flex: 1; min-width: 320px; }
.method-band h3 { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 20px; margin: 0 0 10px; }
.method-band p { font-size: 14px; line-height: 1.6; color: var(--muted); margin: 0; }
.method-band b { color: var(--ink); }
.method-band .logos { display: flex; gap: 28px; align-items: center; }
.method-band .logos img { opacity: 0.9; }

/* ============================================================== MAPS ===== */
/* the mapgl canvas fills the page.
   IMPORTANT: use a viewport-relative height, NOT height:100%. withSpinner wraps
   the map in a positioned, auto-height container, so height:100% would resolve
   against 0 and the map would paint blank. A vh height is always real, which is
   exactly what the original (min-height:90vh) relied on — mapgl's own
   resize-on-show then fills the canvas with no JS resize needed. */
#block_map, #health_map {
  position: absolute !important;
  top: 0; left: 0;
  width: 100% !important;
  height: calc(100vh - 62px) !important;
  min-height: calc(100vh - 62px) !important;
}
/* don't let the spinner wrapper collapse the map's containing block */
.map-page .shiny-spinner-output-container,
.map-page [class*="shiny-spinner"] { position: static !important; display: block; }

/* gradient that improves panel legibility on the right edge */
.map-page::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 520px;
  background: linear-gradient(90deg, transparent, var(--bg) 78%);
  pointer-events: none; z-index: 5;
}

/* floating "map options" button (shown only when sidebar collapsed) */
.map-toggle {
  position: absolute; top: 16px; left: 16px; z-index: 20;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 11px 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(14px);
  color: var(--ink); font-weight: 600; font-size: 13.5px; cursor: pointer;
}

/* ---- floating sidebar (left) ------------------------------------------ */
.map-sidebar {
  position: absolute; top: 16px; left: 16px; bottom: 70px;
  width: 300px; z-index: 20;
  max-height: 70vh;
  background: var(--panel); backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; overflow-y: auto;
  display: flex; flex-direction: column;
  transition: transform .28s ease, opacity .28s ease;
}
.map-sidebar.collapsed { transform: translateX(-340px); opacity: 0; pointer-events: none; }

.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sidebar-title { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 19px; }
.sidebar-intro { font-size: 12px; color: var(--muted); margin-bottom: 20px; line-height: 1.5; }
.sidebar-close { border: none; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }

.field-group { margin-bottom: 22px; }
.field-group > label,
.control-label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 9px; color: var(--ink); }
.section-label {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 11px; padding-bottom: 7px; border-bottom: 1px solid var(--line);
}
.field-note { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.5; font-style: italic; }

#tab-label { display: none; }

/* ---- restyle shinyWidgets controls inside the sidebar ----------------- */
/* segmented pills (radioGroupButtons / sliderTextInput) */
.map-sidebar .btn-group-container-sw,
.map-sidebar .radiobtn .btn-group { display: flex; gap: 6px; flex-wrap: wrap; }
.map-sidebar .btn {
  flex: 1 1 auto;
  border: 1px solid var(--line) !important;
  background: var(--surface) !important;
  color: var(--ink) !important;
  border-radius: 9px !important;
  font-weight: 600; font-size: 12.5px;
  padding: 10px 8px !important;
  box-shadow: none !important;
  white-space: normal; text-align: left;
}
.map-sidebar .btn.active,
.map-sidebar .btn:active,
.map-sidebar .btn:hover {
  border-color: var(--accent) !important;
  background: var(--accent) !important;
  color: var(--on-accent) !important;
}
/* source rows keep their coloured icon, neutral background */
.map-sidebar .source-select .btn { display: flex; align-items: center; gap: 10px; }
.map-sidebar .source-select .btn.active { background: rgba(232,23,93,0.16) !important; color: var(--ink) !important; }

/* ---- Inputs / Outputs segmented TOGGLE --------------------------------
   A pill-track switch so it reads as a mode toggle, not another option row.
   Both halves sit flush inside a recessed track; the active half is filled. */
.io-toggle .btn-group-container-sw,
.io-toggle .btn-group {
  display: flex !important; gap: 0 !important; width: 100%;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px;
}
.io-toggle .btn {
  flex: 1 1 0 !important;
  border: none !important;
  background: transparent !important;
  color: var(--muted) !important;
  border-radius: 999px !important;
  padding: 8px 0 !important;
  text-align: center !important;
  font-weight: 600; font-size: 12.5px;
  transition: background .18s, color .18s;
}
.io-toggle .btn:hover { background: transparent !important; color: var(--ink) !important; }
.io-toggle .btn.active,
.io-toggle .btn.active:hover {
  background: var(--accent) !important;
  color: var(--on-accent) !important;
  box-shadow: 0 2px 8px rgba(232,23,93,0.35);
}

/* sliderTextInput / sliderInput (ion.rangeSlider) */
.map-sidebar .irs--shiny .irs-bar,
.map-sidebar .irs--shiny .irs-handle > i:first-child { background: var(--accent) !important; }
.map-sidebar .irs--shiny .irs-line { background: var(--surface) !important; border: none; }
.map-sidebar .irs--shiny .irs-from, 
.map-sidebar .irs--shiny .irs-to, 
.map-sidebar .irs--shiny .irs-single { background: var(--accent) !important; color: #fff !important; }

/* material switches */
.map-sidebar .material-switch label { font-size: 12.5px !important; color: var(--ink); }


/* selectize dropdown ----------------------------------------------------
   IMPORTANT: selectize appends its dropdown menu OUTSIDE .map-sidebar (often
   to <body>), so scoping these rules to .map-sidebar fails — they must be
   global. CSS vars come from :root so they resolve anywhere. */
.selectize-control.single .selectize-input {
  background: var(--surface) !important; border: 1px solid var(--line) !important;
  color: var(--ink) !important; border-radius: 9px !important;
  padding: 9px 12px !important; font-size: 12.5px; font-weight: 600; box-shadow: none !important;
}
.selectize-control.single .selectize-input.focus,
.selectize-control.single .selectize-input.dropdown-active {
  border-color: var(--accent) !important; box-shadow: 0 0 0 2px rgba(232,23,93,0.25) !important;
}
.selectize-input > .item, .selectize-input > input, .selectize-input > input::placeholder { color: var(--ink) !important; }
.selectize-control .selectize-input::after { border-top-color: var(--muted) !important; }

.selectize-dropdown {
  background: var(--surface) !important; color: var(--ink) !important;
  border: 1px solid var(--line) !important; border-radius: 9px !important;
  font-size: 12.5px; box-shadow: 0 12px 30px rgba(0,0,0,0.45) !important; z-index: 10000 !important;
}
.selectize-dropdown .option {
  padding: 8px 12px !important; color: var(--ink) !important; background: var(--surface) !important;
}
.selectize-dropdown .option:hover,
.selectize-dropdown .option.active {
  background: var(--accent) !important; color: var(--on-accent) !important;
}
/* optgroup category headers */
.selectize-dropdown .optgroup-header {
  font-family: 'JetBrains Mono', monospace !important; font-size: 9.5px !important;
  letter-spacing: 0.12em !important; text-transform: uppercase !important;
  color: var(--accent) !important; background: var(--surface) !important;
  padding: 10px 12px 4px !important; cursor: default;
}
.selectize-dropdown .optgroup:not(:first-child) .optgroup-header {
  border-top: 1px solid var(--line) !important; margin-top: 3px;
}

/* ---- legend + zoom controls ------------------------------------------- */
.map-legend {
  position: absolute; bottom: 18px; left: 332px; z-index: 20;
  background: var(--panel); backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px; width: 320px;
}
.map-legend .legend-title { font-size: 12px; font-weight: 600; margin-bottom: 9px; color: var(--ink); }
.map-legend .legend-bar { height: 10px; border-radius: 5px; background: var(--ramp-inferno); }
.map-legend .legend-scale { display: flex; justify-content: space-between; margin-top: 6px; font-family: 'JetBrains Mono', monospace; font-size: 9.5px; color: var(--muted); }

/* mapgl injects its own legend; tame it to the panel look */
[id^="legend-"] {
  background: var(--panel) !important; color: var(--ink) !important;
  border: 1px solid var(--line) !important; border-radius: 12px !important;
  backdrop-filter: blur(14px); font-family: 'Public Sans', sans-serif !important;
  min-width: 450px !important;
}

/* ============================================================ DATA PANEL  */
.data-panel {
  position: absolute; top: 16px; right: 16px; bottom: 16px;
  width: 400px; z-index: 18;
  background: var(--panel); backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 16px;
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .28s ease, opacity .28s ease;
}
.data-panel.collapsed { transform: translateX(440px); opacity: 0; pointer-events: none; }

.panel-head { padding: 20px 22px 16px; border-bottom: 1px solid var(--line); flex: none; }
.panel-back { display: inline-flex; align-items: center; gap: 6px; border: none; background: transparent; color: var(--accent); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 0; margin-bottom: 12px; }
.panel-kicker { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.panel-title { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 25px; line-height: 1.05; letter-spacing: -0.01em; }
.panel-sub { font-size: 12.5px; color: var(--muted); margin-top: 7px; }

.panel-body { flex: 1; max-height: 70vh; min-height: 0; overflow-y: scroll; padding: 18px 22px 26px; }
.panel-body .fade-in { animation: fadeup .35s ease; }

/* hero metric */
.metric-hero {
  border: 1px solid rgba(244,160,42,0.32); border-radius: 14px;
  background: linear-gradient(135deg, rgba(244,160,42,0.13), rgba(232,23,93,0.06));
  padding: 16px 18px; margin-bottom: 12px;
}
.metric-hero .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.metric-hero .value { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 38px; line-height: 1; color: var(--accent-2); }
.metric-hero .unit { font-size: 14px; color: var(--muted); margin-left: 8px; }
.metric-hero .note { font-size: 12px; color: #FFD7E4; margin-top: 8px; line-height: 1.45; }

/* stat cards */
.stat-cards { display: grid; gap: 10px; margin-bottom: 22px; }
.stat-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 13px 15px; }
.stat-card .value { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 23px; line-height: 1; }
.stat-card .value.amber { color: var(--accent-2); }
.stat-card .label { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.35; }

.panel-section-title { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; display: flex; justify-content: space-between; align-items: center; }
.panel-section-title .unit { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--muted); font-weight: 400; }
.panel-section-note { font-size: 11.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.45; }

/* simple horizontal bars ("who benefits most") */
.bar-list { display: flex; flex-direction: column; gap: 11px; }
.bar-row .bar-meta { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.bar-row .bar-meta .num { font-family: 'JetBrains Mono', monospace; color: var(--muted); }
.bar-row .bar-track { height: 9px; border-radius: 5px; background: var(--surface); overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* diverging bars (exposure inequity) */
.diverge { position: relative; }
.diverge .axis { position: absolute; left: calc(116px + (100% - 166px) * 0.5); top: 0; bottom: 24px; width: 1px; background: var(--line); }
.diverge .row { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; }
.diverge .row .name { width: 108px; flex: none; font-size: 11.5px; text-align: right; color: var(--ink); }
.diverge .row .track { flex: 1; position: relative; height: 18px; }
.diverge .row .fill { position: absolute; top: 2px; bottom: 2px; }
.diverge .row .fill.pos { left: 50%; background: linear-gradient(90deg, rgba(244,160,42,0.5), var(--accent-2)); border-radius: 0 4px 4px 0; }
.diverge .row .fill.neg { background: linear-gradient(90deg, #2E6F9E, rgba(46,111,158,0.5)); border-radius: 4px 0 0 4px; }
.diverge .row .val { width: 42px; flex: none; font-family: 'JetBrains Mono', monospace; font-size: 10.5px; text-align: left; }
.diverge .row .val.pos { color: var(--accent-2); }
.diverge .row .val.neg { color: #5BA3D0; }
.diverge .scale { display: flex; justify-content: space-between; font-family: 'JetBrains Mono', monospace; font-size: 9.5px; color: var(--muted); margin-top: 10px; padding: 0 42px 0 116px; }

/* call-outs */
.panel-note { margin-top: 22px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.panel-note .h { font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.panel-note .t { font-size: 11.5px; color: var(--muted); line-height: 1.55; }
.panel-insight { margin-top: 22px; padding: 14px 16px; border: 1px solid rgba(232,23,93,0.3); border-radius: 12px; background: rgba(232,23,93,0.07); font-size: 12px; line-height: 1.55; color: #FFD7E4; }

.panel-actions { margin-top: 14px; display: flex; gap: 8px; }
.panel-actions .btn,
.panel-actions button {
  flex: 1; padding: 11px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface) !important; color: var(--ink) !important; font-weight: 600; font-size: 12.5px; cursor: pointer;
}

/* empty / prompt state inside panel */
.panel-empty { color: var(--muted); font-size: 13px; line-height: 1.6; padding: 8px 2px; }

/* ggplot output sits transparently inside the panel */
.panel-body .shiny-plot-output img { background: transparent; }

/* ================================================== SKELETON LOADING ===== */
.skeleton-wrap { display: flex; flex-direction: column; gap: 14px; }
.skeleton {
  border-radius: 12px;
  background: linear-gradient(90deg, var(--surface) 25%, rgba(255,255,255,0.07) 50%, var(--surface) 75%);
  background-size: 460px 100%;
  animation: shimmer 1.1s infinite linear;
}
.skeleton.h-hero  { height: 92px; border-radius: 14px; }
.skeleton.h-card  { height: 70px; }
.skeleton.h-chart { height: 150px; margin-top: 8px; }
.skeleton-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.skeleton-status { text-align: center; font-size: 11.5px; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-top: 4px; }

/* the data-panel toggles these two states; JS adds .is-loading */
.data-panel .panel-loading { display: none; }
.data-panel.is-loading .panel-loading { display: block; }
.data-panel.is-loading .panel-content { display: none; }

@keyframes shimmer { 0% { background-position: -460px 0; } 100% { background-position: 460px 0; } }
@keyframes fadeup  { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ringpulse { 0% { box-shadow: 0 0 0 0 rgba(232,23,93,0.55); } 70% { box-shadow: 0 0 0 16px rgba(232,23,93,0); } 100% { box-shadow: 0 0 0 0 rgba(232,23,93,0); } }

/* ================================================================ ABOUT = */
.about { max-width: 1080px; margin: 0 auto; padding: 56px 48px 0; }
.about h1 { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 46px; letter-spacing: -0.025em; margin: 12px 0 38px; }
.team-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 64px; }
.team-card { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.team-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.team-card .meta { padding: 16px 18px; }
.team-card .name { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 16.5px; }
.team-card .role { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.45; }

.about-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; margin-bottom: 64px; }
.about-cols h2 { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 26px; margin: 0 0 20px; }
.paper { padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.paper .title { font-size: 14px; line-height: 1.5; margin-bottom: 5px; }
.paper .cite  { font-size: 12px; color: var(--muted); font-style: italic; }
.about-cols .ack p { font-size: 14.5px; line-height: 1.6; margin: 0 0 18px; }
.about-cols .ack p:first-of-type { color: #D9D4E6; }
.about-cols .ack p:last-of-type  { color: var(--muted); }
.about-cols .logos { display: flex; gap: 26px; align-items: center; margin-top: 34px; }
.about-cols .logos img { opacity: 0.9; }

/* link pill used in body copy (kept from the original site vocabulary) */
.boxed-link { color: var(--ink); text-decoration: underline; }
.boxed-link:hover, .boxed-link:focus {
  text-decoration: none; font-weight: 700; padding: 0.05em 0.3em;
  background-color: var(--accent); border-radius: 5px; color: #fff;
}

/* ================================================================ FOOTER  */
.app-footer {
  border-top: 1px solid var(--line); background: var(--bg-2);
  padding: 26px 48px; display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 16px;
}
.app-footer .left { font-size: 12.5px; color: var(--muted); }
.app-footer .right { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--muted); }

/* ============================================== shiny notifications ====== */
#shiny-notification-panel { position: fixed; top: 78px; right: 0; width: 400px; max-width: 100%; z-index: 99999; }
.shiny-notification {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  backdrop-filter: blur(14px); padding: 1em 1.2em; margin: 1em;
}
.shiny-notification-close { color: var(--muted); }

.control-label .shiny-label-null { display: none !important; }

.form-group { margin-bottom: 0 !important;}

/* ============================================================ RESPONSIVE = */
@media (max-width: 1180px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .tool-grid, .about-cols { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: repeat(2, 1fr); }
  .data-panel { width: 340px; }
}
@media (max-width: 820px) {
  .map-legend, .map-sidebar, .data-panel { width: calc(100% - 32px); }
  .map-legend { left: 16px; bottom: 16px; }
  .hero h1 { font-size: 42px; }
  .hero-inner, .section { padding-left: 24px; padding-right: 24px; }
}

/* style the tooltip bubble to match the redesign */
.mapboxgl-popup-content,
.maplibregl-popup-content {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 12px !important;
  padding: 8px 11px !important;
  box-shadow: 0 8px 26px rgba(0,0,0,0.45) !important;
}
/* force every text node inside the tooltip to the readable ink colour */
.mapboxgl-popup-content *,
.maplibregl-popup-content * { color: var(--ink) !important; }
.mapboxgl-popup-tip,
.maplibregl-popup-tip { display: none !important; }
