/*
 * Site header — logo, curated nav, right-side icons, mobile drawer.
 *
 * Sticky, glass-effect on scroll. Token-driven so dark mode just works.
 */

.iow-site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	background: hsl(0 0% 100% / 0.85);
	-webkit-backdrop-filter: saturate(180%) blur(14px);
	backdrop-filter: saturate(180%) blur(14px);
	border-bottom: 1px solid var(--wp--preset--color--border);
}
.dark .iow-site-header {
	/* Charcoal black, semi-transparent for the glass effect. */
	background: hsl(0 0% 7% / 0.85);
}

.iow-header-inner {
	max-width: 1280px;
	margin: 0 auto;
	padding: 0.75rem 1rem;
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 1.5rem;
}
@media (min-width: 640px) {
	.iow-header-inner { padding: 0.875rem 1.5rem; }
}
@media (min-width: 1024px) {
	.iow-header-inner { padding: 1rem 2rem; }
}

/* Logo */
.iow-header-logo {
	display: inline-flex;
	align-items: center;
	text-decoration: none;
	color: var(--wp--preset--color--foreground);
}
.iow-header-logo img {
	max-height: 36px;
	width: auto;
	display: block;
	transition: filter 200ms ease-out;
}
/*
 * Dark-mode logo flip. The operator uploads a single dark-on-transparent
 * logo (recommended workflow); in dark mode we invert it so it stays
 * legible against the charcoal background. Hue-rotate balances the
 * invert so it doesn't tint blue.
 *
 * If the operator uploads a white-on-transparent logo instead, override
 * by setting the WP Custom Logo to that asset and the inverse rule will
 * kick in correctly (i.e. the light mode would need the invert instead).
 */
.dark .iow-header-logo img {
	filter: invert(1) hue-rotate(180deg);
}
.iow-header-logo-text {
	font-family: var(--wp--preset--font-family--serif);
	font-size: 1.25rem;
	font-weight: 600;
	letter-spacing: -0.01em;
}

/* Primary nav */
.iow-header-nav {
	display: none;
	justify-content: center;
	gap: 1.75rem;
	font-size: 0.9rem;
}
@media (min-width: 880px) {
	.iow-header-nav { display: flex; }
}
.iow-header-nav-link {
	color: var(--wp--preset--color--foreground);
	text-decoration: none;
	font-weight: 500;
	letter-spacing: 0.01em;
	padding: 0.25rem 0;
	border-bottom: 1px solid transparent;
	transition: border-color 200ms ease-out, color 200ms ease-out;
}
.iow-header-nav-link:hover {
	border-bottom-color: var(--wp--preset--color--foreground);
}

/* Right-side icons */
.iow-header-icons {
	display: flex;
	align-items: center;
	gap: 0.25rem;
}
.iow-header-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	color: var(--wp--preset--color--foreground);
	text-decoration: none;
	border-radius: 9999px;
	transition: background 200ms ease-out;
	position: relative;
}
.iow-header-icon:hover {
	background: var(--wp--preset--color--muted);
}
.iow-header-signin {
	width: auto;
	padding: 0 0.75rem;
	font-size: 0.85rem;
	font-weight: 500;
}
.iow-header-signin-label {
	white-space: nowrap;
}

/* Cart badge */
.iow-cart-badge {
	position: absolute;
	top: 6px;
	right: 4px;
	min-width: 18px;
	height: 18px;
	padding: 0 4px;
	background: var(--wp--preset--color--warm);
	color: var(--wp--preset--color--warm-foreground);
	border-radius: 9999px;
	font-size: 0.65rem;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

/* Mobile-only toggle */
.iow-header-mobile-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	background: transparent;
	border: 0;
	color: var(--wp--preset--color--foreground);
	border-radius: 9999px;
	cursor: pointer;
	margin-left: 0.25rem;
}
.iow-header-mobile-toggle:hover {
	background: var(--wp--preset--color--muted);
}
@media (min-width: 880px) {
	.iow-header-mobile-toggle { display: none; }
}

/* Hide signin-icon label on tiny viewports so the row fits */
@media (max-width: 480px) {
	.iow-header-signin { width: 40px; padding: 0; }
	.iow-header-signin .iow-header-signin-label { display: none; }
	.iow-header-signin::before {
		content: '';
		width: 20px; height: 20px;
		background: currentColor;
		mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.8'><circle cx='12' cy='8' r='4'/><path d='M3 21c0-5 4-7 9-7s9 2 9 7'/></svg>") center / contain no-repeat;
	}
}

/* Mobile drawer */
.iow-mobile-drawer {
	position: fixed;
	top: 0; right: 0;
	width: 100%;
	max-width: 320px;
	height: 100vh;
	background: var(--wp--preset--color--background);
	border-left: 1px solid var(--wp--preset--color--border);
	padding: 1.5rem;
	transform: translateX(100%);
	transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
	z-index: 110;
	display: flex;
	flex-direction: column;
}
.iow-mobile-drawer[hidden] {
	display: flex; /* override the [hidden] default — we use transform */
	pointer-events: none;
}
.iow-mobile-drawer.is-open {
	transform: translateX(0);
	pointer-events: auto;
}
.iow-mobile-drawer-close {
	align-self: flex-end;
	background: transparent;
	border: 0;
	color: var(--wp--preset--color--foreground);
	cursor: pointer;
	padding: 0.5rem;
	border-radius: 9999px;
}
.iow-mobile-drawer-nav {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	margin-top: 1rem;
}
.iow-mobile-drawer-nav a {
	display: block;
	padding: 0.875rem 0;
	color: var(--wp--preset--color--foreground);
	text-decoration: none;
	font-size: 1.05rem;
	font-weight: 500;
	border-bottom: 1px solid var(--wp--preset--color--border);
}
.iow-mobile-drawer-nav a:hover {
	color: var(--wp--preset--color--warm);
}
.iow-mobile-drawer-nav hr {
	border: 0;
	border-top: 1px solid var(--wp--preset--color--border);
	margin: 1rem 0;
}

/* Backdrop overlay */
.iow-mobile-drawer-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.4);
	z-index: 105;
	opacity: 0;
	pointer-events: none;
	transition: opacity 280ms;
}
.iow-mobile-drawer-overlay.is-visible {
	opacity: 1;
	pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
	.iow-mobile-drawer,
	.iow-mobile-drawer-overlay {
		transition: none;
	}
}

/* === Star next to a nav item (used on "Members") === */
.iow-header-nav-link {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
}
.iow-nav-star {
	color: var(--wp--preset--color--warm);
	flex-shrink: 0;
}

/* === Desktop dark-mode toggle icon ===
 * Show the sun in dark mode (click to go light) and the moon in light mode
 * (click to go dark). Default: light mode shows moon.
 */
.iow-dark-toggle {
	background: transparent;
	border: 0;
	cursor: pointer;
	padding: 0;
}
.iow-dark-toggle .iow-icon-sun { display: none; }
.iow-dark-toggle .iow-icon-moon { display: inline-block; }
.dark .iow-dark-toggle .iow-icon-sun { display: inline-block; }
.dark .iow-dark-toggle .iow-icon-moon { display: none; }

/* === Mobile dark-mode toggle ===
 * Plain text button inside the mobile drawer. Label flips based on mode.
 */
.iow-mobile-dark-toggle {
	margin-top: 0.75rem;
	background: transparent;
	border: 1px solid var(--wp--preset--color--border);
	color: var(--wp--preset--color--foreground);
	padding: 0.75rem 1rem;
	border-radius: 9999px;
	font-size: 0.95rem;
	font-weight: 500;
	cursor: pointer;
	text-align: left;
}
.iow-mobile-dark-toggle .iow-dark-toggle-label-dark { display: none; }
.iow-mobile-dark-toggle .iow-dark-toggle-label-light { display: inline; }
.dark .iow-mobile-dark-toggle .iow-dark-toggle-label-dark { display: inline; }
.dark .iow-mobile-dark-toggle .iow-dark-toggle-label-light { display: none; }
