/*
 * Layout — the page's frame, and the pieces every section shares.
 */

/*
 * WordPress does not set this globally, and the theme relies on it: every
 * `.gamife-shell` declares `width: min(72rem, 100%)` and its own inline
 * padding, which under content-box adds the padding *on top* of the width. The
 * hero was 1136px wide inside a 1040px viewport, pushing the phone off the
 * right edge by exactly the padding it was given.
 */
*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
	overflow-x: hidden;
}

/* ---------------------------------------------------------------- focus --- */

/*
 * One visible focus ring everywhere, taking its colour from `--focus-ring` so
 * that the dark section can flip it rather than inheriting a ring that vanishes
 * against its own ground.
 */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--focus-ring);
	outline-offset: 3px;
	border-radius: var(--radius-s);
}

/*
 * WordPress prints its own skip link before everything else; this only dresses
 * it, rather than adding a second one that would make the first tab stop
 * ambiguous.
 */
.skip-link.screen-reader-text:focus {
	z-index: 100;
	padding: 0.75rem 1.25rem;
	background: var(--espresso);
	color: var(--surface);
	border-radius: 0 0 var(--radius-m) var(--radius-m);
	text-decoration: none;
	font-weight: 600;
}

/* --------------------------------------------------------------- header --- */

/*
 * The sticky wrapper and the row inside it are separate elements on purpose.
 * The wrapper is the `<header>` the template part renders, and a pattern sits
 * between it and the row — so the flex layout has to live one level in, or it
 * would be trying to lay out a single anonymous child.
 */
.gamife-header {
	position: sticky;
	top: 0;
	z-index: 40;
	background: color-mix(in srgb, var(--surface) 88%, transparent);
	backdrop-filter: saturate(1.4) blur(14px);
	border-bottom: 1px solid transparent;
	transition: border-color var(--dur-settle) var(--ease-settle);
}

/*
 * What the sticky header costs every anchor on the page.
 *
 * `scroll-margin-top` is the only thing standing between a jump link and a
 * heading hidden behind the bar it just scrolled under. The sections with a
 * `--space-xxl` top padding (96px at its smallest) happen to clear the 72px
 * header on their own, which is exactly the kind of accident that holds until
 * someone adjusts the spacing scale — so the offset is stated rather than
 * relied upon.
 *
 * The two that were genuinely broken are the two nobody watches: `#plan-*`,
 * which only navigates when JavaScript has not upgraded the pricing switch and
 * put the plan's name under the header when it did, and `#main`, which is where
 * the skip link sends a keyboard or screen-reader user.
 *
 * `:where()` holds it at zero specificity, and the property is inert except
 * during a scroll-into-view, so this can neither be fought nor affect layout.
 */
:where(#main, #story, #pricing, #privacy, #faq, [id^="plan-"]) {
	scroll-margin-top: calc(var(--header-height) + 1rem);
}

.gamife-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-m);
	min-height: var(--header-height);
	padding-inline: clamp(1.25rem, 5vw, 3rem);
}

.gamife-header__end {
	display: flex;
	align-items: center;
	gap: clamp(0.75rem, 2vw, 1.25rem);
}

/*
 * The read-progress rail along the header's bottom edge.
 *
 * A pseudo-element scaled by a custom property rather than an element of its
 * own: there is no block in the header pattern to carry it, and inventing one
 * would put a decorative div into markup the Site Editor has to open. motion.js
 * writes `--gamife-progress`; with no script it stays at 0 and the rail is a
 * zero-width line nobody sees, which is the correct amount of nothing.
 */
.gamife-header::after {
	content: "";
	position: absolute;
	inset-inline: 0;
	bottom: -1px;
	height: 2px;
	background: var(--cinnamon);
	transform: scaleX(var(--gamife-progress, 0));
	transform-origin: 0 50%;
	opacity: 0;
	transition: opacity var(--dur-settle) var(--ease-settle);
	pointer-events: none;
}

.gamife-header[data-lifted="true"]::after {
	opacity: 1;
}

/* Set by motion.js once the page has scrolled past the hero's first fold. */
.gamife-header[data-lifted="true"] {
	border-bottom-color: var(--outline);
}

.gamife-wordmark {
	font-family: var(--font-display);
	font-size: 1.375rem;
	font-weight: 600;
	letter-spacing: -0.02em;
	color: var(--ink);
	text-decoration: none;
}

.gamife-header__nav {
	display: flex;
	align-items: center;
	gap: clamp(1rem, 2.5vw, 2rem);
}

.gamife-header__nav a {
	color: var(--ink-muted);
	text-decoration: none;
	font-size: var(--text-s);
	font-weight: 500;
}

.gamife-header__nav a:hover {
	color: var(--ink);
}

/* The nav links are wayfinding for a long page; on a narrow screen the CTA is
   the only one that has a job, so the rest step aside rather than wrap. */
@media (max-width: 40rem) {
	.gamife-header__nav a {
		display: none;
	}
}

/* ------------------------------------------------------------- sections --- */

.gamife-section {
	padding-block: var(--space-xxl);
}

.gamife-shell {
	width: min(72rem, 100%);
	margin-inline: auto;
	padding-inline: clamp(1.25rem, 5vw, 3rem);
}

.gamife-measure {
	max-width: var(--measure);
}

/*
 * An eyebrow labels the section it opens. It is set in the app's own chip
 * style — small, letterspaced, muted — so the page and the product share a
 * voice rather than merely a palette.
 */
.gamife-eyebrow {
	display: inline-block;
	margin: 0 0 var(--space-s);
	font-family: var(--font-body);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--ink-faint);
}

.gamife-lede {
	max-width: var(--measure);
	font-size: var(--text-l);
	line-height: 1.6;
	color: var(--ink-muted);
}

/* ---------------------------------------------------------------- cards --- */

/* ------------------------------------------------------------------ cta --- */

.gamife-cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 1rem 2rem;
	border-radius: var(--radius-pill);
	background: var(--espresso);
	color: var(--surface);
	font-weight: 600;
	font-size: var(--text-m);
	line-height: 1;
	text-decoration: none;
	border: 1px solid var(--espresso);
	transition:
		transform var(--dur-press) var(--ease-press),
		background-color var(--dur-press) var(--ease-press);
}

.gamife-cta:hover {
	background: var(--roast);
	border-color: var(--roast);
	color: var(--surface);
	transform: translateY(-2px);
}

.gamife-cta:active {
	transform: translateY(0) scale(0.98);
}

/*
 * Pre-launch. It is not a button and must not look like one you can press —
 * but it still has to read as the place the button will be, or the hero loses
 * its anchor. Same shape, no fill, no pointer.
 */
.gamife-cta--waiting {
	background: transparent;
	color: var(--ink-muted);
	border: 1px dashed var(--outline);
	cursor: default;
}

.gamife-cta--waiting:hover {
	background: transparent;
	color: var(--ink-muted);
	border-color: var(--outline);
	transform: none;
}

.gamife-header__inner .gamife-cta,
.gamife-header__inner .gamife-cta-button .wp-block-button__link {
	padding: 0.6rem 1.15rem;
	font-size: var(--text-s);
	/*
	 * "Coming soon to the App Store" is the hero's label; the header's is just
	 * "Coming soon", and it still wrapped to two lines at 390px — which made the
	 * pill taller than the 4.5rem bar it sits in and pushed it out through the
	 * bottom edge. At 320px it was clipped by the right edge outright. The bar
	 * is a single row and everything in it has to stay on one line.
	 */
	white-space: nowrap;
}

/*
 * The coin pill is hidden until the story starts, but `visibility: hidden`
 * still reserves its width — about a hundred pixels of it — and on a 320px
 * screen that is the difference between the call to action fitting and being
 * cut in half. It is decoration, and the narrowest screens are where there is
 * least room for decoration, so there it is removed from the layout entirely
 * rather than merely made invisible.
 */
@media (max-width: 34rem) {
	.gamife-header__coins {
		display: none;
	}
}

.gamife-cta-note {
	margin: var(--space-s) 0 0;
	font-size: var(--text-s);
	color: var(--ink-faint);
}

/* ---------------------------------------------------------------- phone --- */

/*
 * The device frame. Deliberately plain — a rounded slab with a hairline bezel
 * rather than a drawn iPhone, because a traced handset dates the page the
 * moment the hardware changes, and nothing on the page depends on the model.
 */
.gamife-phone {
	position: relative;
	width: var(--phone-width);

	/*
	 * The iPhone 15/16 hardware ratio. The story stage restates it as a `calc`
	 * (sections.css) because it sizes this frame from its height inside a row
	 * flexbox, where an auto width resolved from `aspect-ratio` is not reliable
	 * across engines. Change this and change that with it.
	 */
	aspect-ratio: 1206 / 2622;
	background: var(--espresso);
	box-shadow: var(--wp--preset--shadow--lift);
	flex: none;

	/*
	 * The corner is a fraction of the frame, not a fixed length.
	 *
	 * This frame is sized five different ways — by width in the hero and the
	 * pricing shot, by height in the story stage, and again in the story's
	 * landscape query — so it renders anywhere from 304px wide on a desktop to
	 * 124px on a phone. A fixed 36px radius reads as a handset at the first and
	 * as a lozenge at the second: 29% of the width instead of 12%, where a real
	 * iPhone is about 13%. That was the mobile bug.
	 *
	 * Percentage radii resolve against this element's own border box — the
	 * horizontal component against its width, the vertical against its height —
	 * so one declaration is correct at every size with no per-section override.
	 * The two components have to describe the same physical length or the
	 * corners go elliptical, which is what ties them to the aspect ratio above:
	 * 11.86% × (1206 / 2622) = 5.455%. Re-derive both together if that ratio
	 * ever changes.
	 */
	border-radius: 11.86% / 5.455%;
}

.gamife-phone__screen {
	/*
	 * The bezel, and the same problem: 6px of padding is 2% of the frame on a
	 * desktop and 4.8% of it on a phone.
	 *
	 * It cannot stay padding. Percentage padding resolves against the
	 * *containing block's* inline size, and that is a different box in every
	 * section the frame appears in. Percentage insets resolve against the
	 * positioned ancestor, which is .gamife-phone itself — block insets against
	 * its height, inline insets against its width. Both land on 6px at the
	 * desktop size and scale from there.
	 */
	position: absolute;
	inset: 0.909% 1.977%;
	overflow: hidden;
	border-radius: 10.43% / 4.691%;
	background: var(--container);
}

/* ---------------------------------------------------------------- pills --- */

/*
 * The coin pill is lifted straight off the app's HUD, where it sits in the
 * top-right of every screen. It is the page's signature: it counts as you
 * scroll the story, so reading the page earns coins the way focusing does.
 */
.gamife-coin-pill {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 1rem 0.5rem 0.5rem;
	border-radius: var(--radius-pill);
	background: var(--container-high);
	border: 1px solid var(--outline);
	font-size: var(--text-s);
	font-weight: 600;
	color: var(--ink);
	white-space: nowrap;
}

.gamife-coin-pill__coin {
	display: grid;
	place-items: center;
	width: 1.6rem;
	height: 1.6rem;
	border-radius: 50%;
	background: var(--espresso);
	color: var(--surface);
	font-size: 0.8rem;
	line-height: 1;
}

/* Tabular figures so a counting number does not jitter its own width. */
.gamife-coin-pill__value {
	font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- footer --- */

.gamife-footer {
	padding-block: var(--space-xl);
	background: var(--container-low);
	border-top: 1px solid var(--outline);
}

.gamife-footer__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-m);
}

.gamife-footer__nav {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-m);
}

.gamife-footer a {
	color: var(--ink-muted);
	text-decoration: none;
	font-size: var(--text-s);
}

.gamife-footer a:hover {
	color: var(--ink);
	text-decoration: underline;
}

.gamife-footer__legal {
	width: 100%;
	margin: 0;
	padding-top: var(--space-s);
	border-top: 1px solid var(--outline);
	font-size: var(--text-s);
	color: var(--ink-faint);
}
