/* =============================================================
   Interactive behaviors — scroll-snap, side nav, progress bar
   ============================================================= */

/* ============ Layout shell ============ */
.cim-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.cim-main {
  grid-column: 2;
  min-width: 0;
}

/* ============ Progress bar (top) ============ */
.progress-track {
  position: fixed;
  top: 0;
  left: 240px;
  right: 0;
  height: 3px;
  background: rgba(15, 23, 42, 0.06);
  z-index: 60;
}
.progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--blue));
  transition: width 0.15s linear;
  border-radius: 0 2px 2px 0;
  width: 0;
}

/* ============ Side nav ============ */
.side-nav {
  grid-column: 1;
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--navy-ink), var(--navy));
  color: #FFFFFF;
  padding: 28px 22px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 2px 0 20px rgba(7, 21, 46, 0.15);
  display: flex;
  flex-direction: column;
}
.side-nav-header {
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 22px;
}
.side-nav-brand {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: #FFFFFF;
  margin-bottom: 2px;
}
.side-nav-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}
.side-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.side-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
  border-bottom: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.side-nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #FFFFFF;
  border-bottom: none;
}
.side-nav-link.active {
  background: rgba(239, 77, 90, 0.14);
  color: #FFFFFF;
  font-weight: 700;
}
.side-nav-link.active::before {
  content: "";
  width: 3px;
  height: 18px;
  background: var(--red);
  border-radius: 1.5px;
  margin-right: -4px;
}
.side-nav-num {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.35);
  min-width: 18px;
}
.side-nav-link.active .side-nav-num {
  color: var(--red);
}
.side-nav-footer {
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.5;
}
.side-nav-footer .pdf-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 600;
  margin-top: 10px;
  transition: background 0.15s;
  cursor: pointer;
}
.side-nav-footer .pdf-download:hover {
  background: rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

/* ============ Sections ============ */
.cim-section {
  min-height: 100vh;
  padding: 80px 96px;
  position: relative;
  scroll-margin-top: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.cim-section > * + * {
  margin-top: 28px;
}

/* First section — cover — full-bleed centered */
.cim-section.cover {
  background: linear-gradient(135deg, var(--navy-ink) 0%, var(--navy) 50%, var(--blue-deep) 100%);
  color: #FFFFFF;
  justify-content: center;
}
.cim-section.cover .hero-title,
.cim-section.cover .subtitle,
.cim-section.cover .eyebrow {
  color: #FFFFFF;
}
.cim-section.cover .eyebrow {
  color: rgba(255, 255, 255, 0.7);
}
.cim-section.cover .subtitle {
  color: rgba(255, 255, 255, 0.8);
}

/* Chapter break */
.cim-section.chapter {
  background:
    radial-gradient(ellipse at top left, rgba(23, 78, 166, 0.06), transparent 60%),
    var(--bg);
  justify-content: center;
  min-height: 80vh;
  padding: 60px 96px;
}

/* ============ Section meta footer ============ */
.section-meta {
  position: absolute;
  bottom: 24px;
  left: 96px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.section-meta .sec-num {
  color: var(--navy);
  font-weight: 800;
}
.section-meta .rule {
  width: 22px;
  height: 1px;
  background: rgba(15, 23, 42, 0.18);
}
.section-footer-confidential {
  position: absolute;
  bottom: 24px;
  right: 96px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  font-weight: 600;
}
.cim-section.cover .section-meta .sec-num,
.cim-section.cover .section-meta,
.cim-section.cover .section-footer-confidential {
  color: rgba(255, 255, 255, 0.55);
}
.cim-section.cover .section-meta .rule {
  background: rgba(255, 255, 255, 0.2);
}

/* ============ Masked indicator (floating) ============ */
.mask-indicator {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 14px;
  background: rgba(12, 34, 72, 0.95);
  color: #FFFFFF;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  z-index: 100;
  display: none;
  box-shadow: var(--shadow-dark);
}
.mask-indicator.visible {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mask-indicator::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px rgba(239, 77, 90, 0.8);
}

/* ============ Reveal animations (subtle) ============ */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* ============ Responsive ============ */
@media (max-width: 960px) {
  .cim-shell {
    grid-template-columns: 1fr;
  }
  .side-nav {
    position: fixed;
    top: 0;
    left: -240px;
    width: 240px;
    transition: left 0.3s;
  }
  .side-nav.open {
    left: 0;
  }
  .progress-track {
    left: 0;
  }
  .cim-section {
    padding: 48px 28px;
  }
}

/* ============ Print CSS ============ */
@media print {
  @page { size: 1920px 1080px; margin: 0; }

  *, *::before, *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  html, body {
    margin: 0;
    padding: 0;
    background: #fff;
    width: 1920px;
  }

  .side-nav,
  .progress-track,
  .mask-indicator {
    display: none !important;
  }

  .cim-shell {
    grid-template-columns: 1fr;
    display: block;
    width: 1920px;
  }
  .cim-main {
    grid-column: 1;
    display: block;
    width: 1920px;
  }

  /* ---------- Sections: one slide = one page ---------- */
  .cim-section {
    width: 1920px !important;
    height: 1080px !important;
    min-height: 1080px !important;
    max-height: 1080px !important;
    padding: 44px 64px !important;
    margin: 0 !important;
    overflow: hidden;
    page-break-after: always;
    page-break-inside: avoid;
    break-after: page;
    break-inside: avoid;
    box-shadow: none;
    border-radius: 0;
    position: relative;
    box-sizing: border-box;
  }
  .cim-section:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  /* Chapter slides keep centered layout */
  .cim-section.chapter {
    justify-content: center;
  }

  /* ---------- Tighter vertical rhythm ---------- */
  .cim-section > * + * {
    margin-top: 14px !important;
  }

  /* ---------- Typography: tighter for print ---------- */
  .hero-title { font-size: 56px !important; }
  .section-title { font-size: 26px !important; margin-bottom: 4px !important; }
  .subtitle { font-size: 13px !important; line-height: 1.45 !important; }
  .eyebrow { font-size: 10px !important; margin-bottom: 6px !important; }
  .chapter-number { font-size: 140px !important; margin-bottom: 12px !important; }
  .chapter-title { font-size: 52px !important; margin-bottom: 8px !important; }

  /* ---------- Components: compact for print ---------- */
  .card { padding: 16px !important; }
  .card.tight { padding: 12px !important; }
  .card.loose { padding: 20px !important; }
  .card h4 { font-size: 12px !important; margin-bottom: 3px !important; }
  .card p { font-size: 10.5px !important; line-height: 1.4 !important; }

  .thesis-band {
    padding: 14px 20px !important;
    font-size: 13px !important;
  }

  .kpi-strip { gap: 1px !important; }
  .kpi-cell { padding: 14px 12px !important; }
  .kpi-value { font-size: 26px !important; }
  .kpi-label { font-size: 9px !important; }

  .grid-2, .grid-3, .grid-4 { gap: 10px !important; }

  /* Tables */
  .wf-table { font-size: 10.5px !important; }
  .wf-table thead th { padding: 8px 10px !important; font-size: 9px !important; }
  .wf-table tbody td { padding: 8px 10px !important; }

  /* Inline styles from faithful HTML */
  .highlight-card { gap: 10px !important; }
  .highlight-body p { font-size: 11px !important; }

  .disclosure-text { font-size: 10px !important; line-height: 1.55 !important; }
  .disclosure-text p + p { margin-top: 6px !important; }

  .contact-card { padding: 16px !important; }

  .toc-grid { gap: 10px !important; }
  .toc-item { padding: 14px !important; gap: 10px !important; }
  .toc-num { font-size: 22px !important; }
  .toc-title { font-size: 13px !important; }

  .tbu { padding: 16px !important; font-size: 11px !important; }

  .segment-row > div { padding: 8px 10px !important; }
  .segment-row { font-size: 10.5px !important; }

  .process-steps { gap: 1px !important; }
  .process-step { padding: 12px 10px !important; }

  .channel-grid { gap: 8px !important; }
  .channel-item { padding: 12px 8px !important; }

  .leader-bio ul { font-size: 11px !important; }
  .leader-card { padding: 14px !important; }

  .entity-diagram { padding: 16px !important; gap: 6px !important; }
  .supply-path { padding: 12px !important; gap: 8px !important; }

  /* Section footer stays pinned */
  .section-meta { bottom: 16px !important; left: 64px !important; }
  .section-footer-confidential { bottom: 16px !important; right: 64px !important; }

  /* Reveal animations: show everything in print */
  .reveal {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  /* Backdrop filter doesn't print */
  .card, .thesis-band, .kpi-strip {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* Images: constrain height to prevent blowout */
  .cim-section img {
    max-height: 360px !important;
    object-fit: contain !important;
  }
  /* Allow SVG charts to size naturally */
  .cim-section svg {
    max-height: 200px !important;
  }

  /* ---------- Financial tables: ultra-compact ---------- */
  .fin-table { font-size: 11px !important; }
  .fin-table thead th { padding: 8px 12px !important; font-size: 9px !important; }
  .fin-table tbody td { padding: 7px 12px !important; }
  .fin-table tbody tr.group-head td { font-size: 11px !important; }

  /* Collapse spacer rows in financial tables */
  .fin-table tbody td:empty,
  .fin-table tbody td:only-child {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
  }

  /* Tighter commentary cards on financial slides */
  #s39 .card, #s40 .card, #s41 .card, #s42 .card {
    padding: 10px 14px !important;
    margin-top: 8px !important;
  }
  #s39 .card h4, #s40 .card h4, #s41 .card h4, #s42 .card h4 {
    font-size: 11px !important;
    margin-bottom: 4px !important;
  }
  #s39 .tbu, #s40 .tbu, #s41 .tbu, #s42 .tbu {
    padding: 8px !important;
    font-size: 10px !important;
    margin-top: 6px !important;
  }

  /* Scale wrapper (injected by JS for Playwright path only) */
  .print-scale-wrap {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    position: relative;
    box-sizing: border-box;
  }
}
