/**
 * Header + footer styles for the Apex child theme.
 * Renders template-parts/header/site-header.php and
 * template-parts/footer/site-footer.php. Enqueued on every page via
 * functions.php (apex_child_enqueue_assets).
 */

/* === site-header.php === */

.apex-topbar {
	background: var( --apex-amber );
	color: var( --apex-ink );
	font-family: var( --apex-ff-mono ), monospace;
	text-transform: uppercase;
	font-size: 12px;
	line-height: 1.6;
	text-align: center;
	padding: 0.4em 1rem;
}

/* Sticky lives on the outer <header class="header"> element: .apex-header is
   nested inside it, so sticky there would only stick within its own parent. */
header.header {
	position: sticky;
	top: 0;
	z-index: 100;
}

body.admin-bar header.header {
	top: var( --wp-admin--admin-bar--height, 32px );
}

.apex-header {
	background: var( --apex-ink );
	border-bottom: 2px solid var( --apex-amber );
}

.neve-skip-link {
	position: absolute;
	left: -9999px;
	top: auto;
	width: 1px;
	height: 1px;
	overflow: hidden;
	z-index: 1000;
}

.neve-skip-link:focus {
	position: absolute;
	left: 1rem;
	top: 1rem;
	width: auto;
	height: auto;
	overflow: visible;
	background: var( --apex-amber );
	color: var( --apex-ink );
	padding: 0.6em 1em;
	font-family: var( --apex-ff-body ), sans-serif;
	font-weight: 600;
	text-decoration: none;
	border: 2px solid var( --apex-ink );
}

.apex-header__inner {
	max-width: 1200px;
	margin: 0 auto;
	padding-inline: clamp( 1rem, 4vw, 2rem );
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	min-height: 72px;
}

/* Brand */

.apex-brand {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	text-decoration: none;
	line-height: 1;
}

.apex-brand__logo {
	display: block;
	flex-shrink: 0;
	width: 42px;
	height: 42px;
}

.apex-brand__logo svg {
	display: block;
	width: 100%;
	height: 100%;
}

.apex-brand__wordmark {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.apex-brand__name {
	font-family: var( --apex-ff-display ), sans-serif;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	font-size: 1.5rem;
	color: #fff;
	line-height: 0.9;
}

.apex-brand__sub {
	font-family: var( --apex-ff-mono ), monospace;
	text-transform: uppercase;
	font-size: 10px;
	letter-spacing: 0.16em;
	color: rgba( 232, 234, 235, 0.7 );
	font-weight: 500;
}

/* Nav */

.apex-nav {
	position: relative;
	display: flex;
	align-items: center;
}

.apex-nav__toggle {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	pointer-events: none;
}

.apex-nav__burger {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	width: 24px;
	height: 24px;
	cursor: pointer;
}

.apex-nav__burger span {
	display: block;
	width: 24px;
	height: 2px;
	background: #fff;
	transition: transform 0.2s ease, opacity 0.2s ease;
}

.apex-nav__burger:focus-visible {
	outline: 3px solid var( --apex-amber );
	outline-offset: 2px;
}

.apex-nav__list {
	display: flex;
	align-items: center;
	gap: 1.75rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.apex-nav__list li {
	position: relative;
}

.apex-nav__list a {
	display: inline-block;
	font-family: var( --apex-ff-body ), sans-serif;
	font-weight: 600;
	text-transform: uppercase;
	font-size: 0.85rem;
	letter-spacing: 0.05em;
	color: var( --apex-footer-text );
	text-decoration: none;
	padding: 0.3em 0;
	border-bottom: 2px solid transparent;
	text-underline-offset: 6px;
}

.apex-nav__list a:hover,
.apex-nav__list a:focus,
.apex-nav__list .current-menu-item > a {
	color: var( --apex-amber );
	border-bottom-color: var( --apex-amber );
}

.apex-nav__list a:focus-visible {
	outline: 3px solid var( --apex-amber );
	outline-offset: 2px;
}

/* Sub-menus */

.apex-nav__list .sub-menu {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 200px;
	background: var( --apex-ink );
	border: 2px solid var( --apex-amber );
	list-style: none;
	margin: 0;
	padding: 0.4rem 0;
	display: none;
	flex-direction: column;
	gap: 0;
	z-index: 10;
}

.apex-nav__list li:hover > .sub-menu,
.apex-nav__list li:focus-within > .sub-menu {
	display: flex;
}

.apex-nav__list .sub-menu a {
	padding: 0.6rem 1rem;
	width: 100%;
	border-bottom: none;
}

/* Actions */

.apex-header__actions {
	display: flex;
	align-items: center;
	gap: 1.25rem;
}

.apex-cart {
	display: flex;
	align-items: center;
	gap: 0.4em;
	font-family: var( --apex-ff-mono ), monospace;
	text-transform: uppercase;
	font-size: 0.8rem;
	color: var( --apex-footer-text );
	text-decoration: none;
}

.apex-cart:hover,
.apex-cart:focus {
	color: var( --apex-amber );
}

.apex-cart:focus-visible {
	outline: 3px solid var( --apex-amber );
	outline-offset: 2px;
}

.apex-cart-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.35em;
	background: var( --apex-amber );
	color: var( --apex-ink );
	font-family: var( --apex-ff-mono ), monospace;
	font-weight: 700;
	text-align: center;
	padding: 0.1em 0.3em;
	border: none;
}

/* Header product search — desktop only; the mobile row is already full. */

.apex-search {
	display: none;
}

@media ( min-width: 1024px ) {
	.apex-search {
		display: flex;
		align-items: center;
		gap: 0;
	}

	.apex-search input[type="search"] {
		width: 170px;
		background: rgba( 255, 255, 255, 0.08 );
		border: 1px solid rgba( 232, 234, 235, 0.3 );
		border-radius: 2px 0 0 2px;
		color: var( --apex-footer-text );
		font-family: var( --apex-ff-mono ), monospace;
		font-size: 0.8rem;
		padding: 0.45em 0.7em;
	}

	.apex-search input[type="search"]::placeholder {
		color: rgba( 232, 234, 235, 0.5 );
	}

	.apex-search input[type="search"]:focus {
		border-color: var( --apex-amber );
		outline: none;
	}

	.apex-search button {
		background: transparent;
		border: 1px solid rgba( 232, 234, 235, 0.3 );
		border-left: none;
		border-radius: 0 2px 2px 0;
		color: var( --apex-amber );
		font-family: var( --apex-ff-mono ), monospace;
		font-size: 0.75rem;
		text-transform: uppercase;
		padding: 0.5em 0.8em;
		cursor: pointer;
	}

	.apex-search button:hover,
	.apex-search button:focus-visible {
		background: var( --apex-amber );
		color: var( --apex-ink );
		outline: none;
	}
}

/* Header button — defined in full here because home.css (which owns the
   base .apex-btn recipe) only loads on the front page. */

.apex-header .apex-btn {
	display: inline-block;
	font-family: var( --apex-ff-body ), sans-serif;
	font-weight: 600;
	text-transform: uppercase;
	text-decoration: none;
	background: var( --apex-amber );
	color: var( --apex-ink );
	border: 2px solid #000;
	box-shadow: 3px 3px 0 #000;
	padding: 0.65em 1.2em;
	transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.apex-header .apex-btn:hover,
.apex-header .apex-btn:focus {
	background: var( --apex-amber-dark );
}

.apex-header .apex-btn:focus-visible {
	outline: 3px solid var( --apex-amber );
	outline-offset: 2px;
}

.apex-header .apex-btn:active {
	box-shadow: 0 0 0 #000;
	transform: translate( 2px, 2px );
}

.apex-header .apex-btn--sm {
	padding: 0.5em 1em;
	font-size: 0.8rem;
}

/* Mobile nav (<1024px) */

@media ( max-width: 1023px ) {
	/* Burger sits on the far left; brand and actions follow. The nav wraps
	   the burger, so ordering the nav first moves the toggle to the left.
	   position:static is essential: it makes the absolute menu panel anchor
	   to the sticky header.header (full width) instead of the tiny nav. */
	.apex-nav {
		order: -1;
		position: static;
	}

	.apex-nav__burger {
		display: flex;
		align-items: center;
		width: 40px;
		height: 40px;
		padding: 8px;
		box-sizing: border-box;
		margin-left: -8px;
	}

	.apex-nav__list {
		display: none;
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		flex-direction: column;
		align-items: stretch;
		gap: 0;
		background: var( --apex-ink );
		border-bottom: 2px solid var( --apex-amber );
		padding: 0.5rem 1.25rem 1rem;
		max-height: calc( 100vh - 110px );
		overflow-y: auto;
		z-index: 5;
	}

	.apex-nav__toggle:checked ~ .apex-nav__list {
		display: flex;
	}

	.apex-nav__list li {
		width: 100%;
	}

	.apex-nav__list a {
		display: block;
		width: 100%;
		padding: 0.75rem 0;
		border-top: 1px solid rgba( 232, 234, 235, 0.15 );
		border-bottom: none;
	}

	.apex-nav__list li:first-child > a {
		border-top: none;
	}

	.apex-nav__list .sub-menu {
		position: static;
		border: none;
		border-top: 1px solid rgba( 232, 234, 235, 0.15 );
		background: transparent;
		padding: 0 0 0 1rem;
		display: none;
	}

	.apex-nav__list li:hover > .sub-menu,
	.apex-nav__list li:focus-within > .sub-menu {
		display: flex;
	}

	.apex-nav__toggle:checked ~ .apex-nav__burger span:nth-child( 1 ) {
		transform: translateY( 7px ) rotate( 45deg );
	}

	.apex-nav__toggle:checked ~ .apex-nav__burger span:nth-child( 2 ) {
		opacity: 0;
	}

	.apex-nav__toggle:checked ~ .apex-nav__burger span:nth-child( 3 ) {
		transform: translateY( -7px ) rotate( -45deg );
	}
}

/* Phones (<700px): drop the non-essentials so the row breathes.
   The "Shop now" button duplicates the nav, and the brand sub-line +
   logo shrink so the wordmark fits next to the burger and cart. */

@media ( max-width: 699px ) {
	.apex-header__inner {
		min-height: 60px;
		gap: 0.6rem;
	}

	.apex-brand__name {
		font-size: 1.15rem;
	}

	.apex-brand__logo {
		width: 34px;
		height: 34px;
	}

	.apex-brand__sub,
	.apex-header .apex-btn--sm {
		display: none;
	}

	.apex-topbar {
		font-size: 11px;
		padding: 0.5em 0.75rem;
	}

	.apex-topbar__more {
		display: none;
	}
}

/* === site-footer.php === */

.apex-footer {
	position: relative;
	background: var( --apex-ink );
	color: var( --apex-footer-text );
}

.apex-footer::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 6px;
	background: var( --apex-hazard );
}

.apex-footer__inner {
	max-width: 1200px;
	margin: 0 auto;
	padding-inline: clamp( 1rem, 4vw, 2rem );
}

.apex-footer__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: clamp( 2rem, 5vw, 3rem );
	padding-block: clamp( 3rem, 7vw, 4.5rem );
}

@media ( min-width: 600px ) {
	.apex-footer__grid {
		grid-template-columns: repeat( 2, 1fr );
	}
}

@media ( min-width: 1024px ) {
	.apex-footer__grid {
		grid-template-columns: repeat( 4, 1fr );
	}
}

.apex-footer__col h4 {
	font-family: var( --apex-ff-display ), sans-serif;
	text-transform: uppercase;
	color: #fff;
	font-size: 0.95rem;
	letter-spacing: 0.06em;
	margin: 0 0 1rem;
}

.apex-footer__logo {
	display: block;
	width: 44px;
	height: 44px;
	margin-bottom: 0.75rem;
}

.apex-footer__logo svg {
	display: block;
	width: 100%;
	height: 100%;
}

.apex-footer__brand-name {
	display: block;
	font-family: var( --apex-ff-display ), sans-serif;
	font-weight: 700;
	text-transform: uppercase;
	color: #fff;
	font-size: 1.4rem;
	line-height: 1;
}

.apex-footer__brand-sub {
	display: block;
	font-family: var( --apex-ff-mono ), monospace;
	text-transform: uppercase;
	font-size: 10px;
	letter-spacing: 0.14em;
	color: rgba( 232, 234, 235, 0.7 );
	margin: 0.5em 0 1em;
}

.apex-footer__brand p {
	margin: 0 0 0.75em;
	color: var( --apex-footer-text );
}

.apex-footer__email {
	font-family: var( --apex-ff-mono ), monospace;
	color: var( --apex-amber );
	text-decoration: none;
	word-break: break-all;
}

.apex-footer__email:hover,
.apex-footer__email:focus {
	text-decoration: underline;
}

.apex-footer__menu {
	list-style: none;
	margin: 0;
	padding: 0;
}

.apex-footer__menu a {
	display: inline-block;
	padding-block: 0.35rem;
	color: var( --apex-footer-text );
	text-decoration: none;
	font-family: var( --apex-ff-body ), sans-serif;
}

.apex-footer__menu a:hover,
.apex-footer__menu a:focus {
	color: var( --apex-amber );
}

.apex-footer__hours {
	list-style: none;
	margin: 0;
	padding: 0;
	font-family: var( --apex-ff-mono ), monospace;
	font-size: 0.85rem;
	line-height: 1.9;
	color: var( --apex-footer-text );
}

.apex-footer__col p {
	font-size: 0.9rem;
	line-height: 1.6;
	color: var( --apex-footer-text );
	margin: 0;
}

.apex-footer__bottom {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	border-top: 1px solid rgba( 232, 234, 235, 0.25 );
	padding: 1.25rem 0;
	font-family: var( --apex-ff-mono ), monospace;
	text-transform: uppercase;
	font-size: 12px;
	color: var( --apex-footer-text );
}

/* Focus visibility (global to header + footer) */

.apex-header a:focus-visible,
.apex-footer a:focus-visible,
.apex-footer button:focus-visible {
	outline: 3px solid var( --apex-amber );
	outline-offset: 2px;
}

/* Reduced motion */

@media ( prefers-reduced-motion: reduce ) {
	.apex-header .apex-btn,
	.apex-nav__burger span,
	.apex-nav__list {
		transition: none !important;
	}
}
