/**
 * SW8 Theme — front-end styles, S8 Design System.
 *
 * Colors, fonts, sizes and spacing come from theme.json (--wp--preset--*,
 * --wp--custom--*). Edit theme.json first; only add CSS here for things
 * theme.json can't express. No build step: native CSS nesting is fine.
 *
 * 0. S8 tokens + sw8-blocks button mapping
 * 1. Base
 * 2. Layout
 * 3. Header (fallback)
 * 4. Footer bar
 * 5. Content: entries, cards, pagination, forms
 * 6. Block style variations
 * 7. Utilities
 * 8. S8 typography helpers
 */

/* ---------------------------------------------------------------------------
 * 0. S8 tokens (aliases of theme.json presets) + sw8-blocks buttons
 * ------------------------------------------------------------------------- */
:root {
	--paper: var(--wp--preset--color--base);
	--cream: var(--wp--preset--color--surface);
	--cream-deep: var(--wp--preset--color--surface-deep);
	--line: var(--wp--preset--color--border);
	--ink: var(--wp--preset--color--contrast);
	--ink-muted: var(--wp--preset--color--muted);
	--gold: var(--wp--preset--color--accent);
	--on-gold: var(--wp--preset--color--contrast);
	--forest: var(--wp--preset--color--primary);
	--on-forest: #fff;
	--clay: var(--wp--preset--color--clay);
	--sage: var(--wp--preset--color--secondary);
	--focus-ring: 0 0 0 3px rgb(242 183 5 / 0.55);
	--font-display: var(--wp--preset--font-family--heading);
	--font-body: var(--wp--preset--font-family--body);
	--measure: 65ch;

	/* sw8-blocks .sw8-btn variants */
	--button--border-radius: 999px;
	--button--border-width: 1px;
	--button--font-family: var(--font-body);
	--button--font-size: 15px;
	--button--font-weight: 700;
	--button--line-height: 1;
	--button--padding-vertical: 16px;
	--button--padding-horizontal: 26px;
	--button-primary--color-background: var(--gold);
	--button-primary--color-background-active: #DCA604;
	--button-primary--color-text: var(--ink);
	--button-primary--color-text-hover: var(--ink);
	--button-secondary--color-background: var(--forest);
	--button-secondary--color-background-active: #162A1F;
	--button-secondary--color-text: #fff;
	--button-secondary--color-text-hover: #fff;
	--button-tertiary--color-background: var(--cream);
	--button-tertiary--color-background-active: var(--cream-deep);
	--button-tertiary--color-text: var(--ink);
	--button-tertiary--color-text-hover: var(--ink);
	--button-outline--color-background: transparent;
	--button-outline--color-background-active: var(--ink);
	--button-outline--color-text: var(--ink);
	--button-outline--color-text-hover: #fff;
}

.sw8-btn {
	letter-spacing: 0.12em;
	text-transform: uppercase;

	&:hover,
	&:active {
		text-decoration: none;
	}
}

/* ---------------------------------------------------------------------------
 * 1. Base
 * ------------------------------------------------------------------------- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
	scroll-padding-top: var(--wp--custom--header-height, 84px);
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

body {
	margin: 0;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

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

:where(h1, h2, h3, h4, h5, h6) {
	margin-block: 0 0.5em;
	text-wrap: balance;
}

:where(p) {
	text-wrap: pretty;
}

:where(a) {
	text-underline-offset: 3px;
}

::selection {
	background: rgb(242 183 5 / 0.45);
	color: var(--ink);
}

:focus-visible {
	outline: 2px solid var(--forest);
	outline-offset: 2px;
	box-shadow: var(--focus-ring);
}

.screen-reader-text {
	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;
}

.skip-link:focus {
	position: fixed !important;
	z-index: 100000;
	top: 0.75rem;
	left: 0.75rem;
	width: auto;
	height: auto;
	padding: 0.75rem 1.25rem;
	margin: 0;
	clip: auto;
	clip-path: none;
	border-radius: var(--wp--custom--radius-pill);
	background: var(--gold);
	color: var(--ink);
	font-weight: 700;
}

/* ---------------------------------------------------------------------------
 * 2. Layout
 * ------------------------------------------------------------------------- */
.site {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
}

.site-main {
	flex: 1 0 auto;
	outline: 0;
}

.page-wrap,
.entry-header {
	padding-block-start: var(--wp--preset--spacing--60);
}

.page-wrap {
	padding-block-end: var(--wp--preset--spacing--70);
}

.page-wrap--center {
	text-align: center;

	.search-form {
		margin-inline: auto;
	}
}

.entry-content:not(.entry-content--blocks) {
	padding-block-end: var(--wp--preset--spacing--70);
}

.entry-content--blocks,
.home .entry-content {
	> .alignfull:first-child {
		margin-block-start: 0;
	}

	> .alignfull:last-child {
		margin-block-end: 0;
	}
}

.page-header {
	margin-block-end: var(--wp--preset--spacing--50);
}

/* Eyebrow: "01  Section name" with a gold number pill. */
.page-eyebrow,
.s8-eyebrow {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 18px;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--ink);
}

.s8-eyebrow__n {
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--gold);
	color: var(--on-gold);
	font-weight: 700;
	letter-spacing: 0;
}

.page-intro,
.s8-lede {
	max-width: var(--measure);
	font-size: 19px;
	line-height: 1.55;
	color: var(--ink-muted);

	.page-wrap--center & {
		margin-inline: auto;
	}
}

/* ---------------------------------------------------------------------------
 * 3. Header (fallback — only when sw8/custom-header isn't available)
 * ------------------------------------------------------------------------- */
.site-header {
	position: sticky;
	top: 0;
	z-index: 50;
	background: rgb(255 255 255 / 0.88);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--line);
}

.site-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--40);
	max-width: var(--wp--style--global--wide-size);
	min-height: var(--wp--custom--header-height, 84px);
	margin-inline: auto;
}

.site-header__brand {
	img {
		display: block;
		width: auto;
		max-height: 44px;
	}
}

.site-title {
	font-family: var(--font-display);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 800;
	color: var(--ink);
	text-decoration: none;
}

.site-header__toggle {
	display: none;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.site-header__toggle-bars,
.site-header__toggle-bars::before,
.site-header__toggle-bars::after {
	display: block;
	width: 24px;
	height: 2px;
	margin-inline: auto;
	background: currentColor;
	transition: transform 200ms ease, opacity 200ms ease;
}

.site-header__toggle-bars {
	position: relative;

	&::before,
	&::after {
		content: "";
		position: absolute;
		left: 0;
	}

	&::before {
		top: -7px;
	}

	&::after {
		top: 7px;
	}
}

.site-header__toggle[aria-expanded="true"] .site-header__toggle-bars {
	background: transparent;

	&::before {
		transform: translateY(7px) rotate(45deg);
	}

	&::after {
		transform: translateY(-7px) rotate(-45deg);
	}
}

.site-nav__menu {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 0.25rem;
	margin: 0;
	padding: 0;
	list-style: none;

	a {
		display: block;
		padding: 6px 10px;
		border-radius: 999px;
		color: var(--ink-muted);
		font-size: 13px;
		font-weight: 600;
		letter-spacing: 0.12em;
		text-transform: uppercase;
		text-decoration: none;

		&:hover {
			background: var(--cream);
			color: var(--ink);
		}
	}

	.current-menu-item > a {
		background: var(--cream);
		color: var(--ink);
	}

	.sub-menu {
		margin: 0;
		padding: 0 0 0 1rem;
		list-style: none;
	}
}

@media (min-width: 992px) {
	.site-nav__menu {
		> li {
			position: relative;
		}

		.sub-menu {
			position: absolute;
			top: 100%;
			left: -1rem;
			min-width: 240px;
			padding: 0.5rem;
			border: 1px solid var(--line);
			border-radius: var(--wp--custom--radius-md);
			background: var(--paper);
			box-shadow: 0 10px 24px rgb(0 0 0 / 0.12);
			opacity: 0;
			visibility: hidden;
			transform: translateY(6px);
			transition: opacity 150ms ease, transform 150ms ease, visibility 150ms;

			a {
				letter-spacing: 0;
				text-transform: none;
				font-size: 15px;
			}
		}

		li:hover > .sub-menu,
		li:focus-within > .sub-menu {
			opacity: 1;
			visibility: visible;
			transform: none;
		}
	}
}

@media (max-width: 991px) {
	.site-header__toggle {
		display: block;
	}

	.site-nav {
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		display: none;
		padding: 1rem var(--wp--preset--spacing--40) 1.5rem;
		background: var(--paper);
		border-bottom: 1px solid var(--line);

		&.is-open {
			display: block;
		}
	}

	.site-nav__menu {
		flex-direction: column;
	}
}

/* ---------------------------------------------------------------------------
 * 4. Footer bar
 * ------------------------------------------------------------------------- */
.site-footer {
	margin-block-start: 0;

	a {
		text-decoration: none;

		&:hover {
			text-decoration: underline;
		}
	}
}

.site-bar {
	padding-block: 1.25rem;
	background: var(--wp--preset--color--primary-dark);
	color: rgb(255 255 255 / 0.72);
	font-size: 13px;
}

.site-bar__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem 1.5rem;
	max-width: var(--wp--style--global--wide-size);
	margin-inline: auto;
}

.site-bar__copy {
	margin: 0;
}

.site-bar__menu {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.25rem;
	margin: 0;
	padding: 0;
	list-style: none;

	a {
		color: inherit;
		text-decoration: none;

		&:hover {
			color: var(--gold);
			text-decoration: underline;
		}
	}
}

/* ---------------------------------------------------------------------------
 * 5. Content
 * ------------------------------------------------------------------------- */
.entry-title {
	margin-block-end: 0.25em;
}

.entry-meta,
.card__meta {
	margin: 0;
	font-size: 13px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ink-muted);
}

.entry-thumbnail {
	margin-block: var(--wp--preset--spacing--50);

	img {
		display: block;
		width: 100%;
		border-radius: var(--wp--custom--radius-lg);
	}
}

/* Cards (archive / search / blog): cream, line border, 22px radius, no shadow. */
.post-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
	gap: var(--wp--preset--spacing--50);
}

.card {
	position: relative;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--line);
	border-radius: var(--wp--custom--radius-lg);
	background: var(--cream);
	transition: border-color 150ms ease;

	&:hover {
		border-color: var(--forest);
	}

	&:hover .card__title a {
		text-decoration: underline;
	}
}

.card__media img {
	display: block;
	width: 100%;
	aspect-ratio: 3 / 2;
	object-fit: cover;
}

.card__body {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	padding: 1.25rem 1.5rem 1.5rem;
}

.card__title {
	margin: 0;
	font-size: 22px;
	line-height: 1.1;

	a {
		color: inherit;
		text-decoration: none;

		&::after {
			content: "";
			position: absolute;
			inset: 0;
		}
	}
}

.card__excerpt {
	margin: 0;
	color: var(--ink-muted);
}

/* Pagination + post nav */
.pagination,
.post-navigation {
	margin-block-start: var(--wp--preset--spacing--60);
}

.nav-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	justify-content: center;

	.page-numbers {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-width: 44px;
		height: 44px;
		padding-inline: 0.75rem;
		border: 1px solid var(--line);
		border-radius: 999px;
		color: var(--ink);
		font-weight: 600;
		text-decoration: none;

		&.current,
		&:hover {
			border-color: var(--gold);
			background: var(--gold);
			color: var(--ink);
		}
	}
}

.post-navigation .nav-links {
	justify-content: space-between;

	a {
		text-decoration: none;
	}
}

.post-nav__label {
	display: block;
	font-size: 13px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ink-muted);
}

/* Forms */
.search-form {
	display: flex;
	gap: 0.5rem;
	max-width: 520px;
}

:where(input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="search"], input[type="number"], select, textarea) {
	width: 100%;
	min-height: 48px;
	padding: 0.75rem 1rem;
	border: 1px solid var(--line);
	border-radius: var(--wp--custom--radius);
	background: var(--paper);
	color: var(--ink);
	font: inherit;

	&:focus {
		border-color: var(--forest);
		outline: none;
		box-shadow: var(--focus-ring);
	}
}

.search-form__input {
	flex: 1;
}

/* ---------------------------------------------------------------------------
 * 6. Block style variations (register in inc/blocks.php → sw8_theme_block_styles)
 * ------------------------------------------------------------------------- */
.wp-block-list.is-style-plain {
	padding-left: 0;
	list-style: none;

	li + li {
		margin-top: 0.4em;
	}
}

.wp-block-list li::marker {
	color: var(--forest);
	font-weight: 700;
}

.wp-block-quote {
	p::before { content: "\201C"; color: var(--gold); }
	p:last-of-type::after { content: "\201D"; color: var(--gold); }

	cite {
		display: block;
		margin-top: 18px;
		font-family: var(--font-body);
		font-size: 13px;
		font-style: normal;
		font-weight: 400;
		letter-spacing: 0.12em;
		text-transform: uppercase;
		color: var(--ink-muted);
	}
}

.wp-block-button.is-style-ghost .wp-block-button__link {
	border: 1px solid var(--line);
	background: transparent;
	color: var(--ink);

	&:hover {
		border-color: var(--ink);
	}
}

.wp-block-button.is-style-dark .wp-block-button__link {
	background: var(--forest);
	color: #fff;

	&:hover {
		background: #162A1F;
	}
}

/* ---------------------------------------------------------------------------
 * 7. Utilities
 * ------------------------------------------------------------------------- */
.is-radius {
	border-radius: var(--wp--custom--radius);
	overflow: hidden;
}

.is-radius-lg {
	border-radius: var(--wp--custom--radius-lg);
	overflow: hidden;
}

/* ---------------------------------------------------------------------------
 * 8. S8 typography helpers
 * ------------------------------------------------------------------------- */
.s8-dot { color: var(--gold); }

.s8-hl {
	padding: 0 0.1em 0.04em;
	margin: 0 -0.04em;
	border-radius: 0.14em;
	background: var(--gold);
	color: var(--on-gold);
	box-decoration-break: clone;
	-webkit-box-decoration-break: clone;
}

.s8-kicker {
	display: block;
	margin-bottom: 0.35em;
	font-size: 0.3em;
	line-height: 1.15;
	letter-spacing: -0.01em;
	color: var(--forest);
}

.s8-num { font-variant-numeric: tabular-nums; }
