/* ============================================================
   et-book faces
   ============================================================ */
@font-face {
  font-family: "et-book";
  src: url("fonts/et-book/et-book-roman-line-figures.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "et-book";
  src: url("fonts/et-book/et-book-display-italic-old-style-figures.woff") format("woff");
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "et-book";
  src: url("fonts/et-book/et-book-bold-line-figures.woff") format("woff");
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "et-book-semi";
  src: url("fonts/et-book/et-book-semi-bold-old-style-figures.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --paper: #fffff8;
  --ink: #14130f;
  --ink-soft: #4a463c;
  --ink-faint: #7d786a;
  --rule: #e6e2d3;
  --rule-soft: #efece0;
  --accent: #7a1705;      /* deep oxblood — links / emphasis */
  --accent-soft: #a8623f;
  --dyn: #305d5a;         /* teal — the dynamic/LEAPS strategy */
  --fixed: #9c6b16;       /* ochre — fixed leverage */
  --fixed3: #a56b5f;      /* muted red-brown — fixed 3x */
  --band: #e9e4d4;
  --card: #fffffc;
  --card-shadow: 0 1px 0 rgba(20,19,15,0.02), 0 18px 40px -32px rgba(20,19,15,0.35);
  --pos: #2f6b46;
  --neg: #9c2a12;
  --maxw-body: 720px;
  --content-font: "et-book", Palatino, "Palatino Linotype", Georgia, serif;
}

[data-theme="dark"] {
  --paper: #15141a;
  --ink: #ece7db;
  --ink-soft: #b6b0a1;
  --ink-faint: #857f70;
  --rule: #2b2833;
  --rule-soft: #211f28;
  --accent: #e0916b;      /* warm terracotta — links / emphasis */
  --accent-soft: #c9795a;
  --dyn: #63b6ad;         /* teal — the dynamic/LEAPS strategy */
  --fixed: #d3a24c;       /* ochre — fixed leverage */
  --fixed3: #a86555;      /* muted red-brown — fixed 3x */
  --band: #23212b;
  --card: #1b1a21;
  --card-shadow: 0 1px 0 rgba(0,0,0,0.2), 0 20px 44px -30px rgba(0,0,0,0.7);
  --pos: #63c48c;
  --neg: #e0805f;
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--content-font);
  font-size: 21px;
  line-height: 1.62;
  font-feature-settings: "onum" 1, "liga" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.3s ease, color 0.3s ease;
}

::selection { background: rgba(122, 23, 5, 0.14); }

/* ============================================================
   Three-column shell
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns:
    minmax(180px, 1fr)
    minmax(auto, var(--maxw-body))
    minmax(220px, 1.15fr);
  column-gap: 40px;
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ---- left: table of contents ---- */
.toc-col { position: relative; }
.toc {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 96px 8px 48px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.toc::-webkit-scrollbar { display: none; }
.toc__label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10.5px;
  color: var(--ink-faint);
  margin: 0 0 14px 14px;
  font-weight: 600;
}
.toc a {
  display: block;
  padding: 4px 0 4px 14px;
  margin-left: -1px;
  color: var(--ink-faint);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.toc a:hover { color: var(--ink); }
.toc a.is-active {
  color: var(--ink);
  border-left-color: var(--accent);
  font-weight: 600;
}
.toc a.toc--sub { padding-left: 28px; font-size: 12px; }
.toc a.toc--head { margin-top: 14px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; }

/* ---- middle: article ---- */
.article-col { min-width: 0; }
article { padding: 92px 0 160px; }

/* ---- right: margin / footnotes ---- */
.notes-col { position: relative; }

/* ============================================================
   Typography
   ============================================================ */
.eyebrow {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 22px;
}
h1 {
  font-weight: normal;
  font-size: 48px;
  line-height: 1.08;
  letter-spacing: -0.012em;
  margin: 0 0 22px;
}
.lede {
  font-size: 23px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.byline {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  margin: 26px 0 0;
}
.rule-break {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 40px 0;
}
.rule-break--major { margin-top: 104px; }

h2 {
  font-weight: normal;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.008em;
  margin: 62px 0 8px;
  padding-top: 6px;
}
h2 .h2-num {
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--accent-soft);
  margin-bottom: 10px;
}
h3 {
  font-family: "et-book-semi", var(--content-font);
  font-weight: normal;
  font-size: 22px;
  margin: 40px 0 4px;
  color: var(--ink);
}

p { margin: 18px 0; }
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(122,23,5,0.28); }
a:hover { border-bottom-color: var(--accent); }
em { font-style: italic; }
strong { font-family: "et-book-semi", var(--content-font); font-weight: normal; }

blockquote {
  margin: 30px 0;
  padding: 4px 0 4px 26px;
  border-left: 2px solid var(--accent-soft);
  font-style: italic;
  color: var(--ink-soft);
}
blockquote p { margin: 8px 0; }

ul, ol { margin: 18px 0; padding-left: 26px; }
li { margin: 8px 0; }

.small-caps {
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

/* KaTeX-ish inline math fallback */
.math {
  font-family: "Latin Modern Math", "STIX Two Math", Cambria, Georgia, serif;
  font-style: italic;
}
.formula {
  display: block;
  text-align: center;
  font-family: "Latin Modern Math", "STIX Two Math", Cambria, Georgia, serif;
  font-size: 22px;
  margin: 26px 0;
  color: var(--ink);
}

/* ============================================================
   Sidenotes / footnotes (right rail, prominent on hover)
   ============================================================ */
.fnref {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.62em;
  font-weight: 600;
  color: var(--accent);
  vertical-align: super;
  line-height: 0;
  padding: 0 1px;
  cursor: pointer;
  border: 0;
}

.sidenote {
  position: absolute;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-faint);
  opacity: 0.62;
  padding-left: 4px;
  border-left: 2px solid var(--rule);
  transition: opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  cursor: default;
}
.sidenote .sn-num {
  color: var(--accent);
  font-weight: 700;
  margin-right: 5px;
}
.sidenote:hover,
.sidenote.is-lit {
  opacity: 1;
  color: var(--ink-soft);
  border-left-color: var(--accent);
}
.sidenote a { font-size: inherit; }

/* ============================================================
   Figures & charts
   ============================================================ */
.figure {
  margin: 44px 0;
}
.figure--wide {
  /* let charts bleed a little into the right rail on large screens */
  width: calc(100% + 150px);
}
.chart-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 22px 22px 16px;
  box-shadow: var(--card-shadow);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.chart-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin: 0 0 2px;
}
.chart-sub {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 12px;
  color: var(--ink-faint);
  margin: 0 0 16px;
}
.chart-wrap { position: relative; width: 100%; }
.chart-readout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  min-height: 32px;
  margin: 4px 0 10px;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 11px;
  line-height: 1.25;
}
.chart-readout__title {
  color: var(--ink-faint);
  font-weight: 700;
}
.chart-readout__item {
  font-weight: 700;
  white-space: nowrap;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }
.chart-head-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.path-control-stack {
  display: grid;
  gap: 8px;
  min-width: 0;
  width: 100%;
}
.path-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 2px;
  width: 100%;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.path-tabs button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ink-faint);
  padding: 5px 8px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.path-tabs--samples button { font-size: 11px; padding: 4px 7px; }
.path-tabs button:hover { color: var(--ink); }
.path-tabs button.is-active {
  background: var(--dyn);
  color: var(--paper);
}

/* ============================================================
   Interactive result controls
   ============================================================ */
.results-explorer .chart-card { padding-bottom: 20px; }
.explorer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}
.histogram-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  margin-top: 8px;
}
.histogram-grid .chart-sub { margin-bottom: 8px; }
.path-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 26px;
  margin-top: 10px;
}
.path-cell-title { margin: 0 0 2px; font-weight: 600; }
@media (max-width: 720px) {
  .path-grid { grid-template-columns: minmax(0, 1fr); }
}
.chart-note { color: var(--ink-faint); font-weight: 400; font-size: 0.85em; }
.legend-item { cursor: default; }
.path-controls { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.path-resample {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.path-resample:hover { background: var(--dyn); color: var(--paper); border-color: var(--dyn); }
.path-sample-label { color: var(--ink-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.explorer-table { margin: 24px 0 0; }
.explorer-table table { font-size: 12.5px; min-width: 820px; }
.explorer-table caption { font-size: 13px; }
.explorer-table th,
.explorer-table td { padding: 7px 9px; }
.explorer-table tbody tr:nth-child(even) { background: rgba(125, 120, 106, 0.055); }
figcaption {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-faint);
  margin-top: 12px;
  padding-left: 2px;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { margin: 40px 0; overflow-x: auto; }
table {
  border-collapse: collapse;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13.5px;
}
caption {
  caption-side: top;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 10px;
}
thead th {
  text-align: right;
  font-weight: 600;
  color: var(--ink-faint);
  border-bottom: 1.5px solid var(--ink);
  padding: 8px 12px;
  white-space: nowrap;
}
thead th:first-child { text-align: left; }
tbody td {
  text-align: right;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
}
tbody td:first-child { text-align: left; color: var(--ink); }
tbody td.choice { color: var(--dyn); font-weight: 600; }
tbody tr.row-prod { background: rgba(48,93,90,0.07); }
tbody tr.row-prod td:first-child { font-weight: 600; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* compact inline table (leverage-vs-vol lookup) */
.mini-table {
  width: auto;
  margin: 26px 0;
  border-collapse: collapse;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13.5px;
}
.mini-table th, .mini-table td {
  padding: 7px 16px;
  text-align: center;
  border-bottom: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
}
.mini-table thead th { border-bottom: 1.5px solid var(--ink); color: var(--ink-faint); font-weight: 600; }
.mini-table td:first-child, .mini-table th:first-child { text-align: left; color: var(--ink); }

/* ============================================================
   Callout
   ============================================================ */
.callout {
  margin: 36px 0;
  padding: 20px 24px;
  background: rgba(48,93,90,0.06);
  border: 1px solid rgba(48,93,90,0.22);
  border-radius: 4px;
  font-size: 19px;
}
.callout p { margin: 8px 0; }
.callout strong { color: var(--dyn); }


/* ============================================================
   Footer
   ============================================================ */
.foot {
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.6;
}
.foot a { border: 0; }

/* mobile footnote list (hidden on desktop) */
.mobile-notes { display: none; }

/* ============================================================
   Theme toggle (fixed, top-right)
   ============================================================ */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 22px;
  z-index: 50;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: 0 6px 20px -14px rgba(20,19,15,0.6);
  transition: background-color 0.25s ease, color 0.25s ease,
              border-color 0.25s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent-soft);
  transform: translateY(-1px);
}
.theme-toggle:active { transform: translateY(0); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }

@media (max-width: 820px) {
  .theme-toggle { top: 14px; right: 14px; width: 36px; height: 36px; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1180px) {
  .shell {
    grid-template-columns: minmax(150px, 200px) minmax(auto, var(--maxw-body));
    max-width: 960px;
  }
  .notes-col { display: none; }
  .figure--wide { width: 100%; }
  /* render footnotes inline as a list at the end */
  .mobile-notes { display: block; }
}

@media (max-width: 820px) {
  body { font-size: 19px; line-height: 1.6; }
  .shell {
    grid-template-columns: 1fr;
    padding: 0 22px;
  }
  .toc-col { display: none; }
  article { padding: 52px 0 100px; }
  h1 { font-size: 36px; }
  h2 { font-size: 25px; }
  .lede { font-size: 20px; }
  .figure--wide { width: 100%; }
  .path-control-stack { margin-bottom: 16px; }
  .explorer-head { display: block; }
}
