/* Drivers section: noise vs Quietcation Score scatter (Wave 2 rework, Wave 10 storytelling pass). */

.drivers-section { background: transparent; }

.drivers-section .drivers-intro { max-width: 64ch; margin-bottom: 32px; }
.drivers-section .drivers-lead { max-width: 60ch; }

.drivers-tabs {
  display: inline-flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin: 0;
  position: relative;
}

.drivers-tab {
  padding: 10px 18px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-responsive),
              background var(--dur-fast) var(--ease-responsive),
              border-color var(--dur-fast) var(--ease-responsive);
  position: relative;
  white-space: nowrap;
  text-align: left;
}

.drivers-tab:hover { color: var(--ink); }
.drivers-tab.is-active { color: var(--brand-navy); font-weight: 600; }
.drivers-tab:focus-visible {
  outline: 2px solid var(--brand-sky);
  outline-offset: 2px;
  border-radius: 4px;
}

.drivers-tab .meta { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.drivers-tab .name { font-family: var(--font-display); font-weight: 500; font-size: 0.95rem; color: var(--ink-soft); }
.drivers-tab.is-active .name { color: var(--brand-navy); font-weight: 600; }
.drivers-tab .weight { display: none; font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); font-weight: 500; }
.drivers-tab .corr-line { display: none; align-items: center; gap: 14px; margin-top: 8px; }
.drivers-tab .corr-text { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); min-width: 64px; flex: 0 0 auto; }
.drivers-tab .corr-bar { flex: 1 1 auto; min-width: 40px; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.drivers-tab .corr-bar-fill { display: block; height: 100%; background: var(--ink-soft); border-radius: 2px; }
.drivers-tab.is-active .corr-bar-fill { background: var(--brand-sky); }

.drivers-tabs .tab-underline {
  position: absolute;
  bottom: -1px;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--brand-sky);
  transition: transform 220ms var(--ease-responsive), width 220ms var(--ease-responsive);
  transform: translateX(0);
  pointer-events: none;
}

/* Desktop sidebar layout: tabs become a vertical column on the left of the chart. */
@media (min-width: 920px) {
  .drivers-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 36px;
    align-items: start;
    margin-top: 8px;
  }
  .drivers-tabs {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: none;
    border-right: 1px solid var(--line);
    padding-right: 16px;
  }
  .drivers-tabs .tab-underline { display: none; }
  .drivers-tab {
    padding: 14px 14px 14px 18px;
    border-radius: 0;
    border-left: 3px solid transparent;
  }
  .drivers-tab:hover { background: rgba(46, 123, 232, 0.04); }
  .drivers-tab.is-active {
    border-left-color: var(--brand-sky);
    background: var(--brand-sky-soft);
  }
  .drivers-tab .name { font-size: 1rem; }
  .drivers-tab .weight { display: inline; }
  .drivers-tab .corr-line { display: flex; }
}

/* Takeaway aside: a fade-swap card below the chart that updates per tab. */
.drivers-takeaway {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand-sky);
  border-radius: 14px;
  padding: 22px 26px;
  margin-top: 24px;
  max-width: 780px;
  transition: opacity 220ms var(--ease-responsive);
}
.drivers-takeaway.is-fading { opacity: 0; }
.drivers-takeaway-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 6px;
  letter-spacing: 0.02em;
}
.drivers-takeaway-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--brand-navy);
  margin: 0 0 8px;
  line-height: 1.2;
}
.drivers-takeaway-body {
  font-family: var(--font-body);
  font-size: 0.98rem;
  color: var(--ink);
  line-height: 1.55;
  margin: 0;
}

/* Selected dot: clear ring + lift so the click feedback is unmistakable. */
.drivers-chart .dot.is-selected {
  stroke: var(--brand-navy);
  stroke-width: 2;
  r: 8;
  filter: drop-shadow(0 2px 6px rgba(15, 27, 51, 0.18));
}

/* Popover: anchored card that appears next to the clicked dot.
   Gives the click a visible payoff (city name, country, the active metric
   value, official score, rank, and a Stasher CTA). */
.drivers-popover {
  position: absolute;
  z-index: 5;
  min-width: 240px;
  max-width: 280px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px 16px;
  box-shadow: 0 10px 28px rgba(15, 27, 51, 0.14), 0 2px 6px rgba(15, 27, 51, 0.06);
  font-family: var(--font-body);
  animation: drivers-popover-in 220ms var(--ease-stately) both;
}
@keyframes drivers-popover-in {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.drivers-popover[hidden] { display: none; }
.drivers-popover .dp-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.drivers-popover .dp-close:hover { background: rgba(15, 27, 51, 0.06); color: var(--ink); }
.drivers-popover .dp-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}
.drivers-popover .dp-country {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 2px 0 14px;
}
.drivers-popover .dp-stats {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}
.drivers-popover .dp-stats > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.drivers-popover .dp-stats > div:first-child { border-top: none; padding-top: 0; }
.drivers-popover .dp-stats dt {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
}
.drivers-popover .dp-stats dd {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--brand-navy);
  margin: 0;
}
.drivers-popover .dp-cta {
  display: inline-block;
  width: 100%;
  text-align: center;
  background: var(--brand-navy);
  color: #ffffff;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: 999px;
  transition: background var(--dur-fast) var(--ease-responsive);
}
.drivers-popover .dp-cta:hover { background: var(--brand-navy-deep); }

@media (max-width: 720px) {
  .drivers-popover { left: 12px !important; right: 12px !important; max-width: none; min-width: 0; top: auto !important; bottom: 12px; }
}

.drivers-chart { width: 100%; display: block; }
.drivers-chart .axis-baseline { stroke: rgba(15, 27, 51, 0.06); stroke-width: 1; }
.drivers-chart .axis-tick-label {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 11px;
  fill: var(--muted);
  letter-spacing: 0.02em;
}
.drivers-chart .axis-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  fill: var(--ink-soft);
}
.drivers-chart .quadrant-good { fill: rgba(46, 123, 232, 0.04); }
.drivers-chart .quadrant-bad { fill: rgba(176, 67, 42, 0.04); }
.drivers-chart .regression {
  stroke: var(--ink-soft);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  opacity: 0.4;
  fill: none;
}
.drivers-chart .dot {
  transition: r var(--dur-fast) var(--ease-responsive), opacity var(--dur-fast) var(--ease-responsive);
  cursor: pointer;
}
.drivers-chart .dot.is-landmark { stroke: var(--paper); stroke-width: 1.5; }
.drivers-chart .dot-halo {
  fill: var(--brand-sky);
  opacity: 0;
  transition: opacity 180ms ease, r 180ms ease;
  pointer-events: none;
}
.drivers-chart .dot-halo.is-active { opacity: 0.18; }
.drivers-chart .leader { stroke: var(--ink); stroke-width: 1; opacity: 0.5; }
.drivers-chart .label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  fill: var(--ink);
  paint-order: stroke fill;
  stroke: var(--paper);
  stroke-width: 4;
  stroke-linejoin: round;
  pointer-events: none;
}
.drivers-chart .label.is-emphasis { fill: var(--brand-sky); }
.drivers-chart .corr-chip { fill: var(--paper-2); stroke: var(--line); }
.drivers-chart .corr-chip-text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  fill: var(--ink);
}
.drivers-chart .corr-chip-meta {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.66rem;
  fill: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.drivers-chart .corr-bar-bg { fill: var(--line); }
.drivers-chart .corr-bar { fill: var(--brand-sky); }

@media (max-width: 919px) {
  .drivers-layout { display: block; }
  .drivers-tabs {
    display: flex;
    flex-direction: row;
    gap: 0;
    overflow-x: auto;
    padding-right: 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    flex-wrap: nowrap;
  }
  .drivers-tab {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
  }
  .drivers-tab.is-active {
    border-bottom-color: var(--brand-sky);
    background: transparent;
    border-left-color: transparent;
  }
}

@media (max-width: 720px) {
  .drivers-chart .label { font-size: 10px; }
  /* On narrow viewports the absolute landmark labels were clipping past
     the right edge. Pad the chart shell so the labels can sit inside. */
  .drivers-section .chart-shell.driver-shell { padding: 14px 10px; }
  .drivers-section .driver-shell svg { overflow: visible; }
}
