/*
 * WP Custom – reset and base styles.
 *
 * Layer order. Unlayered CSS (Elementor, WordPress) beats every normal
 * declaration here, so base styles never fight Global Classes.
 * For !important declarations the order flips: earlier layers win. So the
 * reduced-motion rules in reset beat everything, and utilities beat compat.
 */
@layer wpcustom.reset, wpcustom.base, wpcustom.utilities, wpcustom.compat;

/* ---------- Reset ---------- */
@layer wpcustom.reset {
	*, *::before, *::after { box-sizing: border-box; }

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

	body {
		margin: 0;
		min-height: 100dvh;
		overflow-x: clip;
		line-height: 1.6;
		-webkit-font-smoothing: antialiased;
		text-rendering: optimizeLegibility;
	}

	h1, h2, h3, h4, h5, h6, p, ul, ol, figure, blockquote { margin-top: 0; }
	h1, h2, h3, h4, h5, h6 { line-height: 1.2; text-wrap: balance; }
	p { text-wrap: pretty; }

	img, video { max-width: 100%; height: auto; }
	input, button, textarea, select { font: inherit; }
	button { cursor: pointer; }

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

/* ---------- Base ---------- */
@layer wpcustom.base {
	body {
		color: var(--wpcustom-color-text);
		font-family: var(--wpcustom-font-text);
		font-weight: var(--wpcustom-font-text-weight);
		background: var(--wpcustom-color-white, #fff);
	}

	h1, h2, h3, h4, h5, h6 {
		font-family: var(--wpcustom-font-primary);
		font-weight: var(--wpcustom-font-primary-weight);
	}

	/* Team convention: links inherit colour, no underline, smooth transition. */
	a {
		color: inherit;
		text-decoration: none;
		transition: var(--wpcustom-transition);
	}

	:focus-visible { outline: 2px solid var(--wpcustom-color-primary); outline-offset: 2px; }

	.screen-reader-text {
		position: absolute !important;
		width: 1px; height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}
	.skip-link:focus {
		position: fixed !important;
		top: 8px; left: 8px;
		width: auto; height: auto;
		clip-path: none;
		z-index: 100000;
		padding: 12px 20px;
		background: #fff;
		color: #111;
	}

	/* Fallback layout (no Elementor template assigned). */
	.container {
		width: min(100% - 2 * var(--wpcustom-space-s), var(--wpcustom-container));
		margin-inline: auto;
	}
	.site-main > .container,
	.site-main > article.container { padding-block: var(--wpcustom-space-l); }

	.site-header .hdTop .container,
	.site-header .hdBot .container {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
		gap: var(--wpcustom-space-s);
		padding-block: var(--wpcustom-space-s);
	}
	.site-header .hdLogo img { max-height: 80px; width: auto; }
	.site-title { font-family: var(--wpcustom-font-primary); font-weight: var(--wpcustom-font-primary-weight); font-size: 1.5rem; }

	.site-header nav ul,
	.site-footer nav ul { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin: 0; padding: 0; list-style: none; }
	.site-header nav li { position: relative; }
	.site-header nav .sub-menu {
		display: none;
		position: absolute;
		top: 100%;
		left: 0;
		z-index: 50;
		min-width: 220px;
		flex-direction: column;
		gap: 0;
		padding: 0.5rem 0;
		background: #fff;
		box-shadow: var(--wpcustom-shadow);
	}
	.site-header nav .sub-menu a { display: block; padding: 0.4rem 1rem; }
	.site-header nav .sub-menu .sub-menu { top: 0; left: 100%; }
	.site-header nav li:hover > .sub-menu,
	.site-header nav li:focus-within > .sub-menu { display: flex; }

	/* Sticky header (main.js adds .sticky / .is-sticky after scrolling). */
	.site-header.sticky { position: sticky; top: 0; z-index: 100; background: #fff; box-shadow: var(--wpcustom-shadow); }

	.site-footer { background: var(--wpcustom-color-dark-gray); color: var(--wpcustom-color-white); padding-block: var(--wpcustom-space-m); }
	.site-footer .ftNav,
	.site-footer .ftCopy { margin-top: var(--wpcustom-space-s); }
	.site-footer .copyright { margin: 0; font-size: 0.875rem; opacity: 0.8; }

	.has-sidebar { display: grid; gap: var(--wpcustom-space-m); }
	.has-sidebar .container { width: 100%; }
	@media (min-width: 1025px) {
		.has-sidebar { grid-template-columns: minmax(0, 1fr) 320px; }
	}

	.post-list { display: grid; gap: var(--wpcustom-space-m); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
	.post-card__image img { border-radius: var(--wpcustom-radius-m); aspect-ratio: 16 / 10; object-fit: cover; width: 100%; }

	.alignwide { max-width: calc(var(--wpcustom-container) + 200px); margin-inline: auto; }
	.alignfull { width: 100vw; margin-inline: calc(50% - 50vw); }
}

/*
 * Unlayered on purpose: must beat WordPress's global-styles link rule.
 * Only non-Elementor posts/pages carry .wpcustom-prose (template-parts/singular.php).
 */
.wpcustom-prose a:not([class]) { color: var(--wpcustom-color-primary); text-decoration: underline; text-underline-offset: 0.15em; }
