/*
 * Base layer (002 T005; 006 T016): reset, the multi-scale type hierarchy,
 * accessibility primitives and the global non-essential-motion guard.
 *
 * Loads after `theme-tokens.css`; every value here is a token reference
 * (design-tokens.md §3, visual-system §3).
 */

/* ---------------------------------------------------------------------
 * Reset (small, opinionated)
 * ------------------------------------------------------------------- */

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

html {
	-webkit-text-size-adjust: 100%;
}

/*
 * Non-essential motion (research R12): smooth scrolling only when the visitor
 * has not asked for reduced motion. Everything token-driven is additionally
 * neutralised by the token file's reduced-motion override.
 */
@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}

body {
	margin: 0;
	font-family: var(--font-body);
	font-size: var(--text-md);
	line-height: var(--leading-normal);
	color: var(--color-text);
	background-color: var(--color-bg);
	overflow-wrap: break-word; /* no horizontal-scroll traps at extreme widths */
}

img,
svg,
video {
	max-width: 100%;
	height: auto; /* keeps intrinsic ratio when width is constrained */
}

iframe {
	max-width: 100%;
	border: 0;
}

button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}

/* ---------------------------------------------------------------------
 * Typography primitives (006 FR-003, visual-system §3): display face for
 * headings/statements/numerals, Manrope for everything else — hierarchy
 * comes from scale, weight, colour and rhythm, not from a third family.
 * ------------------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
	margin: 0 0 var(--space-4);
	font-family: var(--font-display);
	font-weight: var(--weight-display);
	line-height: var(--leading-tight);
	letter-spacing: var(--tracking-tight);
	color: var(--color-text-strong);
}

h1 {
	font-size: var(--text-6xl); /* 48 → 72px (FR-003 major headings; the
	                               homepage hero overrides with --text-hero) */
}

h2 {
	font-size: var(--text-4xl);
}

h3 {
	font-size: var(--text-2xl);
}

h4 {
	font-size: var(--text-xl);
}

h5,
h6 {
	font-family: var(--font-body);
	font-weight: var(--weight-bold);
	font-size: var(--text-lg);
	letter-spacing: normal;
}

p,
ul,
ol,
dl,
figure,
blockquote {
	margin: 0 0 var(--space-4);
}

ul,
ol {
	padding-left: var(--space-6);
}

li + li {
	margin-top: var(--space-2);
}

small {
	font-size: var(--text-sm);
}

strong,
b {
	font-weight: var(--weight-bold);
}

hr {
	margin: var(--space-8) 0;
	border: 0;
	border-top: var(--border-default);
}

/* ---------------------------------------------------------------------
 * Eyebrows / labels (006 visual-system §3): uppercase, tracked, small —
 * the site's "editorial tag" voice. Used by every section heading.
 * ------------------------------------------------------------------- */

.eyebrow,
.label,
.section__eyebrow {
	display: block;
	margin: 0 0 var(--space-4);
	font-family: var(--font-body);
	font-size: var(--text-eyebrow);
	font-weight: var(--weight-medium);
	line-height: var(--leading-snug);
	letter-spacing: var(--tracking-wide);
	text-transform: uppercase;
	color: var(--color-text-muted);
}

/* Display numerals `01`–`08` (006 FR-003/FR-014): display weight, tight. */
.numeral {
	font-family: var(--font-display);
	font-weight: var(--weight-display);
	letter-spacing: var(--tracking-tight);
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------
 * Links (`.link` component family lives in components.css) — 006 FR-007:
 * the editorial underline draws left → right (interaction-motion §2).
 * ------------------------------------------------------------------- */

a {
	color: var(--color-action);
	text-decoration-line: underline;
	text-decoration-thickness: var(--border-thin);
	text-underline-offset: 0.2em;
	/* `text-decoration-skip-ink` keeps descenders clean while the box
	 * animates; the gradient trick below is the motion, this is the base. */
	transition: var(--transition-hover);
}

a:hover {
	color: var(--color-action-hover);
	text-decoration-color: var(--color-action-hover);
}

/*
 * Left → right underline draw (FR-007, interaction-motion §2): the
 * decoration is painted from a background gradient, so hover grows it from
 * the start of the word to the end in ~140ms. Reduced motion zeroes the
 * token, so the underline simply appears.
 */
.link-underline,
.entry-content a,
.site-footer a:not(.button) {
	text-decoration: none;
	background-image: linear-gradient(currentColor, currentColor);
	background-repeat: no-repeat;
	background-position: 0 100%;
	background-size: 0% var(--border-thin);
	transition:
		background-size var(--duration-fast) var(--ease-standard),
		color var(--duration-fast) var(--ease-standard);
}

.link-underline:hover,
.link-underline:focus-visible,
.entry-content a:hover,
.entry-content a:focus-visible,
.site-footer a:not(.button):hover,
.site-footer a:not(.button):focus-visible {
	background-size: 100% var(--border-thin);
}

/*
 * Quiet editorial link — visually subordinate to the primary CTA (005 US1.4,
 * research R8): no underline at rest, ink not button; on hover/focus the
 * underline draws left → right (link-hover, interaction type 2).
 */
.link--quiet {
	color: var(--color-text-strong);
	text-decoration: none;
	text-underline-offset: 0.25em;
}

.link--quiet:hover,
.link--quiet:focus-visible {
	color: var(--color-action-hover);
	text-decoration: underline;
	text-decoration-thickness: var(--border-thin);
	text-decoration-color: currentColor;
}

/* ---------------------------------------------------------------------
 * Accessibility primitives (FR-033–035, SC-008)
 * ------------------------------------------------------------------- */

/* Visible focus everywhere — never removed without a replacement (005
 * FR-027 / interaction-motion.md §5: 2px --color-focus outline + offset).
 * Dark sections remap --color-focus to white locally (layout.css). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

/* Skip link: off-screen until focused (T010). */
.skip-link {
	position: absolute;
	top: -100%;
	left: var(--space-4);
	z-index: var(--z-skip-link);
	padding: var(--space-2) var(--space-4);
	background: var(--color-action);
	color: var(--color-action-text);
	font-weight: var(--weight-medium);
	text-decoration: none;
	border-radius: 0 0 var(--radius-button) var(--radius-button);
}

.skip-link:focus,
.skip-link:focus-visible {
	top: 0;
	color: var(--color-action-text);
}

/*
 * Canonical screen-reader-only / off-screen utility. `.screen-reader-text`
 * is the WordPress core spelling; `.visually-hidden` is the contract name
 * (components.md §1). Both are defined once, here.
 */
.visually-hidden,
.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.visually-hidden:focus,
.screen-reader-text:focus {
	position: static !important;
	width: auto;
	height: auto;
	margin: 0;
	overflow: visible;
	clip: auto;
	clip-path: none;
	white-space: normal;
}

/* ---------------------------------------------------------------------
 * Editorial content (posts & pages) — reading comfort
 * ------------------------------------------------------------------- */

.entry-header {
	margin-bottom: var(--space-6);
}

.entry-title {
	margin-bottom: var(--space-3);
}

.entry-content {
	font-size: var(--text-lg);
	line-height: var(--leading-normal);
}

.entry-content > * + * {
	margin-top: var(--space-4);
}

.entry-content h2 {
	margin-top: var(--space-9);
}

.entry-content h3 {
	margin-top: var(--space-7);
}

.entry-content ul,
.entry-content ol {
	padding-left: var(--space-6);
}

.entry-content li + li {
	margin-top: var(--space-2);
}

.entry-content blockquote {
	margin-left: 0;
	padding: var(--space-4) var(--space-5);
	border-left: var(--border-thin) solid var(--color-border-strong);
	background: var(--color-surface-alt);
	font-family: var(--font-display);
	font-weight: var(--weight-medium);
	font-style: normal;
	letter-spacing: var(--tracking-tight);
}

.entry-content img {
	border-radius: var(--radius-card);
}

.entry-content .wp-block-image,
.entry-content figure {
	margin-inline: auto;
}

.entry-content a {
	text-decoration: underline;
}

/* Fixed WP admin bar never overlaps content (SC-008). */
body.admin-bar {
	padding-top: calc(var(--wp-admin--admin-bar--height, 32px) + var(--space-2));
}

@media screen and (max-width: 782px) {
	body.admin-bar {
		padding-top: calc(var(--wp-admin--admin-bar--height, 46px));
	}
}
