/* ==========================================================================
   Header Styles — Lepapa Theme
   ========================================================================== */

.site-header {
	position: relative;
	z-index: 100;
	background-color: var(--color-bg);
}

.site-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 var(--container-padding);
	height: 90px;
}

/* Transparent header on front page */
.site-header--transparent {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	background: transparent;
	border-bottom: none;
	transition: color 0.4s ease;
}

.site-header--transparent,
.site-header--transparent .site-title a,
.site-header--transparent .header-nav a,
.site-header--transparent .header-action-btn {
	color: var(--color-white);
	transition: color 0.4s ease;
}

.site-header--transparent .menu-toggle {
	color: var(--color-white);
	transition: color 0.4s ease;
}

/* Site Branding — Centered
   ========================================================================== */

.site-branding {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	text-align: center;
}

.site-logo {
	display: block;
}

.site-logo img {
	width: 130px;
	height: 34px;
	display: block;
	/* Default: dark logo for non-front pages */
	filter: brightness(0);
}

/* White logo on transparent header */
.site-header--transparent .site-logo img {
	filter: none;
	transition: filter 0.4s ease;
}

.site-logo:hover {
	opacity: 1;
}

/* Left Navigation
   ========================================================================== */

.header-nav--left > ul {
	display: flex;
	gap: var(--nav-gap);
	list-style: none;
	margin: 0;
	padding: 0;
}

.header-nav--left a {
	display: block;
	color: var(--color-black);
	font-family: var(--font-body);
	font-size: var(--font-size-body2);
	font-weight: 500;
	text-decoration: none;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	transition: opacity var(--transition-fast);
}

.header-nav--left a:hover {
	opacity: 1;
}

/* Dropdown Submenus
   ========================================================================== */

.menu-item-has-children {
	position: relative;
}

/* Full-width dropdown background — height set via JS --dropdown-h */
.site-header::after {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	top: 100%;
	height: var(--dropdown-h, 0px);
	background: var(--color-light-grey);
	z-index: 99;
	transition: height 0.3s ease;
	pointer-events: none;
}

.sub-menu {
	position: absolute;
	left: 0;
	top: 100%;
	list-style: none;
	margin: 0;
	padding: 24px 0 32px;
	min-width: max-content;
	visibility: hidden;
	clip-path: inset(0 0 100% 0);
	transition: clip-path 0.3s ease, visibility 0.3s ease;
	z-index: 100;
}

/* On homepage the transparent header keeps transparent dropdown */
.site-header--transparent::after {
	background: transparent;
}

.menu-item-has-children:hover > .sub-menu {
	clip-path: inset(0 0 0 0);
	visibility: visible;
}

.sub-menu li + li {
	margin-top: 8px;
}

.sub-menu a {
	font-size: var(--font-size-body2);
	font-weight: 400;
	text-transform: none;
	letter-spacing: 0;
	white-space: nowrap;
}

/* Right Actions (icons)
   ========================================================================== */

.header-actions {
	display: flex;
	align-items: center;
	gap: var(--icon-gap);
}

.header-action-btn {
	display: flex;
	align-items: center;
	gap: 4px;
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	color: var(--color-black);
	transition: opacity var(--transition-fast);
}

.header-action-btn:hover {
	opacity: 1;
}

.header-action-btn svg {
	width: 24px;
	height: 24px;
}

/* Cart icon with count inside */
.cart-icon {
	position: relative;
	width: 24px;
	height: 24px;
	display: block;
}

.cart-icon--close {
	display: none;
}

.cart-icon svg {
	display: block;
}

.cart-count {
	position: absolute;
	width: 8.15px;
	height: 12px;
	left: calc(50% - 8.15px / 2 + 0.09px);
	top: 8px;
	font-family: 'Inter', sans-serif;
	font-style: normal;
	font-weight: 400;
	font-size: 12px;
	line-height: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	color: currentColor;
}

/* Mobile Menu Toggle
   ========================================================================== */

.menu-toggle {
	display: none;
	background: none;
	border: none;
	padding: var(--space-sm);
	color: var(--color-text);
	cursor: pointer;
}

.menu-toggle__close {
	display: none;
}

/* Mobile styles (440px frame) */
@media (max-width: 768px) {
	.site-header__inner {
		padding: 0 20px;
		height: clamp(56px, 13.6vw, 70px);
	}

	/* Show hamburger on left */
	.menu-toggle {
		display: block;
		order: -1;
		padding: 4px;
	}

	/* Hide desktop nav */
	.header-nav--left {
		display: none;
	}

	/* Hide user icon on mobile */
	.header-action-btn--user {
		display: none;
	}

	.header-actions {
		gap: 11px;
	}

	/* Keep logo centered */
	.site-branding {
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
	}

	.site-logo img {
		width: clamp(80px, 22.7vw, 130px);
		height: auto;
	}

	/* Hide dropdown pseudo-element on mobile */
	.site-header::after {
		display: none;
	}
}

/* ==========================================================================
   Mobile Menu — hamburger → X, full-screen overlay
   ========================================================================== */

/* Hamburger → X toggle */
.mobile-menu-open .menu-toggle__open {
	display: none;
}

.mobile-menu-open .menu-toggle__close {
	display: block;
}

/* Hide search icon when menu is open */
.mobile-menu-open .header-action-btn--search {
	display: none;
}

/* Header matches overlay background when menu is open */
.mobile-menu-open .site-header {
	background: var(--color-light-grey);
	position: relative;
	z-index: 201;
}

/* Force homepage transparent header solid on menu open */
.mobile-menu-open .site-header--transparent {
	position: relative;
	top: auto;
	left: auto;
	right: auto;
}

.mobile-menu-open .site-header--transparent,
.mobile-menu-open .site-header--transparent .site-title a,
.mobile-menu-open .site-header--transparent .header-nav a,
.mobile-menu-open .site-header--transparent .header-action-btn {
	color: var(--color-text);
}

.mobile-menu-open .site-header--transparent .menu-toggle {
	color: var(--color-text);
}

.mobile-menu-open .site-header--transparent .site-logo img {
	filter: brightness(0);
}

/* Mobile menu overlay — hidden on desktop */
.mobile-menu {
	display: none;
}

@media (max-width: 768px) {
	.mobile-menu {
		display: flex;
		flex-direction: column;
		position: fixed;
		top: clamp(56px, 13.6vw, 70px);
		left: 0;
		right: 0;
		bottom: 0;
		background: var(--color-light-grey);
		z-index: 200;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		visibility: hidden;
		pointer-events: none;
	}

	.mobile-menu[data-open="true"] {
		visibility: visible;
		pointer-events: auto;
	}

	/* Menu items — hidden until open, then staggered slide-in */
	.mobile-menu__item,
	.mobile-menu__bottom {
		opacity: 0;
		transform: translateY(-20px);
		transition: opacity 0.4s ease-out, transform 0.4s ease-out;
		transition-delay: 0ms;
	}

	/* Staggered entrance */
	.mobile-menu--items-visible .mobile-menu__item,
	.mobile-menu--items-visible .mobile-menu__bottom {
		opacity: 1;
		transform: translateY(0);
	}

	.mobile-menu--items-visible .mobile-menu__item:nth-child(1) { transition-delay: 0ms; }
	.mobile-menu--items-visible .mobile-menu__item:nth-child(2) { transition-delay: 100ms; }
	.mobile-menu--items-visible .mobile-menu__item:nth-child(3) { transition-delay: 200ms; }
	.mobile-menu--items-visible .mobile-menu__item:nth-child(4) { transition-delay: 300ms; }
	.mobile-menu--items-visible .mobile-menu__item:nth-child(5) { transition-delay: 400ms; }
	.mobile-menu--items-visible .mobile-menu__item:nth-child(6) { transition-delay: 500ms; }
	.mobile-menu--items-visible .mobile-menu__bottom { transition-delay: 550ms; }

	/* Navigation
	   ================================================================ */

	.mobile-menu__nav {
		padding: 108px 24px 0;
	}

	.mobile-menu__list {
		list-style: none;
		margin: 0;
		padding: 0;
		display: flex;
		flex-direction: column;
		gap: 24px;
	}

	.mobile-menu__toggle,
	.mobile-menu__link {
		display: block;
		background: none;
		border: none;
		padding: 0;
		margin: 0;
		cursor: pointer;
		font-family: var(--font-body);
		font-size: 24px;
		font-weight: 500;
		line-height: 1;
		color: var(--color-text);
		text-decoration: none;
		text-align: left;
	}

	/* Subcategories */
	.mobile-menu__sub {
		list-style: none;
		margin: 0;
		padding: 0;
		overflow: hidden;
		max-height: 0;
		transition: max-height 0.3s ease;
	}

	.mobile-menu__item--has-children.mobile-menu__item--open > .mobile-menu__sub {
		max-height: 500px;
	}

	.mobile-menu__sub li:first-child {
		margin-top: 16px;
	}

	.mobile-menu__sub li + li {
		margin-top: 12px;
	}

	.mobile-menu__sub a {
		font-family: var(--font-body);
		font-size: 12px;
		font-weight: 400;
		line-height: 1.2;
		color: var(--color-text);
		text-decoration: none;
	}

	.mobile-menu__sub a:active {
		opacity: 0.6;
	}

	/* Bottom section
	   ================================================================ */

	.mobile-menu__bottom {
		margin-top: 144px;
		padding: 0 24px 40px;
		display: flex;
		flex-direction: column;
		gap: 80px;
	}

	.mobile-menu__account {
		display: flex;
		flex-direction: column;
		gap: 20px;
	}

	.mobile-menu__account-link {
		font-family: var(--font-body);
		font-size: 14px;
		font-weight: 500;
		line-height: 1;
		color: var(--color-text);
		text-decoration: none;
	}

	.mobile-menu__wishlist-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
	}

	.mobile-menu__wishlist-link {
		font-family: var(--font-body);
		font-size: 14px;
		font-weight: 500;
		line-height: 1;
		color: var(--color-text);
		text-decoration: none;
	}

	.mobile-menu__wishlist-more {
		display: none;
	}

	.mobile-menu__wishlist-count {
		font-size: 9px;
		margin-left: 1px;
	}

	/* Wishlist product cards — horizontal scroll */
	.mobile-menu__wishlist-products {
		display: flex;
		gap: 12px;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}

	.mobile-menu__wishlist-products::-webkit-scrollbar {
		display: none;
	}

	.mobile-menu__wishlist-products:empty {
		display: none;
	}

	.mobile-menu__wishlist-card {
		width: 120px;
		flex-shrink: 0;
		text-decoration: none;
		color: inherit;
	}

	.mobile-menu__wishlist-card-image {
		width: 120px;
		height: 155px;
		background: #E8E8E8;
		overflow: hidden;
	}

	.mobile-menu__wishlist-card-image img {
		width: 100%;
		height: 100%;
		object-fit: cover;
		display: block;
	}

	.mobile-menu__wishlist-card-name {
		font-size: 12px;
		font-weight: 400;
		line-height: 1.4;
		color: var(--color-text);
		margin-top: 7px;
	}

	.mobile-menu__wishlist-card-price {
		font-size: 12px;
		font-weight: 400;
		line-height: 1.2;
		color: var(--color-dark-grey);
		margin-top: 2px;
	}

	.mobile-menu__footer {
		display: flex;
		flex-direction: column;
		gap: 36px;
	}

	.mobile-menu__empty-msg {
		font-size: 12px;
		font-weight: 400;
		line-height: 1.2;
		color: var(--color-text);
		margin: 0;
	}

	.mobile-menu__support {
		display: flex;
		flex-direction: column;
		gap: 4px;
		font-size: 12px;
		font-weight: 400;
		line-height: 1.2;
		color: var(--color-text);
	}

	.mobile-menu__country-link {
		color: var(--color-text);
		text-decoration: underline;
	}
}

/* Logged-in admin bar offset */
.admin-bar .site-header--transparent {
	top: 32px;
}

@media (max-width: 782px) {
	.admin-bar .site-header--transparent {
		top: 46px;
	}

	.admin-bar .mobile-menu {
		top: calc(clamp(56px, 13.6vw, 70px) + 46px);
	}

	/* Reset transparent header offset when mobile menu is open
	   (position: relative + top: 46px would double-offset the header) */
	.mobile-menu-open .site-header--transparent {
		top: auto;
	}
}
