/* Section 6 · How it works – full-screen sticky card stack  (template-parts/home/process.php)

   How it slides (same on desktop and mobile):
   every card is position: sticky at the same top (--ptop) and is as tall as the screen
   (--ph). Normal scrolling brings the next card up over the current one, so the sliding is
   pure CSS – no pinning, no snapping, no scroll hijacking.
   motion.js → processStack() adds the extras: the card going behind shrinks (+ a light dim
   layer), each card's text rises in step by step (.is-in), and the dots follow (.is-active).

   Controls (on .process):
     --ptop    top of the free area (below the fixed header)
     --pbot    space kept free at the bottom (mobile action bar + gap)
     --ph-max  biggest card height (cards never get taller than this, even on tall screens)
     --ph      card height = free screen height, but at least 340px and at most --ph-max
     --pstick  where the card sticks – centred inside the free area
     --pgap    gap between cards while one slides in
   Note: sticky stops working if any parent gets overflow: hidden – keep parents unclipped. */

.process {
	--ptop: calc(var(--header-h) + var(--admin-bar) + 24px);
	--pbot: calc(var(--mbar-space, 0px) + 24px);
	--ph-max: 480px;
	--pfree: calc(100vh - var(--ptop) - var(--pbot));
	--pfree: calc(100svh - var(--ptop) - var(--pbot));
	--ph: clamp(340px, var(--pfree), var(--ph-max));
	--pstick: calc(var(--ptop) + max(0px, (var(--pfree) - var(--ph)) / 2));
	--pgap: 32px;
	background: var(--navy); color: var(--on-navy); border-radius: var(--r-lg);
	padding: clamp(80px, 11vw, 150px) 0 clamp(40px, 6vw, 80px);
}
.process h2 { color: var(--on-navy); }
.process .lede { color: var(--on-navy-muted); margin-top: 18px; max-width: 56ch; }

/* ------------------------------------------------------------------ stack --- */
.pstack-wrap { position: relative; margin-top: clamp(40px, 6vw, 64px); }
.pstack { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--pgap); }

.pcard {
	position: sticky; top: var(--pstick); height: var(--ph);
	display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr;
	padding: clamp(26px, 3.4vw, 48px); border-radius: var(--r-lg); overflow: hidden; isolation: isolate;
	color: var(--brand-text);
	background:
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400' fill='none' stroke='%230A3558' stroke-opacity='.09' stroke-width='1'%3E%3Ccircle cx='330' cy='330' r='60'/%3E%3Ccircle cx='330' cy='330' r='110'/%3E%3Ccircle cx='330' cy='330' r='160'/%3E%3Ccircle cx='330' cy='330' r='210'/%3E%3Ccircle cx='330' cy='330' r='260'/%3E%3C/svg%3E") right bottom / min(70%, 620px) no-repeat,
		linear-gradient(165deg, var(--brand-on-dark) 0%, color-mix(in srgb, var(--brand-on-dark) 86%, var(--brand-tint)) 100%);
	box-shadow: 0 -14px 34px -18px rgba(0, 0, 0, .45), 0 1px 0 rgba(255, 255, 255, .6) inset;
	transform-origin: center center; backface-visibility: hidden;
}
/* Light dim layer on the card going behind (motion.js sets --dim 0 → ~0.3) */
.pcard::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--brand-primary-dark); opacity: var(--dim, 0); pointer-events: none; z-index: 1; }
.pcard.is-scaling { will-change: transform; }

.pcard .n { grid-column: 1; grid-row: 1; font-family: var(--font-head); font-weight: 700; font-size: clamp(3.6rem, 6.5vw, 6.5rem); line-height: .8; letter-spacing: -.05em; color: var(--brand-primary); font-variant-numeric: tabular-nums; }
.pcard .ico { grid-column: 2; grid-row: 1; width: 80px; height: 80px; border-radius: 24px; background: var(--brand-tint); display: grid; place-items: center; color: var(--brand-primary); }
.pcard .ico .icon { width: 34px; height: 34px; stroke-width: 1.4; }

/* Desktop: title + text sit at the bottom of the card, side by side */
.pcard-body {
	grid-column: 1 / -1; grid-row: 2; align-self: end;
	display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); align-items: end;
	border-top: 1px solid color-mix(in srgb, var(--brand-primary) 14%, transparent); padding-top: clamp(20px, 2.6vh, 28px);
}
.pcard h3 { color: var(--brand-primary); font-size: clamp(1.8rem, 2.8vw, 2.6rem); line-height: 1.05; }
.pcard p { color: var(--brand-muted); font-size: clamp(1rem, 1.1vw, 1.1rem); line-height: 1.6; max-width: 46ch; }

/* ------------------------------------------------------- staged text reveal --- */
/* Only hidden while processStack() runs (.is-stack) – without JS everything is visible. */
.is-stack .pcard [data-stage] {
	opacity: 0; transform: translateY(26px);
	transition: opacity .6s var(--ease-out), transform .6s var(--ease-out);
	transition-delay: calc(var(--d, 0) * .09s + .05s);
}
.is-stack .pcard.is-in [data-stage] { opacity: 1; transform: none; }

/* ------------------------------------------------------------------- dots --- */
/* Sit on the right edge of the cards, stay at the card's middle while scrolling. */
.pdots-wrap { display: none; position: absolute; inset: 0; padding: calc(var(--ph) / 2) 0; pointer-events: none; z-index: 5; }
.is-stack .pdots-wrap { display: block; }
.pdots {
	position: sticky; top: calc(var(--pstick) + var(--ph) / 2); transform: translateY(-50%);
	display: flex; flex-direction: column; gap: 11px; align-items: center;
	width: fit-content; margin-left: auto; margin-right: clamp(12px, 1.6vw, 22px);
}
.pdot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--brand-primary) 55%, transparent); transition: background-color .3s, transform .3s, border-color .3s; }
.pdot.is-active { background: var(--brand-primary); border-color: var(--brand-primary); transform: scale(1.4); }

/* ----------------------------------------------------------------- mobile --- */
@media (max-width: 900px) {
	.pcard .ico { width: 72px; height: 72px; border-radius: 22px; }
	.pcard .ico .icon { width: 32px; height: 32px; }
	.pcard-body { grid-template-columns: 1fr; gap: 12px; align-items: start; }
}
@media (max-width: 760px) {
	.process {
		--ptop: calc(var(--header-h) + var(--admin-bar) + 14px);
		--pbot: calc(var(--mbar-space, 0px) + 14px);
		--ph-max: 400px;
		--pgap: 18px;
		padding-top: clamp(64px, 16vw, 90px);
	}
	.pcard {
		padding: clamp(24px, 6vw, 36px); padding-right: 36px; border-radius: var(--r-md);
		background-size: min(110%, 460px) auto, auto;
	}
	.pcard .n { font-size: clamp(3.6rem, 18vw, 5.5rem); }
	.pcard .ico { width: 64px; height: 64px; border-radius: 20px; }
	.pcard .ico .icon { width: 30px; height: 30px; }
	/* Mobile: number + icon on top, title + text at the bottom (same as desktop) */
	.pcard-body { padding-top: 18px; }
	.pcard h3 { font-size: clamp(1.6rem, 7vw, 2.1rem); }
	.pcard p { font-size: 1rem; }
	.pdots { margin-right: 12px; gap: 9px; }
	.pdot { width: 7px; height: 7px; }
}

/* Very short screens (landscape phones): no stacking, simple list of cards */
@media (max-height: 520px) {
	.pcard { position: relative; top: auto; height: auto; min-height: 0; }
	.pcard-body { align-self: start; margin-top: 20px; }
	.pdots-wrap { display: none !important; }
}
