/**
 * Problem section — sticky scroll chapters (01 → 02 → 03).
 * Tokens from globals.css. Do not hide overflow on .stage--problem (breaks sticky).
 */

/*
 * Genesis sets `overflow-x: hidden` on html/body, which breaks position:sticky.
 * `clip` prevents horizontal scroll without disabling sticky pinning.
 */
html:has(.se-problem),
html:has(.se-problem) body,
body.home,
body.page-template-templatesflexible-sections-php {
	overflow-x: clip !important;
}

.se-problem.stage--problem {
	position: relative;
	overflow: visible;
	background: var(--color-surface-soft);

	--accent: var(--color-primary);
	--accent-bright: var(--color-secondary);
	--ink: var(--color-ink);
	--ink-soft: var(--color-ink-soft);
	--max: var(--container-max);
}

.se-problem.stage--problem::before {
	content: "";
	position: absolute;
	inset: 0;
	opacity: 0.25;
	background-image:
		linear-gradient(var(--color-primary-border) 1px, transparent 1px),
		linear-gradient(90deg, var(--color-primary-border) 1px, transparent 1px);
	background-size: 72px 72px;
	mask-image: radial-gradient(ellipse 85% 85% at 50% 50%, #000 30%, transparent 80%);
	pointer-events: none;
	z-index: 0;
}

/* Tall scroll track — panel stays pinned while chapters swap */
.se-problem .problem-pin {
	position: relative;
	height: 300vh;
}

.se-problem .problem-sticky {
	position: sticky;
	top: var(--nav-h);
	z-index: 1;
	height: calc(100vh - var(--nav-h));
	height: calc(100dvh - var(--nav-h));
	overflow: hidden;
	display: grid;
	place-items: center;
	padding-block: clamp(1rem, 3vh, 3rem);
	box-sizing: border-box;
}

.admin-bar .se-problem .problem-sticky {
	top: calc(var(--nav-h) + 32px);
	height: calc(100dvh - var(--nav-h) - 32px);
}

@media screen and (max-width: 782px) {
	.admin-bar .se-problem .problem-sticky {
		top: calc(var(--nav-h) + 46px);
		height: calc(100dvh - var(--nav-h) - 46px);
	}
}

.se-problem .problem-stage {
	position: relative;
	z-index: 2;
	display: grid;
	grid-template-columns: 1fr;
	gap: 2rem;
	width: 100%;
	max-width: var(--max);
	margin-inline: auto;
	padding-inline: var(--gutter);
}

@media (min-width: 900px) {
	.se-problem .problem-stage {
		grid-template-columns: 1fr 1fr;
		align-items: center;
		gap: 4rem;
	}
}

/* Interactive grid — cells fill on hover */
.se-problem .problem-grid-bg {
	position: absolute;
	inset: 0;
	z-index: 0;
	opacity: 0.95;
	overflow: hidden;
	background: var(--color-surface-soft);
	pointer-events: auto;
}

.se-problem .interactive-grid-pattern-svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.se-problem .interactive-grid-cell {
	fill: transparent;
	stroke: none;
	transition: fill 0.15s ease-out;
	cursor: crosshair;
}

.se-problem .interactive-grid-cell:hover {
	fill: var(--color-primary);
	opacity: 0.16;
	transition: none;
}

/* Copy */
.se-problem .problem-copy {
	transition:
		opacity 0.35s var(--ease-out),
		transform 0.35s var(--ease-out);
}

.se-problem .problem-copy.is-swap {
	opacity: 0;
	transform: translateY(12px);
}

.se-problem .problem-index {
	display: block;
	font-family: var(--font-display);
	font-size: clamp(4rem, 12vw, 10rem);
	font-weight: 800;
	line-height: 1;
	color: transparent;
	-webkit-text-stroke: 3px rgba(139, 127, 212, 0.45);
}

.se-problem .problem-heading {
	font-family: var(--font-display);
	font-size: clamp(1.5rem, 4vw, 2.75rem);
	font-weight: 500;
	line-height: 1.1;
	letter-spacing: 0.02em;
	margin: 0 0 var(--space-4);
	color: var(--ink);
}

.se-problem .problem-text {
	margin: 0;
	max-width: 42ch;
	font-family: var(--font-body);
	font-size: var(--fs-base);
	font-weight: 400;
	line-height: 1.7;
	color: var(--ink-soft);
}

/* Viz */
.se-problem .problem-viz {
	position: relative;
	aspect-ratio: 1;
	max-width: min(420px, 70vw);
	width: 100%;
	margin-inline: auto;
	border-radius: 50%;
	border: 2px solid var(--color-primary-border);
	background: radial-gradient(
		circle,
		rgba(107, 98, 172, 0.16) 0%,
		rgba(139, 127, 212, 0.05) 50%,
		transparent 72%
	);
	display: grid;
	place-items: center;
	overflow: hidden;
}

.se-problem .problem-viz__icon,
.se-problem .problem-viz__svg {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 52%;
	height: 52%;
	object-fit: contain;
	opacity: 0.95;
	z-index: 1;
	overflow: visible;
	shape-rendering: geometricPrecision;
	transition:
		opacity 0.25s var(--ease-out),
		transform 0.25s var(--ease-out);
}

.se-problem .problem-viz__icon.is-swap,
.se-problem .problem-viz__svg.is-swap {
	opacity: 0;
	transform: scale(0.88);
}

.se-problem .problem-viz__ring {
	position: absolute;
	inset: 8%;
	border-radius: 50%;
	border: 1px dashed rgba(107, 98, 172, 0.45);
	animation: se-problem-spin 20s linear infinite;
	pointer-events: none;
	z-index: 2;
}

@keyframes se-problem-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Chapter dots */
.se-problem .problem-progress {
	position: absolute;
	right: max(1rem, var(--gutter));
	top: 50%;
	transform: translateY(-50%);
	z-index: 3;
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
}

.se-problem .problem-progress button {
	width: 10px;
	height: 10px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(107, 98, 172, 0.25);
	cursor: pointer;
	transition:
		background 0.2s,
		transform 0.2s;
}

.se-problem .problem-progress button.is-active {
	background: var(--accent);
	transform: scale(1.35);
}

.se-problem .problem-hint {
	position: absolute;
	bottom: 1.25rem;
	left: 50%;
	transform: translateX(-50%);
	z-index: 3;
	margin: 0;
	font-size: var(--fs-2xs);
	font-weight: 600;
	letter-spacing: var(--tracking-label);
	text-transform: uppercase;
	color: rgba(107, 98, 172, 0.55);
	pointer-events: none;
	transition: opacity 0.3s;
}

.se-problem .problem-hint.is-hidden {
	opacity: 0;
}

/* ---- Responsive ---- */
@media (max-width: 1200px) {
	.se-problem .problem-heading {
		font-size: clamp(1.4rem, 3.2vw, 2.35rem);
	}

	.se-problem .problem-viz {
		max-width: min(360px, 65vw);
	}
}

@media (max-width: 899px) {
	.se-problem .problem-pin {
		height: 260vh;
	}

	.se-problem .problem-stage {
		gap: 1.5rem;
	}

	.se-problem .problem-index {
		-webkit-text-stroke-width: 2px;
		margin-bottom: 0;
		font-size: clamp(3rem, 18vw, 5.5rem);
	}

	.se-problem .problem-heading {
		font-size: clamp(1.35rem, 5vw, 1.85rem);
		line-height: 1.2;
	}

	.se-problem .problem-text {
		font-size: var(--fs-sm);
		max-width: none;
	}

	.se-problem .problem-viz {
		max-width: 220px;
	}

	.se-problem .problem-progress {
		right: 0.75rem;
	}

	.se-problem .problem-progress button {
		/* Larger hit area on touch */
		width: 12px;
		height: 12px;
		box-shadow: 0 0 0 8px transparent;
	}

	.se-problem .problem-hint {
		bottom: 0.85rem;
		font-size: 0.625rem;
	}
}

@media (max-width: 768px) {
	.se-problem .problem-sticky {
		padding-block: clamp(1rem, 3vh, 2rem);
		align-content: center;
	}

	.se-problem .problem-stage {
		gap: 3.25rem;
	}
}

@media (max-width: 480px) {
	.se-problem .problem-pin {
		height: 240vh;
	}

	.se-problem .problem-index {
		font-size: 124px;
		margin-bottom: 0;
	}

	.se-problem .problem-heading {
		font-size: clamp(1.25rem, 6vw, 1.55rem);
		margin-bottom: var(--space-3);
	}

	.se-problem .problem-text {
		font-size: var(--fs-xs);
		line-height: 1.65;
	}

	.se-problem .problem-viz {
		max-width: 285px;
	}

	.se-problem .problem-progress {
		right: 0.5rem;
		gap: 0.85rem;
	}
}

@media (max-width: 400px) {
	.se-problem .problem-index {
		font-size: 70px;
	}
	.se-problem .problem-heading {
		font-size: 18px;
		margin-bottom: 8px;
	}
	.se-problem .problem-viz {
        max-width: 180px;
    }
	.se-problem .problem-progress button {
		width: 8px;
        height: 8px;
	}
	.se-problem .problem-progress {
		gap: 0.45rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.se-problem .problem-viz__ring {
		animation: none;
	}

	.se-problem .problem-viz__icon,
	.se-problem .problem-viz__svg,
	.se-problem .problem-copy {
		transition: none;
	}
}
