/**
 * Layout: containers, grids, glass header, footer.
 */

.container {
	width: 100%;
	max-width: var(--aio-wide);
	margin-inline: auto;
	padding-inline: var(--aio-gutter);
}

.container--narrow {
	max-width: var(--aio-content);
}

.site {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.site-main {
	flex: 1 0 auto;
	padding-block: clamp(1.5rem, 4vw, 3rem);
}

.section {
	margin-block: clamp(2.5rem, 6vw, 4.5rem);
}

.section:first-child {
	margin-top: 0;
}

.section__head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.75rem 1.5rem;
	margin-bottom: 1.5rem;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid var(--aio-line);
}

.section__title {
	margin: 0;
	font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
}

.section__title::before {
	content: "";
	display: inline-block;
	width: 4px;
	height: 0.85em;
	margin-inline-end: 0.6rem;
	border-radius: 2px;
	background: linear-gradient(180deg, var(--aio-brand-500), var(--aio-brand-600));
	vertical-align: -0.05em;
}

.section__link {
	font-size: 0.875rem;
	font-weight: 600;
	white-space: nowrap;
}

.section__link::after {
	content: " →";
}

/* ---------- Grids ---------- */

.grid {
	display: grid;
	gap: clamp(1rem, 2.5vw, 1.75rem);
}

.grid--2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }

.layout-sidebar {
	display: grid;
	gap: clamp(2rem, 4vw, 3.5rem);
	align-items: start;
}

@media (min-width: 1000px) {
	.layout-sidebar {
		grid-template-columns: minmax(0, 1fr) 320px;
	}

	.layout-sidebar--left {
		grid-template-columns: 300px minmax(0, 1fr);
	}
}

.sidebar {
	position: sticky;
	top: calc(var(--aio-header-height) + 1.5rem);
	display: grid;
	gap: 1.5rem;
}

@media (max-width: 999px) {
	.sidebar {
		position: static;
	}
}

/* ---------- Header ---------- */

.site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	border-width: 0 0 1px;
	border-radius: 0;
	box-shadow: none;
}

.site-header::after {
	content: "";
	position: absolute;
	inset: auto 0 -1px;
	height: 1px;
	background: linear-gradient(90deg, transparent, var(--aio-glass-edge), transparent);
}

.header-bar {
	display: flex;
	align-items: center;
	gap: clamp(0.5rem, 2vw, 1.25rem);
	min-height: var(--aio-header-height);
	min-width: 0;
}

/*
 * Flex items default to min-width:auto, which means the header refuses to
 * shrink below the intrinsic width of the logo + nav + actions and pushes a
 * horizontal scrollbar onto the whole document. Every direct child opts out.
 */
.header-bar > * {
	min-width: 0;
}

.site-branding {
	display: flex;
	align-items: center;
	flex-shrink: 0;
	min-width: 0;
}

.site-logo img,
.custom-logo {
	width: auto;
	height: 38px;
	max-width: 100%;
}

@media (max-width: 480px) {
	.site-logo img,
	.custom-logo {
		height: 30px;
	}
}

.site-logo--mark img {
	height: 34px;
}

.site-title {
	margin: 0;
	font-size: 1.1875rem;
	font-weight: 800;
	letter-spacing: -0.03em;
	line-height: 1;
}

.site-title a {
	color: var(--aio-brand-600);
}

.site-title a:hover {
	text-decoration: none;
}

.site-title__accent {
	color: var(--aio-brand-500);
}

/* Nav sits next to the logo, not pushed to the far edge */

.primary-nav {
	margin-inline-start: 0.5rem;
}

.primary-nav ul {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.primary-nav a {
	display: block;
	padding: 0.45rem 0.75rem;
	border-radius: var(--aio-radius-sm);
	color: var(--aio-text);
	font-size: 0.9rem;
	font-weight: 600;
	transition: background-color var(--aio-transition), color var(--aio-transition);
}

.primary-nav a:hover,
.primary-nav .current-menu-item > a,
.primary-nav .current_page_item > a {
	background: var(--aio-primary-tint);
	color: var(--aio-primary);
	text-decoration: none;
}

.primary-nav__footer {
	display: none;
}

.header-actions {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	margin-inline-start: auto;
}

/* ---------- Compact expanding search ---------- */

.header-search {
	position: relative;
}

.header-search__panel {
	position: absolute;
	top: calc(100% + 0.6rem);
	inset-inline-end: 0;
	z-index: 130;
	width: min(420px, calc(100vw - 2 * var(--aio-gutter)));
	padding: 0.65rem;
	border-radius: var(--aio-radius);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px) scale(0.98);
	transform-origin: top right;
	transition:
		opacity 160ms var(--aio-ease),
		transform 200ms var(--aio-spring),
		visibility 160ms;
}

.header-search[data-open="true"] .header-search__panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}

.header-search[data-open="true"] .header-search__toggle {
	background: var(--aio-primary-tint);
	border-color: var(--aio-primary);
	color: var(--aio-primary);
}

/* On wide screens the search stays inline but stays small */
@media (min-width: 1120px) {
	.header-search__panel {
		width: 420px;
	}
}

/* ---------- Topics bar ---------- */

.topics-bar {
	border-top: 1px solid var(--aio-glass-edge);
}

.topics-bar__list {
	display: flex;
	gap: 1.25rem;
	margin: 0;
	padding: 0.55rem 0;
	overflow-x: auto;
	list-style: none;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.topics-bar__list::-webkit-scrollbar {
	display: none;
}

.topics-bar__list a {
	color: var(--aio-muted);
	font-size: 0.78rem;
	font-weight: 700;
	white-space: nowrap;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.topics-bar__list a:hover,
.topics-bar__list .current-menu-item > a {
	color: var(--aio-primary);
	text-decoration: none;
}

@media (max-width: 900px) {
	.topics-bar {
		display: none;
	}
}

/* ---------- Mobile nav ---------- */

/*
 * Scoped to .header-actions on purpose. .nav-toggle also carries .icon-btn,
 * which sets display:inline-flex in components.css — that file loads after
 * this one, so a bare `.nav-toggle { display: none }` loses the cascade and
 * the hamburger stays visible on desktop. The extra class raises specificity.
 */
.header-actions .nav-toggle {
	display: none;
}

.nav-toggle__bars {
	display: grid;
	gap: 4px;
	width: 18px;
}

.nav-toggle__bars span {
	display: block;
	height: 2px;
	border-radius: 2px;
	background: currentColor;
	transition: transform var(--aio-transition), opacity var(--aio-transition);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(1) {
	transform: translateY(6px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(2) {
	opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars span:nth-child(3) {
	transform: translateY(-6px) rotate(-45deg);
}

@media (max-width: 1000px) {
	.header-actions__cta {
		display: none;
	}
}

@media (max-width: 920px) {
	/*
	 * CRITICAL — do not add backdrop-filter back to .site-header at this
	 * breakpoint.
	 *
	 * .primary-nav is a descendant of .site-header and uses position:fixed to
	 * cover the viewport. An ancestor carrying backdrop-filter (or filter, or
	 * transform) becomes the containing block for fixed descendants, so the
	 * open menu was being positioned and clipped against the 66px-tall header
	 * box instead of the viewport — it slid open into a sliver nobody could
	 * see. .site-header inherits the blur from .glass, which is why this
	 * override is needed rather than simply absent.
	 *
	 * Dropping the blur here also removes the most expensive paint on the
	 * page for exactly the devices least able to afford it.
	 */
	.site-header {
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
		background: var(--aio-bg);
	}

	.header-actions .nav-toggle {
		display: inline-flex;
	}

	.header-actions__account {
		display: none;
	}

	.primary-nav {
		position: fixed;
		inset: var(--aio-header-height) 0 0;
		z-index: 90;
		display: flex;
		flex-direction: column;
		gap: 1.5rem;
		margin: 0;
		padding: 1.5rem var(--aio-gutter) 2.5rem;
		background: var(--aio-bg);
		overflow-y: auto;
		transform: translateX(100%);
		transition: transform 260ms var(--aio-ease);
	}

	@supports (backdrop-filter: blur(1px)) {
		.primary-nav {
			background: var(--aio-glass-bg-strong);
			-webkit-backdrop-filter: blur(24px) saturate(180%);
			backdrop-filter: blur(24px) saturate(180%);
		}
	}

	.primary-nav[data-open="true"] {
		transform: translateX(0);
	}

	.primary-nav ul {
		flex-direction: column;
		align-items: stretch;
		gap: 0.25rem;
	}

	.primary-nav a {
		padding: 0.85rem 1rem;
		font-size: 1.0625rem;
	}

	.primary-nav__footer {
		display: grid;
		gap: 0.6rem;
		margin-top: auto;
		padding-top: 1.5rem;
		border-top: 1px solid var(--aio-line);
	}
}

/* ---------- Footer CTA ---------- */

.footer-cta-wrap {
	margin-top: clamp(3rem, 8vw, 5rem);
}

.footer-cta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1.5rem 2.5rem;
	padding: clamp(1.5rem, 4vw, 2.5rem);
	border-radius: var(--aio-radius-lg);
	overflow: hidden;
}

.footer-cta::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background:
		radial-gradient(24rem 16rem at 88% 10%, rgba(82, 113, 255, 0.22), transparent 65%),
		radial-gradient(20rem 14rem at 4% 92%, rgba(64, 90, 166, 0.18), transparent 65%);
	pointer-events: none;
}

.footer-cta__text {
	flex: 1 1 300px;
}

.footer-cta__text h2 {
	margin-bottom: 0.35rem;
	font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.75rem);
}

.footer-cta__text p {
	margin: 0;
	color: var(--aio-muted);
	max-width: 46ch;
}

.footer-cta__form {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	flex: 1 1 320px;
	max-width: 440px;
}

.footer-cta__form input[type="email"] {
	flex: 1 1 190px;
	min-width: 0;
}

/* ---------- Footer ---------- */

.site-footer {
	margin-top: clamp(2.5rem, 6vw, 4rem);
	border-top: 1px solid var(--aio-line);
	background: linear-gradient(180deg, transparent, var(--aio-surface-2));
	color: var(--aio-muted);
	font-size: 0.9375rem;

	/*
	 * The footer is five columns of links plus post thumbnails and is always
	 * below the fold. Skipping its layout and paint until it scrolls into
	 * view takes real work off the main thread during LCP. The intrinsic
	 * size keeps the scrollbar honest while it is skipped.
	 */
	content-visibility: auto;
	contain-intrinsic-size: auto 480px;
}

.footer-grid {
	display: grid;
	gap: clamp(2rem, 4vw, 3rem);
	padding-block: clamp(2.5rem, 5vw, 4rem);
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

.footer-brand {
	grid-column: 1 / -1;
	max-width: 40ch;
}

@media (min-width: 1000px) {
	.footer-grid {
		grid-template-columns: 1.6fr 1fr 1fr 1.4fr 1fr;
	}

	.footer-brand {
		grid-column: span 1;
	}
}

.footer-brand .site-logo img {
	height: 34px;
}

.footer-brand__blurb {
	margin: 1rem 0 1.25rem;
	font-size: 0.875rem;
	line-height: 1.65;
}

.footer-trust {
	display: grid;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 0.8125rem;
}

.footer-trust li {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
}

.footer-trust__icon {
	flex: 0 0 16px;
	width: 16px;
	height: 16px;
	margin-top: 0.15rem;
	border-radius: 50%;
	background: var(--aio-primary-tint);
	color: var(--aio-primary);
	font-size: 10px;
	font-weight: 800;
	line-height: 16px;
	text-align: center;
}

.footer-col__title {
	margin: 0 0 1rem;
	color: var(--aio-ink);
	font-size: 0.75rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.09em;
}

.footer-col ul {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 0.55rem;
	font-size: 0.875rem;
}

.footer-col li {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5rem;
}

.footer-col a {
	color: var(--aio-muted);
}

.footer-col a:hover {
	color: var(--aio-primary);
}

.footer-count {
	flex: 0 0 auto;
	color: var(--aio-line-strong);
	font-size: 0.75rem;
	font-variant-numeric: tabular-nums;
}

/* Latest posts in the footer */

.footer-posts {
	display: grid;
	gap: 0.85rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.footer-posts li {
	display: block;
}

.footer-posts a {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	color: var(--aio-muted);
}

.footer-posts a:hover {
	text-decoration: none;
}

.footer-posts img {
	flex: 0 0 52px;
	width: 52px;
	height: 40px;
	object-fit: cover;
	border-radius: var(--aio-radius-sm);
}

.footer-posts__title {
	display: block;
	color: var(--aio-ink);
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.4;
	transition: color var(--aio-transition);
}

.footer-posts a:hover .footer-posts__title {
	color: var(--aio-primary);
}

.footer-posts__date {
	display: block;
	margin-top: 0.15rem;
	font-size: 0.75rem;
}

.site-info {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding-block: 1.25rem;
	border-top: 1px solid var(--aio-line);
	font-size: 0.8125rem;
}

.site-info ul {
	display: flex;
	flex-wrap: wrap;
	gap: 1.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.site-info a {
	color: var(--aio-muted);
}

.back-to-top {
	margin-inline-start: auto;
}

/* ---------- Breadcrumbs (global — archives need them too) ---------- */

.breadcrumbs,
.rank-math-breadcrumb {
	margin-bottom: 1.25rem;
	color: var(--aio-muted);
	font-size: 0.8125rem;
}

.breadcrumbs ol,
.breadcrumbs ul {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.45rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.breadcrumbs li {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
}

.breadcrumbs li + li::before {
	content: "›";
	color: var(--aio-line-strong);
}

.breadcrumbs a {
	color: var(--aio-muted);
}

.breadcrumbs a:hover {
	color: var(--aio-primary);
}

.breadcrumbs [aria-current="page"] {
	color: var(--aio-ink);
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 40ch;
}

/* ---------- Page header (global) ---------- */

.page-header {
	margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
	padding-bottom: 1.5rem;
	border-bottom: 1px solid var(--aio-line);
}

.page-header__title {
	margin-bottom: 0.5rem;
}

.page-header__desc {
	max-width: 68ch;
	margin-bottom: 1rem;
	color: var(--aio-muted);
	font-size: 1.0625rem;
}

.page-header__desc p:last-child {
	margin-bottom: 0;
}

.page-header__meta {
	color: var(--aio-muted);
	font-size: 0.875rem;
}

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

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.text-center { text-align: center; }
.text-muted { color: var(--aio-muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flow > * + * { margin-top: 1rem; }
.stack { display: grid; gap: 1rem; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
