/* ==================================================================
   SAASPOCALYPSE 2026 — saaspocalypse.css
   Page-specific styles on top of ../../styles.css. Shares tokens
   (--gold, --surface, --border, etc.) so colors stay consistent
   with the rest of Rycode.

   TABLE OF CONTENTS
   -----------------
   1. EMERGING RISK PILL      (the "Emerging Risk · 2026" badge)
   2. KPI TILES                (3 tiles under the executive summary)
   3. REPORT CHART WRAP        (shared container for all charts)
   4. REPORT CALLOUTS          (vulnerable-zone / moat boxes)
   5. REPORT PANELS            (bordered content cards w/ heading)
   6. CALCULATOR BANNER        (full-width CTA below the line chart)
   7. FINANCE GRID             (2-col doughnut + tab layout)
   8. YEAR TOGGLE              (2024 / 2026 doughnut switch)
   9. TAB SWITCHER             (Why Finance / Why GRC tabs)
  10. RESPONSIVE               (breakpoints + stacking)
   ================================================================== */


/* ==================================================================
   1. EMERGING RISK PILL
   A small gold/amber badge next to the status chip in the hero meta
   row. Signals this is an emerging-risk briefing, not a casual essay.
   ================================================================== */
.risk-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5ch;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--gold);
  background: rgba(212, 168, 75, 0.08);
  border: 1px solid rgba(212, 168, 75, 0.35);
  white-space: nowrap;
}


/* ==================================================================
   2. KPI TILES
   The three stat cards under the executive summary — loss / loss /
   growth. Color-coded by outcome (gold-hot for loss, green for growth).
   ================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-4);
  margin-top: var(--s-6);
}

.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.kpi-tile.is-loss   { border-left: 3px solid #ffb547; }   /* gold-hot for losses */
.kpi-tile.is-growth { border-left: 3px solid #4ade80; }   /* live-green for growth */

.kpi-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-faint);
  margin: 0;
}
.kpi-value {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1;
}
.kpi-tile.is-loss   .kpi-value { color: #ffb547; }
.kpi-tile.is-growth .kpi-value { color: #4ade80; }

.kpi-note {
  font-size: var(--fs-small);
  color: var(--text-soft);
  margin: 0;
  line-height: 1.5;
}


/* ==================================================================
   3. REPORT CHART WRAP
   Shared container for every chart on the page. Aspect-ratio keeps
   it proportional; Chart.js handles its own responsiveness inside.
   ================================================================== */
.report-chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  margin-top: var(--s-5);
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 480px;
}
.report-chart-wrap.is-compact {
  aspect-ratio: 4 / 3;
  max-height: 340px;
  padding: var(--s-4);
  margin-top: var(--s-4);
}
.report-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}


/* ==================================================================
   4. REPORT CALLOUTS
   The paired "vulnerable zone / moat" cards under the vendor chart.
   ================================================================== */
.report-callout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-3);
  margin-top: var(--s-4);
}
.report-callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--s-4);
}
.report-callout.is-warning { border-left: 3px solid #ffb547; }
.report-callout.is-safe    { border-left: 3px solid #4ade80; }

.callout-label {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin: 0 0 var(--s-2);
}
.report-callout.is-warning .callout-label { color: #ffb547; }
.report-callout.is-safe    .callout-label { color: #4ade80; }

.callout-body {
  font-size: var(--fs-small);
  color: var(--text-soft);
  margin: 0;
  line-height: 1.55;
}


/* ==================================================================
   5. REPORT PANELS
   Reusable bordered content card — used for "Why companies are
   turning away" and for the finance-grid columns.
   ================================================================== */
.report-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  margin-top: var(--s-5);
}
.report-panel-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 var(--s-3);
  color: var(--text);
  letter-spacing: -0.01em;
}

/* Bulleted argument list inside a panel. */
.report-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.report-list li {
  padding-left: var(--s-4);
  border-left: 2px solid var(--gold-dim, rgba(212, 168, 75, 0.35));
  font-size: var(--fs-small);
  color: var(--text-soft);
  line-height: 1.6;
}
.report-list li strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.25rem;
}


/* ==================================================================
   6. CALCULATOR BANNER
   Full-width CTA card placed directly under the Build-vs-Buy chart.
   Prominent — this is the whole point of the report-plus-calculator
   pairing. Gold radial glow on top so the eye stops here.
   ================================================================== */
.calc-banner {
  margin-top: var(--s-5);
  border: 1px solid var(--border-hot, rgba(212, 168, 75, 0.45));
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(255, 181, 71, 0.10), transparent 60%),
    var(--surface);
  overflow: hidden;
}
.calc-banner-inner {
  padding: var(--s-6) var(--s-5);
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}
.calc-banner-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--gold);
  margin: 0 0 var(--s-2);
}
.calc-banner-title {
  font-size: clamp(1.25rem, 2.6vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--text);
  margin: 0 0 var(--s-3);
}
.calc-banner-title em {
  font-style: normal;
  background: linear-gradient(135deg, #ffb547 0%, #d4a84b 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}
.calc-banner-body {
  font-size: var(--fs-small);
  color: var(--text-soft);
  margin: 0 0 var(--s-4);
  line-height: 1.6;
}
.calc-banner-cta .btn { min-width: 240px; }


/* ==================================================================
   7. FINANCE GRID
   The finance/GRC deep-dive section: doughnut on the left, tab card
   on the right. Stacks single-column on smaller screens.
   ================================================================== */
.finance-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-4);
  margin-top: var(--s-5);
}
.finance-grid .report-panel { margin-top: 0; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-3);
}


/* ==================================================================
   8. YEAR TOGGLE
   Small two-button toggle above the doughnut (2024 / 2026). The
   active button gets gold fill so the current view is unambiguous.
   ================================================================== */
.year-toggle {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.year-btn {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.year-btn:hover { color: var(--text); }
.year-btn.is-active {
  background: rgba(212, 168, 75, 0.18);
  color: var(--gold);
}
.year-btn:focus-visible {
  outline: 2px solid var(--gold-hot);
  outline-offset: 2px;
}

/* Insight caption below the doughnut — updates with the toggle. */
.panel-insight {
  margin: var(--s-3) 0 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--text-faint);
  letter-spacing: 0.02em;
  line-height: 1.5;
}


/* ==================================================================
   9. TAB SWITCHER
   The two-tab card ("Why finance is building" / "Why GRC vendors
   survive"). Gold underline on the active tab.
   ================================================================== */
.tab-header {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  border-bottom: 1px solid var(--border);
  margin: calc(var(--s-5) * -1) calc(var(--s-5) * -1) var(--s-4);
  padding: var(--s-3) var(--s-5) 0;
  background: rgba(255, 255, 255, 0.015);
}
.tab-btn {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: var(--fs-small);
  font-weight: 600;
  padding: var(--s-3) var(--s-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;  /* overlaps the 1px bottom border when active */
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.is-active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.tab-btn:focus-visible {
  outline: 2px solid var(--gold-hot);
  outline-offset: 2px;
  border-radius: 4px;
}

.tab-body { position: relative; }
.tab-pane {
  display: none;
  animation: tab-fade 200ms var(--ease) both;
}
.tab-pane.is-active { display: block; }
@media (prefers-reduced-motion: reduce) {
  .tab-pane { animation: none; }
}
@keyframes tab-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tab-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--s-2);
}
.tab-heading.is-grc { color: #4ade80; }

.tab-lede {
  font-size: var(--fs-small);
  color: var(--text-soft);
  margin: 0 0 var(--s-3);
  line-height: 1.6;
}

.tab-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.tab-list li {
  padding-left: var(--s-4);
  border-left: 2px solid rgba(212, 168, 75, 0.35);
  font-size: var(--fs-small);
  color: var(--text-soft);
  line-height: 1.55;
}
.tab-list li strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.tab-list.is-grc li { border-left-color: rgba(74, 222, 128, 0.45); }

.tab-insight {
  margin-top: var(--s-4);
  padding: var(--s-3);
  border: 1px solid rgba(74, 222, 128, 0.25);
  background: rgba(74, 222, 128, 0.06);
  border-radius: var(--radius-md);
  font-size: var(--fs-small);
  color: #b9f0c7;  /* a lighter tint of green so it still reads on dark */
  line-height: 1.55;
}
.tab-insight strong { color: #4ade80; }


/* ==================================================================
  10. RESPONSIVE
   Desktop: KPIs become 3-col, callouts become 2-col, finance deep
   dive becomes 2-col.
   ================================================================== */
@media (min-width: 768px) {
  .kpi-grid           { grid-template-columns: repeat(3, 1fr); }
  .report-callout-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1024px) {
  .finance-grid { grid-template-columns: 1fr 1fr; align-items: start; }
}


/* ==================================================================
   11. Q2 2026 UPDATE — page-local additions for v1.1
   All classes namespaced to avoid leaking into the original sections.
   ================================================================== */

/* ——— Provenance note under the dual-PDF CTA ——— */
.case-cta-note {
  margin-top: var(--s-3);
  max-width: 65ch;
  font-size: var(--fs-small);
  color: var(--text-faint);
  line-height: 1.55;
  font-style: italic;
}

/* ——— Updated pill in the hero meta row ——— */
.updated-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid rgba(74, 222, 128, 0.4);
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.08);
  color: #4ade80;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ——— Mini table of contents (in the hero) ——— */
.case-toc {
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
  max-width: 65ch;
}
.case-toc-label {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 var(--s-3);
}
.case-toc-list {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: var(--s-2);
  counter-reset: toc;
}
.case-toc-list li {
  counter-increment: toc;
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
}
.case-toc-list li::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--text-faint);
  letter-spacing: 0.1em;
}
.case-toc-list a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.case-toc-list a:hover {
  color: var(--gold-hot);
  border-bottom-color: var(--gold-dim);
}
.case-toc-tag {
  display: inline-block;
  margin-left: var(--s-2);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ——— Q2 update section — section eyebrow gets a small treatment so
    the reader can clearly tell "you're in the new section" ——— */
.section-q2 .section-title { color: var(--text); }
.section-q2 .section-eyebrow {
  color: #4ade80;            /* live-green to signal "fresh" */
}

/* H3 inside the Q2 section — slightly smaller than the section title
   but bigger than the report-panel-title style. */
.q2-h3 {
  font-size: 1.5rem;
  margin: var(--s-3) 0 var(--s-3);
  color: var(--text);
  line-height: 1.3;
}

/* ——— Bank stage matrix ——— */
.bank-matrix-wrap,
.grc-matrix-wrap {
  margin: var(--s-5) 0;
  padding: 0;
  /* Allow horizontal scroll on narrow viewports rather than crushing
     the table. The caption explains what's there for screen readers. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.bank-matrix,
.grc-matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  /* Ensure table doesn't squeeze too tight on mobile — horizontal
     scroll kicks in instead. */
  min-width: 640px;
}
.bank-matrix-caption,
.grc-matrix-caption {
  caption-side: bottom;
  font-size: var(--fs-small);
  color: var(--text-faint);
  text-align: left;
  padding: var(--s-3) var(--s-4);
  border-top: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.bank-matrix th,
.bank-matrix td,
.grc-matrix th,
.grc-matrix td {
  padding: var(--s-3) var(--s-4);
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-small);
}
.bank-matrix tbody tr:last-child th,
.bank-matrix tbody tr:last-child td,
.grc-matrix tbody tr:last-child th,
.grc-matrix tbody tr:last-child td {
  border-bottom: none;
}
.bank-matrix thead th,
.grc-matrix thead th {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
/* Row labels — bank/vendor names on the left */
.bank-matrix tbody th,
.grc-matrix tbody th {
  text-align: left;
  font-weight: 600;
  color: var(--text);
}
.bank-matrix-sub,
.grc-matrix-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-top: 2px;
  text-transform: none;
}
/* Filled cells — gold dot signals "yes" */
.bank-matrix td.is-on,
.grc-matrix td.is-on {
  color: var(--gold);
  font-size: 1.15rem;
  font-weight: 700;
}
.bank-matrix-rowhead-empty,
.grc-matrix-rowhead-empty { background: transparent; }

/* GRC architecture column — small categorical badge */
.grc-matrix-arch {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.grc-matrix-arch.is-native  { color: #4ade80; }   /* AI-native */
.grc-matrix-arch.is-mixed   { color: var(--gold); }
.grc-matrix-arch.is-legacy  { color: #ffb547; }

/* ——— Downstream impacts — clean numbered list ——— */
.downstream-list {
  margin: var(--s-4) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: downstream;
  display: grid;
  gap: var(--s-3);
}
.downstream-list li {
  counter-increment: downstream;
  position: relative;
  padding: var(--s-4) var(--s-5) var(--s-4) calc(var(--s-7) + 12px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  line-height: 1.6;
}
.downstream-list li::before {
  content: counter(downstream);
  position: absolute;
  left: var(--s-4); top: var(--s-4);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold);
  width: var(--s-5);
  text-align: center;
}
.downstream-list strong { color: var(--text); }

/* ——— Archive divider between Q2 and original sections ——— */
.section-divider {
  padding-top: var(--s-7);
  padding-bottom: var(--s-3);
}
.archive-divider {
  text-align: center;
  max-width: 65ch;
  margin: 0 auto;
}
.archive-rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 var(--s-5);
}
.archive-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 var(--s-3);
}
.archive-title {
  font-size: 1.75rem;
  color: var(--text-muted);  /* slightly de-emphasized vs. Q2 H2s */
  margin: 0 0 var(--s-3);
}
.archive-note {
  color: var(--text-faint);
  font-size: var(--fs-small);
  font-style: italic;
  margin: 0;
}

/* ——— Footnote callers (sup.fn) and references list ——— */
sup.fn {
  font-size: 0.65em;
  vertical-align: super;
  line-height: 0;
  margin-left: 1px;
}
sup.fn a {
  color: var(--gold);
  text-decoration: none;
  padding: 0 2px;
  border-radius: 3px;
  transition: background 0.12s ease;
}
sup.fn a:hover { background: rgba(212, 168, 75, 0.15); }
sup.fn a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.sources {
  margin-top: var(--s-7);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
}
.sources-title {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 var(--s-4);
}
.sources-list {
  margin: 0;
  padding: 0 0 0 var(--s-5);
  counter-reset: refnum;
}
.sources-list li {
  counter-increment: refnum;
  list-style: none;
  position: relative;
  padding: var(--s-2) 0 var(--s-2) var(--s-4);
  font-size: var(--fs-small);
  color: var(--text-muted);
  line-height: 1.55;
  border-bottom: 1px dashed transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.sources-list li::before {
  content: counter(refnum) ".";
  position: absolute;
  left: -1.5rem;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--text-faint);
  letter-spacing: 0.05em;
  font-weight: 600;
}
/* Highlight the source row when its hash is the current target —
   so a reader who clicks a footnote caller is visually anchored. */
.sources-list li:target {
  background: rgba(212, 168, 75, 0.08);
  border-color: var(--gold-dim);
  border-radius: 6px;
  padding-left: var(--s-4);
}
.sources-list a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid var(--gold-dim);
}
.sources-list a:hover {
  color: var(--gold-hot);
  border-bottom-color: var(--gold-hot);
}

/* ——— Reduced motion override for the new components ——— */
@media (prefers-reduced-motion: reduce) {
  .case-toc-list a,
  sup.fn a,
  .sources-list li,
  .sources-list a { transition: none !important; }
}
