/* Purpose: PedalBox Series "02 · The Machine" scene
 * (template-parts/series/machine-scene.php + assets/js/series-machine.js).
 * Default = static poster (no JS / reduced motion). .is-live = sticky stage. */

/* Section copy follows the site type system: no monospace labels, no
 * synthesised italics (the heading face has no italic cut). */
.series-inside--machine {
	--font-mono: var(--font-body);
}
.series-inside--machine .series-inside__quote,
.series-inside--machine .series-inside__quote * {
	font-style: normal;
}

/* ---------- static ---------- */
.machine-scene { position: relative; }
.machine-scene__runway { position: relative; }
.machine-scene__stage { position: relative; }
.machine-scene__canvas,
.machine-scene__caps,
.machine-scene__inside { display: none; }
.machine-scene__poster {
	width: min(100%, 720px);
	margin: var(--space-12) auto 0;
	padding-inline: var(--container-pad);
}
.machine-scene__poster img {
	display: block;
	width: 100%;
	height: auto;
}

/* ---------- live ---------- */
.machine-scene.is-live .machine-scene__runway { height: var(--machine-runway, 700vh); }
.machine-scene.is-live .machine-scene__stage {
	position: sticky;
	top: 0;
	height: 100vh;
	height: 100svh;
	/* dvh tracks the collapsing URL bar, so the stage always fills exactly what
	   is visible — svh left a band of page below it once the chrome retracted,
	   which is what mis-framed the station. The runway stays svh so the total
	   scroll length never changes under the reader. (user, 2026-09-16) */
	height: 100dvh;
	overflow: hidden;
}
.machine-scene.is-live .machine-scene__poster { display: none; }
.machine-scene.is-live .machine-scene__canvas {
	display: block;
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

/* Film captions: one per beat, in a corner. */
.machine-scene.is-live .machine-scene__caps {
	display: block;
	position: absolute;
	inset: 0;
	margin: 0;
	padding: 0;
	list-style: none;
	pointer-events: none;
}
.machine-scene__cap {
	position: absolute;
	display: grid;
	gap: var(--space-3);
	max-width: 26rem;
	opacity: 0;
	will-change: transform, opacity;
}
.machine-scene__cap--bl { left: clamp(2rem, 7vw, 8rem); bottom: 14vh; }
.machine-scene__cap--tr { right: clamp(2rem, 7vw, 8rem); top: 16vh; text-align: right; }
.machine-scene__cap-tag {
	font-family: var(--font-body);
	font-size: var(--text-xs);
	letter-spacing: var(--tracking-wider);
	text-transform: uppercase;
	color: var(--color-primary);
}
.machine-scene__cap-line {
	font-family: var(--font-heading);
	font-weight: var(--weight-light);
	font-size: clamp(2rem, 3.4vw, 3.25rem);
	line-height: 1.02;
	letter-spacing: var(--tracking-tight);
	color: var(--color-text-strong);
}
.machine-scene__cap-sub {
	font-family: var(--font-body);
	font-size: var(--text-base);
	line-height: var(--leading-normal);
	color: var(--color-text-muted);
}

/* Part marks around the opened unit (desktop). */
.machine-scene.is-live .machine-scene__inside {
	display: block;
	position: absolute;
	inset: 0;
	pointer-events: none;
}
.machine-scene__marks {
	margin: 0;
	padding: 0;
	list-style: none;
}
.machine-scene__mark {
	position: absolute;
	left: 0;
	top: 0;
	opacity: 0;
	will-change: transform, opacity;
}
.machine-scene__mark-dot {
	position: absolute;
	width: 9px;
	height: 9px;
	margin: -4.5px 0 0 -4.5px;
	border-radius: var(--radius-full);
	background: var(--color-text-strong);
	box-shadow: 0 0 0 4px rgba(233, 231, 226, 0.14), 0 0 16px rgba(233, 231, 226, 0.45);
	transition: transform 0.25s ease;
}
.machine-scene__mark-line {
	position: absolute;
	left: 0;
	top: 0;
	width: var(--len, 0);
	height: 1px;
	background: linear-gradient(90deg, rgba(233, 231, 226, 0.5), rgba(233, 231, 226, 0.15));
	transform: rotate(var(--ang, 0));
	transform-origin: 0 50%;
}
.machine-scene__mark-tag {
	position: absolute;
	left: var(--lx, 0);
	top: var(--ly, 0);
	display: flex;
	flex-direction: column;
	gap: 4px;
	width: max-content;
	max-width: 15rem;
	transform: translate(12px, -50%);
}
.machine-scene__mark.is-left .machine-scene__mark-tag {
	align-items: flex-end;
	text-align: right;
	transform: translate(calc(-100% - 12px), -50%);
}
.machine-scene__mark-label {
	font-family: var(--font-heading);
	font-weight: var(--weight-light);
	font-size: var(--text-lg);
	color: var(--color-text-strong);
}
.machine-scene__mark-sub {
	font-family: var(--font-body);
	font-size: var(--text-xs);
	line-height: 1.5;
	letter-spacing: var(--tracking-wide);
	text-transform: uppercase;
	color: var(--color-text-muted);
}
.machine-scene__mark-caption { display: none; }

/* ---------- compact (phones, tablets) ---------- */
.machine-scene.is-live.is-compact .machine-scene__cap,
.machine-scene.is-live.is-compact .machine-scene__cap--tr {
	left: 20px;
	right: 20px;
	top: auto;
	bottom: calc(28px + env(safe-area-inset-bottom, 0px));
	max-width: none;
	text-align: left;
}
.machine-scene.is-live.is-compact .machine-scene__cap-line { font-size: clamp(1.75rem, 8vw, 2.25rem); }
.machine-scene.is-live.is-compact .machine-scene__cap-sub { font-size: var(--text-sm); }
.machine-scene.is-live.is-compact .machine-scene__mark-line,
.machine-scene.is-live.is-compact .machine-scene__mark-tag { display: none; }
.machine-scene.is-live.is-compact .machine-scene__mark.is-active .machine-scene__mark-dot { transform: scale(1.6); }
.machine-scene.is-live.is-compact .machine-scene__mark-caption {
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
	position: absolute;
	left: 20px;
	right: 20px;
	bottom: calc(28px + env(safe-area-inset-bottom, 0px));
	margin: 0;
	opacity: 0;
}
.machine-scene__mark-caption-num {
	font-size: var(--text-xs);
	letter-spacing: var(--tracking-wider);
	color: var(--color-text-muted);
	font-variant-numeric: tabular-nums;
}
.machine-scene__mark-caption-label {
	font-family: var(--font-heading);
	font-weight: var(--weight-light);
	font-size: clamp(1.75rem, 8vw, 2.25rem);
	color: var(--color-text-strong);
}
.machine-scene__mark-caption-sub {
	font-size: var(--text-xs);
	letter-spacing: var(--tracking-wide);
	text-transform: uppercase;
	color: var(--color-text-muted);
}

/* Continuous (right after the scene hero): transparent while it slides over the
 * hero's last viewport, then an opaque stage once pinned (series-machine.js). */
.series-inside.is-continuous { z-index: 2; background: transparent; }
.machine-scene.is-continuous .machine-scene__stage { background: transparent; }
.machine-scene.is-continuous .machine-scene__stage.is-cover { background: var(--color-bg); }

/* ---------- full scene (2026-09-16) ----------
 * One continuous station story: the Design and PerfecTune rows and the opening
 * play inside this scene as beats (machine-scene.php / inside.php / statement.php).
 * Chapter copy sits left; the model / throttle map sit right, over the canvas. */
.machine-scene__anchor {
	position: absolute;
	left: 0;
	top: calc(var(--at, 0) * 100vh);
	top: calc(var(--at, 0) * 100svh);
	width: 1px;
	height: 1px;
	pointer-events: none;
}
/* Ambient: a low red floor glow + grain under the station, so the black around it
 * reads as a space, not an empty screen (matches the home film's ground). */
.machine-scene.is-live .machine-scene__stage::before {
	content: '';
	position: absolute;
	inset: 0;
	pointer-events: none;
	opacity: var(--ambient, 1);
	background:
		radial-gradient(58% 42% at 50% 80%, rgba(255, 0, 18, 0.16), rgba(255, 0, 18, 0.04) 46%, transparent 72%),
		radial-gradient(120% 90% at 50% 50%, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.55) 100%);
}
.machine-scene.is-live .machine-scene__stage::after {
	content: '';
	position: absolute;
	inset: -50%;
	width: 200%;
	height: 200%;
	pointer-events: none;
	opacity: 0.05;
	mix-blend-mode: overlay;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
	animation: machine-grain 0.9s steps(6) infinite;
}
@keyframes machine-grain {
	0% { transform: translate(0, 0); }
	25% { transform: translate(-6%, 4%); }
	50% { transform: translate(5%, -7%); }
	75% { transform: translate(-3%, 8%); }
	100% { transform: translate(0, 0); }
}
.machine-scene.is-live .machine-scene__canvas { z-index: 1; }

.machine-scene__chapter {
	position: absolute;
	z-index: 3;
	left: clamp(2rem, 7vw, 8rem);
	top: 16vh;
	max-width: 26rem;
	opacity: 0;
	pointer-events: none;
}
.machine-scene__chapter .series-eyebrow { margin: 0 0 var(--space-4); }
.machine-scene__chapter-heading {
	margin: 0;
	font-family: var(--font-heading);
	font-weight: var(--weight-light);
	font-size: clamp(2.25rem, 4.4vw, 4.25rem);
	line-height: 1.02;
	text-wrap: balance;
}
.machine-scene__chapter-heading .accent { color: var(--color-primary); }
.machine-scene__chapter-body {
	max-width: 36ch;
	margin: var(--space-6) 0 0;
	font-size: clamp(var(--text-md), 1.3vw, var(--text-lg));
	line-height: var(--leading-normal);
	color: var(--color-text-muted);
}
.machine-scene__chapter-list {
	margin: var(--space-6) 0 0;
	padding: 0;
	list-style: none;
	font-size: var(--text-sm);
	letter-spacing: var(--tracking-wide);
	text-transform: uppercase;
	color: var(--color-text-muted);
}
.machine-scene__chapter-list li { padding: var(--space-3) 0; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.machine-scene__chapter--inside { top: 12vh; max-width: 22rem; }

/* 360° model over the held surface shot (design beat). */
.machine-scene__model {
	position: absolute;
	z-index: 2;
	left: 46%;
	top: 8%;
	width: 48%;
	height: 84%;
	opacity: 0;
	pointer-events: none;
}
.machine-scene__viewer {
	display: block;
	width: 100%;
	height: 100%;
	background: transparent;
	--poster-color: transparent;
}
.machine-scene__model-hint {
	position: absolute;
	left: 50%;
	bottom: 2%;
	transform: translateX(-50%);
	padding: 0.5rem 0.9rem;
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 999px;
	font-size: var(--text-xs);
	letter-spacing: var(--tracking-wider);
	color: var(--color-text-muted);
	white-space: nowrap;
}

/* Throttle map (tune beat): the unit sits right; the map sits between copy and unit. */
.machine-scene__tune {
	position: absolute;
	z-index: 2;
	left: 35%;
	top: 24vh;
	width: min(25vw, 25rem);
	opacity: 0;
	pointer-events: none;
}
.machine-scene__curve { display: block; width: 100%; height: auto; overflow: visible; }
.machine-scene__axis { stroke: rgba(255, 255, 255, 0.22); stroke-width: 1; }
.machine-scene__axis-label { fill: var(--color-text-muted); font-size: 9px; letter-spacing: 0.2em; }
.machine-scene__axis-label--y { transform: rotate(-90deg) translate(-44px, -6px); transform-origin: 34px 44px; }
.machine-scene__curve-stock,
.machine-scene__curve-tune {
	fill: none;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-dasharray: 1;
	stroke-dashoffset: 1;
}
.machine-scene__curve-stock { stroke: rgba(255, 255, 255, 0.45); stroke-dasharray: 1; }
.machine-scene__curve-tune { stroke: var(--color-primary); stroke-width: 2; filter: drop-shadow(0 0 6px rgba(255, 0, 18, 0.6)); }
.machine-scene__curve-dot { fill: var(--color-primary); opacity: 0; filter: drop-shadow(0 0 8px rgba(255, 0, 18, 0.9)); }
.machine-scene__tune-legend {
	display: flex;
	gap: var(--space-3);
	align-items: center;
	margin: var(--space-3) 0 0 40px;
	font-size: var(--text-xs);
	letter-spacing: var(--tracking-wider);
	text-transform: uppercase;
	color: var(--color-text-muted);
}
.machine-scene__tune-key { display: inline-block; width: 18px; height: 2px; }
.machine-scene__tune-key--stock { background: rgba(255, 255, 255, 0.45); }
.machine-scene__tune-key--tune { background: var(--color-primary); margin-left: var(--space-4); }

/* Phones: copy at the bottom, model/map full width in the lower half. */
.machine-scene.is-live.is-compact .machine-scene__chapter,
.machine-scene.is-live.is-compact .machine-scene__chapter--inside {
	left: var(--space-5, 1.25rem);
	right: var(--space-5, 1.25rem);
	top: auto;
	bottom: 8vh;
	max-width: none;
}
.machine-scene.is-live.is-compact .machine-scene__chapter-heading { font-size: clamp(1.75rem, 8vw, 2.25rem); }
.machine-scene.is-live.is-compact .machine-scene__chapter-body { display: none; }
.machine-scene.is-live.is-compact .machine-scene__model { left: 4%; top: 6%; width: 92%; height: 52%; }
.machine-scene.is-live.is-compact .machine-scene__tune { left: 8%; top: 8vh; width: 84%; }

/* Phones, opened unit: it is pinned to the bottom, so its copy and the mark
 * caption move to the top of the stage. */
.machine-scene.is-live.is-compact .machine-scene__chapter--inside { top: 8vh; bottom: auto; }
.machine-scene.is-live.is-compact .machine-scene__mark-caption { top: 8vh; bottom: auto; }
.machine-scene.is-live.is-compact .machine-scene__tune { top: 5vh; }

/* PerfecTune signal (v3): raw pedal signal in from the left, rewritten curve out
 * to the right, the unit between them. Full-width band across the lower stage. */
.machine-scene__tune { left: 6%; width: 88%; top: 52vh; }
.machine-scene__signal { display: block; width: 100%; height: auto; overflow: visible; }
.machine-scene__sig-in,
.machine-scene__sig-out {
	fill: none;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-dasharray: 1;
	stroke-dashoffset: 1;
	vector-effect: non-scaling-stroke;
}
.machine-scene__sig-in { stroke: rgba(255, 255, 255, 0.5); }
.machine-scene__sig-out { stroke: var(--color-primary); stroke-width: 2.5; filter: drop-shadow(0 0 8px rgba(255, 0, 18, 0.7)); }
.machine-scene__sig-label { fill: var(--color-text-muted); font-size: 11px; letter-spacing: 0.24em; }
.machine-scene.is-live.is-compact .machine-scene__tune { left: 4%; width: 92%; top: 58vh; }

/* Part marks and their leaders sit IN FRONT of the render (user, 2026-09-16). */
.machine-scene.is-live .machine-scene__inside { z-index: 4; }

/* Marks in the pod scene's red language (user, 2026-09-16): small red core in a
 * thin ring with a soft glow; the hairline fades out from the part. */
.machine-scene.is-live .machine-scene__mark-dot {
	width: 7px;
	height: 7px;
	margin: -3.5px 0 0 -3.5px;
	background: var(--color-primary);
	box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.55), 0 0 0 5px rgba(255, 0, 18, 0.55), 0 0 18px rgba(255, 0, 18, 0.55);
}
.machine-scene.is-live .machine-scene__mark-line { background: linear-gradient(90deg, rgba(255, 0, 18, 0.85), rgba(255, 0, 18, 0.12)); }

/* The section after the full scene overlaps the tail viewport and DISSOLVES in:
 * its content is pinned (machine-next-pin, added by the engine) while --reveal
 * (engine, from the tail) fades it up as the closed unit fades down. */
.series-inside--machine.is-full-scene + section {
	position: relative;
	z-index: 3;
	margin-top: -100vh;
	margin-top: -100svh;
	background: transparent;
	opacity: var(--reveal, 1);
}
.series-inside--machine.is-full-scene + section .machine-next-pin {
	position: sticky;
	top: 0;
	min-height: 100vh;
	min-height: 100svh;
	display: flex;
	flex-direction: column;
	justify-content: safe center;
}

/* Caption 2 (PerfecTune) reads from the right; the unit drifts left under it. */
.machine-scene.is-live:not(.is-compact) .machine-scene__chapter--tune {
	left: auto;
	right: clamp(2rem, 7vw, 8rem);
	text-align: right;
}
.machine-scene.is-live:not(.is-compact) .machine-scene__chapter--tune .machine-scene__chapter-body { margin-left: auto; }

/* Continuous scene: the floor glow / grain only exist once the stage is pinned
 * and covering — before that the stage scrolls up under the hero transparent
 * (a glow there read as a red band with a hard edge). */
.machine-scene.is-continuous .machine-scene__stage:not(.is-cover)::before,
.machine-scene.is-continuous .machine-scene__stage:not(.is-cover)::after { opacity: 0; }

/* Feature points on the turning unit — same red language as the part marks. */
.machine-scene__fpoints { display: none; }
.machine-scene.is-live .machine-scene__fpoints {
	display: block;
	position: absolute;
	inset: 0;
	z-index: 4;
	margin: 0;
	padding: 0;
	list-style: none;
	pointer-events: none;
}
.machine-scene__fpoint {
	position: absolute;
	left: 0;
	top: 0;
	opacity: 0;
	will-change: transform, opacity;
}
.machine-scene__fpoint .machine-scene__mark-tag { position: absolute; left: var(--lx, 0); top: var(--ly, 0); white-space: nowrap; transform: translate(12px, -50%); }
.machine-scene__fpoint.is-left .machine-scene__mark-tag { transform: translate(calc(-100% - 12px), -50%); text-align: right; }
.machine-scene.is-live.is-compact .machine-scene__fpoint .machine-scene__mark-tag { display: block; }

/* Feature labels wrap into a column (single lines ran into the chapter copy). */
.machine-scene__fpoint .machine-scene__mark-tag { white-space: normal; width: 13rem; }
.machine-scene__fpoint .machine-scene__mark-sub { display: block; }

/* Story chapters: right-side variant mirrors the PerfecTune block. */
.machine-scene.is-live:not(.is-compact) .machine-scene__chapter--right {
	left: auto;
	right: clamp(2rem, 7vw, 8rem);
	text-align: right;
}
.machine-scene.is-live:not(.is-compact) .machine-scene__chapter--right .machine-scene__chapter-body { margin-left: auto; }
.machine-scene__fpoints { display: none !important; }

/* phones: the pinned next-section wrapper must not pad the section to a full
   viewport — its content is short there and the rest read as a gap (2026-09-16) */
@media (max-width: 1023px) {
	.series-inside--machine.is-full-scene + section .machine-next-pin { height: auto; min-height: 0; }
}

/* Phones, per chapter (user, 2026-09-16): chapters 1/3/5 (cap, Signal, Reversible)
   put the unit LOW and the copy UP; 2/4 (PerfecTune, Five modes) the reverse; the
   explode's copy sits up (unit bottom-pinned). */
.machine-scene.is-live.is-compact .machine-scene__cap,
.machine-scene.is-live.is-compact .machine-scene__cap--tr,
.machine-scene.is-live.is-compact .machine-scene__chapter--left,
.machine-scene.is-live.is-compact .machine-scene__chapter--inside {
	top: calc(var(--hero-bars, 0px) + 10vh);
	bottom: auto;
}
.machine-scene.is-live.is-compact .machine-scene__chapter--tune,
.machine-scene.is-live.is-compact .machine-scene__chapter--right {
	top: auto;
	bottom: 8vh;
}

/* The unit's LED: same treatment as the hero's (red glow, screen blend, size tied to
   the camera scale) — blinks once as each chapter arrives. Outer span positions, inner
   one animates, so the blink never fights the positioning. */
.machine-scene__led {
	position: absolute;
	left: 0;
	top: 0;
	width: 0;
	height: 0;
	opacity: 0;
	pointer-events: none;
	z-index: 3;
}
.machine-scene__led i {
	position: absolute;
	left: 0;
	top: 0;
	width: calc(260px * var(--machine-k, 0.4));
	height: calc(260px * var(--machine-k, 0.4));
	border-radius: var(--radius-full);
	background: radial-gradient(circle, rgba(255, 46, 36, 0.75) 0%, rgba(255, 46, 36, 0.24) 28%, rgba(255, 46, 36, 0) 68%);
	mix-blend-mode: screen;
	opacity: 0;
	transform: translate(-50%, -50%) scale(1);
}
.machine-scene__led.is-blink i { animation: machine-led-blink 620ms ease-out 1; }
@keyframes machine-led-blink {
	0% { opacity: 0; transform: translate(-50%, -50%) scale(0.65); }
	22% { opacity: 0.95; transform: translate(-50%, -50%) scale(1.3); }
	100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .machine-scene__led.is-blink i { animation: none; } }

/* Image card under each station chapter (2a–2e), fading with its copy
   (fs_machine_shot, inc/helpers.php). Height-capped for short laptop windows.
   (user, 2026-09-21) */
.machine-scene__shot {
	width: min(24rem, 42svh);
	aspect-ratio: 3 / 2;
	margin: var(--space-6) 0 0;
	overflow: hidden;
	border-radius: var(--radius-md);
	background: #0b0b0b;
}
.machine-scene__shot img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.machine-scene.is-live:not(.is-compact) .machine-scene__chapter--tune .machine-scene__shot,
.machine-scene.is-live:not(.is-compact) .machine-scene__chapter--right .machine-scene__shot { margin-left: auto; }
.machine-scene.is-live.is-compact .machine-scene__shot {
	/* fixed, not %: chapters shrink-to-fit their text, so % gave every card a
	   different size (user, 2026-09-21) */
	width: min(11.5rem, 100%);
	aspect-ratio: 3 / 2;
	margin-top: var(--space-4);
}

/* 2a caption: red accent phrase, broken after "between" on phones only (user, 2026-09-21). */
.machine-scene__cap-line .accent { color: var(--color-primary); }
.machine-scene__br-phone { display: none; }
.machine-scene.is-live.is-compact .machine-scene__br-phone { display: inline; }
