/* ============================================================
   Dengue Dashboard — scoped CSS (dd- prefix)
   Font: Open Sans (loaded via dengue_dashboard/open_sans library)
   ============================================================ */

.dengue-dashboard-wrap {
  font-family: "Open Sans", sans-serif;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(100vh - var(--dd-offset-top, 0px));
  min-height: 500px;
  color: #1e293b;
  --dd-accent:      #d6006c;
  --dd-accent-soft: rgba(214,0,108,0.08);
  --dd-border:      rgba(0,0,0,0.08);
  --dd-surface:     #ffffff;
  --dd-muted:       #64748b;
  --dd-sev-high:    #ae2e82;
  --dd-sev-medium:  #d92c8a;
  --dd-sev-low:     #69afc2;
  --dd-sev-minimal: #66808a;
  --dd-tooltip-border: #c31c86;
  --dd-tooltip-num:    #6e8c95;
}
/* Block mode: use configured height instead of 100vh */
.dengue-dashboard-wrap.dd-is-block {
  height: var(--dd-block-height, 600px);
  min-height: 400px;
}

/* ── BODY ── */
.dd-body { flex: 1; position: relative; overflow: hidden; min-height: 0; }

/* ── MAP ── */
.dd-map {
  position: absolute; top: 0; bottom: 0; right: 0;
  left: 308px; /* clears the 240px info panel + 12px gap + 16px breathing room */
  z-index: 1;
}
.leaflet-container { background: #ffffff !important; }
.dd-map .leaflet-control-zoom a {
  background: #fff !important; color: #475569 !important;
  border-color: #e2e8f0 !important; box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
}
.dd-map .leaflet-control-zoom a:hover { color: var(--dd-accent) !important; }
.dd-map .leaflet-control-attribution {
  background: rgba(255,255,255,0.88) !important;
  font-size: 0.5rem !important; color: #94a3b8 !important; backdrop-filter: blur(4px);
}
.dd-map .leaflet-popup-content-wrapper {
  background: #fff !important; border: none !important;
  border-radius: 14px !important; box-shadow: 0 10px 40px rgba(0,0,0,0.13) !important;
}
.dd-map .leaflet-popup-tip { background: #fff !important; }
.dd-map .leaflet-popup-content { margin: 13px 16px !important; }
.dd-popup-state { font-size: 1.35rem; letter-spacing: 3px; color: var(--dd-accent); line-height: 1; font-weight: 800; }
.dd-popup-full  { font-size: 0.7rem; color: var(--dd-muted); margin-bottom: 8px; }
.dd-popup-count { display: flex; align-items: baseline; gap: 5px; }
.dd-popup-num   { font-size: 2.2rem; color: #1e293b; line-height: 1; font-weight: 800; }
.dd-popup-unit  { font-size: 0.52rem; color: var(--dd-muted); letter-spacing: 1px; text-transform: uppercase; }
.dd-popup-info  { margin-top: 6px; font-size: 0.52rem; color: var(--dd-muted); border-top: 1px solid #f1f5f9; padding-top: 6px; }
.dd-marker {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 700; color: #fff; cursor: pointer;
  transition: transform 0.2s ease; text-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.dd-marker:hover { transform: scale(1.1); }

/* ── NO-DATA OVERLAY ── */
.dd-no-data {
  position: absolute; inset: 0; z-index: 450;
  display: flex; align-items: center; justify-content: center;
  background: rgba(241,245,249,0.82); backdrop-filter: blur(4px);
  pointer-events: none;
}
.dd-no-data-inner {
  background: #fff; border: 1.5px solid var(--dd-border);
  border-radius: 16px; padding: 28px 36px; text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1); pointer-events: auto;
}
.dd-no-data-icon  { font-size: 2rem; margin-bottom: 10px; }
.dd-no-data-title { font-size: 1rem; font-weight: 700; color: #1e293b; margin-bottom: 6px; }
.dd-no-data-sub   { font-size: 0.75rem; color: var(--dd-muted); }
.dd-no-data-back {
  margin-top: 16px;
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1.5px solid var(--dd-accent); color: var(--dd-accent);
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.3px;
  padding: 7px 18px; border-radius: 999px; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.dd-no-data-back:hover,
.dd-no-data-back:focus-visible { background: var(--dd-accent); color: #fff; }

/* ── LEFT INFO PANEL — unified overlay, bottom-left ── */
.dd-info-panel {
  position: absolute;
  left: 12px; top: 12px;
  z-index: 40;
  width: 280px;
  background: rgba(255,255,255,0.98);
  border: 1.5px solid var(--dd-accent);
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  backdrop-filter: blur(8px);
  padding: 0;
  overflow: hidden;
}

.dd-info-section {
  padding: 14px 16px;
}
.dd-info-section--chart { padding-top: 0; }

.dd-info-sep {
  height: 0; border-top: 1.5px solid var(--dd-accent);
  margin: 0;
}

/* Section titles ("State by state guide to dengue" / "Severity scale") */
.dd-info-section .dd-guide-title {
  font-size: 0.8rem; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--dd-accent); font-weight: 700; margin-bottom: 8px;
}

/* Shared stat typography (still used for the chart sub-stat) */
.dd-stat-label {
  font-size: 0.8rem; letter-spacing: 2px; text-transform: uppercase;
  color: var(--dd-muted); font-weight: 600; margin-bottom: 3px;
}
.dd-stat-num {
  font-size: 2.2rem; color: var(--dd-accent); line-height: 1;
  margin: 2px 0 2px; font-weight: 800;
}
.dd-stat-num--chart { font-size: 1.5rem; color: #1e7bb0; }
.dd-stat-sub { font-size: 0.6rem; color: var(--dd-muted); }

/* State-by-state guide list (legacy — kept for backward compatibility, no longer rendered into by default) */
.dd-state-list { display: flex; flex-direction: column; }
.dd-state-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.8rem; color: #1e293b; padding: 3px 0;
}
.dd-state-row--nationwide { font-weight: 700; }
.dd-state-row--loading, .dd-state-row--empty { color: var(--dd-muted); font-size: 0.72rem; font-style: italic; }
.dd-state-row-code { color: #1e293b; }
.dd-state-row-val  { font-weight: 600; color: #1e293b; }
.dd-state-row.dd-active .dd-state-row-code,
.dd-state-row.dd-active .dd-state-row-val { color: var(--dd-accent); }

/* ── YEAR SELECTOR LIST — radio per year, pink-themed scrollbar ── */
.dd-year-list {
  display: flex; flex-direction: column;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 6px;
  margin-right: -6px;
  scrollbar-width: thin;
  scrollbar-color: var(--dd-accent) transparent;
}
.dd-year-list::-webkit-scrollbar { width: 6px; }
.dd-year-list::-webkit-scrollbar-track { background: transparent; }
.dd-year-list::-webkit-scrollbar-thumb {
  background: var(--dd-accent); border-radius: 3px; opacity: 0.7;
}
.dd-year-list::-webkit-scrollbar-thumb:hover { background: var(--dd-sev-high); }

.dd-year-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; color: #1e293b; padding: 4px 2px;
  cursor: pointer; border-radius: 4px;
  transition: background 0.12s;
}
.dd-year-row:hover { background: var(--dd-accent-soft); }
.dd-year-row--loading, .dd-year-row--empty {
  color: var(--dd-muted); font-size: 0.72rem; font-style: italic; cursor: default;
}
.dd-year-row--loading:hover, .dd-year-row--empty:hover { background: none; }

.dd-year-radio-wrap { display: flex; align-items: center; flex-shrink: 0; }
.dd-year-radio {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--dd-muted);
  cursor: pointer; position: relative; flex-shrink: 0;
  transition: border-color 0.12s;
}
.dd-year-radio:hover { border-color: var(--dd-accent); }
.dd-year-radio:checked { border-color: var(--dd-accent); }
.dd-year-radio:checked::after {
  content: ''; position: absolute; inset: 2.5px;
  border-radius: 50%; background: var(--dd-accent);
}

.dd-year-label { flex: 1; }
.dd-year-val   { font-weight: 600; color: #1e293b; display: none;}
.dd-year-row.dd-active .dd-year-label,
.dd-year-row.dd-active .dd-year-val { color: var(--dd-accent); font-weight: 700; }

/* Severity legend items — inside info panel */
.dd-legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem; color: #1e293b; margin-bottom: 6px; line-height: 1;
}
.dd-legend-item:last-child { margin-bottom: 0; }
.dd-leg-icon { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.dd-leg-icon svg { display: block; }
.dd-leg-icon--high    { color: var(--dd-sev-high); }
.dd-leg-icon--medium  { color: var(--dd-sev-medium); }
.dd-leg-icon--low     { color: var(--dd-sev-low); }
.dd-leg-icon--minimal { color: var(--dd-sev-minimal); }
.dd-leg-val { margin-left: auto; color: #1e293b; }

/* Chart toggle button — inside panel */
.dd-chart-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 9px 14px;
  background: none;
  border: none; border-top: 1px solid var(--dd-border);
  cursor: pointer; font-size: 0.68rem; font-weight: 600;
  color: var(--dd-accent); gap: 6px;
  transition: background 0.14s;
  text-align: center;
}
.dd-chart-toggle:hover { background: var(--dd-accent-soft); }

/* ── AGE/SEX CHART PANEL ── */
.dd-chart-panel {
  position: absolute;
  left: 12px; bottom: 24px;
  width: clamp(300px, 38vw, 500px);
  z-index: 450;
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--dd-border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  max-height: 320px;
}
.dd-chart-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 8px; border-bottom: 1px solid var(--dd-border); flex-shrink: 0;
}
.dd-chart-title { font-size: 0.7rem; font-weight: 700; color: #1e293b; }
.dd-chart-close {
  background: none; border: none; cursor: pointer;
  color: var(--dd-muted); font-size: 0.8rem; padding: 2px 6px;
  border-radius: 4px; transition: background 0.12s;
}
.dd-chart-close:hover { background: #f1f5f9; color: #1e293b; }
.dd-chart-body { padding: 10px 14px 4px; flex: 1; overflow: hidden; }
.dd-chart-body canvas { width: 100% !important; display: block; }
.dd-chart-legend {
  display: flex; flex-wrap: wrap; gap: 5px 10px;
  padding: 6px 14px 10px; flex-shrink: 0;
}
.dd-cl-item { display: flex; align-items: center; gap: 5px; font-size: 0.6rem; color: var(--dd-muted); }
.dd-cl-dot  { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* Sex dot in filter options */
.dd-sex-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  display: inline-block; margin-right: 2px;
}

.dd-nationwide-fixed {
  position: absolute; right: 16px; bottom: 16px; z-index: 40;
  background: rgba(255,255,255,0.98);
  border: 2px solid var(--dd-sev-low);
  border-radius: 6px;
  padding: 8px 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  pointer-events: none;
  transition: left 0.18s ease, top 0.18s ease;
}
/* Floating mode — box moved next to the hovered/pinned state marker via inline left/top (desktop only, set in JS) */
.dd-nationwide-fixed.dd-nw-floating {
  right: auto; bottom: auto;
  transform: translateY(calc(-100% - 16px));
}
.dd-nw-label {
  font-size: 1rem; letter-spacing: 1px; text-transform: uppercase;
  color: var(--dd-sev-low);
  display: flex; align-items: center; gap: 5px;
}
.dd-nw-pin {
  display: inline-block; width: 10px; height: 14px; flex-shrink: 0;
  background-image: url(../images/map-pin.png);
  background-size: contain; background-repeat: no-repeat; background-position: center;
}
.dd-nw-value {
  font-size:2.5rem; font-weight: 700; color: var(--dd-accent); line-height: 1.2;
}
.dd-corner-decor {
  position: absolute; left: 0; bottom: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: flex-start;
  pointer-events: none;
  max-width: calc(100% - 210px);
}
.dd-mosquito-decor {
  pointer-events: none;
  width: 280px;
  height: 231px; /* matches source artwork aspect ratio (428x353) */
  background-image: url(../images/mosquito.png);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: left top;
  margin: -8px 0 -95px 4px; /* pulls the note up so the dashed tail runs behind it */
}

.dd-map-note {
  position: relative; /* establishes paint order above the mosquito artwork */
  padding: 8px 12px 16px 16px;
  line-height: 1.4;
  color: #1e293b;
  overflow-wrap: break-word;
  pointer-events: auto;
}
.dd-map-note p { margin: 0 0 6px; }
.dd-map-note p:last-child { margin-bottom: 0; }
.dd-map-note a { color: var(--dd-accent); }

@media (max-width: 900px) {
  .dd-corner-decor { bottom: 43%; max-width: calc(100% - 210px); }
  .dd-mosquito-decor { transform: scale(0.65); transform-origin: left top; margin: -8px 0 -155px 4px; }
}
@media (max-width: 480px) {
  .dd-mosquito-decor { display: none; }
  .dd-map-note { padding-top: 8px; }
}

/* ── TOUCH/HOVER HINT — moved above the Nationwide box ── */
.dd-touch-hint {
  position: absolute; right: 16px; bottom: 76px; z-index: 40;
  width: 44px; height: 44px;
  background-image: url(../images/hand-tap.png);
  background-size: contain; background-repeat: no-repeat; background-position: center;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.12));
  animation: dd-hint-tap 1.8s ease-in-out infinite;
}
@keyframes dd-hint-tap { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }
@media (max-width: 900px) {
  .dd-touch-hint { bottom: 68px; }
}

/* ── LOADING ── */
.dd-loading {
  position: absolute; inset: 0; z-index: 900;
  background: rgba(241,245,249,0.88);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.dd-loading.hidden { display: none; }
.dd-loading-inner {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  font-size: 0.72rem; color: var(--dd-muted); letter-spacing: 1px;
}
.dd-spinner {
  width: 32px; height: 32px; border: 3px solid #e2e8f0;
  border-top-color: var(--dd-accent); border-radius: 50%;
  animation: dd-spin 0.8s linear infinite;
}

@media (max-width: 900px) {
  .dd-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .dd-info-panel {
    position: static;
    width: auto;
    max-width: none;
    margin: 12px 12px 0;
    flex: 0 1 auto;
    max-height: 42%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .dd-map {
    position: relative;
    left: 0; right: 0; top: 0; bottom: 0;
    flex: 1 1 auto;
    min-height: 220px; /* safety floor only — flex-grow does the real sizing */
    margin-top: 12px;
  }
  .dd-chart-panel {
    left: 12px; right: 12px; bottom: 12px;
    width: auto;
  }
  .dd-nationwide-fixed { top: 0; right: 12px; padding: 6px 12px; height: 70px;}
  .dd-nw-value { font-size: 1.8rem; text-align: left;}
}
@media (max-width: 480px) {
  .dd-info-panel { margin: 8px 8px 0; max-height: 26%; position: absolute; top: 70%; width: 90%;}
  .dd-map        { margin-top: -70%; }
  .dd-corner-decor {
    bottom: 30%;
    max-width: 100%;
  }
  .dd-map-note {
    font-size: 12px;
  }
  .dengue-dashboard-wrap.dd-is-block {
    height: calc(100vh - var(--dd-offset-top, 0px));
    min-height: 710px;
  }
}

/* ── GEO TOOLTIP (choropleth hover) ── */
.leaflet-tooltip.dd-geo-tooltip {
  background: #fff;
  border: 2px solid var(--dd-tooltip-border);
  border-radius: 2px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  padding: 14px 17px;
  pointer-events: none;
  min-width: 170px;
}
.leaflet-tooltip.dd-geo-tooltip::before { display: none !important; }

/* Tooltip content styles — callout box: pin + STATE name + big number */
.leaflet-tooltip.dd-geo-tooltip .dd-popup-state {
  font-size: 0.85rem; font-weight: 700; letter-spacing: 0.5px;
  color: var(--dd-tooltip-border); line-height: 1; margin-bottom: 8px;
  text-transform: uppercase; display: flex; align-items: center; gap: 5px;
}
.leaflet-tooltip.dd-geo-tooltip .dd-popup-state::before {
  content: ""; display: inline-block; width: 12px; height: 16px;
  background-image: url(../images/map-pin.png);
  background-size: contain; background-repeat: no-repeat; background-position: center;
}
.leaflet-tooltip.dd-geo-tooltip .dd-popup-full { display: none; }
.leaflet-tooltip.dd-geo-tooltip .dd-popup-count {
  display: flex; align-items: baseline; gap: 5px; margin-bottom: 0;
}
.leaflet-tooltip.dd-geo-tooltip .dd-popup-num {
  font-size: 2.3rem; color: var(--dd-tooltip-num); line-height: 1; font-weight: 800;
}
.leaflet-tooltip.dd-geo-tooltip .dd-popup-unit { display: none; }
.leaflet-tooltip.dd-geo-tooltip .dd-popup-info { display: none; }
.leaflet-tooltip.dd-geo-tooltip .dd-popup-nodata {
  font-size: 0.72rem; color: #94a3b8; font-style: italic;
}

/* Smaller popup proportions on mobile/tablet — narrow screens can't fit the
   desktop sizing without clipping off the edge */
@media (max-width: 900px) {
  .leaflet-tooltip.dd-geo-tooltip {
    padding: 9px 12px;
    min-width: 120px;
    max-width: 60vw;
    border-width: 1.5px;
  }
  .leaflet-tooltip.dd-geo-tooltip .dd-popup-state {
    font-size: 0.68rem;
    margin-bottom: 4px;
  }
  .leaflet-tooltip.dd-geo-tooltip .dd-popup-state::before {
    width: 9px; height: 12px;
  }
  .leaflet-tooltip.dd-geo-tooltip .dd-popup-num {
    font-size: 1.5rem;
  }
}
@media (max-width: 480px) {
  .leaflet-tooltip.dd-geo-tooltip {
    padding: 7px 10px;
    min-width: 100px;
  }
  .leaflet-tooltip.dd-geo-tooltip .dd-popup-state { font-size: 0.6rem; }
  .leaflet-tooltip.dd-geo-tooltip .dd-popup-num   { font-size: 1.25rem; }
  .dd-touch-hint {
    position: absolute; right: 16px; top: 10px; z-index: 40;
  }
}

/* Hide zoom control (map is locked on all screen sizes) */
.dd-map .leaflet-control-zoom { display: none !important; }

/* Smooth GeoJSON state transitions */
.leaflet-interactive { transition: fill-opacity 0.15s ease; }
