/* Product section (owner: product builder): the asset taken apart in 3D (#product).
   Port of public/prototypes/homepage/cinematic/exploded.css. Tokens come from home-base.css.
   Markup: templates/index/home/_product_exploded.html.twig. Script: assets/landing/product.js (+ product-scene.js).
   Audit fixes: the tall scroll track and the scroll hint exist only under .cn-exploded.is-3d, so without WebGL the
   section is one readable stage (major 3); the selected tab badge and the active callout use dark Gold so they hold 3:1
   as components and 4.5:1 for their numbers (A11Y-09); no italic (CT-15); the stage clips with overflow: clip; content
   that the compact layouts hide stays readable to assistive technology; without scripts every card shows. */

/* ---------- Stage ---------- */

.cn-exploded { position: relative; z-index: 1; background: var(--paper); color: var(--ink); }
.cn-exploded__stage { --edge: max(var(--gutter), (100% - 1360px) / 2); position: sticky; top: var(--header); height: calc(100vh - var(--header)); height: calc(100svh - var(--header)); overflow: clip; }

/* The scroll track that takes the asset apart exists only once WebGL is known to work (major 3). */
@media (min-width: 1024px) and (prefers-reduced-motion: no-preference) {
    .cn-exploded.is-3d { height: 560vh; }
}

.cn-exploded__canvas { position: absolute; inset: 0; }
.cn-exploded__canvas canvas { display: block; width: 100%; height: 100%; opacity: 0; transition: opacity 0.6s var(--ease-out); }
.cn-exploded.is-ready .cn-exploded__canvas canvas { opacity: 1; }
.cn-exploded__leaders { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.cn-exploded__leaders path { fill: none; stroke: var(--gold); stroke-width: 1.5; }
.cn-exploded__leaders circle { fill: var(--gold); }
.cn-exploded__leaders .is-dim path { stroke: rgb(14 59 42 / 0.28); }
.cn-exploded__leaders .is-dim circle:not(.cn-balloon) { fill: rgb(14 59 42 / 0.4); }
.cn-exploded__leaders .is-dim .cn-balloon { fill: var(--tint-1, #3E6353); }
.cn-exploded__leaders text { font: 600 12px/1 var(--font-display); fill: var(--paper); text-anchor: middle; dominant-baseline: central; }
.cn-exploded__leaders .cn-balloon { fill: var(--forest); }
/* A11Y-09: Paper numbers on dark Gold hold 4.96:1; Nexus Gold would be 2.97:1. */
.cn-exploded__leaders .is-active .cn-balloon { fill: var(--gold-text); }

/* ---------- Copy, capabilities, card ---------- */

.cn-exploded__copy { position: absolute; z-index: 3; top: clamp(28px, 5vh, 56px); left: var(--edge); width: min(660px, 48vw); }
.cn-exploded__heading { margin: 0; font: 700 clamp(2.2rem, 1rem + 3vw, 4rem)/1 var(--font-display); letter-spacing: -0.04em; color: var(--forest); text-wrap: balance; }
.cn-exploded__heading > span { display: block; color: var(--slate); }
.cn-exploded__heading .cn-l { color: inherit; }
.cn-exploded__intro { max-width: 44ch; margin: 20px 0 0; font-size: 1.05rem; line-height: 1.6; color: var(--slate); }

.cn-caps { position: absolute; z-index: 3; left: var(--edge); bottom: clamp(28px, 5vh, 56px); display: grid; gap: 2px; }
.cn-caps button { display: flex; align-items: center; gap: 14px; padding: 7px 0; border: 0; background: none; font: 600 1.05rem/1.2 var(--font-display); color: var(--slate); text-align: left; cursor: pointer; transition: color 0.3s ease, translate 0.45s var(--ease-out); }
.cn-caps b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: rgb(14 59 42 / 0.08); font: 600 11px/1 var(--font-display); color: var(--forest); transition: background-color 0.3s ease, color 0.3s ease; }
.cn-caps button:hover { color: var(--forest); translate: 4px 0; }
.cn-caps [aria-selected="true"] { color: var(--forest); }
/* A11Y-09: the selected badge is dark Gold: 4.96:1 against Paper as a component, 5.41:1 for its white number. */
.cn-caps [aria-selected="true"] b { background: var(--gold-text); color: var(--white); }

.cn-cards { position: absolute; z-index: 3; right: var(--edge); bottom: clamp(28px, 5vh, 56px); width: min(380px, 32vw); }
.cn-card { padding: 22px 22px 20px; border: 1px solid rgb(14 59 42 / 0.14); border-radius: 16px; background: var(--white); box-shadow: 0 40px 80px -48px rgb(14 59 42 / 0.55); }
.cn-card__part { margin: 0 0 6px; font-size: 11.5px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-text); }
.cn-card h3 { margin: 0; font: 700 1.5rem/1.1 var(--font-display); letter-spacing: -0.02em; color: var(--forest); }
.cn-card > p:not(.cn-card__part) { margin: 8px 0 16px; font-size: 15px; line-height: 1.5; color: var(--slate); }
.cn-card dl { display: grid; margin: 0; }
.cn-card dl div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--rule); font-size: 14px; }
.cn-card dt { color: var(--slate); }
.cn-card dd { margin: 0; font-weight: 600; color: var(--forest); text-align: right; }

.cn-exploded__note { position: absolute; z-index: 3; right: var(--edge); top: clamp(28px, 5vh, 56px); margin: 0; font-size: 12px; color: var(--slate); }
/* The hint belongs to the scroll-driven scene only (major 3); product.js writes its text and shows it. */
.cn-exploded__hint { display: none; position: absolute; z-index: 3; left: 50%; bottom: 22px; translate: -50% 0; margin: 0; font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--slate); opacity: 0; transition: opacity 0.4s ease; }
.cn-exploded.is-3d.is-ready .cn-exploded__hint { display: block; }
.cn-exploded__hint.is-shown { opacity: 1; }

/* ---------- Direct manipulation ---------- */

.cn-exploded__canvas { touch-action: pan-y; }
.cn-exploded__canvas.is-grab { cursor: grab; }
.cn-exploded__canvas.is-dragging { cursor: grabbing; }
.cn-exploded__canvas.is-pointer { cursor: pointer; }
.cn-exploded__leaders g { transition: opacity 0.3s ease; }
.cn-exploded__leaders .is-hot .cn-balloon { fill: var(--gold-text); }
.cn-exploded__leaders .is-hot path { stroke: var(--gold); }

/* Focus on Paper needs the darker gold to hold 3:1. The card takes focus as a tab panel with no focusable content. */
.marketing-page--record .cn-exploded :focus-visible { outline-color: var(--gold-text); }
.cn-card:focus-visible { outline-offset: 3px; }

/* Short desktop viewports: the card drops its sentence so the part it describes stays in view. */
@media (min-width: 1024px) and (max-height: 820px) {
    .cn-card > p:not(.cn-card__part) { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .cn-card h3 { margin-bottom: 14px; }
}

/* Very short desktop viewports (a laptop at 125% zoom): the intro steps back too, so the copy never meets the tabs. */
@media (min-width: 1024px) and (max-height: 680px) {
    .cn-exploded__intro { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* Below 1024px nothing pins: the stage stacks in the flow, plays once, and the capabilities become a row of numbered
   tabs that switch the card directly. The intro, the card's sentence and its last two facts leave the picture but
   stay readable to assistive technology. */
@media (max-width: 1023px) {
    .cn-exploded { height: auto; margin-top: 0; }
    .cn-exploded__stage { position: relative; top: 0; height: max(720px, calc(100svh - var(--header))); }
    .cn-exploded__copy { width: auto; right: var(--gutter); }
    .cn-exploded__intro,
    .cn-card > p:not(.cn-card__part),
    .cn-card dl div:nth-child(n+3) { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .cn-exploded__heading { font-size: clamp(1.8rem, 1rem + 4vw, 2.6rem); }
    .cn-caps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); left: var(--gutter); right: var(--gutter); bottom: clamp(16px, 3vh, 28px); gap: 6px; }
    .cn-caps button { justify-content: center; min-height: 44px; padding: 6px 0; }
    .cn-caps button:hover { translate: none; }
    .cn-caps b { width: 36px; height: 36px; font-size: 12px; }
    .cn-caps span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .cn-cards { left: var(--gutter); right: var(--gutter); bottom: calc(clamp(16px, 3vh, 28px) + 56px); width: auto; }
    .cn-card { padding: 18px 18px 14px; }
    .cn-card h3 { font-size: 1.3rem; }
    .cn-card dl { margin-top: 8px; }
    .cn-exploded__note { top: auto; right: auto; left: var(--gutter); bottom: calc(clamp(16px, 3vh, 28px) + 56px + 172px); }
    .cn-exploded__hint { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    .cn-exploded { height: auto; margin-top: 0; }
    .cn-exploded__stage { position: relative; top: 0; height: auto; min-height: 110vh; }
}

/* ---------- Without scripts ----------
   Nothing is taken apart and the tabs cannot switch, so the stage becomes a plain Paper section: the heading and intro,
   then every capability card, then the note. */

html:not(.home-js) .cn-exploded__stage { position: static; display: grid; gap: 40px; height: auto; min-height: 0; padding: var(--band-pad) var(--edge); }
html:not(.home-js) .cn-exploded :is(.cn-exploded__copy, .cn-cards, .cn-exploded__note) { position: static; width: auto; }
html:not(.home-js) .cn-exploded :is(.cn-caps, .cn-exploded__hint, .cn-exploded__canvas, .cn-exploded__leaders) { display: none; }
html:not(.home-js) .cn-exploded :is(.cn-exploded__intro, .cn-card > p:not(.cn-card__part), .cn-card dl div) { position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal; }
html:not(.home-js) .cn-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; }
html:not(.home-js) .cn-card[hidden] { display: block; }
html:not(.home-js) .cn-card > p:not(.cn-card__part) { margin: 8px 0 16px; }
