/**
 * Layout: shell, header, navigation, search, sidebar, footer, pagination.
 *
 * Written with logical properties throughout, so an RTL locale mirrors
 * correctly without a second stylesheet of overrides.
 */

.wpx-container {
	width: min(100% - 2rem, var(--wpx-container));
	margin-inline: auto;
}

/* --- Shell ------------------------------------------------------------- */

.wpx-shell {
	display: grid;
	gap: var(--wpx-gutter);
	padding-block: var(--wpx-space-6);
	grid-template-columns: 1fr;
}

@media (min-width: 900px) {
	.wpx-sidebar-right .wpx-shell {
		grid-template-columns: minmax(0, 1fr) var(--wpx-sidebar-width);
	}

	.wpx-sidebar-left .wpx-shell {
		grid-template-columns: var(--wpx-sidebar-width) minmax(0, 1fr);
	}

	.wpx-sidebar-left .wpx-main { order: 2; }
	.wpx-sidebar-left .wpx-sidebar { order: 1; }
}

.wpx-main { min-width: 0; }

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

.wpx-header {
	background: var(--wpx-surface-1);
	border-block-end: 1px solid var(--wpx-border);
}

.wpx-header.is-sticky {
	position: sticky;
	top: 0;
	z-index: var(--wpx-z-sticky);
	backdrop-filter: blur(8px);
	background: rgb(from var(--wpx-surface-1) r g b / 0.92);
}

.wpx-header__inner {
	display: flex;
	align-items: center;
	gap: var(--wpx-space-4);
	min-height: 68px;
	flex-wrap: wrap;
}

.wpx-header__brand img { max-height: 44px; width: auto; }

.wpx-logo-text {
	font-size: var(--wpx-text-xl);
	font-weight: var(--wpx-weight-bold);
	color: var(--wpx-text);
	letter-spacing: -0.01em;
}

.wpx-logo-text:hover { color: var(--wpx-accent); }

/* --- Navigation -------------------------------------------------------- */

.wpx-nav { margin-inline-end: auto; }

.wpx-menu {
	display: flex;
	gap: var(--wpx-space-1);
	list-style: none;
	margin: 0;
	padding: 0;
}

.wpx-menu li { position: relative; }

.wpx-menu a {
	display: block;
	padding: var(--wpx-space-2) var(--wpx-space-3);
	border-radius: var(--wpx-radius);
	color: var(--wpx-text-muted);
	font-weight: var(--wpx-weight-medium);
	font-size: var(--wpx-text-sm);
	transition: color var(--wpx-transition), background var(--wpx-transition);
}

.wpx-menu a:hover,
.wpx-menu .current-menu-item > a {
	color: var(--wpx-text);
	background: var(--wpx-surface-3);
}

/* Underline that grows from the centre — the one flourish in the nav. */
.wpx-menu > li > a::after {
	content: "";
	display: block;
	height: 2px;
	margin-top: 3px;
	background: var(--wpx-accent);
	transform: scaleX(0);
	transition: transform var(--wpx-transition);
}

.wpx-menu > li > a:hover::after,
.wpx-menu > .current-menu-item > a::after { transform: scaleX(1); }

/* Submenus */
.wpx-menu ul {
	position: absolute;
	inset-inline-start: 0;
	top: 100%;
	z-index: var(--wpx-z-dropdown);
	min-width: 210px;
	margin: 0;
	padding: var(--wpx-space-2);
	list-style: none;
	background: var(--wpx-surface-2);
	border: 1px solid var(--wpx-border);
	border-radius: var(--wpx-radius);
	box-shadow: var(--wpx-shadow-lg);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	transition: opacity var(--wpx-transition), transform var(--wpx-transition), visibility var(--wpx-transition);
}

.wpx-menu li:hover > ul,
.wpx-menu li:focus-within > ul {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.wpx-nav-toggle {
	display: none;
	width: 42px;
	height: 42px;
	background: transparent;
	border: 1px solid var(--wpx-border);
	border-radius: var(--wpx-radius);
	cursor: pointer;
	position: relative;
}

.wpx-nav-toggle__bar,
.wpx-nav-toggle__bar::before,
.wpx-nav-toggle__bar::after {
	position: absolute;
	inset-inline: 11px;
	height: 2px;
	background: var(--wpx-text);
	transition: transform var(--wpx-transition), opacity var(--wpx-transition);
}

.wpx-nav-toggle__bar { top: 50%; transform: translateY(-50%); }
.wpx-nav-toggle__bar::before { content: ""; top: -6px; }
.wpx-nav-toggle__bar::after { content: ""; top: 6px; }

.wpx-nav-toggle[aria-expanded="true"] .wpx-nav-toggle__bar { background: transparent; }
.wpx-nav-toggle[aria-expanded="true"] .wpx-nav-toggle__bar::before { transform: translateY(6px) rotate(45deg); }
.wpx-nav-toggle[aria-expanded="true"] .wpx-nav-toggle__bar::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 899px) {
	.wpx-nav-toggle { display: block; order: 3; }

	.wpx-nav {
		order: 5;
		flex-basis: 100%;
		display: none;
	}

	.wpx-nav.is-open { display: block; padding-block-end: var(--wpx-space-3); }

	.wpx-menu { flex-direction: column; }

	.wpx-menu ul {
		position: static;
		opacity: 1;
		visibility: visible;
		transform: none;
		box-shadow: none;
		border: 0;
		padding-inline-start: var(--wpx-space-4);
	}

	.wpx-header__search { order: 4; flex-basis: 100%; }
}

/* --- Search ------------------------------------------------------------ */

.wpx-search { position: relative; min-width: 200px; }

.wpx-search__field { position: relative; display: flex; }

.wpx-search__input { padding-inline-end: 42px; }

.wpx-search__submit {
	position: absolute;
	inset-inline-end: 0;
	top: 0;
	height: 100%;
	width: 42px;
	display: grid;
	place-items: center;
	background: transparent;
	border: 0;
	color: var(--wpx-text-dim);
	cursor: pointer;
	transition: color var(--wpx-transition);
}

.wpx-search__submit:hover { color: var(--wpx-accent); }

.wpx-search__results {
	position: absolute;
	inset-inline: 0;
	top: calc(100% + 6px);
	z-index: var(--wpx-z-dropdown);
	max-height: 60vh;
	overflow-y: auto;
	background: var(--wpx-surface-2);
	border: 1px solid var(--wpx-border);
	border-radius: var(--wpx-radius);
	box-shadow: var(--wpx-shadow-lg);
	animation: wpx-drop var(--wpx-duration) var(--wpx-ease-out);
}

@keyframes wpx-drop {
	from { opacity: 0; transform: translateY(-8px); }
	to   { opacity: 1; transform: translateY(0); }
}

.wpx-suggestion {
	display: flex;
	align-items: center;
	gap: var(--wpx-space-3);
	padding: var(--wpx-space-2) var(--wpx-space-3);
	color: var(--wpx-text);
	border-block-end: 1px solid var(--wpx-border);
	transition: background var(--wpx-transition);
}

.wpx-suggestion:last-child { border-block-end: 0; }

.wpx-suggestion:hover,
.wpx-suggestion.is-active {
	background: var(--wpx-surface-3);
	color: var(--wpx-text);
}

.wpx-suggestion img {
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: var(--wpx-radius-sm);
	flex: none;
}

.wpx-suggestion__title {
	font-weight: var(--wpx-weight-medium);
	font-size: var(--wpx-text-sm);
}

.wpx-suggestion__meta {
	font-size: var(--wpx-text-xs);
	color: var(--wpx-text-dim);
}

.wpx-search__status {
	padding: var(--wpx-space-3);
	font-size: var(--wpx-text-sm);
	color: var(--wpx-text-dim);
	text-align: center;
}

.wpx-search__all {
	display: block;
	padding: var(--wpx-space-3);
	text-align: center;
	font-size: var(--wpx-text-sm);
	font-weight: var(--wpx-weight-medium);
	border-block-start: 1px solid var(--wpx-border);
}

/* --- Social ------------------------------------------------------------ */

.wpx-social {
	display: flex;
	gap: var(--wpx-space-1);
	list-style: none;
	margin: 0;
	padding: 0;
}

.wpx-social__link {
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	border-radius: var(--wpx-radius);
	color: var(--wpx-text-dim);
	transition: color var(--wpx-transition), background var(--wpx-transition), transform var(--wpx-transition);
}

.wpx-social__link:hover {
	color: var(--wpx-text);
	background: var(--wpx-surface-3);
	transform: translateY(-2px);
}

/* --- Sidebar ----------------------------------------------------------- */

.wpx-widget {
	background: var(--wpx-surface-2);
	border: 1px solid var(--wpx-border);
	border-radius: var(--wpx-radius);
	margin-block-end: var(--wpx-gutter);
	overflow: hidden;
}

.wpx-widget__title {
	margin: 0;
	padding: var(--wpx-space-3) var(--wpx-space-4);
	background: var(--wpx-surface-3);
	border-block-end: 1px solid var(--wpx-border);
	font-size: var(--wpx-text-sm);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.wpx-widget > *:not(.wpx-widget__title) { padding: var(--wpx-space-4); margin: 0; }

.wpx-widget ul { list-style: none; padding: 0; }

.wpx-widget li + li { margin-block-start: var(--wpx-space-2); }

.wpx-widget a { color: var(--wpx-text-muted); }
.wpx-widget a:hover { color: var(--wpx-accent); }

/* --- Breadcrumbs ------------------------------------------------------- */

.wpx-breadcrumbs ol {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wpx-space-2);
	list-style: none;
	margin: 0 0 var(--wpx-space-4);
	padding: 0;
	font-size: var(--wpx-text-sm);
	color: var(--wpx-text-dim);
}

.wpx-breadcrumbs li:not(:last-child)::after {
	content: "/";
	margin-inline-start: var(--wpx-space-2);
	color: var(--wpx-border-strong);
}

/* --- Pagination -------------------------------------------------------- */

.wpx-pagination ul {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wpx-space-2);
	justify-content: center;
	list-style: none;
	margin: var(--wpx-space-6) 0 0;
	padding: 0;
}

.wpx-pagination a,
.wpx-pagination span {
	display: grid;
	place-items: center;
	min-width: 40px;
	height: 40px;
	padding-inline: var(--wpx-space-3);
	background: var(--wpx-surface-2);
	border: 1px solid var(--wpx-border);
	border-radius: var(--wpx-radius);
	color: var(--wpx-text-muted);
	font-size: var(--wpx-text-sm);
	transition: background var(--wpx-transition), color var(--wpx-transition), border-color var(--wpx-transition);
}

.wpx-pagination a:hover {
	background: var(--wpx-surface-3);
	border-color: var(--wpx-border-strong);
	color: var(--wpx-text);
}

.wpx-pagination .current {
	background: var(--wpx-accent);
	border-color: var(--wpx-accent);
	color: var(--wpx-accent-ink);
}

/* --- Page headers ------------------------------------------------------ */

.wpx-page-title { margin-block-end: var(--wpx-space-2); }

.wpx-archive-header { margin-block-end: var(--wpx-space-5); }

.wpx-archive-description { color: var(--wpx-text-muted); }

.wpx-section-title {
	position: relative;
	padding-inline-start: var(--wpx-space-3);
	margin-block: var(--wpx-space-6) var(--wpx-space-4);
	font-size: var(--wpx-text-xl);
}

.wpx-section-title::before {
	content: "";
	position: absolute;
	inset-inline-start: 0;
	top: 0.2em;
	bottom: 0.2em;
	width: 3px;
	background: var(--wpx-accent);
	border-radius: var(--wpx-radius-pill);
}

.wpx-empty {
	padding: var(--wpx-space-7) var(--wpx-space-4);
	text-align: center;
	color: var(--wpx-text-dim);
	background: var(--wpx-surface-2);
	border: 1px dashed var(--wpx-border);
	border-radius: var(--wpx-radius);
}

.wpx-404 { padding-block: var(--wpx-space-6); max-width: 560px; }

/* --- Ads --------------------------------------------------------------- */

.wpx-ad { margin-block: var(--wpx-space-5); text-align: center; }
.wpx-ad--header { margin-block: 0; padding-block: var(--wpx-space-4); }

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

.wpx-footer {
	margin-block-start: var(--wpx-space-7);
	background: var(--wpx-surface-1);
	border-block-start: 1px solid var(--wpx-border);
}

.wpx-footer__widgets {
	display: grid;
	gap: var(--wpx-gutter);
	padding-block: var(--wpx-space-6);
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.wpx-footer .wpx-widget { background: transparent; border: 0; }
.wpx-footer .wpx-widget__title { background: transparent; border: 0; padding-inline: 0; }
.wpx-footer .wpx-widget > *:not(.wpx-widget__title) { padding-inline: 0; }

.wpx-footer__bar {
	border-block-start: 1px solid var(--wpx-border);
	padding-block: var(--wpx-space-4);
}

.wpx-footer__bar-inner {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wpx-space-4);
	align-items: center;
	justify-content: space-between;
	font-size: var(--wpx-text-sm);
	color: var(--wpx-text-dim);
}

.wpx-copyright { margin: 0; }

.wpx-footer-menu {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wpx-space-4);
	list-style: none;
	margin: 0;
	padding: 0;
}

/* --- Hero --------------------------------------------------------------- */

.wpx-hero {
	position: relative;
	display: grid;
	place-items: center;
	min-height: var(--wpx-hero-height, 420px);
	padding: var(--wpx-space-7) var(--wpx-space-4);
	margin-block-end: var(--wpx-space-6);
	border-radius: var(--wpx-radius-lg);
	background: var(--wpx-surface-2);
	overflow: hidden;
	text-align: center;
}

.wpx-hero.has-image::before {
	content: "";
	position: absolute;
	inset: 0;
	background-image: var(--wpx-hero-image);
	background-size: cover;
	background-position: center;
	transform: scale(1.03);
}

.wpx-hero.has-image::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		to bottom,
		rgb(from var(--wpx-bg) r g b / calc(var(--wpx-hero-overlay, 55%) * 0.6)),
		rgb(from var(--wpx-bg) r g b / var(--wpx-hero-overlay, 55%))
	);
}

.wpx-hero__inner {
	position: relative;
	z-index: 1;
	width: min(100%, 640px);
}

.wpx-hero__title {
	margin-block-end: var(--wpx-space-2);
	text-shadow: 0 2px 12px rgb(0 0 0 / 0.4);
}

.wpx-hero__subtitle {
	margin-block-end: var(--wpx-space-5);
	font-size: var(--wpx-text-lg);
	color: var(--wpx-text-muted);
}

.wpx-hero__search { max-width: 460px; margin-inline: auto; }

.wpx-row + .wpx-row { margin-block-start: var(--wpx-space-6); }

/* Sticky header gets its shadow only after the page scrolls. */
.wpx-header.is-scrolled { box-shadow: var(--wpx-shadow); }
