/**
 * TitanWorks EV — global base styles.
 *
 * Tokens live in theme.json. This file holds only what every page needs:
 * fallback font metrics, focus, form fields, shared utility classes used by
 * patterns (labels, section marks, cards) and motion rules.
 * Component CSS lives in assets/css/blocks/ and loads per block.
 */

/* Metric-matched fallbacks (computed against Arial/Liberation Sans) keep
   layout stable while the web fonts swap in. */
@font-face {
	font-family: "Inter Fallback";
	src: local("Arial"), local("Liberation Sans"), local("Helvetica");
	size-adjust: 107.5%;
	ascent-override: 90.1%;
	descent-override: 22.4%;
	line-gap-override: 0%;
}

@font-face {
	font-family: "Lexend Fallback";
	src: local("Arial"), local("Liberation Sans"), local("Helvetica");
	size-adjust: 115.2%;
	ascent-override: 86.8%;
	descent-override: 21.7%;
	line-gap-override: 0%;
}

:root {
	--titanworks-ev--focus: var(--wp--preset--color--ink);
	--titanworks-ev--focus-offset: var(--wp--preset--color--base);
	--titanworks-ev--scrim: rgb(0 0 0 / 0.55);
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: 16px;
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizelegibility;
	overflow-wrap: break-word;
}

img,
video,
iframe {
	max-width: 100%;
}

img {
	height: auto;
}

/* ---------- Focus (R-01) ---------- */

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--titanworks-ev--focus);
	outline-offset: 2px;
	box-shadow: 0 0 0 4px var(--titanworks-ev--focus-offset);
	border-radius: 2px;
}

.is-surface-dark,
.has-deep-background-color,
.has-night-background-color,
.has-deep-panel-gradient-background {
	--titanworks-ev--focus: var(--wp--preset--color--accent);
	--titanworks-ev--focus-offset: transparent;
}

.skip-link.screen-reader-text:focus {
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--on-accent);
	font-weight: 700;
	z-index: 100000;
}

/* ---------- Text links inside running text ---------- */

:where(.wp-block-post-content, .entry-content, .wp-block-comment-content) a:not(.wp-element-button) {
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
}

:where(.wp-block-post-content, .entry-content) a:not(.wp-element-button):hover {
	text-decoration-thickness: 2px;
	text-decoration-color: var(--wp--preset--color--accent);
}

/* ---------- Buttons ---------- */

.wp-element-button,
.wp-block-button__link {
	min-height: 40px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	cursor: pointer;
	transition: background-color var(--wp--custom--motion--fast) var(--wp--custom--motion--ease);
}

.wp-block-button.is-style-outline > .wp-block-button__link {
	background: transparent;
	color: var(--wp--preset--color--ink);
	border: 1px solid currentcolor;
}

.wp-block-button.is-style-outline > .wp-block-button__link:hover {
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--base);
}

:where(.wp-element-button, .wp-block-button__link, button)[disabled],
:where(.wp-element-button, .wp-block-button__link)[aria-disabled="true"] {
	opacity: 0.5;
	cursor: not-allowed;
}

/* ---------- Form fields ---------- */

:where(input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="hidden"]), select, textarea) {
	min-height: var(--wp--custom--field-height);
	padding: 10px 14px;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--s);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--ink);
	font: inherit;
	font-size: max(16px, 1em);
	box-sizing: border-box;
	max-width: 100%;
}

:where(input, select, textarea)::placeholder {
	color: var(--wp--preset--color--muted);
	opacity: 1;
}

:where(input[type="checkbox"], input[type="radio"]) {
	width: 18px;
	height: 18px;
	accent-color: var(--wp--preset--color--link);
}

label {
	font-weight: 600;
}

/* ---------- Category label (R-03, R-05) ---------- */

.titanworks-ev-label,
.taxonomy-category.wp-block-post-terms {
	font-size: var(--wp--preset--font-size--label);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	line-height: 1.4;
}

.taxonomy-category.wp-block-post-terms a {
	color: inherit;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 24px;
}

.taxonomy-category.wp-block-post-terms a::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--wp--preset--color--accent);
	flex: none;
}

.taxonomy-category.wp-block-post-terms .wp-block-post-terms__separator {
	display: none;
}

.taxonomy-category.wp-block-post-terms a + .wp-block-post-terms__separator + a,
.taxonomy-category.wp-block-post-terms a ~ a {
	margin-left: 10px;
}

/* Label sitting on an image gets a dark pill (R-03). */
.is-style-on-image.taxonomy-category.wp-block-post-terms a {
	background: var(--titanworks-ev--scrim);
	color: #fff;
	box-sizing: border-box;
	align-items: center;
	min-height: 24px; /* WCAG 2.2 target size */
	padding: 2px 8px;
	border-radius: var(--wp--custom--radius--xs);
}

/* ---------- Section heading with the "//" mark ---------- */

.is-style-section-mark {
	font-size: var(--wp--preset--font-size--lead);
	letter-spacing: -0.02em;
	display: flex;
	align-items: baseline;
	gap: 0.35em;
}

.is-style-section-mark::after {
	content: "//";
	color: var(--wp--preset--color--accent);
	font-style: italic;
	font-weight: 700;
	letter-spacing: -0.1em;
}

/* ---------- Cards (shared hover behaviour) ---------- */

.titanworks-ev-card {
	position: relative;
}

.titanworks-ev-card .wp-block-post-featured-image {
	overflow: hidden;
	border-radius: var(--wp--custom--radius--xs);
	background: var(--wp--preset--color--deep);
}

.titanworks-ev-card .wp-block-post-featured-image img {
	transition: transform var(--wp--custom--motion--base) var(--wp--custom--motion--ease);
}

.titanworks-ev-card:hover .wp-block-post-featured-image img,
.titanworks-ev-card:focus-within .wp-block-post-featured-image img {
	transform: scale(1.04);
}

.titanworks-ev-card .wp-block-post-title a {
	background-image: linear-gradient(var(--wp--preset--color--accent), var(--wp--preset--color--accent));
	background-size: 0 2px;
	background-position: 0 100%;
	background-repeat: no-repeat;
	transition: background-size var(--wp--custom--motion--base) var(--wp--custom--motion--ease);
}

.titanworks-ev-card:hover .wp-block-post-title a,
.titanworks-ev-card .wp-block-post-title a:focus-visible {
	background-size: 100% 2px;
}

/* Meta row: "By Author · Date" */
.titanworks-ev-meta {
	font-size: var(--wp--preset--font-size--meta);
	color: var(--wp--preset--color--muted);
	line-height: var(--wp--custom--line-height--ui);
}

.titanworks-ev-meta .wp-block-post-author-name a {
	color: var(--wp--preset--color--link);
	text-decoration: none;
	display: inline-block;
	min-height: 24px;
	line-height: 24px;
}

/* ---------- Utilities ---------- */

.titanworks-ev-visually-hidden {
	clip-path: inset(50%);
	height: 1px;
	width: 1px;
	overflow: hidden;
	position: absolute;
	white-space: nowrap;
}

/* ---------- Motion ---------- */

@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;
	}
}
