/* ═══════════════════════════════════════════
   THRIVE HOLDINGS — Institutional Long-Read
   ═══════════════════════════════════════════ */

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

:root {
  /* Primary */
  --thrive-red: #C41E2A;
  --thrive-red-dark: #9A1820;
  --black: #0b0b0b;
  --white: #ffffff;
  --cream: #FDFBF7;

  /* Neutrals */
  --sand: #E8DED1;
  --camel: #C4A882;
  --stone: #B8B0A8;
  --charcoal: #4A4543;

  /* Extended */
  --forest: #2D5A3D;
  --forest-light: #3A7350;
  --sage: #7BA38C;
  --amber: #D4910A;
  --navy: #1E3255;

  /* Semantic */
  --bg-primary: var(--cream);
  --bg-secondary: #F4F0EA;
  --accent: var(--thrive-red);
  --accent-dim: rgba(196, 30, 42, 0.06);
  --accent-glow: rgba(196, 30, 42, 0.12);
  --text-primary: #1a1816;
  --text-secondary: #5C5652;
  --text-muted: #918A84;
  --border-light: rgba(196, 30, 42, 0.08);
  --border-medium: rgba(74, 69, 67, 0.15);
  --gold: #C7A44A;
  --gold-dim: rgba(199, 164, 74, 0.12);
  --bg-dim: #F4F0EA;

  /* Typography */
  --font-serif: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', monospace;

}

/* ─── Reset ─── */

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

html {
  scroll-behavior: smooth;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.72;
  overflow-x: hidden;
}

::selection {
  background: rgba(196, 30, 42, 0.15);
  color: var(--black);
}

.hero ::selection {
  background: rgba(196, 30, 42, 0.45);
  color: #fff;
}

/* ─── Typography ─── */

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.25;
}

h2 {
  font-size: 1.65rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.3rem;
}

h3 {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--charcoal);
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1.15rem;
  max-width: 62ch;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
a:hover { border-bottom-color: var(--accent); }

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-bottom-color: transparent;
}

.toc-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

strong { font-weight: 500; }

/* ═══════════════════════════════════════════
   HERO
   ═══════════════════════════════════════════ */

.hero {
  position: relative;
  width: 100vw;
  min-height: 100vh;
  overflow: hidden;
  background: #141414;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem 3rem;
  gap: 2rem;
}

/* Flag wrapper — sized for the vertical banner, centered */
.hero-flag-wrap {
  position: relative;
  width: min(420px, 55vw);
  aspect-ratio: 468 / 690;
  flex-shrink: 0;
}

.flag-container {
  position: absolute;
  inset: 0;
  cursor: grab;
}

.flag-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Title area — below the flag, dark on cream */
.hero-text {
  text-align: center;
  z-index: 10;
  max-width: 600px;
}

.hero-clock {
  position: absolute;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 300;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.7);
  z-index: 10;
  font-variant-numeric: tabular-nums;
}

.hero-byline {
  position: absolute;
  bottom: 2.5rem;
  left: 2rem;
  font-family: var(--font-body);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  z-index: 10;
}

.hero-byline a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  transition: color 0.2s, border-color 0.2s;
}

.hero-byline a:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.6);
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 0.6rem;
  color: #ffffff;
}

.hero-subtitle {
  font-family: var(--font-serif);
  font-style: normal;
  font-size: clamp(0.85rem, 1.5vw, 1.05rem);
  font-weight: 300;
  color: rgba(255, 255, 255, 0.7);
  max-width: 42ch;
  margin: 0 auto;
  letter-spacing: 0.01em;
}


/* ═══════════════════════════════════════════
   LAYOUT — TOC + CONTENT + PROGRESS
   ═══════════════════════════════════════════ */

.page-body {
  position: relative;
  display: grid;
  grid-template-columns: 240px 1fr 44px;
  min-height: 100vh;
}

/* ─── TOC Sidebar ─── */

.toc-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 3.5rem 1.2rem 2rem 1.8rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--border-medium);
  background: var(--bg-primary);
  z-index: 50;
  overflow-y: auto;
  scrollbar-width: thin;
}

.toc-label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
}

.toc-list {
  list-style: none;
}

.toc-item {
  margin-bottom: 0.15rem;
}

.toc-link {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  padding: 0.35rem 0.55rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  border: none;
  transition: color 0.25s, background 0.25s;
}

.toc-link:hover {
  color: var(--text-secondary);
  background: var(--accent-dim);
  border: none;
}

.toc-link.active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
  border-left: 2px solid var(--accent);
  padding-left: calc(0.55rem - 2px);
}

.toc-num {
  font-size: 0.55rem;
  opacity: 0.5;
  min-width: 1.4em;
}

/* ─── Main Content ─── */

.content-area {
  max-width: 740px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 2.5rem 6rem;
}

/* ─── Progress Rail ─── */

#progress-rail {
  position: fixed;
  top: 0;
  right: 0;
  width: 44px;
  height: 100vh;
  z-index: 50;
  pointer-events: auto;
}

.rail-track {
  position: absolute;
  left: 50%;
  top: 12%;
  bottom: 12%;
  width: 1.5px;
  background: var(--border-medium);
  transform: translateX(-50%);
}

.rail-indicator {
  position: absolute;
  left: 50%;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  transform: translateX(-50%);
  transition: top 0.08s linear;
  box-shadow: 0 0 8px rgba(196, 30, 42, 0.3);
}

.rail-pct {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

#progress-rail:hover .rail-pct {
  opacity: 1;
}

.rail-tick {
  position: absolute;
  left: 50%;
  width: 14px;
  height: 1.5px;
  background: var(--charcoal);
  opacity: 0.25;
  transform: translateX(-50%);
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.2s, width 0.2s;
}

.rail-tick:hover {
  opacity: 0.7;
  width: 20px;
}

.rail-tick:hover::after {
  content: attr(data-label);
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--black);
  color: var(--white);
  padding: 3px 8px;
  border-radius: 3px;
}

/* ═══════════════════════════════════════════
   SECTIONS
   ═══════════════════════════════════════════ */

.dd-section {
  padding: 3rem 0 3.5rem;
  border-bottom: 1px solid var(--border-medium);
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.65s ease, transform 0.65s ease;
  position: relative;
}

.dd-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.dd-section:last-child {
  border-bottom: none;
}

.dd-section-num {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.6;
  margin-bottom: 0.4rem;
}

.dd-section-title {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
}

.dd-section-title::after {
  content: '';
  display: block;
  width: 32px;
  height: 2px;
  background: var(--accent);
  margin-top: 0.65rem;
  opacity: 0.5;
}

.dd-section-body {
  position: relative;
}

.dd-section-body p {
  font-size: 0.94rem;
  line-height: 1.78;
  color: var(--text-primary);
}

.dd-section-body p + p {
  margin-top: 0;
}

/* ─── Epigraph / Quote ─── */

.epigraph {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-style: italic;
  font-weight: 300;
  line-height: 1.45;
  color: var(--charcoal);
  border-left: 3px solid var(--accent);
  padding: 0.8rem 0 0.8rem 1.8rem;
  margin: 0 0 2.5rem 0;
  max-width: 52ch;
}

.epigraph cite {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.8rem;
}

/* ─── Section Lead ─── */

.section-lead {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--text-secondary);
  margin-bottom: 1.2rem;
}

/* ─── Inline Quotes ─── */

.inline-quote {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--charcoal);
  background: var(--accent-dim);
  padding: 0.8rem 1.2rem;
  border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0;
  margin: 1.2rem 0;
  font-size: 0.95rem;
  line-height: 1.6;
}

.inline-quote .quote-source {
  display: block;
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ─── Sidenotes ─── */

.sidenote-ref {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 4px;
  border-radius: 2px;
  margin-left: 2px;
  vertical-align: super;
  line-height: 0;
  cursor: default;
}

.sidenote-ref::before { content: '['; }
.sidenote-ref::after { content: ']'; }

.sidenote {
  position: absolute;
  right: -210px;
  width: 185px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  line-height: 1.6;
  color: var(--text-muted);
  border-left: 1px solid var(--accent-glow);
  padding-left: 10px;
}

.sidenote-num {
  font-weight: 600;
  color: var(--accent);
  margin-right: 3px;
}

/* ─── Callout Boxes ─── */

.callout {
  padding: 1.1rem 1.3rem;
  border-radius: 4px;
  margin: 1.4rem 0;
  border-left: 3px solid;
  font-size: 0.88rem;
  line-height: 1.7;
}

.callout h4 {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.callout p {
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
}

.callout p:last-child { margin-bottom: 0; }

.callout--threat {
  background: rgba(196, 30, 42, 0.04);
  border-color: var(--thrive-red);
}
.callout--threat h4 { color: var(--thrive-red); }

.callout--inversion {
  background: rgba(45, 90, 61, 0.04);
  border-color: var(--forest);
}
.callout--inversion h4 { color: var(--forest); }

/* ─── Diagrams ─── */

.dd-diagram {
  margin: 2rem 0;
  padding: 1.8rem;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  background: var(--bg-secondary);
  position: relative;
  overflow: hidden;
}

.dd-diagram::before {
  content: attr(data-figure);
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 0.52rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.35;
}

.dd-diagram svg {
  width: 100%;
  height: auto;
  display: block;
}

.dd-diagram figcaption {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 1rem;
  letter-spacing: 0.03em;
}

/* ─── Company Sections ─── */

.company-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.3rem;
}

.company-tag {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--white);
  background: var(--accent);
  padding: 2px 8px;
  border-radius: 2px;
}

.metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 1rem 0 1.5rem;
  padding: 0.8rem 1rem;
  background: var(--bg-secondary);
  border-radius: 4px;
  border: 1px solid var(--border-medium);
}

.metric {
  display: flex;
  flex-direction: column;
}

.metric-value {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--accent);
  line-height: 1.2;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ─── Thrive // Endmark ─── */

.thrive-endmark {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 3rem 0 2rem;
}

.thrive-endmark span {
  display: block;
  width: 18px;
  height: 36px;
  background: var(--border-medium);
  transform: skewX(-12deg);
  border-radius: 2px;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 1300px) {
  .sidenote {
    right: -190px;
    width: 165px;
  }
}

@media (max-width: 1100px) {
  .page-body {
    grid-template-columns: 1fr;
  }

  .toc-sidebar {
    display: none;
  }

  .content-area {
    max-width: 680px;
    padding: 2rem 2rem 5rem;
  }

  .sidenote {
    position: static;
    right: auto;
    width: 100%;
    margin: 1rem 0;
    padding: 0.7rem 0.9rem;
    background: var(--bg-secondary);
    border-left: 2px solid var(--accent-glow);
    border-radius: 0 4px 4px 0;
    font-size: 0.65rem;
  }
}

@media (max-width: 900px) {
  #progress-rail {
    display: none;
  }

  .page-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  html { font-size: 15.5px; }

  .hero-title { font-size: 2.2rem; }

  .content-area {
    padding: 2.5rem 1.2rem 4rem;
  }

  .dd-section {
    padding: 2rem 0 2.5rem;
  }

  .epigraph {
    font-size: 1.25rem;
    padding-left: 1.2rem;
  }

  .callout {
    padding: 0.9rem 1rem;
  }

  .metric-row {
    gap: 1rem;
  }

  .dd-diagram {
    padding: 1rem;
  }
}

/* ─── Reduced Motion ─── */

@media (prefers-reduced-motion: reduce) {
  .dd-section {
    opacity: 1;
    transform: none;
    transition: none;
  }
  html {
    scroll-behavior: auto;
  }
}
