/**
 * AdepaTrade — base layer.
 * Consumes theme.json tokens only (--wp--preset--*, --wp--custom--*).
 * Contents: root helpers · focus · selection · prose measure · utilities · reduced motion.
 */

:root {
	--adepa-focus-color: var(--wp--preset--color--brand-red);
	--adepa-rule: var(--wp--custom--border--hairline) solid var(--wp--preset--color--grey-200);
	--adepa-ease: var(--wp--custom--motion--ease);
	--adepa-header-h: var(--wp--custom--header--height);
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: calc(var(--wp--custom--header--height-compact) + 16px);
}

@media (prefers-reduced-motion: no-preference) {
	html { scroll-behavior: smooth; }
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
	font-feature-settings: "kern" 1;
}

/* Contexts with a dark background flip the focus ring to white (red on charcoal is 2.6:1). */
.is-style-dark-section,
.is-style-raised-dark,
.adepa-footer,
.adepa-overlay,
.has-charcoal-background-color,
.has-charcoal-2-background-color,
.has-brand-red-background-color,
.wp-block-cover {
	--adepa-focus-color: var(--wp--preset--color--white);
}

/* ---------- Focus: visible, 2px, offset; never removed ---------- */
:where(a, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"]), .wp-element-button):focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--adepa-focus-color);
	outline-offset: var(--wp--custom--focus--offset);
	box-shadow: none;
}
:where(a, button, input, select, textarea, summary):focus:not(:focus-visible) {
	outline: none;
}

/* ---------- Selection ---------- */
::selection {
	background: var(--wp--preset--color--brand-red);
	color: var(--wp--preset--color--white);
}

/* ---------- Links: ink with fine underline that turns red ---------- */
:where(.wp-site-blocks) :where(p, li, dd, figcaption, td) a:where(:not(.wp-element-button)) {
	text-decoration-line: underline;
	text-decoration-thickness: 1px;
	text-decoration-color: var(--wp--preset--color--grey-300);
	text-underline-offset: 0.22em;
	transition: color var(--wp--custom--motion--fast) linear, text-decoration-color var(--wp--custom--motion--fast) linear;
}
:where(.wp-site-blocks) :where(p, li, dd, figcaption, td) a:where(:not(.wp-element-button)):is(:hover, :focus-visible) {
	text-decoration-color: currentColor;
	text-decoration-thickness: 2px;
}
.is-style-dark-section :where(p, li) a:where(:not(.wp-element-button)),
.adepa-footer :where(p, li) a:where(:not(.wp-element-button)) {
	text-decoration-color: rgba(255, 255, 255, 0.35);
}
.is-style-dark-section :where(p, li) a:where(:not(.wp-element-button)):hover,
.adepa-footer :where(p, li) a:where(:not(.wp-element-button)):hover {
	text-decoration-color: var(--wp--preset--color--brand-red-bright);
}

/* ---------- Typography details ---------- */
:where(h1, h2, h3, h4, .wp-block-heading) {
	text-wrap: balance;
	font-kerning: normal;
}
:where(p, li, figcaption) {
	text-wrap: pretty;
}
.has-display-font-size {
	line-height: var(--wp--custom--line-height--display);
	letter-spacing: var(--wp--custom--letter-spacing--display);
	font-weight: 700;
}
.has-label-font-size {
	letter-spacing: var(--wp--custom--letter-spacing--label);
}
:where(strong, b) { font-weight: 600; }
:where(abbr[title]) { text-decoration: underline dotted; cursor: help; }

/* Reading measure (~68ch) in post content and prose areas, left edge kept on the content column. */
.wp-block-post-content.is-layout-constrained > :is(p, ul, ol):not(.has-text-align-center):not(.has-text-align-right):not(.alignwide):not(.alignfull) {
	max-width: min(var(--wp--style--global--content-size), var(--wp--custom--layout--reading));
	margin-left: max(0px, calc((100% - var(--wp--style--global--content-size)) / 2)) !important;
	margin-right: auto !important;
}
/* Single + page: the reading column shares the left edge of the (wide, left-aligned) article header. */
.adepa-content:not(.adepa-content--canvas).is-layout-constrained > :not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright) {
	margin-left: max(0px, calc((100% - var(--wp--style--global--wide-size)) / 2)) !important;
	margin-right: auto !important;
}
.adepa-measure,
.adepa-measure > p {
	max-width: var(--wp--custom--layout--reading);
}

/* ---------- Media ---------- */
img, svg, video { max-width: 100%; height: auto; }
.wp-block-image img { border-radius: 0; }
figure.wp-block-image figcaption.wp-element-caption,
.wp-block-image .wp-element-caption {
	margin-top: var(--wp--preset--spacing--20);
	text-align: left;
}

/* ---------- Layout helpers ---------- */
.adepa-container-standard { max-width: var(--wp--custom--layout--standard); margin-inline: auto; }
.adepa-container-max { max-width: var(--wp--custom--layout--max); margin-inline: auto; }

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

/* Section rhythm utility classes (tokens: section.sm / md / lg) */
.adepa-section-sm { padding-block: var(--wp--custom--section--sm); }
.adepa-section-md { padding-block: var(--wp--custom--section--md); }
.adepa-section-lg { padding-block: var(--wp--custom--section--lg); }

/* Main landmark: header is sticky, so anchor jumps (skip link) land below it. */
main#main:focus { outline: none; }

/* Skip link (0.4.31, CP-01D R1 / D-06): first focusable element of <body> on every template
   (functions.php adepatrade_skip_link -> #main). Visually hidden until focused; when focused it shows at the
   top-left, below the admin bar when one is shown. Dark surface, so the focus ring is white. */
.adepa-skip-link {
	--adepa-focus-color: var(--wp--preset--color--white);
	position: fixed;
	top: calc(var(--wp-admin--admin-bar--height, 0px) + 0.5rem);
	left: 0.5rem;
	z-index: 100000;
	display: inline-flex;
	align-items: center;
	min-height: var(--wp--custom--touch-target);
	padding: 0 1.25rem;
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--white);
	font-weight: 700;
	text-decoration: none;
}
.adepa-skip-link:not(:focus) {
	width: 1px;
	height: 1px;
	min-height: 0;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---------- Forms (core search etc.) ---------- */
:where(input[type="text"], input[type="search"], input[type="email"], input[type="tel"], input[type="url"], textarea, select) {
	font: inherit;
	color: var(--wp--preset--color--ink);
	background: var(--wp--preset--color--white);
	border: 1px solid var(--wp--preset--color--grey-500);
	border-radius: var(--wp--custom--radius--sm);
	min-height: var(--wp--custom--touch-target);
	padding: 0.625rem 0.875rem;
}
:where(input, textarea, select)::placeholder { color: var(--wp--preset--color--grey-500); opacity: 1; }

/* ---------- Reduced motion: kill non-essential motion everywhere ---------- */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
