/*
 * Frelim Care base styles: token aliases, type, focus and motion.
 * Colours come only from theme.json presets via the --fc-* aliases below.
 */

:root {
	/* Palette aliases. */
	--fc-indigo: var(--wp--preset--color--indigo);
	--fc-indigo-deep: var(--wp--preset--color--indigo-deep);
	--fc-ember: var(--wp--preset--color--ember);
	--fc-amber: var(--wp--preset--color--amber);
	--fc-ember-text: var(--wp--preset--color--ember-text);
	--fc-ink: var(--wp--preset--color--ink);
	--fc-muted: var(--wp--preset--color--muted);
	--fc-cream: var(--wp--preset--color--cream);
	--fc-white: var(--wp--preset--color--white);
	--fc-success: var(--wp--preset--color--success);
	--fc-error: var(--wp--preset--color--error);
	--fc-ember-amber: var(--wp--preset--gradient--ember-amber);

	/* Spacing aliases (8/16/24/32/48/64/96). */
	--fc-space-10: var(--wp--preset--spacing--10);
	--fc-space-20: var(--wp--preset--spacing--20);
	--fc-space-30: var(--wp--preset--spacing--30);
	--fc-space-40: var(--wp--preset--spacing--40);
	--fc-space-50: var(--wp--preset--spacing--50);
	--fc-space-60: var(--wp--preset--spacing--60);
	--fc-space-70: var(--wp--preset--spacing--70);

	/* Shape and layout. */
	--fc-radius-card: var(--wp--custom--radius--card);
	--fc-radius-pill: var(--wp--custom--radius--pill);
	--fc-shadow-card: var(--wp--custom--shadow--card);
	--fc-gutter: var(--wp--custom--gutter);
	--fc-content: var(--wp--style--global--content-size);
	--fc-prose: 50ch;

	/*
	 * Focus colours: their own tokens, so the high-contrast palette (which remaps the
	 * accent presets) and dark surfaces can set them explicitly.
	 */
	--fc-focus-ring: var(--wp--preset--color--indigo);
	--fc-focus-gap: var(--wp--preset--color--white);
	--fc-focus-halo: var(--wp--preset--color--amber);

	/* Derived tints, still token-only. */
	--fc-line: color-mix(in srgb, var(--fc-indigo) 14%, var(--fc-white));
	--fc-cream-soft: color-mix(in srgb, var(--fc-cream) 50%, var(--fc-white));
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

/*
 * Root size: 18px at the browser default, so 1rem is the body size and every rem-based size
 * follows the reader's browser setting. The A- / A+ controls (prefs.js) step it to 112.5%
 * and 125% of that; prefs-early.js sets data-text-size before first paint.
 */
html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	font-size: 112.5%;
	/* Keep anchored and focused elements clear of the sticky masthead (nav.js measures it). */
	scroll-padding-top: calc(var(--fc-masthead-h, 88px) + var(--fc-space-20));
}

html[data-text-size="1"] {
	font-size: calc(112.5% * 1.125);
}

html[data-text-size="2"] {
	font-size: calc(112.5% * 1.25);
}

html:has(> body.admin-bar) {
	scroll-padding-top: calc(var(--fc-masthead-h, 88px) + var(--wp-admin--admin-bar--height, 0px) + var(--fc-space-20));
}

/*
 * High contrast: an Indigo, white and ink palette with underlined links. Overriding the
 * presets themselves carries the change into every block colour class and --fc-* alias.
 * Success and error keep their colours because they carry meaning (always with words too).
 */
html[data-contrast="high"] {
	--wp--preset--color--indigo-deep: var(--wp--preset--color--indigo);
	--wp--preset--color--ember: var(--wp--preset--color--indigo);
	--wp--preset--color--amber: var(--wp--preset--color--indigo);
	--wp--preset--color--ember-text: var(--wp--preset--color--indigo);
	--wp--preset--color--muted: var(--wp--preset--color--ink);
	--wp--preset--color--cream: var(--wp--preset--color--white);
	--wp--preset--gradient--ember-amber: linear-gradient(var(--wp--preset--color--indigo), var(--wp--preset--color--indigo));
	--fc-line: var(--wp--preset--color--ink);
	--fc-cream-soft: var(--wp--preset--color--white);
	/* Amber is remapped above, so the halo is set outright: Indigo ring, white gap, ink halo. */
	--fc-focus-halo: var(--wp--preset--color--ink);
}

html[data-contrast="high"] a:not(.wp-element-button, .wp-block-button__link) {
	text-decoration-line: underline !important;
	text-decoration-thickness: 2px;
}

body {
	margin: 0;
	font-synthesis: none;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
	overflow-wrap: break-word;
}

img,
svg,
video {
	max-width: 100%;
	height: auto;
}

/* Type. Sizes and weights live in theme.json; these refine rhythm. */
:where(h1, h2, h3, h4, h5, h6) {
	text-wrap: balance;
	margin-block: 0 0.5em;
}

:where(p, li, dd, figcaption) {
	text-wrap: pretty;
}

small,
.has-small-font-size {
	font-size: max(15px, 0.833rem);
}

/* Prose: keep reading lines under 80 characters. Inside a constrained layout this also narrows the children. */
.fc-prose {
	--wp--style--global--content-size: var(--fc-prose);
	max-width: var(--fc-prose);
}

/*
 * Default pages put body copy straight in post content, at the 1200px content width.
 * Cap that copy only. Groups, grids and aligned blocks stay on the wide column.
 */
.fc-main .wp-block-post-content > :where(p, ul, ol, dl, blockquote):not(.fc-page-intro__lead) {
	max-width: var(--fc-prose);
	margin-inline: 0 auto !important;
}

.fc-main .wp-block-post-content > :where(h2) {
	max-width: var(--fc-prose);
	margin-top: 2.5rem;
	margin-bottom: 0.75rem;
	margin-inline: 0 auto !important;
}

.fc-main .wp-block-post-content > :where(h2):first-child {
	margin-top: 0;
}

.fc-prose > :where(p, ul, ol, dl, blockquote, figure) {
	max-width: var(--fc-prose);
}

/*
 * A constrained layout centres narrow children; prose should start on the content column's
 * left edge instead. WordPress sets those margins with !important, so this has to as well.
 */
.is-layout-constrained > .fc-prose {
	margin-inline-start: max(0px, (100% - var(--fc-content)) / 2) !important;
}

.fc-eyebrow {
	display: block;
	margin-block: 0 var(--fc-space-10);
	font-size: 0.7778rem; /* 14px */
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1.4;
	text-transform: uppercase;
	color: var(--fc-ember-text);
}

.fc-phone {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

:where(a) {
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
}

:where(a):hover {
	text-decoration-thickness: 2px;
}

::selection {
	background: var(--fc-cream);
	color: var(--fc-indigo-deep);
}

/*
 * Focus: 3px Indigo outline, 2px offset, 6px Amber halo.
 * The first shadow fills the offset gap so the outline reads on any background.
 */
:where(a, button, input, select, textarea, summary, [tabindex], [contenteditable="true"]):focus-visible,
.wp-element-button:focus-visible,
.wp-block-button__link:focus-visible {
	outline: 3px solid var(--fc-focus-ring);
	outline-offset: 2px;
	box-shadow: 0 0 0 2px var(--fc-focus-gap), 0 0 0 11px var(--fc-focus-halo);
}

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
	word-wrap: normal !important;
}

.screen-reader-text:focus {
	clip-path: none;
}

/* Skip link: first focusable element on every page (first in the header landmark); shown when focused. */
.fc-skip-link {
	position: fixed;
	top: var(--fc-space-10);
	left: var(--fc-space-10);
	z-index: 1000;
	padding: 12px var(--fc-space-30);
	border-radius: var(--fc-radius-pill);
	font-weight: 600;
	color: var(--fc-white);
	background-color: var(--fc-indigo);
	text-decoration: none;
	transform: translateY(calc(-100% - 100px));
}

.fc-skip-link:focus {
	transform: none;
}

.admin-bar .fc-skip-link {
	top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--fc-space-10));
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition: none !important;
		animation: none !important;
		scroll-behavior: auto !important;
	}
}

ul > li::marker {
	color: var(--fc-ember);
}
