:root {
	/*
	 * Raw endpoint constants shared by the semantic tokens and the ambient
	 * Day/Night interpolation, so the gradual states can never drift away
	 * from the approved Light and Dark baselines.
	 */
	--ew-color-bg-light: #faf7f2;
	--ew-color-bg-dark: #101612;
	--ew-color-surface-light: #fffdf8;
	--ew-color-surface-dark: #151d18;
	--ew-color-muted-light: #e9e3d8;
	--ew-color-muted-dark: #1c2721;
	--ew-color-border-light: #d8d1c4;
	--ew-color-border-dark: #34433a;
	/* Brand band material: the approved deep green at full light, and the
	   same green subtly deepened at full Night, so the footer, dock and
	   conversion bands answer the exposure while the identity holds. */
	--ew-color-green-dark-light: #143528;
	--ew-color-green-dark-dark: #0c1a12;

	/* Architectural material, independent of brand and ambient UI colours.
	   Each stop describes a machined face, bevel or recessed gasket. */
	--ew-frame-metal-x: linear-gradient(90deg, #191c1c 0%, #676962 10%, #bbb9ad 17%, #424642 24%, #303533 66%, #535852 78%, #95978c 85%, #202523 94%);
	--ew-frame-metal-y: linear-gradient(180deg, #b6b5aa 0%, #666961 14%, #303633 26%, #252b28 67%, #777a70 78%, #151b18 91%);
	--ew-frame-pull: linear-gradient(90deg, #171c1a 0%, #303632 18%, #969a8e 30%, #dddcd0 42%, #797f74 56%, #303832 83%, #141a16 100%);

	/*
	 * Ambient progress: 0 = full Light environment, 1 = full Dark. Written
	 * pre-paint by the bootstrap and streamed by the Home Day/Night owner;
	 * it never reaches media, only the shell presentation tokens below.
	 */
	--ew-theme-progress: 0;

	/* Semantic surface and text tokens (light baseline). */
	--ew-bg: var(--ew-color-bg-light);
	--ew-surface: var(--ew-color-surface-light);
	--ew-surface-muted: var(--ew-color-muted-light);
	--ew-text: #1d1c1a;
	--ew-text-muted: #5d625e;
	--ew-border: var(--ew-color-border-light);
	--ew-border-media: rgb(29 28 26 / 0.18);
	--ew-overlay-media: linear-gradient(180deg, rgb(16 22 18 / 0.02), rgb(16 22 18 / 0.34));
	--ew-label-on-media: #ffffff;
	--ew-action: #1f4a38;
	--ew-on-action: #ffffff;
	--ew-link: #1f4a38;

	/* Translucent editorial plate surface (calm scenes, overlays). */
	--ew-scrim: rgb(255 253 248 / 0.82);

	/* Status and on-brand constants. */
	--ew-danger: #8a3b2a;
	--ew-on-brand: #f5f1e9;

	/* Controlled brand accent from the approved compact symbol. */
	--ew-accent: #d47b21;
	/* Text-safe derivative of the accent: meets 4.5:1 on paper and stone. */
	--ew-accent-text: #8f4a0c;

	color-scheme: light;

	/* Brand palette (brand roles only — never universal surfaces/text). */
	--ew-ink: #1d1c1a;
	--ew-paper: #faf7f2;
	--ew-stone: #e9e3d8;
	--ew-line: #d8d1c4;
	--ew-deep-green: #1f4a38;
	/*
	 * Brand band material. Only the Home - the page that owns the Day/Night
	 * exposure - deepens the band with --ew-theme-progress (bootstrap
	 * anchors it pre-paint; no-JS falls back to 0). Every other route keeps
	 * the approved constant in both themes.
	 */
	--ew-green-dark: #143528;
	--ew-leaf: #6fa845;
	--ew-amber: #c88a3d;

	/* Final pairing approved in the client adjustments dated 2026-11-03. Catamaran carries
	   display type; Instrument Sans carries body and UI. Both are self-hosted OFL,
	   and the fallback stacks stay neutral so a missing file degrades quietly. */
	--ew-font-body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
	--ew-font-display: "Catamaran", "Segoe UI", system-ui, -apple-system, sans-serif;

	/* Drawn with by the brand guideline itself, extracted from its vector
	   colour operators. Recorded with provenance and confidence in the brand
	   register; not yet certified against an official digital specification. */
	--ew-brand-deep-green: #16281c;
	--ew-brand-beige: #f2ede2;
	--ew-brand-olive: #686f39;
	--ew-brand-orange: #dc7025;
	--ew-brand-mist-blue: #9db7c2;
	--ew-brand-stone: #d8d3c7;
	--ew-brand-lime: #b9c079;

	--ew-container-max: 75rem;
	--ew-gutter: 1.5rem;
	--ew-reading-measure: 46rem;

	--ew-space-xxs: 0.375rem;
	--ew-space-xs: clamp(0.75rem, 0.7rem + 0.2vw, 1rem);
	--ew-space-sm: clamp(1.5rem, 1.2rem + 1vw, 2.5rem);
	--ew-space-md: clamp(2.25rem, 1.6rem + 2.2vw, 4.25rem);
	--ew-space-lg: clamp(3.5rem, 2.25rem + 4.5vw, 7rem);

	--ew-radius: 0.25rem;
	--ew-line-width: 1px;

	/*
	 * Fluid display scale: editorial statement sizes that grow with the
	 * viewport between the body scale and the architectural ceiling.
	 */
	--ew-display-lg: clamp(2rem, 1.1rem + 3.2vw, 3.25rem);
	--ew-display-xl: clamp(2.5rem, 1.5rem + 4.2vw, 4.5rem);

	/*
	 * Motion roles (spec §5): exact single-value contracts. Public ease
	 * curves are capped at three; additions require a documented consumer
	 * with a perceptible difference.
	 */
	--ew-motion-instant: 0ms;
	--ew-motion-fast: 180ms;
	--ew-motion-editorial: 550ms;
	--ew-motion-signature: 1250ms;

	--ew-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
	--ew-ease-editorial: cubic-bezier(0.645, 0.045, 0.355, 1);
	--ew-ease-signature: cubic-bezier(0.16, 1, 0.3, 1);

	/* Legacy aliases during migration; removal needs its own decision. */
	--ew-motion-section: var(--ew-motion-editorial);
	--ew-motion-ease: var(--ew-ease-out);
}

html[data-ew-theme="dark"] {
	/* Semantic surface and text tokens (dark baseline). */
	--ew-bg: var(--ew-color-bg-dark);
	--ew-surface: var(--ew-color-surface-dark);
	--ew-surface-muted: var(--ew-color-muted-dark);
	--ew-text: #f5f1e9;
	--ew-text-muted: #b9c1bb;
	--ew-border: var(--ew-color-border-dark);
	--ew-border-media: rgb(245 241 233 / 0.2);
	--ew-overlay-media: linear-gradient(180deg, rgb(0 0 0 / 0.08), rgb(0 0 0 / 0.48));
	--ew-label-on-media: #f5f1e9;
	--ew-action: #79a98f;
	--ew-on-action: #0d1510;
	--ew-link: #a8c8b5;

	--ew-scrim: rgb(16 22 18 / 0.78);

	--ew-danger: #e0937c;

	/* Accent stays readable on the dark shell. */
	--ew-accent: #e08a2e;
	--ew-accent-text: #e9a45b;

	color-scheme: dark;

	/*
	 * Brand aliases follow the theme so existing var() consumers (plugin
	 * reveal CSS, decorative scenes, comparison chrome) adapt coherently.
	 * Brand roles stay brand roles — these are not universal surfaces.
	 * --ew-green-dark deliberately keeps its light-theme depth: the footer
	 * band and decorative glass stay brand-deep in both themes so
	 * --ew-on-brand text keeps its measured contrast.
	 */
	--ew-ink: #f5f1e9;
	--ew-paper: var(--ew-color-bg-dark);
	--ew-stone: var(--ew-color-muted-dark);
	--ew-line: var(--ew-color-border-dark);
	--ew-deep-green: #79a98f;
}

/*
 * Ambient Day/Night exposure.
 *
 * While the Home comparator sits between its endpoints, the whole shell is
 * one room receiving a changing amount of light: the divider position is
 * the only source, theme-controller.js converts it into a target luminance
 * that runs on a straight line between the two endpoint luminances (50%
 * Day reads as roughly half the illumination), solves the matching
 * color-mix share every tick and writes it as
 * --ew-ambient-light-share. There are no dead zones, plateaus or
 * concentrated ramps: the very first step of the range already changes the
 * light, and the endpoints are reached only at the extremes.
 *
 * Every text-bearing shell surface rides that same luminance path, and the
 * shell text tokens are contrast-locked curves written per tick by the
 * controller — the two text families swap only at the single surface
 * luminance where pure black and pure white both clear AA, so semantic
 * consolidation never moves the surface and never yields grey. Media,
 * comparison imagery and editorial overlays on imagery are untouched. This
 * block sits after html[data-ew-theme="dark"] so it wins the cascade while
 * active.
 */
html[data-ew-ambient="true"] {
	--ew-bg: color-mix(in srgb, var(--ew-color-bg-light) var(--ew-ambient-light-share, 100%), var(--ew-color-bg-dark));
	--ew-paper: color-mix(in srgb, var(--ew-color-bg-light) var(--ew-ambient-light-share, 100%), var(--ew-color-bg-dark));
	/* Every text-bearing shell surface rides the SAME exposure path: the
	   contrast bounds are calibrated against this one curve. Surface
	   hierarchy returns verbatim at the endpoints; borders and lines keep
	   their own interpolation for structure. */
	--ew-surface: var(--ew-bg);
	--ew-surface-muted: var(--ew-bg);
	--ew-stone: var(--ew-bg);
	--ew-border: color-mix(in srgb, var(--ew-color-border-light) var(--ew-ambient-light-share, 100%), var(--ew-color-border-dark));
	--ew-line: color-mix(in srgb, var(--ew-color-border-light) var(--ew-ambient-light-share, 100%), var(--ew-color-border-dark));

	/* Contrast-locked shell text, written per tick by theme-controller.js. */
	--ew-text: var(--ew-ambient-text, #000000);
	--ew-ink: var(--ew-ambient-ink, #000000);
	--ew-text-muted: var(--ew-ambient-text-muted, #000000);
	--ew-deep-green: var(--ew-ambient-deep-green, #000000);
	--ew-link: var(--ew-ambient-link, #000000);
	--ew-action: var(--ew-ambient-action, #000000);
	--ew-accent-text: var(--ew-ambient-accent-text, #000000);
}

html[data-ew-ambient="true"][data-ew-theme="dark"] {
	--ew-text: var(--ew-ambient-text, #ffffff);
	--ew-ink: var(--ew-ambient-ink, #ffffff);
	--ew-text-muted: var(--ew-ambient-text-muted, #ffffff);
	--ew-deep-green: var(--ew-ambient-deep-green, #ffffff);
	--ew-link: var(--ew-ambient-link, #ffffff);
	--ew-action: var(--ew-ambient-action, #ffffff);
	--ew-accent-text: var(--ew-ambient-accent-text, #ffffff);
}

/*
 * Home only: the brand band material answers the Day/Night exposure — the
 * footer, dock and conversion bands receive proportionally less light as
 * Night is revealed, while the green identity holds at both extremes.
 * Every other route keeps the approved constant above.
 */
body.home {
	--ew-green-dark: color-mix(
		in srgb,
		var(--ew-color-green-dark-light) calc((1 - var(--ew-theme-progress, 0)) * 100%),
		var(--ew-color-green-dark-dark)
	);
}
