/* CSAP case-study page. Loaded after styles.css; uses only its tokens. */
/* Hero (reuses .hero, .eyebrow, .lead, .card) */
:root { --cs-bar-h: 2.875rem; }
.hero--sub { min-height: calc(100svh - var(--header-h) - var(--cs-bar-h)); }
.hero--sub .hero__inner { grid-template-columns: minmax(0, 1fr); }
.hero--sub h1 { max-width: 24ch; }
.cs-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); align-self: stretch; width: 100%; margin-top: var(--space-4); }
.cs-stats .card { gap: .25rem; justify-content: flex-start; }
.cs-stats .card:hover { border-color: var(--color-border); }
.cs-stats strong { font-size: clamp(3rem, 2.2rem + 3vw, 4.5rem); font-weight: 740; color: var(--color-accent); line-height: 1.1; letter-spacing: -.02em; }
.cs-stats span { font-size: .875rem; line-height: 1.35; color: var(--color-muted); }
@media (max-width: 39.99rem) { .cs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cs-stats.cs-stats--build { grid-template-columns: minmax(0, 1fr); margin-top: 0; }
@media (min-width: 40rem) and (max-width: 55.99rem) { .cs-stats.cs-stats--build { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.cs__back { margin-bottom: var(--space-3); font-size: .875rem; }
.hero--sub .cs__back { order: -1; }
.cs__back a { color: var(--color-muted); }
.cs__back a:hover { color: var(--color-accent); }

/* On this page bar: full-bleed strip directly under the site header; sticky from 48rem (JS only), one appearance */
:root { --cs-bar-h: 3rem; }
.cs-toc {
  --cs-toc-fill: color-mix(in srgb, var(--color-accent) 12%, var(--color-bg));
  box-sizing: border-box; display: flex; align-items: center; justify-content: center; min-height: var(--cs-bar-h);
  background: var(--color-bg); border-bottom: 1px solid var(--color-border);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .cs-toc {
    background: color-mix(in srgb, var(--color-bg) 72%, transparent);
    -webkit-backdrop-filter: blur(10px) saturate(1.05);
    backdrop-filter: blur(10px) saturate(1.05);
  }
}
@media (min-width: 48rem) { .js .cs-toc { position: sticky; top: var(--header-h); z-index: 40; } }
.cs-toc__inner { position: relative; display: flex; justify-content: center; }
.cs-toc__list { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 var(--space-1); }
.cs-toc__list a, .cs-toc__btn {
  display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0 .75rem; border-radius: var(--radius-sm);
  color: var(--color-text); text-decoration: none; font-size: .875rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
}
.cs-toc__list a:focus-visible, .cs-toc__btn:focus-visible { outline-offset: 2px; }
.cs-toc__list a:focus-visible { background: var(--cs-toc-fill); }
@media (hover: hover) { .cs-toc__list a:hover, .cs-toc__btn:hover { background: var(--cs-toc-fill); } }
.cs-toc__btn { display: none; gap: .5rem; font-family: inherit; background: none; border: 0; cursor: pointer; }
.cs-toc__btn svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur) var(--ease); }
.cs-toc.is-open .cs-toc__btn svg { transform: rotate(180deg); }
@media (min-width: 48rem) { .js .cs .section { scroll-margin-top: var(--cs-bar-h); } }
@media (max-width: 47.99rem) {
  .js .cs-toc__btn { display: inline-flex; }
  .js .cs-toc__list {
    display: none; position: absolute; top: 100%; left: 50%; z-index: 5; transform: translateX(-50%);
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0; width: max-content; max-width: calc(100vw - 2rem);
    padding: .25rem var(--space-2); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    box-shadow: 0 .75rem 1.5rem -1rem rgba(0, 0, 0, .35);
  }
  .js .cs-toc.is-open .cs-toc__list { display: flex; }
  .js .cs-toc__list li + li { border-top: 1px solid var(--color-border); }
}
@media (prefers-reduced-motion: reduce) { .cs-toc__btn svg { transition: none; } }

/* Section rhythm for loose paragraphs */
.cs .section .wrap > * + * { margin-top: var(--space-2); }
.cs p, .cs li { max-width: var(--measure); }

/* Data tables in a card shell (.card tokens, .facts-label headers); rows stack below 40rem */
.cs-tablecard { padding: 0; overflow: hidden; }
.cs-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .9375rem; line-height: 1.55; }
.cs-table th, .cs-table td { padding: var(--space-2) var(--space-3); text-align: left; vertical-align: top; border-top: 1px solid var(--color-border); overflow-wrap: break-word; }
.cs-table thead th { padding-block: var(--space-2) .75rem; border-top: 0; border-bottom: 1px solid var(--color-border-strong); }
.cs-table tbody th { font-weight: 650; }
.cs-table--status col:first-child { width: 26%; }
@media (max-width: 39.99rem) {
  .cs-table colgroup { display: none; }
  .cs-table, .cs-table tbody, .cs-table tr, .cs-table th, .cs-table td { display: block; width: 100%; }
  .cs-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .cs-table tr { padding: var(--space-2) var(--space-3); border-top: 1px solid var(--color-border); }
  .cs-table tbody tr:first-child { border-top: 0; }
  .cs-table th, .cs-table td { padding: .25rem 0; border: 0; }
  .cs-table [data-label]::before { content: attr(data-label); display: block; font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--color-muted); }
}



/* Diagrams: inline SVG, theme tokens only */
.dg { margin-block: var(--space-3); }
.dg svg { display: block; width: 100%; height: auto; max-width: 22.5rem; margin-inline: 0; overflow: visible; }
.dg--hold svg { max-width: 40rem; }
.dg-node { fill: var(--color-surface); stroke: var(--color-border-strong); stroke-width: 1.5; }
.dg-node--end { fill: var(--color-surface-alt); }
.dg-node--planned { fill: none; stroke-dasharray: 5 4; }
.dg-text { fill: var(--color-text); font: 500 13px var(--font-sans); }
.dg-small { fill: var(--color-muted); font: 500 11.5px var(--font-sans); }
.dg-line { fill: none; stroke: var(--color-muted); stroke-width: 1.75; }
.dg-line--planned { stroke-dasharray: 5 4; }
.dg-line--clar { stroke-dasharray: 2 3; }
.dg-head { fill: var(--color-muted); }
.dg-axis { stroke: var(--color-border-strong); stroke-width: 2; }
.dg-dot { fill: var(--color-bg); stroke: var(--color-text); stroke-width: 2; }
.dg-dot--accent { fill: var(--color-accent); stroke: var(--color-accent); }
.dg-hold { fill: var(--color-surface-alt); stroke: var(--color-border-strong); }
.dg-resv { fill: var(--color-accent); }



/* Why I built it: loop graphic in the .about-open__inner split (shown on mobile too, below the text) */
.about-open__inner > .about-open__art { display: block; margin: 0; }
.about-open__art.loop { width: min(100%, 20rem); justify-self: center; }
.cs .about-open__inner:has(> .about-open__art) { align-items: start; }
.loop svg { display: block; width: 100%; height: auto; }
.lp-box { fill: var(--color-surface); stroke: var(--color-border-strong); stroke-width: 1.5; }
.lp-box--accent { fill: var(--color-accent); stroke: var(--color-accent); }
.lp-text { fill: var(--color-text); font: 600 15px var(--font-sans); }
.lp-text--accent { fill: var(--color-on-accent); }
.lp-small { fill: var(--color-muted); font: 500 14px var(--font-sans); letter-spacing: .08em; text-transform: uppercase; }
.lp-line { fill: none; stroke: var(--color-muted); stroke-width: 2; }
.lp-line--loop { stroke-dasharray: 5 4; }
.lp-head { fill: var(--color-muted); }

/* Diagrams: compact version below 48rem, wide version from 48rem (the hidden one is display:none, so only one is exposed) */
.dg__wide { display: none; }
@media (min-width: 64rem) { .dg__compact { display: none; } .dg__wide { display: block; } }
.dg .dg__wide svg { max-width: none; }
.dgw-text { fill: var(--color-text); font: 500 16px var(--font-sans); }
.dgw-text--on { fill: var(--color-on-accent); font-weight: 650; }
.dgw-text--strong { font-weight: 700; }
.dgw-small { fill: var(--color-muted); font: 500 14px var(--font-sans); }
.dg-node--accent { fill: var(--color-accent); stroke: var(--color-accent); }
.section--tint .dg-node:not(.dg-node--planned):not(.dg-node--accent):not(.dg-node--end) { fill: var(--color-bg); }
.section--tint .dg-node--end { fill: var(--color-surface-alt); }
.dg-text--strong { font-weight: 700; }
.cs__bridge { max-width: none; text-align: center; color: var(--color-muted); }

/* Funding scenarios: three .card in a .card-grid */
@media (min-width: 40rem) and (max-width: 47.99rem) { .card-grid--3, .card-grid--2 { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 48rem) { .card-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .card-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.js .card-grid.card-grid--3, .js .card-grid.card-grid--2 { align-items: stretch; }
.fund { gap: 0; }
.fund__figure { margin-top: var(--space-1); font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem); font-weight: 740; letter-spacing: -.02em; line-height: 1.15; }
.fund__figure span { display: block; font-size: .8125rem; font-weight: 500; letter-spacing: 0; color: var(--color-muted); }
.fund__bar { display: flex; gap: 4px; height: 1.25rem; margin-block: var(--space-2); border-radius: 99px; overflow: hidden; }
.fund__seg--dep { flex: 0 0 calc(var(--dept) - 2px); background: var(--color-accent); }
.fund__seg--dir { flex: 1 1 0; min-width: 0; background: var(--color-border-strong); }
.fund__bar[data-split="dept"] .fund__seg--dir, .fund__bar[data-split="dir"] .fund__seg--dep { display: none; }
.fund__bar[data-split="dept"] .fund__seg--dep { flex: 1 1 0; }
.fund__line { display: flex; align-items: center; gap: .5rem; font-size: .9375rem; line-height: 1.5; }
.fund__dot { flex: none; width: .75rem; height: .75rem; border-radius: 50%; }
.fund__dot--dep { background: var(--color-accent); }
.fund__dot--dir { background: var(--color-border-strong); }
.fund__avail { margin-top: var(--space-2); padding-top: var(--space-1); border-top: 1px solid var(--color-border); font-size: .8125rem; color: var(--color-muted); }

/* Controls table: shared column widths so both groups align */
.cs-table--controls col:nth-child(1) { width: 20%; }
.cs-table--controls col:nth-child(2) { width: 18%; }
.cs-table--controls col:nth-child(3) { width: 38%; }
.cs-table--controls col:nth-child(4) { width: 24%; }
.cs-table .cs-group th { padding-block: .75rem; color: var(--color-muted); background: color-mix(in srgb, var(--color-text) 5%, transparent); }
@media (max-width: 39.99rem) { .cs-table .cs-group { padding: 0; } .cs-table .cs-group th { padding: .75rem var(--space-3); } }

/* Build and testing, video, technical details */
.cs .about-open__inner + .subhead { margin-top: var(--space-4); }
.cs .card-grid + .hero__target { margin-top: var(--space-3); }
.cs-video { gap: .5rem; max-width: 51.25rem; margin-inline: auto; margin-top: var(--space-4); }
.cs-video video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; background: var(--color-surface-alt); border-radius: var(--radius-sm); }
.cs-video .stage__caption { max-width: none; margin: 0; }
.cs-stack { display: grid; gap: var(--space-2); }
.cs-details { padding-block: 0; }
.cs-details summary { cursor: pointer; min-height: 3.25rem; display: flex; align-items: center; font-weight: 650; }
.cs-details[open] summary { margin-bottom: var(--space-1); }
.cs-details[open] { padding-bottom: var(--space-3); }
.cs-details .proof-points { columns: 14rem 3; column-gap: var(--space-4); }
.cs-details .proof-points li { break-inside: avoid; padding-block: .125rem; }

.cs .card__title + p { margin-top: var(--space-1); }

/* Section heading with a short intro beside it (avoids a lone narrow paragraph under the heading) */
.cs-head { max-width: none; }
.cs-head p { max-width: none; margin-top: var(--space-2); }
@media (min-width: 56rem) {
  .cs-head { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--space-4); align-items: center; }
  .cs-head p { margin-top: 0; }
}
.cs .section .wrap > p[data-reveal] { max-width: none; }
.cs .section .wrap > .hero__target { width: 100%; }
.cs .section .wrap > p.cs-funding[data-reveal] { max-width: var(--measure); }
@media (min-width: 56rem) {
  .cs #build .about-open__inner:has(> .about-open__art) { align-items: stretch; }
  .cs #build .about-open__art { display: grid; }
  .cs-stats.cs-stats--build { grid-template-rows: repeat(3, minmax(0, 1fr)); align-self: stretch; }
  .cs-stats--build .card { justify-content: center; padding-block: var(--space-1); }
  .cs-stats--build strong { font-size: clamp(1.75rem, 1.2rem + 1.2vw, 2.25rem); }
}

/* Swimlane diagram (wide, >= 64rem): replaces the wide lifecycle and timeline diagrams in "How it works" */
.sw-lane { fill: var(--color-surface); stroke: var(--color-border); stroke-width: 1; }
.sw-title { fill: var(--color-text); font: 700 18px var(--font-sans); }
.sw-sub, .sw-muted { fill: var(--color-muted); font: 500 15px var(--font-sans); }
.sw-label { fill: var(--color-text); font: 500 15px var(--font-sans); }
.sw-bar { fill: var(--color-accent-soft); }
@media (min-width: 64rem) { .dg--hold { display: none; } }

/* Mobile and tablet consistency (below 64rem only; desktop is untouched) */
.cs .cs-hold-note { margin-top: var(--space-2); max-width: none; }
@media (min-width: 64rem) { .cs-hold-note { display: none; } }
@media (max-width: 47.99rem) {
  .dg__compact .dg-text { font-size: 13.2px; }
  .dg__compact .dg-small { font-size: 13.2px; }
}
@media (min-width: 48rem) and (max-width: 63.99rem) {
  .dg--life .dg__compact svg { max-width: 40rem; }
  .dg--life .dg__compact svg, .dg--hold .dg__compact svg { margin-inline: auto; }
}
@media (max-width: 63.99rem) { .cs__back a { padding-block: 4px; } }

/* "How it works" caption sentence: shown only with the compact diagrams (below 64rem); the swimlane already says it */
@media (min-width: 64rem) { .cs__bridge { display: none; } }
