/* === FedACT Companion Site — Design System === */

:root {
  --bg: #fbfaf7;
  --bg-elevated: #ffffff;
  --ink: #15212e;
  --ink-soft: #3a4a5c;
  --ink-muted: #6b7785;
  --rule: #e3e0d8;
  --upstream: #1f3a52;
  --midmarket: #4a7396;
  --downstream: #7aa6cc;
  --feedback: #16a085;
  --accent: #c8392c;
  --accent-dim: #a82e22;
  --gold: #c8a62e;
  --gold-bg: #fdf8e8;
}

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

html {
  scroll-behavior: smooth;
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Newsreader', Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
}

/* === Typography === */

.font-ui, label, .slider-label, .readout-label, .btn, .chapter-foot, .cover-eyebrow, .chapter-num, .pillar-num, .plain-label, .cover-abstract-label {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.font-mono, .readout-value, .metric-number, code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

h1, h2, h3, h4 { font-weight: 500; line-height: 1.2; }

/* === NAV === */

#nav { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; background: var(--bg); border-bottom: 1px solid var(--rule); padding: 0 2rem; display: flex; align-items: center; height: 52px; gap: 1.5rem; }
#nav-title { font-family: 'Inter', sans-serif; font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nav-progress { flex: 1; height: 3px; background: var(--rule); border-radius: 2px; }
#nav-progress-bar { height: 100%; background: var(--accent); border-radius: 2px; width: 0; transition: width 0.1s linear; }

/* === Chapter Rail === */

#chapter-rail { position: fixed; left: 2rem; top: 50%; transform: translateY(-50%); z-index: 999; display: flex; flex-direction: column; gap: 1.2rem; }
.rail-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rule); cursor: pointer; transition: all 0.25s; position: relative; }
.rail-dot.active { background: var(--accent); transform: scale(1.5); }
.rail-dot:hover { background: var(--ink-muted); }
.rail-dot .rail-label { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); white-space: nowrap; font-family: 'Inter', sans-serif; font-size: 0.65rem; color: var(--ink-muted); opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.rail-dot:hover .rail-label, .rail-dot.active .rail-label { opacity: 1; }

@media (max-width: 1100px) { #chapter-rail { display: none; } }

/* === Sections === */

.chapter {
  max-width: 920px;
  margin: 0 auto;
  padding: 7rem 2rem 5rem;
  border-bottom: 1px solid var(--rule);
}

.chapter-num {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.chapter h2 {
  font-size: 2.4rem;
  margin-bottom: 1rem;
  color: var(--ink);
  line-height: 1.15;
}

.chapter-lede {
  font-size: 1.25rem;
  line-height: 1.55;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 2rem;
  max-width: 780px;
}

/* === Cover Page === */

.cover { border-bottom: none; padding-top: 6rem; padding-bottom: 4rem; }
.cover-inner { display: flex; flex-direction: column; align-items: center; text-align: center; }

.cover-eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

.cover-title {
  font-size: 2.8rem;
  line-height: 1.18;
  margin-bottom: 1.5rem;
  max-width: 800px;
  font-weight: 500;
  color: var(--ink);
}

.cover-title em { font-style: italic; color: var(--accent); }

.cover-byline {
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-bottom: 3rem;
  line-height: 1.6;
}

.cover-byline .muted { color: var(--ink-muted); font-size: 0.82rem; }

/* cover-abstract block */
.cover-abstract {
  text-align: left;
  max-width: 780px;
  background: var(--gold-bg);
  border-left: 4px solid var(--gold);
  padding: 1.8rem 2rem;
  margin: 0 auto 3rem;
  border-radius: 0 6px 6px 0;
}

.cover-abstract-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1rem;
  font-weight: 600;
}

.cover-abstract p {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--ink-soft);
  margin-bottom: 1rem;
}

.cover-abstract p:last-child { margin-bottom: 0; }

/* pillar cards */
.cover-pillars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 840px;
  width: 100%;
}

.pillar {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.8rem 1.5rem;
  text-align: left;
  transition: box-shadow 0.25s;
}

.pillar:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }

.pillar-num {
  font-family: 'Inter', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

.pillar h4 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--ink);
}

.pillar p {
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.55;
}

@media (max-width: 720px) {
  .cover-pillars { grid-template-columns: 1fr; }
  .cover-title { font-size: 2rem; }
}

/* === Plain-English Cards === */

.plain-card {
  background: var(--gold-bg);
  border-left: 4px solid var(--gold);
  padding: 1.5rem 1.8rem;
  border-radius: 0 6px 6px 0;
  margin: 2rem 0;
}

.plain-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.plain-card p {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
}

.plain-card p:last-child { margin-bottom: 0; }

/* === Equation Block === */

.equation-block {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.5rem 2rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}

.equation-block .katex-display { margin: 0.5rem 0; }

/* === Interactive Section === */

.interactive-section {
  margin: 2rem 0;
}

.control-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
  margin-bottom: 1.5rem;
}

.control-group {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem 1.2rem;
}

.control-group label {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.control-group input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.control-group input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.control-group .range-value {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--accent);
  margin-left: 0.5rem;
  min-width: 2.5em;
}

/* === Readout Cards === */

.readout-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.readout-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem;
  text-align: center;
}

.readout-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.readout-value {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink);
}

/* === Charts === */

.chart-container {
  width: 100%;
  min-height: 380px;
  margin: 1.5rem 0;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

/* === Callout === */

.callout {
  background: var(--bg-elevated);
  border-left: 4px solid var(--accent);
  padding: 1.5rem 1.8rem;
  border-radius: 0 6px 6px 0;
  margin: 2rem 0;
}

.callout p {
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink-soft);
  font-style: italic;
}

.callout p em { font-style: normal; color: var(--accent); font-weight: 500; }

/* === Chapter Footer === */

.chapter-foot {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--ink-muted);
  text-decoration: none;
  margin-top: 2rem;
  transition: color 0.2s;
}

.chapter-foot:hover { color: var(--accent); }

.chapter-foot .arrow {
  display: inline-block;
  transition: transform 0.25s;
}

.chapter-foot:hover .arrow { transform: translateX(6px); }

/* === Footnote === */

.footnote { font-size: 0.78rem; color: var(--ink-muted); margin-top: 0.5rem; font-style: italic; }

/* === Buttons === */

.btn {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 1.2rem;
  border-radius: 4px;
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }

.btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 1rem 0; }

/* === Strategy Cards === */

.strategy-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 1.5rem 0; }

.strategy-card {
  background: var(--bg-elevated);
  border: 2px solid var(--rule);
  border-radius: 8px;
  padding: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.strategy-card:hover { border-color: var(--midmarket); }

.strategy-card.selected { border-color: var(--accent); background: #fdf2f1; }

.strategy-card h4 { font-family: 'Inter', sans-serif; font-size: 0.85rem; color: var(--ink); margin-bottom: 0.3rem; }

.strategy-card p { font-size: 0.78rem; color: var(--ink-muted); }

/* === Architecture Diagram === */

.svg-diagram {
  width: 100%;
  max-width: 800px;
  margin: 2rem auto;
  display: block;
}

/* === Table === */

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.82rem;
}

.data-table th, .data-table td {
  padding: 0.6rem 0.8rem;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}

.data-table th {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 600;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table .highlight { color: var(--accent); font-weight: 600; }

/* === Metric highlight === */

.metric-highlight { color: var(--accent); font-weight: 600; }

/* Plotly override */
.js-plotly-plot .plotly .main-svg { background: transparent !important; }
.js-plotly-plot .plotly .bg { fill: transparent !important; }

/* === Responsive === */

@media (max-width: 720px) {
  .chapter { padding: 5rem 1.2rem 3rem; }
  .chapter h2 { font-size: 1.7rem; }
  .chapter-lede { font-size: 1.05rem; }
  .cover-title { font-size: 2rem; }
  .control-row { grid-template-columns: 1fr; }
  .readout-row { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}

/* Print hide nav */
@media print {
  #nav, #chapter-rail { display: none; }
  .chapter { break-inside: avoid; }
}
