/* Let There Be Simulation — site styles (layered over Bootstrap 5.3) */
:root {
  --font-read: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, Cambria, "Times New Roman", serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, .09);
  --warm: #b45309;
  --warm-soft: rgba(180, 83, 9, .09);
  --rule: rgba(28, 35, 48, .14);
  --muted: #5b6573;
  --nav-h: 56px;
}
[data-bs-theme="light"] {
  --bs-body-bg: #faf8f3;
  --bs-body-color: #1c2330;
  --bs-emphasis-color: #0d1420;
  --bs-border-color: rgba(28, 35, 48, .14);
}
[data-bs-theme="dark"] {
  --bs-body-bg: #0d1117;
  --bs-body-color: #d5dbe6;
  --bs-emphasis-color: #f1f4fa;
  --bs-border-color: rgba(213, 219, 230, .16);
  --accent: #5eead4;
  --accent-soft: rgba(94, 234, 212, .09);
  --warm: #fbbf24;
  --warm-soft: rgba(251, 191, 36, .09);
  --rule: rgba(213, 219, 230, .16);
  --muted: #8f9bb0;
}

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { font-family: var(--font-ui); background: var(--bs-body-bg); }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 2000; background: var(--bs-body-bg); padding: .5rem .75rem; border-radius: .375rem; }

/* Progress bar */
.progress-bar-top { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 1100; background: var(--accent);
  transform: scaleX(0); transform-origin: 0 50%; }

/* Nav */
.site-nav { height: var(--nav-h); padding: 0; background: color-mix(in srgb, var(--bs-body-bg) 82%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule); }
.site-nav .navbar-brand { font-weight: 650; letter-spacing: -.01em; font-size: 1rem; }
.toc-toggle { display: inline-flex; align-items: center; gap: .4rem; }
#themeToggle { display: inline-flex; align-items: center; padding: .35rem .5rem; }
[data-bs-theme="light"] .icon-sun, [data-bs-theme="dark"] .icon-moon { display: none; }

/* Hero (always dark, "blueprint" look) */
.hero { position: relative; overflow: hidden; color: #e8edf7; background: #0b1220; isolation: isolate; }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -2;
  background:
    radial-gradient(60rem 28rem at 78% -10%, rgba(94,234,212,.20), transparent 60%),
    radial-gradient(40rem 24rem at 0% 110%, rgba(251,191,36,.12), transparent 60%),
    linear-gradient(rgba(148,163,184,.07) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(90deg, rgba(148,163,184,.07) 1px, transparent 1px) 0 0 / 36px 36px; }
.hero-art { position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity .8s ease;
  background-size: cover; background-position: center; }
.hero-art.has-image { opacity: .35; }
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(11,18,32,.2), rgba(11,18,32,.75)); }
.hero-inner { padding-block: clamp(3.5rem, 9vw, 7rem); max-width: 60rem; margin-inline: auto; }
.hero-kicker { font: 500 .8rem/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: #5eead4; margin-bottom: 1.25rem; }
.hero-title { font-family: var(--font-ui); font-weight: 750; letter-spacing: -.03em; line-height: 1.02;
  font-size: clamp(2.6rem, 8vw, 5.2rem); margin: 0 0 1rem; color: #fff; }
.hero-sub { font-size: clamp(1.15rem, 2.6vw, 1.6rem); line-height: 1.35; color: #cbd5e6; max-width: 40rem; margin-bottom: .75rem; }
.hero-tag { font-family: var(--font-read); font-style: italic; color: #9fb0c9; font-size: 1.05rem; margin-bottom: 1.5rem; }
.hero-meta { display: flex; flex-wrap: wrap; gap: .6rem; font: 500 .85rem var(--font-mono); color: #9fb0c9; margin-bottom: 2rem; }
.btn-hero { background: #5eead4; border-color: #5eead4; color: #04211d; font-weight: 600; }
.btn-hero:hover, .btn-hero:focus-visible { background: #99f6e4; border-color: #99f6e4; color: #04211d; }
.hero-credit { margin: 2.25rem 0 0; font-size: .8rem; color: #7f90ab; }

/* Layout + TOC */
.layout { padding-block: 2.5rem 4rem; }
.toc-panel { --bs-offcanvas-width: 320px; }
@media (min-width: 992px) {
  .toc-sticky { position: sticky; top: calc(var(--nav-h) + 20px); max-height: calc(100vh - var(--nav-h) - 40px);
    overflow-y: auto; padding: 0 .5rem 1rem 0; scrollbar-width: thin; }
}
.toc-group { font: 600 .7rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 1.25rem 0 .4rem; }
.toc-group:first-child { margin-top: 0; }
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc-link { display: flex; gap: .6rem; padding: .32rem .75rem; margin-left: -1px; border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none; font-size: .88rem; line-height: 1.35; }
.toc-link:hover { color: var(--bs-emphasis-color); }
.toc-link.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc-n { flex: 0 0 1.4rem; font-family: var(--font-mono); font-size: .75rem; padding-top: .1rem; opacity: .75; }

/* Article */
.article { font-family: var(--font-read); font-size: 1.1875rem; line-height: 1.75; max-width: 46rem; }
.chapter { padding-block: 0 3rem; margin-bottom: 3rem; border-bottom: 1px solid var(--rule); }
.chapter:last-of-type { border-bottom: 0; }
.chapter-head { margin-bottom: 1.5rem; }
.kicker { font: 600 .75rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 .5rem; }
.article h2 { position: relative; font-family: var(--font-ui); font-weight: 720; letter-spacing: -.02em; line-height: 1.12;
  font-size: clamp(1.8rem, 4.2vw, 2.5rem); color: var(--bs-emphasis-color); margin: 0; }
.anchor { position: absolute; left: -1.4ch; color: var(--accent); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .anchor, .anchor:focus-visible { opacity: .7; }
@media (max-width: 767px) { .anchor { display: none; } }
.article h3 { font-family: var(--font-ui); font-weight: 650; font-size: 1.15rem; letter-spacing: -.005em; color: var(--bs-emphasis-color);
  margin: 2.25rem 0 .75rem; padding-bottom: .4rem; border-bottom: 1px solid var(--rule); }
.article p { margin: 0 0 1.15rem; }
.article p.lead { font-size: 1.35rem; line-height: 1.6; color: var(--bs-emphasis-color); font-weight: 400; }
.article p.lead-in { font-weight: 600; margin-bottom: .6rem; color: var(--bs-emphasis-color); }

.points { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.points li { position: relative; padding: .15rem 0 .15rem 1.5rem; margin-bottom: .7rem; }
.points li::before { content: ""; position: absolute; left: .25rem; top: .8em; width: .42rem; height: .42rem;
  background: var(--accent); border-radius: 1px; transform: rotate(45deg); }
.points li.stage::before { background: var(--warm); }
.lbl { font-family: var(--font-ui); font-weight: 650; font-size: .95em; color: var(--bs-emphasis-color); }

/* Callouts */
.callout { margin: 1.5rem 0 1.75rem; padding: 1rem 1.15rem 1rem 1.25rem; border-radius: .5rem; border: 1px solid var(--rule); border-left-width: 4px; }
.callout p { margin: 0; font-size: 1.05rem; line-height: 1.65; }
.callout-tag { display: inline-block; font: 650 .7rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase; margin-bottom: .4rem; }
.callout-hash { background: var(--warm-soft); border-left-color: var(--warm); }
.callout-hash .callout-tag { color: var(--warm); }
.callout-note { background: var(--accent-soft); border-left-color: var(--accent); }
.callout-note .callout-tag { color: var(--accent); }
.pullquote { font-family: var(--font-ui); font-weight: 700; font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -.02em;
  line-height: 1.2; color: var(--bs-emphasis-color); margin: 2.5rem 0 0 !important; padding-left: 1.1rem; border-left: 4px solid var(--accent); }

/* Chapter variants */
.chapter-concl { background: var(--accent-soft); border: 1px solid var(--rule); border-radius: .75rem; padding: 2rem 1.5rem 2.25rem; }
@media (min-width: 768px) { .chapter-concl { padding: 2.5rem 2.5rem 2.75rem; } }
.chapter-check { border-left: 4px solid var(--warm); padding-left: 1.25rem; }
.chapter-check .kicker { color: var(--warm); }

/* Footer, to-top */
.site-footer { border-top: 1px solid var(--rule); padding-block: 2rem; color: var(--muted); font-size: .9rem; }
.to-top { position: fixed; right: 1rem; bottom: 1rem; z-index: 1000; width: 2.75rem; height: 2.75rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: var(--bs-body-bg); border: 0;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.to-top[hidden] { display: none; }
.to-top:hover { filter: brightness(1.1); color: var(--bs-body-bg); }

@media (max-width: 575px) {
  .article { font-size: 1.0625rem; line-height: 1.7; }
  .article p.lead { font-size: 1.2rem; }
}
@media print {
  .site-nav, .toc-panel, .progress-bar-top, .to-top, .hero-art, .btn-hero, .skip-link { display: none !important; }
  .hero { color: #000; background: none; }
  .hero::before, .hero::after { display: none; }
  .hero-title, .hero-sub, .hero-tag, .hero-meta, .hero-kicker, .hero-credit { color: #000 !important; }
  .article { max-width: none; font-size: 11pt; }
  .col-lg-9 { width: 100%; }
  .chapter { break-inside: auto; }
  h2, h3 { break-after: avoid; }
}

/* 404 page */
.hero-full { min-height: 100vh; display: flex; align-items: center; }
