/* ============================================================
   ComplianceIQ — Data Story (NYT-style)
   ============================================================ */

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface2: #f4f4f0;
  --border: #e5e5e0;
  --border2: #d4d4cf;
  --accent: #3b82f6;
  --accent2: #6366f1;
  --green: #10b981;
  --green-bg: rgba(16,185,129,0.08);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.06);
  --amber: #f59e0b;
  --amber-bg: rgba(245,158,11,0.07);
  --text: #1a1a1a;
  --text2: #4a4a4a;
  --text3: #8a8a8a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ---- STICKY NAV ---- */
.story-nav {
  position: fixed;
  top: 0;
  left: 0; right: 0;
  z-index: 100;
  background: rgba(250,250,247,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  height: 52px;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}
.nav-back {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.2s;
}
.nav-back:hover { opacity: 0.7; }
.nav-brand {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.story-demo-toggle {
  margin-left: auto;
}
.nav-progress-track {
  flex: 1;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.nav-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width 0.1s;
}

/* ---- HERO ---- */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 32px 60px;
  position: relative;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(59,130,246,0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(99,102,241,0.04) 0%, transparent 60%);
}
.hero-content { max-width: 720px; }
.hero-kicker {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}
.hero-title {
  font-family: 'Playfair Display', 'DM Serif Display', serif;
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 24px;
  letter-spacing: -1px;
}
.hero-subtitle {
  font-size: 19px;
  color: var(--text2);
  line-height: 1.7;
  max-width: 600px;
  margin: 0 auto 28px;
  font-weight: 300;
}
.hero-subtitle strong {
  font-weight: 600;
  color: var(--text);
}
.hero-meta {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 48px;
}
.hero-byline, .hero-date {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.5px;
}
.hero-date::before {
  content: '·';
  margin-right: 20px;
}

/* School score cards in hero */
.hero-schools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
}
.hero-school-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  transition: transform 0.3s, box-shadow 0.3s;
}
.hero-school-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.08);
}
.school-score-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--green-bg);
  color: var(--green);
  border: 2px solid var(--green);
}
.school-score-circle.wm-score {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: var(--amber);
}
.school-info-text { text-align: left; }
.school-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.school-card-loc {
  font-size: 12px;
  color: var(--text3);
  font-family: 'DM Mono', monospace;
}
.hero-vs {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  color: var(--text3);
  font-style: italic;
}

/* Scroll cue */
.scroll-cue {
  position: absolute;
  bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text3);
  font-size: 12px;
  animation: bounce 2s ease-in-out infinite;
}
.scroll-arrow { font-size: 18px; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* ---- ARTICLE ---- */
.story-article {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 32px 80px;
}

/* Section spacing */
.story-section {
  padding: 80px 0 40px;
  border-bottom: 1px solid var(--border);
}
.story-section:last-child { border-bottom: none; }

/* Override for methodology which goes wider */
.methodology-section {
  max-width: none;
}

.section-label {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.section-title {
  font-family: 'Playfair Display', 'DM Serif Display', serif;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 28px;
  color: var(--text);
  letter-spacing: -0.5px;
}

.story-lead {
  font-size: 19px;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 20px;
  font-weight: 300;
}

.story-article p {
  font-size: 17px;
  line-height: 1.85;
  color: var(--text2);
  margin-bottom: 20px;
}
.story-article p strong {
  color: var(--text);
  font-weight: 600;
}
.story-article p em {
  font-style: italic;
}

/* Pull quotes */
.pullquote {
  margin: 48px 0;
  padding: 0 0 0 32px;
  border-left: 3px solid var(--accent);
  position: relative;
}
.pullquote-mark {
  font-family: 'Playfair Display', serif;
  font-size: 64px;
  color: rgba(59,130,246,0.15);
  position: absolute;
  top: -20px;
  left: 24px;
  line-height: 1;
}
.pullquote blockquote {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  line-height: 1.6;
  color: var(--text);
  font-style: italic;
  font-weight: 400;
}

/* ---- METHODOLOGY SECTION ---- */
.method-intro {
  display: flex;
  gap: 0;
  margin-bottom: 48px;
  position: relative;
}
.method-intro-accent {
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  border-radius: 4px;
  flex-shrink: 0;
  margin-right: 20px;
}
.method-intro-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.method-intro-body {
  font-size: 16px;
  color: var(--text2);
  line-height: 1.7;
  margin-bottom: 8px;
}
.method-intro-body strong { color: var(--text); font-weight: 600; }
.method-intro-sub {
  font-size: 14px;
  color: var(--text3);
  line-height: 1.7;
  font-style: italic;
}

/* Pipeline steps — single row, breaks out of narrow article */
.pipeline-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 0;
  flex-wrap: nowrap;
  justify-content: center;
  /* break out of the 780px article container */
  width: 100vw;
  max-width: 1140px;
  margin-left: 50%;
  transform: translateX(-50%);
}
button.pipe-step {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
}
.pipe-step {
  flex: 1 1 0;
  min-width: 0;
  max-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 18px;
  text-align: center;
  transition: all 0.3s;
  cursor: pointer;
  user-select: none;
}
.pipe-step:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(59,130,246,0.1);
  transform: translateY(-2px);
}
.pipe-step.active-step {
  border-color: var(--accent);
  background: rgba(59,130,246,0.05);
  box-shadow: 0 4px 20px rgba(59,130,246,0.12);
}
.pipe-step-num {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}
.pipe-step-desc {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.5;
}
.pipe-arrow {
  font-size: 18px;
  color: var(--text3);
  padding: 0 8px;
  flex-shrink: 0;
}

/* Pipeline Output Panel */
.pipeline-output {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s ease,
              margin 0.35s ease;
  margin: 0 0 0 0;
  /* match pipeline breakout width */
  width: 100vw;
  max-width: 1140px;
  margin-left: 50%;
  transform: translateX(-50%);
}
.pipeline-output.visible {
  max-height: 800px;
  opacity: 1;
  margin: 28px 0 48px 0;
  margin-left: 50%;
}
.pipe-output-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(0,0,0,0.04);
  animation: outputFadeIn 0.35s ease;
}
@keyframes outputFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.pipe-output-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.pipe-output-step-badge {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(59,130,246,0.08);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.18);
}
.pipe-output-title {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.pipe-output-body {
  padding: 20px;
}
.pipe-output-body p {
  font-size: 14px !important;
  color: var(--text2) !important;
  line-height: 1.7;
  margin-bottom: 14px !important;
}
.pipe-output-body p:last-child { margin-bottom: 0 !important; }
.pipe-output-body strong { color: var(--text); }

/* Output table */
.pipe-output-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 12px;
}
.pipe-output-table th {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text3);
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.pipe-output-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  vertical-align: top;
}
.pipe-output-table tr:last-child td { border-bottom: none; }
.pipe-output-table tr:hover td { background: rgba(59,130,246,0.02); }

/* Stat row in output */
.pipe-output-stats {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.pipe-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  flex: 1;
  min-width: 120px;
  text-align: center;
}
.pipe-stat-num {
  font-family: 'DM Serif Display', serif;
  font-size: 24px;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}
.pipe-stat-label {
  font-size: 11px;
  color: var(--text3);
  font-family: 'DM Mono', monospace;
}

/* Terminal-style output block */
.pipe-terminal {
  background: #0f1118;
  border-radius: 10px;
  padding: 14px 16px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  line-height: 1.9;
  color: #a0aab8;
  margin-top: 12px;
  overflow-x: auto;
}
.pipe-terminal .t-green { color: #10b981; }
.pipe-terminal .t-red { color: #ef4444; }
.pipe-terminal .t-blue { color: #3b82f6; }
.pipe-terminal .t-amber { color: #f59e0b; }
.pipe-terminal .t-dim { color: #4a5568; }

/* ---- CHART CARDS ---- */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  margin: 40px 0;
  overflow: visible;
  box-shadow: 0 2px 12px rgba(0,0,0,0.03);
}
.chart-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 18px 18px 0 0;
}
.chart-icon { font-size: 22px; }
.chart-title {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.chart-subtitle {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
  font-family: 'DM Mono', monospace;
}
.chart-badges {
  padding: 14px 24px 0;
  display: flex;
  gap: 8px;
}
.chart-badge {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 5px;
}
.state-badge {
  background: rgba(99,102,241,0.08);
  color: var(--accent2);
  border: 1px solid rgba(99,102,241,0.18);
}
.fed-badge {
  background: rgba(59,130,246,0.08);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.18);
}
.chart-area {
  padding: 24px;
  overflow-x: auto;
}

/* ---- INSIGHT BOX ---- */
.insight-box {
  border-left: 3px solid var(--accent);
  background: rgba(59,130,246,0.03);
  border-radius: 0 12px 12px 0;
  padding: 20px 24px;
  margin: 32px 0;
}
.insight-label {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 600;
}
.insight-box p {
  font-size: 15px !important;
  color: var(--text2) !important;
  margin-bottom: 0 !important;
  line-height: 1.7;
}
.insight-box p strong { color: var(--text); }

/* ---- IO ROW ---- */
.io-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 32px 0;
}
.io-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--surface);
}
.io-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px;
}
.io-label.output-label { color: var(--accent); }
.io-card p {
  font-size: 13px !important;
  color: var(--text2) !important;
  margin-bottom: 0 !important;
  line-height: 1.6;
}

/* ---- EVIDENCE LOG ---- */
.evidence-block {
  background: #0f1118;
  border-radius: 14px;
  overflow: hidden;
  margin: 32px 0;
}
.evidence-header {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #8892a4;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}
.evidence-log {
  padding: 16px 20px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  line-height: 2;
  color: #a0aab8;
  overflow-x: auto;
}
.log-line {
  white-space: nowrap;
  opacity: 0;
  animation: logFade 0.4s ease forwards;
}
.log-line:nth-child(1) { animation-delay: 0.2s; }
.log-line:nth-child(2) { animation-delay: 0.4s; }
.log-line:nth-child(3) { animation-delay: 0.6s; }
.log-line:nth-child(4) { animation-delay: 0.8s; }
.log-line:nth-child(5) { animation-delay: 1.0s; }
.log-line:nth-child(6) { animation-delay: 1.2s; }
.log-line:nth-child(7) { animation-delay: 1.4s; }
@keyframes logFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.log-ts { color: #6b7280; margin-right: 8px; }
.log-ok { color: var(--green); font-weight: 600; }
.log-fail { color: var(--red); font-weight: 600; }
.dimmed { opacity: 0.4 !important; }

/* ---- FAILURE CARDS ---- */
.failures-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin: 40px 0;
}
.failure-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.failure-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: 4px 0 0 4px;
}
.failure-card.fail-red::before { background: var(--red); }
.failure-card.fail-amber::before { background: var(--amber); }
.failure-card:hover {
  border-color: var(--border2);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  transform: translateY(-2px);
}
.failure-school {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}
.failure-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.failure-evidence {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 10px;
}
.failure-tag {
  display: inline-block;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 5px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.failure-tag.tag-red {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}
.failure-tag.tag-amber {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid rgba(245,158,11,0.2);
}

/* ---- TAKEAWAY GRID ---- */
.takeaway-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 40px 0;
}
.takeaway-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  transition: all 0.25s;
}
.takeaway-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(59,130,246,0.08);
}
.takeaway-num {
  font-family: 'DM Serif Display', serif;
  font-size: 38px;
  color: var(--accent);
  margin-bottom: 8px;
  line-height: 1;
}
.takeaway-text {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.65;
}

/* ---- CTA ---- */
.cta-block {
  text-align: center;
  margin: 52px 0 0;
}
.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(59,130,246,0.25);
  transition: all 0.3s;
}
.cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(59,130,246,0.3);
}

/* ---- FOOTER ---- */
.story-footer {
  border-top: 1px solid var(--border);
  padding: 24px 32px;
  background: var(--surface2);
}
.footer-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text3);
}

/* ---- D3 TOOLTIP ---- */
.tooltip {
  position: fixed;
  padding: 10px 14px;
  background: rgba(15,23,42,0.92);
  color: #e8ecf3;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  line-height: 1.5;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 300;
  max-width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.tooltip.visible { opacity: 1; }

/* D3 chart helpers */
.bar-label {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  fill: var(--text3);
}
.axis-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  fill: var(--text3);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1000px) {
  .nav-inner { gap: 12px; }
  .nav-progress-track { display: none; }
  .methodology-section {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
  }
}
@media (max-width: 768px) {
  .nav-brand { display: none; }
  .hero-schools { flex-direction: column; gap: 12px; }
  .hero-vs { display: none; }
  .pipeline-steps { flex-direction: column; gap: 8px; }
  .pipe-arrow { transform: rotate(90deg); }
  .io-row { grid-template-columns: 1fr; }
  .takeaway-grid { grid-template-columns: 1fr; }
  .failures-grid { grid-template-columns: 1fr; }
  .story-article { padding: 0 20px 60px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }

