/* ============================================================
   INTELLIGENCE — Quarto Theme
   Special Elite + Courier Prime
   White base · Dark mode via body.quarto-dark
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Special+Elite&family=Courier+Prime:ital,wght@0,400;0,700;1,400&display=swap');

/* ── CSS Variables — Light ────────────────────────────────── */
:root,
[data-bs-theme="light"],
body.quarto-light {
  --ink:          #0a0c10;
  --paper:        #ffffff;
  --off-white:    #f2f2f2;
  --accent:       #c8102e;
  --accent-dim:   rgba(200, 16, 46, 0.08);
  --steel:        #4a5568;
  --muted:        #7a8494;
  --rule:         rgba(10, 12, 16, 0.10);
  --code-bg:      #0f1117;
  --code-fg:      #e2ddd5;
  --epigraph-fg:  #444;
  --epigraph-src: #777;
  --mono:         'Courier Prime', monospace;
  --sans:         'Special Elite', serif;
  --body:         'Courier Prime', monospace;
}

/* ── CSS Variables — Dark ─────────────────────────────────── */
body.quarto-dark {
  --ink:          #eae6de;
  --paper:        #0f1117;
  --off-white:    #181c24;
  --accent:       #e8294a;
  --accent-dim:   rgba(232, 41, 74, 0.12);
  --steel:        #8896aa;
  --muted:        #5c6878;
  --rule:         rgba(234, 230, 222, 0.10);
  --code-bg:      #080a0e;
  --code-fg:      #c9c4bb;
  --epigraph-fg:  #b0b0b0;
  --epigraph-src: #9a9a9a;
}

/* ── Bootstrap variable bridge ───────────────────────────── */
:root,
[data-bs-theme="light"],
body.quarto-light {
  --bs-body-bg:           #ffffff;
  --bs-body-color:        #0a0c10;
  --bs-secondary-bg:      #f2f2f2;
  --bs-tertiary-bg:       #f2f2f2;
  --bs-link-color:        #0a0c10;
  --bs-link-hover-color:  #c8102e;
  --bs-border-color:      rgba(10, 12, 16, 0.10);
}

body.quarto-dark {
  --bs-body-bg:           #0f1117;
  --bs-body-color:        #eae6de;
  --bs-secondary-bg:      #181c24;
  --bs-tertiary-bg:       #181c24;
  --bs-link-color:        #eae6de;
  --bs-link-hover-color:  #e8294a;
  --bs-border-color:      rgba(234, 230, 222, 0.10);
}

/* ── Reading progress bar ─────────────────────────────────── */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  z-index: 9999;
  width: calc(100% * var(--scroll, 0));
  transition: width 0.1s linear;
}

/* ── Base ─────────────────────────────────────────────────── */
body {
  font-family: var(--body) !important;
  font-size: 1rem;
  line-height: 1.9;
  color: var(--ink) !important;
  background-color: var(--paper) !important;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Force dark mode palette on key structural elements */
body.quarto-dark .quarto-container,
body.quarto-dark #quarto-content,
body.quarto-dark .page-columns {
  background-color: var(--paper) !important;
  color: var(--ink) !important;
}

body.quarto-dark #quarto-sidebar,
body.quarto-dark .sidebar {
  background-color: var(--off-white) !important;
}

body.quarto-dark .nav-link,
body.quarto-dark .sidebar-item a,
body.quarto-dark .chapter-link {
  color: var(--steel) !important;
}

body.quarto-dark a {
  color: var(--ink) !important;
  text-decoration-color: var(--accent) !important;
}

body.quarto-dark a:hover {
  color: var(--accent) !important;
}

body.quarto-dark p,
body.quarto-dark li,
body.quarto-dark td,
body.quarto-dark th {
  color: var(--ink) !important;
}

/* ── Images ───────────────────────────────────────────────── */
img {
  max-width: 100%;
  height: auto;
}

figure {
  text-align: center;
}

/* ── Headings ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  transition: color 0.25s ease;
}

h1 {
  font-size: 2.2rem;
  border-bottom: 3px solid var(--ink);
  padding-bottom: 0.4rem;
}

h2 {
  font-size: 1.5rem;
  border-left: 3px solid var(--accent);
  padding-left: 0.75rem;
  margin-left: -0.78rem;
}

h3 {
  font-size: 1rem;
  color: var(--muted);
}

/* ── Links ────────────────────────────────────────────────── */
a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent);
}

/* ── Horizontal Rules ─────────────────────────────────────── */
hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

/* ── Code — inline ────────────────────────────────────────── */
code, kbd, samp, tt {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--off-white);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.1em 0.35em;
  color: var(--accent);
  transition: background 0.25s ease;
}

/* ── Code — block ─────────────────────────────────────────── */
pre {
  background: var(--code-bg) !important;
  border: none;
  border-radius: 0;
  border-left: 3px solid var(--accent);
  padding: 1.4rem 1.6rem;
  overflow-x: auto;
  position: relative;
  transition: background 0.25s ease;
}

pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--code-fg);
  font-size: 0.85rem;
  line-height: 1.7;
}

/* ── Blockquotes ──────────────────────────────────────────── */
blockquote {
  border-left: 3px solid var(--accent);
  margin: 2rem 0;
  padding: 0.5rem 0 0.5rem 1.5rem;
  font-style: italic;
  color: var(--steel);
  transition: color 0.25s ease;
}

/* ── Epigraph ─────────────────────────────────────────────── */
.epigraph {
  font-family: var(--sans);
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--epigraph-fg);
  margin: 3rem 0;
  padding: 1.5rem 2rem 1.5rem 1.8rem;
  position: relative;
  border: none;
  background: transparent;
  transition: color 0.25s ease;
}

.epigraph::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--ink);
  opacity: 0.2;
  transition: background 0.25s ease;
}

.epigraph::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--accent);
  opacity: 0.65;
}

.epigraph > p:first-child {
  position: relative;
}

.epigraph > p:first-child::before {
  content: "\201C";
  font-family: var(--sans);
  font-size: 4.5rem;
  font-weight: 400;
  font-style: normal;
  color: var(--accent);
  opacity: 0.12;
  line-height: 0;
  position: absolute;
  top: 2rem;
  left: -0.4rem;
  pointer-events: none;
}

.epigraph footer {
  margin-top: 1rem;
  font-style: normal;
  font-size: 0.8rem;
  font-family: var(--sans);
  letter-spacing: 0.05em;
  color: var(--epigraph-src);
  transition: color 0.25s ease;
}

.epigraph footer::before {
  content: "— ";
  color: var(--accent);
  opacity: 0.8;
}

/* ── Tables ───────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.95rem;
  margin: 1.5rem 0;
}

thead tr {
  border-bottom: 2px solid var(--ink);
  background: var(--off-white);
  transition: background 0.25s ease;
}

thead th {
  font-family: var(--sans);
  font-weight: 400;
  letter-spacing: 0.04em;
  font-size: 0.9rem;
  padding: 0.6rem 0.9rem;
  text-align: left;
}

tbody td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--rule);
}

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

/* ── Callout / Alert boxes ────────────────────────────────── */
.callout {
  border-radius: 0;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
}

/* ── Navigation sidebar ───────────────────────────────────── */
#quarto-sidebar {
  background: var(--off-white);
  border-right: 1px solid var(--rule);
  transition: background 0.25s ease;
}

.sidebar-title {
  font-family: var(--sans) !important;
  font-weight: 400 !important;
  letter-spacing: 0.02em !important;
}

.sidebar-item a {
  font-family: var(--sans);
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--steel);
  transition: color 0.15s;
}

.sidebar-item a:hover {
  color: var(--accent);
}

.sidebar-item.active > a {
  color: var(--ink);
}

/* ── Table of Contents ────────────────────────────────────── */
#TOC {
  border-left: 1px solid var(--rule);
  padding-left: 1.2rem;
  font-size: 0.85rem;
}

#TOC a {
  text-decoration: none;
  color: var(--muted);
  display: block;
  padding: 0.15rem 0;
  transition: color 0.15s;
  font-family: var(--sans);
}

#TOC a:hover,
#TOC a.active {
  color: var(--accent);
}

.sidebar nav[role="doc-toc"] ul > li > a.active {
  padding-left: 0.75rem;
  border-left: 3px solid var(--accent);
  margin-left: -3px;
}

/* ── Footer ───────────────────────────────────────────────── */
.nav-footer {
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ── Redaction ────────────────────────────────────────────── */
.redacted {
  background: var(--ink);
  color: var(--ink);
  cursor: default;
  user-select: none;
  padding: 0 0.25em;
  border-radius: 1px;
  transition: background 0.3s ease, color 0.3s ease;
}

.redacted:hover {
  background: var(--accent-dim);
  color: var(--steel);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--off-white); }
::-webkit-scrollbar-thumb { background: var(--steel); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Selection ────────────────────────────────────────────── */
::selection {
  background: var(--accent);
  color: var(--paper);
}
