/* style.css — Robert's Theorem
   Aesthetic: light, generous, mathematical elegance.
   Typography: body 1.25rem, headings up to 4rem. */

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

:root {
  --bg: #FAFAF8;
  --text: #1A1A1A;
  --text-mid: #4B5563;
  --text-light: #616875;   /* 5.0:1+ on every background it sits on */
  --blue: #2563EB;
  --blue-fade: rgba(37, 99, 235, 0.06);
  --green: #10B981;
  --green-dark: #047857;   /* text-safe green: 5.5:1 on white, 5.3:1 on --bg */
  --green-fade: rgba(16, 185, 129, 0.06);
  --amber: #F59E0B;
  --amber-dark: #B45309;   /* text-safe amber: 5.0:1 on white, 4.8:1 on --bg */
  --amber-fade: rgba(245, 158, 11, 0.06);
  --red: #EF4444;
  --red-fade: rgba(239, 68, 68, 0.06);
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.12);
  --card-bg: #FFFFFF;
  --section-alt: #F3F3EE;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  --font-display: Georgia, 'Times New Roman', serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 1.25rem;
  line-height: 1.85;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* --- Progress Bar --- */

#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--green), var(--amber));
  width: 0;
  z-index: 1000;
  transition: width 89ms linear;
}

/* --- Typography --- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}

h1 {
  font-size: clamp(3rem, 7vw, 4.5rem);
  font-weight: 300;
  margin-bottom: 0.6rem;
  letter-spacing: -0.03em;
}

h2 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 0.6rem;
}

h3 {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 600;
  font-family: var(--font);
  margin-bottom: 0.6rem;
}

p {
  margin-bottom: 1.4rem;
  color: var(--text-mid);
}

.section-subtitle {
  font-size: 1.35rem;
  line-height: 1.6;
  max-width: 640px;
  margin-bottom: 2rem;
  color: var(--text-mid);
  font-family: var(--font-display);
  font-style: italic;
}

strong { font-weight: 600; color: var(--text); }
em { font-style: italic; }

/* --- Sections --- */

.section {
  padding: 6rem 2rem;
  max-width: 960px;
  margin: 0 auto;
  position: relative;
}

.section-alt {
  background: linear-gradient(
    180deg,
    rgba(243, 243, 238, 0) 0%,
    var(--section-alt) 5%,
    var(--section-alt) 95%,
    rgba(243, 243, 238, 0) 100%
  );
}

.section-inner {
  max-width: 750px;
  margin: 0 auto;
}

/* --- Hero --- */

.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  position: relative;
  background:
    radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.02) 1px, transparent 0) 0 0 / 32px 32px,
    var(--bg);
}

.hero-content {
  max-width: 750px;
}

.hero h1 {
  margin-bottom: 0.4rem;
}

.hero .subtitle {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--text-light);
  margin-bottom: 2.5rem;
}

.scroll-hint {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-top: 3rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* --- Quote styling (Robert's text) --- */

.quote {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-style: italic;
  line-height: 1.8;
  color: var(--text);
  border-left: 4px solid var(--amber);
  padding: 1.5rem 2rem;
  margin: 2rem 0;
  background: rgba(245, 158, 11, 0.04);
  border-radius: 0 12px 12px 0;
}

.quote .attribution {
  display: block;
  font-style: normal;
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 500;
}

/* --- Insight Boxes --- */

.insight {
  border-left: 4px solid var(--blue);
  padding: 1.5rem 2rem;
  background: var(--blue-fade);
  border-radius: 0 12px 12px 0;
  margin: 2rem 0;
  font-size: 1.15rem;
}

.insight p { color: var(--text); margin-bottom: 0; }

.insight.green {
  border-color: var(--green);
  background: var(--green-fade);
}

.insight.amber {
  border-color: var(--amber);
  background: var(--amber-fade);
}

.insight.red {
  border-color: var(--red);
  background: var(--red-fade);
}

/* --- Cards --- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  margin: 1rem 0;
  transition: transform 377ms var(--ease), border-color 233ms ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
}

.card h3 {
  font-size: 1.3rem;
  margin-bottom: 0.4rem;
}

.card p {
  font-size: 1.1rem;
  color: var(--text-mid);
  margin-bottom: 0;
  line-height: 1.6;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
  margin: 2rem 0;
}

/* --- Formula Display --- */

.formula {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  background: #FFFFFF;
  padding: 2rem 2.5rem;
  border-radius: 12px;
  margin: 2rem 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  line-height: 2.2;
  letter-spacing: 0.01em;
}

.formula .correction {
  color: var(--amber);
  font-weight: 700;
  font-size: 1.25rem;
}

/* --- Canvas --- */

.canvas-container {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 2rem 0;
  background: var(--card-bg);
}

.canvas-container canvas {
  width: 100%;
  display: block;
}

/* Reserve each chart's height before JS draws it — zero layout shift.
   Values mirror the fixed heights viz.js assigns per pane. */
#problem-canvas    { height: 480px; }
#sufficient-canvas { height: 320px; }
#merge-canvas      { height: 400px; }
#cascade-canvas    { height: 520px; }
#stability-canvas  { height: 620px; }

/* Replay control under the cascade — the one interactive element. */
.viz-controls {
  text-align: center;
  margin: -0.8rem 0 0;
}
.viz-replay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 21px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-mid);
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 144ms ease, color 144ms ease, background-color 144ms ease;
}
.viz-replay:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-fade);
}
.viz-replay:active {
  background: rgba(37, 99, 235, 0.1);
}

/* --- Comparison Table --- */

.compare-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 1.1rem;
}

.compare-table th {
  text-align: left;
  padding: 0.8rem 1rem;
  border-bottom: 2px solid var(--border-strong);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mid);
}

.compare-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}

.compare-table .correct { color: var(--green-dark); font-weight: 600; }

/* --- Stat Indicators --- */

.stat-row {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin: 2rem 0;
}

.stat-item {
  flex: 1;
  min-width: 140px;
  text-align: center;
  padding: 1.2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card-bg);
}

.stat-item .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.stat-item .stat-label {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.3rem;
}

/* --- Timeline --- */

.timeline {
  position: relative;
  padding-left: 40px;
  margin: 2.5rem 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border-strong);
}

.timeline-item {
  position: relative;
  padding-bottom: 2rem;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 610ms var(--ease), transform 610ms var(--ease);
}

.timeline-item.visible {
  opacity: 1;
  transform: translateX(0);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -36px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border-strong);
  border: 2px solid var(--bg);
}

.timeline-item.foundation::before { background: var(--blue); }
.timeline-item.industry::before { background: var(--text-mid); }
.timeline-item.proof::before { background: var(--green); }

/* Robert's discovery — PROMINENT */
.timeline-item.discovery::before {
  background: var(--amber);
  width: 18px;
  height: 18px;
  left: -39px;
  top: 3px;
  border: 3px solid rgba(245, 158, 11, 0.35);
}

.timeline-item.discovery .timeline-year {
  font-size: 1.1rem;
  color: var(--amber-dark);
}

.timeline-item.discovery .timeline-event {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.timeline-item.discovery .timeline-who {
  font-size: 1rem;
  color: var(--amber-dark);
  font-weight: 500;
}

.timeline-year {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-mid);
  font-size: 0.9rem;
}

.timeline-event {
  font-size: 1.1rem;
  margin-top: 2px;
}

.timeline-who {
  font-size: 0.9rem;
  color: var(--text-light);
}

/* --- Code Block (Lean) with terminal chrome --- */

.lean-code {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.7;
  background: #1E293B;
  color: #E2E8F0;
  padding: 2.5rem 2rem 1.5rem;
  border-radius: 12px;
  overflow-x: auto;
  margin: 1.5rem 0;
  white-space: pre;
  position: relative;
}

.lean-code::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px 12px 0 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lean-code::after {
  content: '\25CF  \25CF  \25CF    Lean 4';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  padding: 7px 14px;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

.lean-code .keyword { color: #C084FC; }
.lean-code .type { color: #67E8F9; }
.lean-code .name { color: #86EFAC; }
.lean-code .comment { color: #94A3B8; }
.lean-code .tactic { color: #FDE047; }

/* --- Personal note from Tim --- */

#note-from-tim .section-inner {
  max-width: 640px;
}

#note-from-tim p {
  font-family: var(--font-display);
  font-size: 1.3rem;
  line-height: 1.9;
  color: var(--text-mid);
  margin-bottom: 1.2rem;
}

/* --- Scroll Reveal --- */

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 610ms var(--ease), transform 610ms var(--ease);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Counter --- */

.counter {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* --- Footer --- */

.footer {
  text-align: center;
  padding: 4rem 2rem;
  border-top: 1px solid var(--border);
}

.footer p:first-child {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text);
}

.footer a {
  color: var(--blue);
  text-decoration: none;
}

/* --- Responsive --- */

@media (max-width: 640px) {
  html,
  body {
    overflow-x: hidden;
  }

  .section {
    padding: 3rem 1.2rem;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .section-inner {
    max-width: 100%;
    min-width: 0;
  }

  .compare-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    font-size: 0.95rem;
  }

  .compare-table th,
  .compare-table td {
    padding: 0.7rem 0.75rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .stat-row {
    flex-direction: column;
    gap: 0.8rem;
  }

  .formula {
    font-size: 0.95rem;
    padding: 1.2rem 1.5rem;
  }

  .quote {
    font-size: 1.1rem;
    padding: 1rem 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { transition: none; opacity: 1; transform: none; }
  .timeline-item { transition: none; opacity: 1; transform: none; }
  #progress-bar { transition: none; }
  .card { transition: none; }
  .viz-replay { transition: none; }
}
/* v1775501381 */

/* Restoration polish: responsive charts, keyboard states, and calmer touch UI. */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

canvas,
svg {
  max-width: 100%;
}

button,
a,
input,
select {
  touch-action: manipulation;
}

.formula {
  max-width: 100%;
}

@media (hover: none) {
  .card:hover {
    transform: none;
  }
}

@media (max-width: 640px) {
  .hero {
    min-height: 88svh;
    padding: 3.5rem 1.2rem;
  }

  .footer {
    padding: 3rem 1.2rem;
  }
}
