@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@400;600;700&family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;600&display=swap');

:root {
  --bg: #f2ebe0;
  --ink: #1f2420;
  --ink-soft: #3a3f3b;
  --accent: #e0764b;
  --accent-dark: #b95f34;
  --teal: #3d6b73;
  --navy: #1f2b2f;
  --paper: #fff7ec;
  --line: #d8c9b2;
  --shadow: rgba(31, 43, 47, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Helvetica", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #f9f1e6 0%, #efe4d2 45%, #e4d5bf 100%);
  line-height: 1.6;
}

.noise {
  position: fixed;
  inset: 0;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120"><filter id="n"><feTurbulence baseFrequency="0.8" numOctaves="2" seed="2"/></filter><rect width="120" height="120" filter="url(%23n)" opacity="0.12"/></svg>');
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.4;
  z-index: 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 3rem;
  padding: 4.5rem 8vw 3rem;
  align-items: center;
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: clamp(2.5rem, 4vw, 4.2rem);
  line-height: 1.05;
  margin: 0.3rem 0 1rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-dark);
}

.lead {
  font-size: 1.1rem;
  color: var(--ink-soft);
  max-width: 38rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  margin: 2rem 0 1.5rem;
  flex-wrap: wrap;
}

.btn {
  background: var(--navy);
  color: #fdf4ea;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 12px 24px var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px var(--shadow);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.ghost {
  background: transparent;
  border: 2px solid var(--navy);
  color: var(--navy);
  box-shadow: none;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.2rem;
  margin-top: 1.5rem;
}

.metric {
  font-size: 2rem;
  font-weight: 700;
  display: block;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hero-graphic {
  background: var(--navy);
  padding: 1.5rem;
  border-radius: 28px;
  box-shadow: 0 18px 40px rgba(31, 43, 47, 0.4);
}

.hero-graphic svg {
  width: 100%;
  height: auto;
  display: block;
}

.legend {
  display: flex;
  justify-content: space-between;
  margin-top: 0.8rem;
  font-size: 0.75rem;
  color: #f5e7d5;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

main {
  padding: 0 8vw 5rem;
  position: relative;
  z-index: 1;
}

.section {
  padding: 3.5rem 0;
  border-top: 1px solid var(--line);
}

.section-head {
  max-width: 48rem;
  margin-bottom: 2.5rem;
}

.section h2 {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: clamp(2rem, 3vw, 3rem);
  margin: 0.5rem 0 1rem;
}

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

.card {
  background: var(--paper);
  border-radius: 22px;
  padding: 1.5rem;
  box-shadow: 0 12px 28px rgba(31, 43, 47, 0.12);
  border: 1px solid #eee0c8;
}

.card h3 {
  margin-top: 0;
  font-size: 1.3rem;
}

.card ul {
  padding-left: 1.1rem;
  margin: 0;
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2rem;
}

.stack {
  display: grid;
  gap: 1.5rem;
}

.pill {
  display: inline-block;
  background: #f5d1a0;
  color: #5b2e13;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.law {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2rem;
  align-items: center;
}

.law-panel {
  background: var(--navy);
  color: #fdf4ea;
  padding: 1.8rem;
  border-radius: 24px;
  box-shadow: 0 18px 32px rgba(31, 43, 47, 0.3);
}

.law-panel pre {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.8rem 1rem;
  border-radius: 12px;
  overflow-x: auto;
  color: #f5e7d5;
}

.law-diagram {
  background: #22353c;
  border-radius: 24px;
  padding: 1rem;
}

.law-diagram svg {
  width: 100%;
  height: auto;
}

.code-card {
  background: #1b2427;
  color: #f5e7d5;
  padding: 1.8rem;
  border-radius: 20px;
  box-shadow: 0 18px 32px rgba(31, 43, 47, 0.32);
}

.sim-panel {
  display: grid;
  gap: 1.5rem;
}

.sim-actions {
  display: flex;
  justify-content: flex-end;
}

.sim-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.sim-controls label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--ink-soft);
}

.sim-controls input,
.sim-controls select {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0.5rem 0.8rem;
  font-size: 0.95rem;
  background: var(--paper);
  color: var(--ink);
}

.sim-status {
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.sim-results {
  overflow-x: auto;
  background: var(--paper);
  border-radius: 18px;
  border: 1px solid #e8d7bd;
  box-shadow: 0 10px 20px rgba(31, 43, 47, 0.08);
}

.sim-results table {
  width: 100%;
  border-collapse: collapse;
  min-width: 540px;
}

.sim-results th,
.sim-results td {
  padding: 0.85rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid #eadbc4;
}

.sim-results th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.sim-results tbody tr:last-child td {
  border-bottom: none;
}

.sim-charts {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.chart-card {
  background: var(--paper);
  border-radius: 18px;
  border: 1px solid #e8d7bd;
  padding: 1rem 1.2rem 1.4rem;
  box-shadow: 0 10px 20px rgba(31, 43, 47, 0.08);
}

.chart-card h3 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
}

.chart-card canvas {
  width: 100%;
  height: auto;
  display: block;
}

.sim-visual {
  background: #1c2a30;
  border-radius: 20px;
  padding: 1.4rem;
  color: #f5e7d5;
  box-shadow: 0 18px 32px rgba(31, 43, 47, 0.3);
  display: grid;
  gap: 1rem;
}

.visual-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}

.visual-head h3 {
  margin: 0 0 0.3rem;
}

.visual-head p {
  margin: 0;
  color: rgba(245, 231, 213, 0.75);
  font-size: 0.9rem;
}

.visual-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.visual-controls label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: rgba(245, 231, 213, 0.8);
}

.visual-controls select {
  border-radius: 10px;
  border: 1px solid rgba(245, 231, 213, 0.3);
  background: #23363d;
  color: #f5e7d5;
  padding: 0.4rem 0.7rem;
}

#sim-canvas {
  width: 100%;
  height: auto;
  border-radius: 16px;
  background: radial-gradient(circle at 20% 20%, #2e4651 0%, #1c2a30 60%);
}

.code-card pre {
  margin: 0;
  font-family: "IBM Plex Mono", "Courier New", monospace;
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.caption {
  margin-top: 0.8rem;
  font-size: 0.85rem;
  color: #f5d1a0;
}

.refs {
  display: grid;
  gap: 1rem;
  padding-left: 1.2rem;
}

.refs li {
  background: var(--paper);
  padding: 1rem 1.2rem;
  border-radius: 16px;
  border: 1px solid #e8d7bd;
  box-shadow: 0 10px 20px rgba(31, 43, 47, 0.08);
}

.note {
  margin-top: 1rem;
  color: var(--ink-soft);
}

.footer {
  padding: 2rem 8vw 3rem;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  background: rgba(245, 231, 213, 0.6);
}

[data-reveal] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-graphic {
    order: -1;
  }

  .hero-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 3.5rem 6vw 2rem;
  }

  main {
    padding: 0 6vw 4rem;
  }

  .hero-metrics {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    transition: none;
  }
}
