/**
 * Madison Equity Data — Equity Atlas (S2, PIP-77) — surface CSS
 * ------------------------------------------------------------------
 * Page-specific rules only. Header/footer/toggle/tier-chip-base come
 * from shared/shell.css + shared/tier.css (imported before this file
 * in <head> per components.md §1 import order).
 * ------------------------------------------------------------------ */

/* ── Layout shell ── */
.atlas-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--sp-6);
  align-items: start;
  padding-top: var(--sp-6);
}
.atlas-main { min-width: 0; }
.atlas-side { position: sticky; top: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }

/* ── Index/story intro strip ── */
.atlas-intro {
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--rule-light);
  margin-bottom: var(--sp-4);
}
.atlas-intro h1 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  margin-bottom: var(--sp-2);
}
.atlas-intro .lede {
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh-relaxed);
  color: var(--ink-mid);
  max-width: var(--max-reading);
}
.atlas-intro .index-note {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--slate);
  margin-top: var(--sp-3);
}

/* ── Three-dial control bar — always visible, Opportunity-Atlas
   pattern (research brief STEAL). Native <select>s for a11y + mobile
   robustness (avoids the radio-list mobile overflow bug the reference
   walkthrough documented on opportunityatlas.org). ── */
.dial-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--paper-raised);
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-4);
}
.dial {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  flex: 1 1 180px;
  min-width: 160px;
}
.dial label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--slate);
}
.dial select {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--motion-quick);
}
.dial select:hover { border-color: var(--accent); }
.dial select:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.dial select:disabled,
.dial select option:disabled { color: var(--slate); }

/* ── Current-layer chrome (title + desc + tier chip above the map) ── */
.current-layer-chrome {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
}
.current-layer-chrome h2 {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  margin: 0;
}
.current-layer-chrome .desc {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--ink-mid);
  flex-basis: 100%;
  margin: 0;
  max-width: var(--max-reading);
}
.index-drill-note {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  color: var(--slate);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.index-drill-note a { font-weight: var(--fw-semibold); }

/* ── Map wrapper + SVG choropleth ── */
.map-wrap {
  position: relative;
  background: var(--parchment);
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 420px;
}
.map-wrap[aria-busy="true"] { opacity: 0.6; }
svg.choropleth {
  display: block;
  width: 100%;
  height: auto;
  max-height: 620px;
}
path.tract {
  stroke: var(--paper-raised);
  stroke-width: 0.6;
  cursor: pointer;
  transition: stroke-width var(--motion-quick), stroke var(--motion-quick);
}
path.tract:hover,
path.tract:focus-visible {
  stroke: var(--ink);
  stroke-width: 1.6;
  outline: none;
}
path.tract:focus-visible {
  stroke: var(--focus-ring);
  stroke-width: 2;
}
path.tract--selected {
  stroke: var(--ink);
  stroke-width: 2.4;
}
path.tract--nodata {
  cursor: default;
}
path.tract-underlay { stroke: none; }

.map-footnote {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--slate);
  border-top: 1px solid var(--rule-light);
  background: var(--paper-raised);
}

.atlas-error {
  padding: var(--sp-8);
  font-family: var(--font-ui);
  color: var(--danger);
  text-align: center;
}

/* ── Tier legend card (full 5-tier, S2's job per components.md §7a) ── */
.legend-card.tier-legend { margin: 0; }

/* ── Tract card — shareable/citable, paper-raised + shadow per
   DESIGN-NOTES.md §5 "Tract cards / embed-by-link" table row. ── */
.tract-card {
  background: var(--paper-raised);
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--sp-6);
  position: relative;
}
.tract-card-close {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  background: none;
  border: none;
  font-size: var(--fs-lg);
  line-height: 1;
  color: var(--slate);
  cursor: pointer;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
}
.tract-card-close:hover { color: var(--ink); background: var(--parchment); }
.tract-card-close:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.tract-card h3 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  margin: 0 var(--sp-8) var(--sp-2) 0;
}
.tract-card h3:focus-visible { outline: none; }
.tract-card-value {
  font-family: var(--font-ui);
  font-size: var(--fs-data-xl);
  font-weight: var(--fw-bold);
  color: var(--ink);
  margin: var(--sp-2) 0;
  line-height: 1;
}
.tract-card-sentence {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
  color: var(--ink-mid);
  margin-bottom: var(--sp-3);
}
.tract-card-tier { margin-bottom: var(--sp-4); }
.tract-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--rule-light);
}
.tract-card-actions .btn,
.tract-card-actions button {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}
.tract-card-actions .btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink-inverse-text-2);
}
.tract-card-actions .btn--primary:hover { background: var(--accent-hover); }
.tract-card-actions .btn:hover { border-color: var(--accent); color: var(--accent); }
.tract-card-actions button:focus-visible,
.tract-card-actions .btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}
.tract-card-deeplink-row {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  margin-top: var(--sp-3);
}
.tract-card-deeplink-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  background: var(--parchment);
  color: var(--ink-mid);
}
.tract-card-poll-note {
  margin-top: var(--sp-4);
  padding: var(--sp-3);
  background: var(--parchment);
  border: 1px dashed var(--rule);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  color: var(--ink-mid);
}

/* ── Compare panel ── */
.compare-panel {
  background: var(--paper-raised);
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-6);
  margin-top: var(--sp-4);
}
.compare-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.compare-panel-header h2 {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  margin: 0;
}
.compare-kind-switch { display: flex; gap: var(--sp-2); }
.compare-kind-switch button {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-mid);
  cursor: pointer;
}
.compare-kind-switch button[aria-pressed="true"] {
  background: var(--accent-tint-2);
  border-color: var(--accent);
  color: var(--accent-hover);
  font-weight: var(--fw-semibold);
}
.compare-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
}
.compare-col {
  padding: var(--sp-4);
  background: var(--parchment);
  border-radius: var(--radius-sm);
  min-height: 140px;
}
.compare-col h3 {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  margin-bottom: var(--sp-1);
}
.compare-metric-name {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--slate);
  margin-bottom: var(--sp-2);
}
.compare-value {
  font-family: var(--font-ui);
  font-size: var(--fs-data-lg);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-2);
}
.compare-sentence {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--ink-mid);
  margin-top: var(--sp-2);
}
.compare-empty, .compare-hint {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  color: var(--slate);
  font-style: italic;
}
.compare-layer-select {
  width: 100%;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  margin-bottom: var(--sp-3);
}
.compare-close-btn {
  background: none;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: var(--sp-1) var(--sp-3);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
}

/* ── Side rail action buttons (compare toggle, methods toggle) ── */
.side-actions { display: flex; flex-direction: column; gap: var(--sp-2); }
.side-actions button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  padding: var(--sp-3) var(--sp-4);
  background: var(--paper-raised);
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  color: var(--ink);
  text-align: left;
}
.side-actions button:hover { border-color: var(--accent); }
.side-actions button[aria-pressed="true"],
.side-actions button[aria-expanded="true"] {
  background: var(--accent-tint);
  border-color: var(--accent);
}
.side-actions button:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

/* ── Docked methods/guide panel — persistent disclosure, never a
   blocking modal (Opportunity Atlas STEAL: always one click away). ── */
.methods-panel {
  background: var(--paper-raised);
  border: 1px solid var(--rule-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--sp-6);
  margin-top: var(--sp-4);
}
.methods-panel h2 {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-3);
}
.methods-panel h2:focus-visible { outline: none; }
.methods-panel h3 {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  margin-top: var(--sp-4);
  margin-bottom: var(--sp-1);
}
.methods-panel p, .methods-panel li {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
  color: var(--ink-mid);
}
.methods-panel ul { padding-left: var(--sp-6); margin-bottom: var(--sp-2); }
.methods-panel .methods-close {
  float: right;
  background: none;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: var(--sp-1) var(--sp-3);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
}
.methods-source-list {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--slate);
  line-height: 1.8;
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--rule-light);
}

/* ── Cross-link strip (charter: tract -> "which policies touch this
   tract?") ── */
.crosslink-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--rule-light);
}
.crosslink-card {
  flex: 1 1 240px;
  padding: var(--sp-4);
  background: var(--parchment);
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule-light);
}
.crosslink-card h3 {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  margin-bottom: var(--sp-1);
}
.crosslink-card p {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  color: var(--ink-mid);
  margin-bottom: var(--sp-2);
}
.crosslink-card a { font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: var(--fw-semibold); }

/* ── Visually-hidden live region ── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* ── Offline export banner (shown only in the standalone export) ── */
.offline-banner {
  background: var(--caution-tint);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: var(--sp-2) var(--sp-4);
  text-align: center;
  border-bottom: 1px solid var(--caution);
}

/* ── Responsive ── */
@media (max-width: 1080px) {
  .atlas-shell { grid-template-columns: 1fr; }
  .atlas-side { position: static; }
}
@media (max-width: 640px) {
  .dial-bar { flex-direction: column; }
  .dial { flex: 1 1 auto; }
  .compare-body { grid-template-columns: 1fr; }
  .tract-card-actions { flex-direction: column; }
  .tract-card-actions .btn, .tract-card-actions button { width: 100%; justify-content: center; }
}

@media print {
  .dial-bar, .side-actions, .compare-panel, .methods-panel { display: none; }
}
