@import url("https://api.fontshare.com/v2/css?f[]=general-sans@400,500,600,700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=DM+Sans:wght@300;400;500&display=swap");

:root {
  --bg: white;
  --surface: #ffffff;
  --surface2: #eaf9fa;
  --code-bg: #d5f2f3;
  --accent: #31bcc3;
  --accent-dim: rgba(49, 188, 195, 0.08);
  --accent-b: rgba(49, 188, 195, 0.2);
  --text: #272640;
  --text-dim: #3d3b5c;
  --text-muted: #7a7897;
  --green: #1a6e38;
  --blue: #1a60c0;
  --purple: #5530a8;
  --pink: #a81850;
  --teal: #31bcc3;
  --bright: #d1fb8b;
  --border: rgba(39, 38, 64, 0.1);
  --sw: 256px;
  --th: 56px;
}

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

html {
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 15.5px;
  line-height: 1.7;
  scrollbar-width: auto;
  scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 2px;
}

/* ── Topbar ── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--th);
  background: #272640;
  border-bottom: none;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px 0 calc(var(--sw) + 24px);
  z-index: 100;
}
.topbar-title {
  font-family: "General Sans", sans-serif;
  font-size: 19px;
  color: #ffffff;
  white-space: nowrap;
  flex-shrink: 0;
}
.progress-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.2s;
}
.progress-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: var(--th);
  left: 0;
  bottom: 0;
  width: var(--sw);
  background: #f4feff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 0 40px;
  z-index: 90;
  scrollbar-width: auto;
  scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}
.sidebar-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 20px 12px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 13px;
  transition:
    background 0.15s,
    color 0.15s;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: var(--accent-dim);
  color: var(--text);
}
.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-dim);
  font-weight: 500;
}
.nav-item.done {
  color: var(--text-muted);
}
.nav-num {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 18px;
}
.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.15s;
}
.nav-item.active .nav-dot {
  background: var(--accent);
}
.nav-item.done .nav-dot {
  background: var(--text-muted);
}
.nav-text {
  line-height: 1.3;
}

/* ── Main ── */
main {
  margin-left: var(--sw);
  padding-top: var(--th);
  min-height: 100vh;
}

/* ── Hero ── */
.hero {
  padding: 64px 56px 48px;
  border-bottom: 1px solid var(--border);
}
.hero-eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
.hero h1 {
  font-family: "General Sans", sans-serif;
  font-size: 52px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 20px;
}
.hero-sub {
  font-size: 17px;
  color: var(--text-dim);
  max-width: 640px;
  line-height: 1.65;
}
.hero-meta {
  margin-top: 32px;
  display: flex;
  gap: 32px;
}
.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hero-stat-val {
  font-family: "General Sans", sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
}
.hero-stat-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Section ── */
.section {
  padding: 56px 56px 48px;
  border-bottom: 1px solid var(--border);
}
.section h2 {
  font-family: "General Sans", sans-serif;
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.2;
}
.section h3 {
  font-family: "General Sans", sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 32px 0 12px;
}
.section p {
  color: var(--text-dim);
  margin-bottom: 16px;
  max-width: 720px;
}
.section p:last-child {
  margin-bottom: 0;
}

/* ── Concept grid ── */
.concept-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 28px 0;
}
.concept-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
}
.concept-title {
  font-family: "General Sans", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.concept-mono {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  color: var(--accent);
  margin-bottom: 8px;
}
.concept-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
}

/* ── Callouts ── */
.callout {
  border-left: 3px solid;
  padding: 14px 18px;
  margin: 24px 0;
  border-radius: 0 6px 6px 0;
  max-width: 720px;
}
.callout-insight {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.callout-workflow {
  border-color: var(--blue);
  background: rgba(26, 96, 192, 0.06);
}
.callout-tip {
  border-color: var(--teal);
  background: rgba(49, 188, 195, 0.06);
}
.callout-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.callout-insight .callout-label {
  color: var(--accent);
}
.callout-workflow .callout-label {
  color: var(--blue);
}
.callout-tip .callout-label {
  color: var(--teal);
}
.callout p {
  font-size: 13.5px;
  color: var(--text-dim);
  max-width: none;
}

/* ── Output blocks ── */
.output-block {
  background: rgba(26, 110, 56, 0.06);
  border: 1px solid rgba(26, 110, 56, 0.2);
  border-radius: 8px;
  overflow: hidden;
  margin: 20px 0;
  max-width: 720px;
}
.output-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green);
  padding: 8px 16px;
  border-bottom: 1px solid rgba(26, 110, 56, 0.15);
  background: rgba(26, 110, 56, 0.04);
}
.output-block pre {
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: rgba(26, 110, 56, 0.9);
  padding: 16px;
  line-height: 1.65;
  white-space: pre;
  overflow-x: auto;
}

/* ── Tranche Table ── */
.tranche-table {
  width: 100%;
  border-collapse: collapse;
  margin: 28px 0;
  font-size: 13.5px;
}
.tranche-table th {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 16px;
  border-bottom: 2px solid var(--border);
}
.tranche-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  vertical-align: middle;
}
.tranche-table tr:last-child td {
  border-bottom: none;
}
.tranche-table tr:hover td {
  background: var(--accent-dim);
}
.rating-pill {
  display: inline-block;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 4px;
  min-width: 44px;
  text-align: center;
}
.r-aaa {
  background: rgba(26, 96, 192, 0.12);
  color: var(--blue);
}
.r-aa {
  background: rgba(26, 110, 56, 0.12);
  color: var(--green);
}
.r-a {
  background: rgba(49, 188, 195, 0.12);
  color: var(--teal);
}
.r-bbb {
  background: rgba(209, 251, 139, 0.4);
  color: #3a6300;
}
.r-bb {
  background: rgba(85, 48, 168, 0.12);
  color: var(--purple);
}
.r-b {
  background: rgba(168, 24, 80, 0.12);
  color: var(--pink);
}
.r-eq {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text-muted);
}

/* ── Waterfall diagram ── */
.waterfall {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 28px 0;
  max-width: 560px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.wf-row {
  display: flex;
  align-items: stretch;
}
.wf-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
  width: 90px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-right: 1px solid var(--border);
  background: var(--surface2);
}
.wf-bar-wrap {
  flex: 1;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-bottom: 1px solid var(--border);
}
.wf-row:last-child .wf-bar-wrap {
  border-bottom: none;
}
.wf-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.wf-detail {
  font-size: 12px;
  color: var(--text-muted);
}
.wf-bar {
  height: 8px;
  border-radius: 3px;
  margin-top: 6px;
}

/* ── Quick grid ── */
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 28px 0;
}
.ref-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
}
.ref-card-title {
  font-family: "General Sans", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.ref-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.ref-card li {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}
.ref-card code {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Comparison ── */
.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 28px 0;
}
.cmp-pane {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.cmp-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
}
.cmp-before .cmp-label {
  color: var(--pink);
}
.cmp-after .cmp-label {
  color: var(--green);
}
.cmp-code {
  flex: 1;
  background: var(--code-bg);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--text);
  padding: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ── Formula box ── */
.formula-box {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin: 20px 0;
  max-width: 720px;
}
.formula-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.formula {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  color: var(--text);
  line-height: 1.8;
}
.formula .var {
  color: var(--purple);
}
.formula .op {
  color: var(--accent);
}
.formula .num {
  color: var(--blue);
}

/* ── Structure diagram ── */
.structure-diagram {
  margin: 28px 0;
  max-width: 780px;
}
.sd-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}
.sd-box {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  text-align: center;
  flex-shrink: 0;
}
.sd-box.accent {
  background: var(--accent-dim);
  border-color: var(--accent-b);
  color: var(--accent);
}
.sd-box.blue {
  background: rgba(26, 96, 192, 0.08);
  border-color: rgba(26, 96, 192, 0.25);
  color: var(--blue);
}
.sd-box.green {
  background: rgba(26, 110, 56, 0.08);
  border-color: rgba(26, 110, 56, 0.25);
  color: var(--green);
}
.sd-arrow {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.sd-note {
  font-size: 12px;
  color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
}

/* ── Quarto document overrides ────────────────────────────────────────────
   Applied when styles.css is loaded via the Quarto `css:` front-matter key.
   Quarto renders with document-css:false, so this file owns the entire layout.
   ───────────────────────────────────────────────────────────────────────── */

/* ── CSS variable for Quarto sidebar width ── */
:root {
  --qsw: 300px; /* Quarto TOC sidebar — wide enough for longest heading */
}

/* ── Page layout: flex row, sidebar + content ── */
#quarto-content {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

/* ── TOC sidebar: sticky, 300 px, resets our .sidebar position:fixed ── */
#quarto-margin-sidebar {
  position: sticky !important;
  top: 0 !important;
  left: auto !important;
  bottom: auto !important;
  width: var(--qsw) !important;
  min-width: var(--qsw) !important;
  max-width: var(--qsw) !important;
  height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 90 !important;
  padding: 28px 0 40px;
  background: #f4feff;
  border-right: 1px solid var(--border);
}

/* ── Main content: take all remaining width, no topbar offset ── */
#quarto-document-content {
  flex: 1;
  min-width: 0;
  width: calc(100% - var(--qsw));
  max-width: none !important;
  margin-left: 0 !important;  /* flex handles positioning; cancel main { margin-left } */
  padding: 40px 56px 80px !important;
  box-sizing: border-box;
}

/* ── Fonts — override Pandoc/browser defaults ── */
body {
  font-family: "DM Sans", sans-serif !important;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text);
}

h1, h2, h3, h4, h5, h6,
.quarto-title h1,
.quarto-title-meta-heading {
  font-family: "General Sans", sans-serif !important;
  color: var(--text);
}

pre, code, kbd, samp,
.sourceCode,
.cell-output pre,
.cell-output-stdout pre {
  font-family: "JetBrains Mono", monospace !important;
}

/* ── Links ── */
a { color: var(--accent); }
a:hover { color: var(--text-dim); text-decoration: none; }

/* ── Title block ── */
.quarto-title-block {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
  margin-bottom: 2.5rem;
}
.quarto-title .title {
  font-family: "General Sans", sans-serif !important;
  font-size: 44px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
}
.quarto-title .subtitle.lead {
  font-family: "JetBrains Mono", monospace !important;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 0.5rem;
}
.quarto-title-meta-heading {
  font-family: "JetBrains Mono", monospace !important;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted) !important;
}
.quarto-title-meta-contents {
  font-size: 13px;
  color: var(--text-dim);
}

/* ── TOC nav links ── */
#TOC h2 {
  font-family: "JetBrains Mono", monospace !important;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 20px 12px;
  margin-bottom: 4px;
}
#TOC ul {
  list-style: none;
  padding-left: 0;
}
#TOC li {
  padding-left: 0;
}
#TOC .nav-link {
  display: block;
  font-family: "JetBrains Mono", monospace !important;
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 20px;
  text-decoration: none;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s, color 0.15s;
}
#TOC .nav-link:hover {
  color: var(--accent);
  background: var(--accent-dim);
}
#TOC .nav-link.active {
  color: var(--accent);
  font-weight: 500;
  border-left-color: var(--accent);
  background: var(--accent-dim);
}
#TOC ul ul .nav-link {
  padding-left: 32px;
  font-size: 11.5px;
}

/* ── Section headings ── */
section h2 {
  font-family: "General Sans", sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin: 2.5rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
section h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }
section h3 {
  font-family: "General Sans", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 1.5rem 0 0.5rem;
}

/* ── Code blocks ── */
div.sourceCode {
  background: var(--code-bg) !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 16px 0;
  overflow-x: auto;
}
div.sourceCode pre {
  background: transparent !important;
  margin: 0;
  padding: 16px;
}

/* ── Cell output ── */
.cell-output,
.cell-output-stdout {
  background: rgba(26, 110, 56, 0.05);
  border: 1px solid rgba(26, 110, 56, 0.18);
  border-radius: 6px;
  margin-top: 8px;
}
.cell-output pre,
.cell-output-stdout pre {
  color: rgba(26, 110, 56, 0.9);
  font-size: 12.5px;
  padding: 12px 16px;
  margin: 0;
}

/* ── great_tables output ── */
.gt_table {
  font-family: "DM Sans", sans-serif !important;
  font-size: 13.5px;
}
.gt_col_heading {
  font-family: "JetBrains Mono", monospace !important;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
