/* Phixo · series before/after compare
 *
 * Styles for every figure rendered by phixo_ba() (inc/phixo-ba.php) and
 * hydrated by assets/js/phixo-series-compare.js. Colours are drawn ONLY from
 * the design-system tokens in phixo.css :root — no hardcoded hex.
 *
 * No-JS contract: with script disabled, both frames are visible and the
 * static comparison reads. The interactive hiding/clipping is gated behind
 * `.phixo-ba.is-hydrated` so a failed/blocked script never leaves a blank or
 * one-sided frame. prefers-reduced-motion drops all transitions.
 *
 * Class map (BEM-ish, prefixed phixo-ba__ to avoid collisions):
 *   .phixo-ba                     figure wrapper
 *   .phixo-ba__stage              positioned image stage
 *   .phixo-ba__frame--before/after
 *   .phixo-ba__label              corner state chip
 *   pattern extras per section below
 */

/* ── Shared shell ──────────────────────────────────────────────────── */
.phixo-ba {
	margin: 0;
	--phixo-ba-frame-shadow: 0 40px 90px -46px rgba(44, 40, 37, 0.55);
	--phixo-ba-radius: 3px;
	--phixo-ba-line: var(--bg); /* linen hairline that reads on dark imagery */
}

.phixo-ba__stage {
	position: relative;
	margin: 0 auto;
	width: 100%;
	max-width: 640px;
	aspect-ratio: 4 / 5;
	border-radius: var(--phixo-ba-radius);
	overflow: hidden;
	background: var(--stone);
	box-shadow: var(--phixo-ba-frame-shadow);
}

.phixo-ba__frame {
	position: absolute;
	inset: 0;
}

.phixo-ba__frame .phixo-ba__img,
.phixo-ba__frame .img-slot {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border: 0;
	margin: 0;
	border-radius: 0;
}

/* No-JS default: the "after" sits above the "before" so both are present and
   the finished frame is what shows. Once hydrated, JS + the rules below take
   control of how the after is revealed per pattern. */
.phixo-ba__frame--before { z-index: 1; }
.phixo-ba__frame--after  { z-index: 2; }

/* ── State labels (corner chips) ───────────────────────────────────── */
.phixo-ba__label {
	position: absolute;
	z-index: 6;
	top: 14px;
	left: 14px;
	font-family: var(--sans);
	font-weight: 600;
	font-size: 10px;
	line-height: 1;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	padding: 6px 11px;
	border-radius: 2px;
	max-width: calc(100% - 28px);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.phixo-ba__label--before {
	background: var(--ink);
	color: var(--bg);
}
.phixo-ba__label--after {
	background: var(--brass);
	color: var(--bg);
}

/* Label placement.
   Default (no-JS): the "after"/finished frame is what shows on top, so its
   label is the top-left one; the "before" label is suppressed so the two
   never stack in the corner. Hydration + per-pattern rules below restore the
   "before" label where the interaction makes both meaningful. */
.phixo-ba__label--before { display: none; }
.phixo-ba__label--after  { display: block; }

/* Slider is a simultaneous split: after (top) + before (bottom) are both
   visible at once, so show both — after top-left, before bottom-left. This
   holds with AND without JS. */
.phixo-ba--slider .phixo-ba__label--before {
	display: block;
	top: auto;
	bottom: 14px;
}

/* Crossfade / annotated / loupe: once hydrated, JS cross-fades the labels via
   .is-on (both are positioned top-left and only one is opacity-visible at a
   time), so let both participate under .is-hydrated. */
.phixo-ba--crossfade.is-hydrated .phixo-ba__label--before,
.phixo-ba--annotated.is-hydrated .phixo-ba__label--before,
.phixo-ba--loupe.is-hydrated .phixo-ba__label--before {
	display: block;
}

/* Captions under the figure. */
.phixo-ba__caption {
	margin: 18px auto 0;
	max-width: 46ch;
	text-align: center;
	font-family: var(--sans);
	font-size: var(--fs-body-sm);
	line-height: var(--lh-body);
	color: var(--mute);
}

/* Shared control action rows. */
.phixo-ba__annotated-actions,
.phixo-ba__loupe-actions {
	display: flex;
	justify-content: center;
	gap: 12px;
	margin-top: 24px;
}

/* Focus ring parity with the house .btn treatment. */
.phixo-ba button:focus-visible,
.phixo-ba [role="slider"]:focus-visible,
.phixo-ba input:focus-visible {
	outline: 3px solid var(--brass);
	outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════════════
   05 · Vertical drag-slider
   ═══════════════════════════════════════════════════════════════════ */
.phixo-ba__stage--slider {
	touch-action: none;
	user-select: none;
	cursor: ns-resize;
}

/* No-JS: static before + after, both legible; hide the divider/handle since
   they'd do nothing. */
.phixo-ba__divider,
.phixo-ba__handle {
	display: none;
}

.phixo-ba--slider.is-hydrated .phixo-ba__divider {
	display: block;
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 2px;
	background: var(--phixo-ba-line);
	box-shadow: 0 0 0 1px var(--line-strong);
	transform: translateY(-50%);
	pointer-events: none;
	z-index: 4;
}

.phixo-ba--slider.is-hydrated .phixo-ba__handle {
	display: flex;
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	/* 56×44 exceeds the 44px hit-target floor (touch-target padding included);
	   the visible pill is centred inside. */
	width: 56px;
	height: 44px;
	padding: 0;
	align-items: center;
	justify-content: center;
	border-radius: 22px;
	background: var(--bg);
	border: 2px solid var(--brass);
	color: var(--brass);
	cursor: ns-resize;
	box-shadow: 0 6px 18px -6px rgba(44, 40, 37, 0.5);
	z-index: 5;
	-webkit-appearance: none;
	appearance: none;
}
.phixo-ba__handle-glyph {
	font-size: 16px;
	line-height: 1;
}

/* Once hydrated the "after" is clipped from the top down to the divider; JS
   sets the inline clip-path, this just guarantees a sane starting state. */
.phixo-ba--slider.is-hydrated .phixo-ba__frame--after {
	clip-path: inset(0 0 50% 0);
	-webkit-clip-path: inset(0 0 50% 0);
}

/* ════════════════════════════════════════════════════════════════════
   01 · Scroll-driven crossfade
   ═══════════════════════════════════════════════════════════════════ */
.phixo-ba__scroll { position: relative; }

/* No-JS: no tall section, just the stacked frames (after on top). */
.phixo-ba__sticky {
	position: relative;
}
.phixo-ba__stage--crossfade {
	max-width: min(560px, 84vw);
	aspect-ratio: 4 / 5;
}
.phixo-ba__progress { display: none; }
.phixo-ba__toggle { display: none; }
.phixo-ba__hint { display: none; }

/* Hydrated · full scroll experience. The section holds for ~2 viewport
   heights and pins the frame; JS maps scroll → after opacity 1:1. */
.phixo-ba--crossfade.is-hydrated:not(.is-collapsed) .phixo-ba__scroll {
	height: 220vh;
}
.phixo-ba--crossfade.is-hydrated:not(.is-collapsed) .phixo-ba__sticky {
	position: sticky;
	top: 0;
	height: 100vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}
.phixo-ba--crossfade.is-hydrated .phixo-ba__frame--after {
	opacity: 0;
	will-change: opacity;
}

/* progress rail (only meaningful when hydrated in scroll mode) */
.phixo-ba--crossfade.is-hydrated:not(.is-collapsed) .phixo-ba__progress {
	display: flex;
	position: absolute;
	left: 16px;
	right: 16px;
	bottom: 16px;
	z-index: 6;
	align-items: center;
	gap: 10px;
}
.phixo-ba__progress-rail {
	flex: 1;
	height: 3px;
	border-radius: 3px;
	overflow: hidden;
	background: var(--stone-soft);
}
.phixo-ba__progress-fill {
	height: 100%;
	width: 0%;
	background: var(--rose);
}
.phixo-ba__progress-pct {
	font-family: var(--sans);
	font-weight: 600;
	font-size: 11px;
	color: var(--bg);
	min-width: 34px;
	text-align: right;
}

/* scroll hint below the frame */
.phixo-ba--crossfade.is-hydrated:not(.is-collapsed) .phixo-ba__hint {
	display: block;
	text-align: center;
	margin: 18px auto 0;
	font-family: var(--sans);
	font-weight: 500;
	font-size: var(--fs-body-sm);
	letter-spacing: 0.06em;
	color: var(--mute);
}

/* Crossfade / annotated / loupe cross-fade their labels via JS .is-on: once
   hydrated, both labels stack top-left and only the .is-on one is visible.
   (Slider is excluded — it shows both at once, top + bottom.) */
.phixo-ba--crossfade .phixo-ba__label,
.phixo-ba--annotated .phixo-ba__label,
.phixo-ba--loupe .phixo-ba__label {
	transition: opacity 0.3s ease;
}
.phixo-ba--crossfade.is-hydrated .phixo-ba__label,
.phixo-ba--annotated.is-hydrated .phixo-ba__label,
.phixo-ba--loupe.is-hydrated .phixo-ba__label {
	opacity: 0;
}
.phixo-ba--crossfade.is-hydrated .phixo-ba__label.is-on,
.phixo-ba--annotated.is-hydrated .phixo-ba__label.is-on,
.phixo-ba--loupe.is-hydrated .phixo-ba__label.is-on {
	opacity: 1;
}

/* Collapsed (coarse-pointer / reduced-motion) fallback: a fixed frame + a
   real "Tap to compare" button. */
.phixo-ba--crossfade.is-collapsed .phixo-ba__scroll { height: auto; }
.phixo-ba--crossfade.is-collapsed .phixo-ba__stage--crossfade { cursor: pointer; }
.phixo-ba--crossfade.is-collapsed .phixo-ba__toggle {
	display: inline-block;
	margin: 20px auto 0;
	font-family: var(--sans);
	font-weight: 600;
	font-size: 11px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--ink);
	background: var(--rose);
	border: 1.5px solid transparent;
	border-radius: 2px;
	padding: 14px 28px;
	cursor: pointer;
}

/* ════════════════════════════════════════════════════════════════════
   02 · Layered reveals (4 stages)
   ═══════════════════════════════════════════════════════════════════ */
.phixo-ba__layers {
	display: grid;
	grid-template-columns: 1.4fr 1fr;
	gap: 44px;
	align-items: center;
}
.phixo-ba__stage--layers {
	max-width: none;
	background: var(--stone);
}

/* Each stage is a stacked frame. No-JS: they cascade (last = final on top),
   so the visitor still sees the finished frame. Hydrated: JS toggles
   .is-active and crossfades. */
.phixo-ba__layer {
	position: absolute;
	inset: 0;
}
.phixo-ba--layers.is-hydrated .phixo-ba__layer {
	opacity: 0;
	transition: opacity 0.55s ease;
}
.phixo-ba--layers.is-hydrated .phixo-ba__layer.is-active {
	opacity: 1;
}

.phixo-ba__layers-controls { min-width: 0; }

.phixo-ba__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 9px;
	margin-bottom: 26px;
}
.phixo-ba__chip {
	font-family: var(--sans);
	font-weight: 600;
	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	padding: 12px 16px; /* ≥44px combined hit target with line-box */
	min-height: 40px;
	border-radius: 2px;
	cursor: pointer;
	border: 1.5px solid var(--line-strong);
	background: transparent;
	color: var(--mute);
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.phixo-ba__chip[aria-pressed="true"] {
	background: var(--ink);
	color: var(--bg);
	border-color: var(--ink);
}

.phixo-ba__scrub { margin-bottom: 30px; }
.phixo-ba__scrub-label {
	display: flex;
	justify-content: space-between;
	font-family: var(--sans);
	font-weight: 600;
	font-size: 10px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--mute);
	margin-bottom: 10px;
}
.phixo-ba__scrub-val { color: var(--brass); }
.phixo-ba__range {
	width: 100%;
	accent-color: var(--brass);
	cursor: pointer;
}
/* No-JS: the range would do nothing, so hide it and lean on the chips (which
   are also inert without JS but read as labels). */
.phixo-ba--layers:not(.is-hydrated) .phixo-ba__scrub { display: none; }

.phixo-ba__stagecopy {
	border-top: 1px solid var(--line);
	padding-top: 22px;
}
.phixo-ba__stagetitle {
	font-family: var(--serif);
	font-weight: 500;
	font-size: var(--fs-h3);
	line-height: var(--lh-heading);
	margin: 0 0 8px;
	color: var(--ink);
}
.phixo-ba__stagedesc {
	font-family: var(--sans);
	font-size: var(--fs-body-sm);
	line-height: var(--lh-body);
	color: var(--ink-soft);
	margin: 0;
}

/* ════════════════════════════════════════════════════════════════════
   03 · Annotated diff
   ═══════════════════════════════════════════════════════════════════ */
.phixo-ba__stage--annotated {
	max-width: min(600px, 90vw);
	aspect-ratio: 5 / 4;
}
/* Hydrated: after hidden until reveal; pins visible on the before. */
.phixo-ba--annotated.is-hydrated .phixo-ba__frame--after {
	opacity: 0;
	transition: opacity 0.5s ease;
}
.phixo-ba--annotated.is-hydrated.is-revealed .phixo-ba__frame--after {
	opacity: 1;
}

.phixo-ba__pins {
	position: absolute;
	inset: 0;
	z-index: 4;
	transition: opacity 0.5s ease;
}
/* No-JS: keep the pins visible but static (they read as a legend on the
   before frame). Their notes are shown via :focus-within too. */
.phixo-ba--annotated.is-hydrated.is-revealed .phixo-ba__pins {
	opacity: 0;
	pointer-events: none;
}

.phixo-ba__pin {
	position: absolute;
	transform: translate(-50%, -50%);
}
.phixo-ba__pin-dot {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 2px solid var(--bg);
	background: var(--brass);
	color: var(--bg);
	font-family: var(--sans);
	font-weight: 700;
	font-size: 12px;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(44, 40, 37, 0.35);
	padding: 0;
}
.phixo-ba__pin-note {
	position: absolute;
	top: -6px;
	width: 176px;
	background: var(--ink);
	color: var(--bg);
	font-family: var(--sans);
	font-weight: 400;
	font-size: 12px;
	line-height: 1.4;
	padding: 9px 12px;
	border-radius: 3px;
	box-shadow: 0 6px 20px -8px rgba(44, 40, 37, 0.6);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.3s ease;
	z-index: 1;
}
.phixo-ba__pin--right .phixo-ba__pin-note {
	left: 34px;
	transform: translateX(-4px);
	text-align: left;
}
.phixo-ba__pin--left .phixo-ba__pin-note {
	right: 34px;
	transform: translateX(4px);
	text-align: right;
}
/* Open state (JS toggles .is-open; :focus-within is the no-JS keyboard path). */
.phixo-ba__pin.is-open { z-index: 6; }
.phixo-ba__pin.is-open .phixo-ba__pin-note,
.phixo-ba__pin:focus-within .phixo-ba__pin-note {
	opacity: 1;
	transform: translateX(0);
	pointer-events: auto;
}

/* Rose-fill primary button. Per the locked CTA rule, on a light section the
   rose CTA carries CHARCOAL text (linen-on-rose fails AA on linen). */
.phixo-ba__reveal {
	display: inline-block;
	font-family: var(--sans);
	font-weight: 600;
	font-size: 11px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--ink);
	background: var(--rose);
	border: 1.5px solid transparent;
	border-radius: 2px;
	padding: 14px 30px;
	cursor: pointer;
	transition: opacity 0.15s ease, transform 0.15s ease;
}
.phixo-ba__reveal:hover,
.phixo-ba__reveal:focus {
	opacity: 0.88;
	transform: translateY(-1px);
}

/* ════════════════════════════════════════════════════════════════════
   04 · Radial spotlight / loupe
   ═══════════════════════════════════════════════════════════════════ */
.phixo-ba__stage--loupe {
	max-width: min(680px, 92vw);
	aspect-ratio: 3 / 2;
	touch-action: none;
	cursor: crosshair;
}
/* Hydrated: the after is clipped to a moving circle (JS sets clip-path). */
.phixo-ba--loupe.is-hydrated .phixo-ba__frame--after {
	clip-path: circle(0px at 50% 50%);
	-webkit-clip-path: circle(0px at 50% 50%);
	will-change: clip-path, transform;
}
.phixo-ba__ring {
	position: absolute;
	top: 0;
	left: 0;
	width: 180px;
	height: 180px;
	border-radius: 50%;
	border: 2px solid var(--bg);
	box-shadow: 0 0 0 1px var(--line-strong), 0 10px 30px -8px rgba(44, 40, 37, 0.5);
	transform: translate(-50%, -50%);
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.2s ease;
	z-index: 5;
}
.phixo-ba__ring.is-on { opacity: 1; }
.phixo-ba__loupe-toggle { cursor: pointer; }

/* ════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 820px) {
	.phixo-ba__layers {
		grid-template-columns: 1fr;
		gap: 28px;
	}
	.phixo-ba__stage {
		max-width: 100%;
	}
}

/* ════════════════════════════════════════════════════════════════════
   Reduced motion — drop every transition/animation. State still changes
   instantly and remains fully operable; the crossfade additionally
   collapses to the tap-toggle via JS (.is-collapsed).
   ═══════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
	.phixo-ba *,
	.phixo-ba *::before,
	.phixo-ba *::after {
		transition: none !important;
		animation: none !important;
	}
	.phixo-ba--loupe.is-hydrated .phixo-ba__frame--after {
		/* No magnify scale under reduced motion (JS already skips the scale);
		   the clip still tracks the pointer 1:1 with no easing. */
		will-change: clip-path;
	}
}
