/**
 * Software page — the interactive card treatments.
 *
 * Ported from the Thailand branch's development page, which uses the same
 * three ideas: cards that light under the pointer, cards that tilt toward it,
 * and a process row that lights up as you scroll through it.
 *
 * Every one of them is an enhancement over a card that already looks finished
 * without it. Nothing here is required for the page to read.
 */

/* -------------------------------------------------- Pointer glow */

/*
 * A soft light that follows the cursor across a card.
 *
 * Position comes from --mx / --my, set by the script in percentages. The
 * default puts it off the card entirely, so a card never starts out lit —
 * a glow sitting in the middle of every card before you touch it reads as a
 * gradient someone forgot to remove.
 */
.software-cards .card,
.software-process .card {
	position: relative;
	overflow: hidden;
	transform-style: preserve-3d;
	transition: border-color 0.3s var(--motion-ease);
}

.software-cards .card::before,
.software-process .card::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 0;
	opacity: 0;
	pointer-events: none;
	background: radial-gradient(
		18rem circle at var(--mx, -20%) var(--my, -20%),
		color-mix(in srgb, var(--brand) 22%, transparent),
		transparent 60%
	);
	transition: opacity 0.35s var(--motion-ease);
}

.software-cards .card:hover::before,
.software-process .card:hover::before {
	opacity: 1;
}

/* Card content has to clear the glow layer. */
.software-cards .card > *,
.software-process .card > * {
	position: relative;
	z-index: 1;
}

.software-cards .card:hover,
.software-process .card:hover {
	border-color: color-mix(in srgb, var(--brand) 55%, transparent);
}

/* -------------------------------------------------- Process, lit by scroll */

/*
 * The five stages light in order as the section passes up the viewport, so
 * the row reads as a sequence rather than five equal boxes. Unlit is not
 * hidden — it is simply quieter, so the whole process is legible at a glance
 * before any of it has lit.
 */
.software-process .card {
	opacity: 0.55;
	transition:
		opacity 0.5s var(--motion-ease),
		border-color 0.5s var(--motion-ease),
		transform 0.5s var(--motion-ease);
}

.software-process .card.is-lit {
	opacity: 1;
	border-color: color-mix(in srgb, var(--brand) 45%, transparent);
}

.software-process .card.is-lit .card__meta {
	color: var(--brand);
}

/* -------------------------------------------------- Reduced motion */

/*
 * Everything lands in its finished state: all stages lit, no tilt, no glow.
 * The page loses its motion and keeps its meaning.
 */
@media (prefers-reduced-motion: reduce) {
	.software-cards .card,
	.software-process .card {
		opacity: 1;
		transform: none !important;
		transition: none;
	}

	.software-cards .card::before,
	.software-process .card::before {
		display: none;
	}
}

/* -------------------------------------------------- The demo window */

/*
 * A mock application, drawn rather than screenshotted.
 *
 * Built from the page's own tokens, so it restyles with the theme and stays
 * crisp at any zoom — a screenshot would be stale the moment either changed,
 * and would be a picture of software rather than something you can tab through.
 */
.demo {
	margin-top: var(--space-5);
}

.demo__tabs {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-1);
	margin-bottom: var(--space-2);
}

.demo__tab {
	padding: 0.55em 1.1em;
	border: 1px solid var(--rule);
	border-radius: var(--radius-pill);
	background: transparent;
	color: var(--muted);
	font-family: var(--wp--preset--font-family--mono, ui-monospace, monospace);
	font-size: 0.78rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	cursor: pointer;
	transition: color 0.2s var(--motion-ease), border-color 0.2s var(--motion-ease);
}

.demo__tab:hover {
	color: var(--fg);
}

.demo__tab.is-on {
	color: var(--brand);
	border-color: color-mix(in srgb, var(--brand) 60%, transparent);
}

.demo__window {
	border: 1px solid var(--rule-strong);
	border-radius: 0.6rem;
	overflow: hidden;
	background-color: var(--surface);
}

.demo__chrome {
	display: flex;
	align-items: center;
	gap: var(--space-1);
	padding: 0.6rem 0.9rem;
	border-bottom: 1px solid var(--rule);
	font-family: var(--wp--preset--font-family--mono, ui-monospace, monospace);
	font-size: 0.72rem;
}

.demo__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background-color: var(--rule-strong);
}

.demo__title {
	margin-inline-start: var(--space-2);
	color: var(--muted);
}

.demo__live {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	margin-inline-start: auto;
	color: var(--brand);
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

/* The pulse is the only thing on the page that repeats forever; keep it faint. */
.demo__live i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background-color: currentColor;
	animation: ssph-pulse 2.4s ease-in-out infinite;
}

@keyframes ssph-pulse {
	0%, 100% { opacity: 0.35; }
	50% { opacity: 1; }
}

.demo__body {
	padding: var(--space-3);
}

.demo__stats {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--space-2);
	margin-bottom: var(--space-3);
}

.demo__stat {
	padding: var(--space-2);
	border: 1px solid var(--rule);
}

.demo__stat-label {
	display: block;
	font-family: var(--wp--preset--font-family--mono, ui-monospace, monospace);
	font-size: 0.68rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--muted);
}

.demo__num {
	display: block;
	margin-top: 0.2em;
	font-size: clamp(1.4rem, 3vw, 2.2rem);
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.02em;
	color: var(--fg);
	/* Figures change width as they count; tabular digits stop the row jittering. */
	font-variant-numeric: tabular-nums;
}

.demo__row {
	display: grid;
	grid-template-columns: 7rem 1fr auto;
	gap: var(--space-2);
	align-items: center;
	padding: 0.7rem 0;
	border-top: 1px solid var(--rule);
	font-size: 0.85rem;
}

.demo__row-id {
	font-family: var(--wp--preset--font-family--mono, ui-monospace, monospace);
	font-size: 0.72rem;
	letter-spacing: 0.08em;
	color: var(--brand);
}

.demo__row-name {
	color: var(--fg);
}

.demo__pill {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	padding: 0.25em 0.7em;
	border: 1px solid var(--rule);
	border-radius: var(--radius-pill);
	font-family: var(--wp--preset--font-family--mono, ui-monospace, monospace);
	font-size: 0.68rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--muted);
	white-space: nowrap;
}

.demo__pill i {
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background-color: var(--brand);
}

.demo__caption {
	margin-top: var(--space-2);
	font-family: var(--wp--preset--font-family--mono, ui-monospace, monospace);
	font-size: 0.72rem;
	letter-spacing: 0.06em;
	color: var(--muted);
}

@media (max-width: 40rem) {
	.demo__stats {
		grid-template-columns: 1fr;
	}

	.demo__row {
		grid-template-columns: 1fr auto;
	}

	.demo__row-id {
		grid-column: 1 / -1;
	}
}

/* -------------------------------------------------- Hero: copy beside demo */

/*
 * Two columns on wide screens, stacked below.
 *
 * The demo is deliberately the second child in the markup rather than being
 * floated first: stacked, it should follow the claim it is evidence for, and
 * a screen reader should hear the argument before the illustration.
 */
.software-hero__grid {
	display: grid;
	gap: var(--space-5);
	align-items: center;
}

@media (min-width: 62rem) {
	.software-hero__grid {
		/*
		 * A wider copy column and a tighter gutter.
		 *
		 * At 27rem against a --space-5 gutter the paragraph was wrapping to
		 * six short lines with a corridor of empty space beside it: the text
		 * read as crammed and the two halves read as unrelated. Giving the
		 * copy 33rem drops it to four comfortable lines, and closing the
		 * gutter binds the claim and its illustration into one composition.
		 */
		grid-template-columns: minmax(0, 33rem) minmax(0, 1fr);
		gap: var(--space-4);
	}
}

.software-hero h1 {
	font-size: clamp(2rem, 4.4vw, 3.4rem);
	line-height: 1.04;
}

.software-hero .lede {
	/* Wider than the global measure: the column is now wide enough to carry it,
	   and a short measure inside a wide column is what made it look cramped. */
	max-width: 52ch;
}

/*
 * The pill above the headline. A dot rather than an icon: it reads as a status
 * light, which is the register the demo beside it is in.
 */
.badge {
	display: inline-flex;
	align-items: center;
	gap: 0.55em;
	margin-bottom: var(--space-3);
	padding: 0.4em 1em;
	border: 1px solid var(--rule-strong);
	border-radius: var(--radius-pill);
	font-family: var(--wp--preset--font-family--mono, ui-monospace, monospace);
	font-size: 0.72rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--fg);
}

.badge::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background-color: var(--brand);
}

/*
 * In the hero the demo carries the composition, so it gets a little more
 * presence than it had as a mid-page band: a real surface and a soft lift off
 * the background.
 */
.software-hero__demo .demo {
	margin-top: 0;
}

.software-hero__demo .demo__window {
	box-shadow: 0 1.5rem 3rem color-mix(in srgb, var(--fg) 9%, transparent);
}

.demo__hint {
	margin: var(--space-2) 0 0;
	font-family: var(--wp--preset--font-family--mono, ui-monospace, monospace);
	font-size: 0.74rem;
	letter-spacing: 0.08em;
	color: var(--fg);
}

.demo__hint + .demo__caption {
	margin-top: 0.25rem;
}
