/*
 * Fit to card: each content card is locked to the pinned stage's height
 * (overflow hidden). feature-stack.js measures every card's tallest state
 * (its copy plus its longest answer open) and sets --fit on the section:
 * 1 = design size, stepping down to 0.82 until every card fits. Type, gaps
 * and paddings below are multiplied by it. If a card still can't fit at
 * 0.82, the JS adds .is-scroll and that one card scrolls on its own (see
 * below) — nothing is ever cut off.
 */
.split-sticky-stack {
    --fit: 1;
    position: relative;
    width: 100%;
    /* one full viewport of scroll per panel — gives the scroll-position
       math a reliable pinned window to compute progress against */
    height: calc(var(--stack-total, 5) * 100vh);
    background-color: #080809;
}

.stack-stage {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Background */
.stack-bg-canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
}
.stack-bg-frame {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transform: scale(1.05);
    transition: opacity 0.8s cubic-bezier(0.25, 1, 0.5, 1), transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.stack-bg-frame.is-active {
    opacity: 1;
    transform: scale(1);
}
.stack-bg-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgb(8 8 9 / 56%) 0%, rgb(8 8 9 / 22%) 50%, rgb(8 8 9 / 27%) 100%);
}

/* Layout */
.stack-viewport-grid {
    position: relative;
    padding: 0 clamp(28px, 4vw, 60px) 0 clamp(40px, 6vh, 64px);
    height: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 80px;
    align-items: center;
    z-index: 2;
}

.stack-left-column {
    position: relative;
    height: 65%;
    display: flex;
    align-items: center;
}
.panels-content-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.feature-content-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    /* "safe" keeps the top reachable if a centred card ever overflows */
    justify-content: safe center;
    opacity: 0;
    transform: translateY(30px);
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}
.feature-content-card.is-active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
/* Last resort (set by feature-stack.js): the card is taller than the
   stage even at the smallest --fit, so it scrolls inside itself. Scroll
   chains back to the page at either end, so the reader is never trapped. */
.feature-content-card.is-scroll {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.panel-auto-num {
    font-family: var(--mono, monospace);
    font-size: 13px;
    color: var(--accent, #ef6c23);
    font-weight: 600;
    letter-spacing: 0.15em;
    margin-bottom: calc(20px * var(--fit));
}
.panel-main-title {
    font-family: var(--sans, sans-serif);
    font-size: calc(clamp(32px, 3.8vw, 52px) * var(--fit));
    line-height: 1.1;
    color: #ffffff;
    font-weight: 500;
    margin: 0 0 calc(24px * var(--fit));
    letter-spacing: -0.02em;
}
.panel-main-desc {
    font-family: var(--sans, sans-serif);
    font-size: calc(15.5px * var(--fit));
    line-height: 1.6;
    color: rgba(255, 255, 255, 1);
    margin: 0 0 calc(36px * var(--fit));
    max-width: 540px;
}

/* Glass accordion */
.panel-accordion-group {
    display: flex;
    flex-direction: column;
    gap: calc(10px * var(--fit));
    max-width: 500px;
}
.panel-faq-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
}
.panel-faq-trigger {
    width: 100%; display: flex; justify-content: space-between; align-items: center;
    background: none; border: 0; cursor: pointer; text-align: left;
    /* 14px floor keeps the tap row at ~44px even at the smallest --fit */
    padding: max(14px, calc(16px * var(--fit))) 20px;
}
.panel-faq-trigger:focus-visible {
    outline: 2px solid var(--accent, #ef6c23);
    outline-offset: -2px;
    border-radius: 12px;
}
.faq-text-span { font-family: var(--sans, sans-serif); font-size: calc(14.5px * var(--fit)); color: #fff; font-weight: 500; }
.faq-plus-minus { flex: none; margin-left: 12px; }
.faq-plus-minus { position: relative; width: 12px; height: 12px; }
.faq-plus-minus::before, .faq-plus-minus::after {
    content: ''; position: absolute; background: #fff; transition: transform 0.25s ease;
}
.faq-plus-minus::before { top: 5px; left: 0; width: 12px; height: 2px; }
.faq-plus-minus::after { left: 5px; top: 0; width: 2px; height: 12px; }
.panel-faq-item.is-open .faq-plus-minus::after { transform: scaleY(0); }

.panel-faq-drawer { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.panel-faq-inner { padding: 0 20px calc(16px * var(--fit)); }
.panel-faq-inner p { font-family: var(--sans, sans-serif); font-size: calc(13.5px * var(--fit)); line-height: 1.5; color: rgba(255,255,255,0.6); margin: 0; }

/* Right-hand nav list */
.stack-right-column {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}
.stack-nav-list {
    display: flex;
    flex-direction: column;
    align-self: center;
    list-style: none;
    margin: 0px;
    padding: 0px;
    gap: 24px;
}
.stack-nav-item {
    padding-left: 16px;
    border-left: 2px solid transparent;
    transition: border-color 0.3s;
}
.stack-nav-item.is-active {
    border-left-color: var(--accent);
}
.stack-nav-anchor-btn {
    background: none; border: 0; padding: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    text-align: right; width: 100%;
    border-radius: 4px;
}
.stack-nav-anchor-btn:focus-visible {
    outline: 2px solid var(--accent, #ef6c23);
    outline-offset: 4px;
}
.nav-btn-title {
    font-family: var(--mono); font-size: 15px; font-weight: 500;
    color: rgba(255, 255, 255, 0.4); transition: color 0.3s ease;
}
.nav-btn-number {
    font-family: var(--mono, monospace); font-size: 14px;
    color: rgba(255, 255, 255, 0.3); transition: color 0.3s ease;
}

/* Active nav item */
.stack-nav-item.is-active .nav-btn-title { color: #ffffff; }
.stack-nav-item.is-active .nav-btn-number { color: var(--accent, #ef6c23); font-weight: 600; }

/*
 * Mobile: same pinned, scroll-scrubbed cross-fade as desktop; only the
 * internal layout changes to a single column with the side nav hidden.
 */
@media (max-width: 960px) {
    .stack-stage { height: 100svh; }

    .stack-right-column { display: none; }

    /*
     * Phones: the heading block starts just below the fixed header, the
     * questions sit at the bottom, and only a small gap is left under them.
     */
    .stack-viewport-grid {
        grid-template-columns: 1fr;
        align-items: stretch;
        padding: clamp(92px, 12svh, 116px) 22px calc(clamp(24px, 4svh, 40px) + env(safe-area-inset-bottom, 0px));
        gap: 0;
        box-sizing: border-box;
    }

    .stack-left-column { height: 100%; }

    .feature-content-card { justify-content: flex-start; }

    .panel-auto-num { margin-bottom: calc(14px * var(--fit)); }
    .panel-main-title { font-size: calc(clamp(26px, 7vw, 34px) * var(--fit)); margin-bottom: calc(14px * var(--fit)); }
    .panel-main-desc { font-size: calc(15.5px * var(--fit)); margin-bottom: 0; }

    /* questions pushed to the bottom of the card */
    .panel-accordion-group { margin-top: auto; padding-top: calc(18px * var(--fit)); max-width: none; gap: calc(8px * var(--fit)); }

    /* even, bottom-weighted darkening behind the stacked mobile content
       instead of the desktop's side-weighted scrim */
    .stack-bg-overlay {
        background: linear-gradient(0deg, rgb(8 8 9 / 78%) 0%, rgb(8 8 9 / 40%) 46%, rgb(8 8 9 / 42%) 100%);
    }
}

/* Respect reduced-motion preference — kill the scale/translate choreography,
   keep only opacity so panel changes still register without induced motion. */
@media (prefers-reduced-motion: reduce) {
    .stack-bg-frame,
    .feature-content-card,
    .stack-nav-item,
    .nav-btn-title,
    .nav-btn-number {
        transition-duration: 0.01ms !important;
        transform: none !important;
    }
    html {
        scroll-behavior: auto;
    }
}
/* Lumart, 12 Nov (phones): (1) the photos weren't centred. A portrait phone
   shows about a third of each landscape photo, and the subjects sit off-centre,
   so each frame gets its own focal point (matched on the file name, so it
   follows the photo if the panels are reordered). (2) Panel changes felt busy:
   the text slid up while the old text slid down and the photo zoomed. On
   phones it's now one calm crossfade: no slide, no zoom, the same timing for
   photo and text. Desktop is unchanged. */
@media (max-width: 960px) {
    .stack-bg-frame[style*="card1-bg"]               { background-position: 27% 50%; }
    .stack-bg-frame[style*="insight-into-action"]    { background-position: 66% 50%; }
    .stack-bg-frame[style*="targeted-interventions"] { background-position: 64% 50%; }
    .stack-bg-frame[style*="preventative-imaging"]   { background-position: 70% 50%; }
    .stack-bg-frame[style*="track-retest-refine"]    { background-position: 68% 50%; }

    .stack-bg-frame,
    .stack-bg-frame.is-active { transform: none; transition: opacity 0.6s ease; }
    .feature-content-card,
    .feature-content-card.is-active { transform: none; transition: opacity 0.45s ease; }
    .feature-content-card:not(.is-active) { transition-duration: 0.25s; } /* old text clears before the new arrives */

    .panel-main-title { font-size: calc(32px * var(--fit)); }
}

/* Lumart, 12 Nov: the orange "01" above each panel becomes a white pill,
   "STEP 1" in black Geist Mono, the dark twin of How it works' black pills. */
.panel-auto-num {
    display: inline-flex; align-self: flex-start; align-items: center; gap: 8px;
    padding: 6px 13px; border-radius: 999px;
    background: #fff; color: var(--ink, #0c0c0d);
    font-family: var(--mono); font-size: 12.5px; font-weight: 500;
    letter-spacing: 0.16em; text-transform: uppercase; line-height: 1.2;
}
.panel-auto-num .pip { width: 6px; height: 6px; border-radius: 50%; background: var(--accent, #ef6c23); }

/* Lumart, 12 Nov: on phones the step pill, title and text were too big, and the
   FAQ answers too faint. */
@media (max-width: 860px) {
  .panel-auto-num { padding: 5px 11px; font-size: 11px; gap: 7px; }
  .panel-main-title { font-size: calc(clamp(24px, 6.6vw, 29px) * var(--fit)); }
  .panel-main-desc { font-size: calc(14.5px * var(--fit)); }
}
.panel-faq-inner p { color: #fff; }
/* Lumart, 12 Nov: the full-bleed photo cards on phones drop the step pill
   entirely, and the body copy gets a little more weight for legibility. */
@media (max-width: 860px) {
  .panel-auto-num { display: none; }
  .panel-main-desc { font-weight: 450; }
}

/* Lumart, 12 Nov: the glass FAQs loaded clear and only went blurry after a
   delay. WebKit skips backdrop-filter on anything inside a parent whose
   opacity is below 1, so while the card faded in the blur was missing and
   then popped on at the end. The fade now runs on the card's children, and
   each glass item fades itself; no ancestor of the glass is ever translucent. */
.feature-content-card,
.feature-content-card.is-active { opacity: 1; }
.feature-content-card > :not(.panel-accordion-group),
.feature-content-card .panel-faq-item { opacity: 0; transition: opacity 0.5s ease; }
.feature-content-card.is-active > :not(.panel-accordion-group),
.feature-content-card.is-active .panel-faq-item { opacity: 1; }
@media (max-width: 960px) {
    .feature-content-card.is-active > :not(.panel-accordion-group),
    .feature-content-card.is-active .panel-faq-item { transition-duration: 0.45s; }
    .feature-content-card:not(.is-active) > :not(.panel-accordion-group),
    .feature-content-card:not(.is-active) .panel-faq-item { transition-duration: 0.25s; }
}
@media (prefers-reduced-motion: reduce) {
    .feature-content-card > *,
    .feature-content-card .panel-faq-item { transition-duration: 0.01ms !important; }
}

/* Lumart, 12 Nov: full-bleed pin (see --barpad in style.css). */
@media (max-width: 960px) {
    .stack-stage { height: 100vh; height: 100lvh; }
    .stack-viewport-grid { padding-bottom: calc(clamp(24px, 4svh, 40px) + env(safe-area-inset-bottom, 0px) + var(--barpad, 0px)); }
}

/* Lumart, 13 Nov (phones): the Home photo cards follow Superpower's step card
   type: a smaller, medium title over bigger body copy, and the pair sits a
   little lower under the header. --fit still scales it down on short phones. */
@media (max-width: 860px) {
  .stack-viewport-grid { padding-top: clamp(124px, 16svh, 156px); }
  .panel-main-title { font-size: calc(25px * var(--fit)); line-height: 1.15; font-weight: 500; letter-spacing: -0.01em; margin-bottom: calc(12px * var(--fit)); }
  .panel-main-desc { font-size: calc(18px * var(--fit)); line-height: 1.45; font-weight: 450; }
}

/* Lumart, 13 Nov (phones): the questions sat under a showing Safari/Chrome
   toolbar. They now keep clear of it: the bottom padding adds the toolbar's
   full height (100lvh - 100svh, both constants, so nothing moves while the
   bar grows or shrinks). */
@media (max-width: 960px) {
  .stack-viewport-grid { padding-bottom: calc(clamp(16px, 2.5svh, 28px) + var(--barpad, 0px) + env(safe-area-inset-bottom, 0px)); }
}

/* Lumart, 13 Nov (desktop): Superpower-style body copy under the photo-card
   titles (bigger, heavier), and no step pill above the title at any width. */
.panel-auto-num { display: none; }
@media (min-width: 861px) {
  .panel-main-desc { font-size: calc(20px * var(--fit)); line-height: 1.45; font-weight: 450; max-width: 560px; }
}

/* Lumart, 13 Nov (desktop): opening a question only moves the questions
   below it (feature-stack.js sets the top padding), and the headings break
   at a similar width ("Every membership begins / with 160+ biomarkers"). */
.feature-content-card.is-anchored { justify-content: flex-start; }
@media (min-width: 961px) {
  .panel-main-title { max-width: 13.5em; text-wrap: balance; }
}

/* Lumart, 13 Nov (desktop): a calmer change between the photo cards. The
   pictures cross-fade with no zoom, and the copy fades with only a small lift. */
@media (min-width: 961px) {
  .stack-bg-frame { transform: none; transition: opacity 0.7s ease; }
  .stack-bg-frame.is-active { transform: none; }
  .feature-content-card { transform: translateY(8px); transition: opacity 0.45s ease, transform 0.5s ease; }
  .feature-content-card.is-active { transform: none; transition-delay: 0.12s; }
}

/* Lumart, 16 Nov (desktop): the pictures section gets the same thin white frame as the heroes. */
@media (min-width: 961px) {
  .stack-stage::after {
    content: ""; position: absolute; inset: 10px; z-index: 60; pointer-events: none;
    border-radius: 24px; box-shadow: 0 0 0 60px var(--bg);
  }
}

/* Lumart, 16 Nov (desktop): "the animation between the steps is too busy".
   No more double exposure: the new picture fades in on top while the old one
   stays fully shown underneath, then the old one drops away. The copy no
   longer lifts: the old copy fades out quickly, the new copy fades in once
   the picture is mostly there. One thing moves at a time. */
@media (min-width: 961px) {
  .stack-bg-frame { z-index: 1; transition: opacity 0s linear 0.45s; }
  .stack-bg-frame.is-active { z-index: 2; transition: opacity 0.4s ease; }
  .feature-content-card,
  .feature-content-card.is-active { transform: none; transition: none; }
  .feature-content-card > :not(.panel-accordion-group),
  .feature-content-card .panel-faq-item { transition: opacity 0.2s ease; }
  .feature-content-card.is-active > :not(.panel-accordion-group),
  .feature-content-card.is-active .panel-faq-item { transition: opacity 0.4s ease 0.25s; }
}
