/* Navigation: mega menu, dropdowns, mini cart, mobile drawer. */

/* Mega menu. */
.mega-item:hover > .mega-link,
.mega-item:focus-within > .mega-link {
	background: rgba(255, 255, 255, 0.12);
}

.mega-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
}

.mega-toggle .icon {
	transition: transform 0.15s ease;
}

.mega-toggle[aria-expanded="true"] .icon {
	transform: rotate(180deg);
}

.mega-item:hover > .mega-toggle,
.mega-item:focus-within > .mega-toggle {
	background: rgba(255, 255, 255, 0.12);
}

.mega-panel {
	background: #fff;
	color: var(--color-text);
	border-top: 3px solid var(--color-accent);
	box-shadow: var(--shadow-lg);
	max-height: calc(100vh - 200px);
	overflow-y: auto;
	transition: opacity 0.15s ease, visibility 0s linear 0.15s;
}

.mega-item:hover > .mega-panel,
.mega-item:focus-within > .mega-panel,
.mega-item.is-open > .mega-panel {
	visibility: visible;
	opacity: 1;
	pointer-events: auto;
	transition-delay: 0s;
}

.mega-item.is-dismissed > .mega-panel {
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
}

.mega-panel__inner {
	padding-block: var(--space-4);
}

.mega-cols {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: var(--space-3) var(--space-4);
}

.mega-col__title {
	display: block;
	margin-bottom: var(--space-1);
	padding-bottom: var(--space-1);
	border-bottom: 1px solid var(--color-border);
	color: var(--color-primary);
	font-weight: 700;
	text-decoration: none;
}

.mega-col__title:hover,
.mega-sub a:hover,
.mega-all:hover {
	text-decoration: underline;
}

.mega-sub a {
	display: block;
	padding: var(--space-half) 0;
	color: var(--grey-700);
	font-size: 0.9375rem;
	text-decoration: none;
}

.mega-all {
	display: inline-flex;
	align-items: center;
	gap: var(--space-half);
	margin-top: var(--space-3);
	font-weight: 700;
	text-decoration: none;
}

/* Dropdown panels (My Garage, mini cart). */
.dropdown-panel {
	position: absolute;
	z-index: calc(var(--header-z) + 10);
	top: calc(100% + var(--space-1));
	right: 0;
	width: min(360px, calc(100vw - 32px));
	padding: var(--space-2);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-lg);
	background: #fff;
	box-shadow: var(--shadow-lg);
}

.dropdown-panel__title {
	margin: 0 0 var(--space-1);
	color: var(--color-primary);
	font-size: 1.0625rem;
	font-weight: 700;
}

.dropdown-panel__text {
	color: var(--color-muted);
}

@media (max-width: 767px) {
	.dropdown {
		position: static;
	}

	.dropdown-panel {
		top: 100%;
		right: var(--space-2);
		left: var(--space-2);
		width: auto;
		margin-top: 0;
	}
}

/* Mini cart (WooCommerce markup). */
.mini-cart-panel .woocommerce-mini-cart {
	margin: 0;
	padding: 0;
	max-height: 50vh;
	overflow-y: auto;
	list-style: none;
}

.mini-cart-panel .woocommerce-mini-cart-item {
	position: relative;
	padding: var(--space-1) var(--space-4) var(--space-1) 0;
	border-bottom: 1px solid var(--color-border);
	font-size: 0.9375rem;
	overflow: hidden;
}

.mini-cart-panel .woocommerce-mini-cart-item img {
	float: left;
	width: 56px;
	height: 56px;
	margin-right: var(--space-1);
	object-fit: contain;
}

.mini-cart-panel .woocommerce-mini-cart-item > a:not(.remove) {
	display: block;
	color: var(--color-primary);
	font-weight: 600;
	text-decoration: none;
}

.mini-cart-panel a.remove {
	position: absolute;
	top: var(--space-1);
	right: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: var(--radius-pill);
	color: var(--color-error);
	font-size: 1.25rem;
	line-height: 1;
	text-decoration: none;
}

.mini-cart-panel a.remove:hover {
	background: var(--grey-100);
}

.mini-cart-panel .quantity {
	display: block;
	color: var(--color-muted);
}

.mini-cart-panel .woocommerce-mini-cart__total {
	display: flex;
	justify-content: space-between;
	margin: var(--space-2) 0;
	font-weight: 700;
}

.mini-cart-panel .woocommerce-mini-cart__buttons {
	display: grid;
	gap: var(--space-1);
	margin: 0;
}

.mini-cart-panel .woocommerce-mini-cart__buttons .button {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	border: 2px solid var(--color-primary);
	border-radius: var(--radius-md);
	background: transparent;
	color: var(--color-primary);
	font-weight: 600;
	text-decoration: none;
}

.mini-cart-panel .woocommerce-mini-cart__buttons .checkout {
	background: var(--color-accent);
	border-color: var(--color-accent);
	color: var(--on-accent);
}

.mini-cart-panel .woocommerce-mini-cart__empty-message {
	margin: 0;
	color: var(--color-muted);
}

/* Mobile drawer. */
.drawer-overlay {
	background: rgba(11, 27, 43, 0.6);
	transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.drawer-overlay.is-open {
	visibility: visible;
	opacity: 1;
	transition-delay: 0s;
}

.drawer {
	display: flex;
	flex-direction: column;
	background: #fff;
	box-shadow: var(--shadow-lg);
	transition: transform 0.25s ease, visibility 0s linear 0.25s;
}

.drawer.is-open {
	visibility: visible;
	transform: none;
	transition-delay: 0s;
}

body.drawer-open {
	overflow: hidden;
}

.drawer__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--space-1) var(--space-2);
	border-bottom: 1px solid var(--color-border);
	background: var(--color-primary);
	color: var(--on-primary);
}

.drawer__head .header-action {
	color: inherit;
}

.drawer__head .header-action:hover {
	background: rgba(255, 255, 255, 0.12);
}

.drawer__head :focus-visible {
	outline-color: #fff;
}

.drawer__title {
	font-size: 1.125rem;
	font-weight: 700;
}

.drawer__body {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.drawer-menu,
.drawer-submenu,
.drawer-links {
	margin: 0;
	padding: 0;
	list-style: none;
}

.drawer-item {
	display: flex;
	flex-wrap: wrap;
	align-items: stretch;
	border-bottom: 1px solid var(--color-border);
}

.drawer-link {
	flex: 1;
	display: flex;
	align-items: center;
	min-height: 48px;
	padding: 0 var(--space-2);
	color: var(--color-primary);
	font-weight: 600;
	text-decoration: none;
}

.drawer-sub-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	border: 0;
	border-left: 1px solid var(--color-border);
	background: none;
	color: var(--color-primary);
	cursor: pointer;
}

.drawer-sub-toggle .icon {
	transition: transform 0.15s ease;
}

.drawer-sub-toggle[aria-expanded="true"] .icon {
	transform: rotate(180deg);
}

.drawer-submenu {
	flex-basis: 100%;
	background: var(--grey-50);
}

.drawer-submenu[hidden] {
	display: none;
}

.drawer-submenu .drawer-item {
	border-bottom-color: var(--grey-200);
}

.drawer-submenu .drawer-link {
	padding-left: var(--space-4);
	font-weight: 500;
}

.drawer-submenu .drawer-submenu .drawer-link {
	padding-left: var(--space-6);
	font-size: 0.9375rem;
}

.drawer-links {
	padding: var(--space-2);
}

.drawer-links a {
	display: flex;
	align-items: center;
	gap: var(--space-1);
	min-height: 44px;
	color: var(--grey-700);
	text-decoration: none;
}

@media (min-width: 1024px) {
	.drawer,
	.drawer-overlay {
		display: none;
	}
}

/* Hover and current-page states for the top bar: an orange bar slides in under the link. */
.mega-link {
	position: relative;
}

.mega-link::after {
	content: "";
	position: absolute;
	right: var(--space-2);
	bottom: 8px;
	left: var(--space-2);
	height: 3px;
	background: var(--color-accent);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 220ms cubic-bezier(0.23, 1, 0.32, 1);
}

.has-panel > .mega-link::after {
	right: var(--space-half);
}

.mega-item:focus-within > .mega-link::after,
.mega-item.is-open > .mega-link::after,
.mega-link[aria-current="page"]::after {
	transform: scaleX(1);
}

@media (hover: hover) and (pointer: fine) {
	.mega-item:hover > .mega-link::after {
		transform: scaleX(1);
	}

	.mega-item:hover > .mega-toggle .icon {
		transform: rotate(180deg);
	}
}

/* No background tint: the bar carries the hover state. */
.mega-item:hover > .mega-link,
.mega-item:focus-within > .mega-link,
.mega-item:hover > .mega-toggle,
.mega-item:focus-within > .mega-toggle {
	background: none;
}

.mega-toggle .icon {
	transition: transform 220ms cubic-bezier(0.23, 1, 0.32, 1);
}

/* Dropdown: eases down into place; waits a moment before closing so it does not flicker shut. */
.mega-panel {
	transform: translateY(-6px);
	transition: opacity 180ms cubic-bezier(0.23, 1, 0.32, 1) 120ms, transform 180ms cubic-bezier(0.23, 1, 0.32, 1) 120ms, visibility 0s linear 300ms;
}

.mega-item:hover > .mega-panel,
.mega-item:focus-within > .mega-panel,
.mega-item.is-open > .mega-panel {
	transform: none;
	transition: opacity 180ms cubic-bezier(0.23, 1, 0.32, 1), transform 180ms cubic-bezier(0.23, 1, 0.32, 1), visibility 0s;
}

.mega-col__title {
	transition: border-color 200ms ease;
}

.mega-col__title:hover {
	border-bottom-color: var(--color-accent);
	text-decoration: none;
}

.mega-sub a {
	transition: color 160ms ease, transform 200ms cubic-bezier(0.23, 1, 0.32, 1);
}

.mega-sub a:hover {
	color: var(--color-primary);
	text-decoration: none;
	transform: translateX(3px);
}

/* Header action icons (Garage, Account, Cart): a crisp press. */
.header-action {
	transition: background-color 160ms ease, transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.header-action:active {
	transform: scale(0.96);
}

@media (prefers-reduced-motion: reduce) {
	.mega-link::after,
	.mega-panel,
	.mega-sub a,
	.mega-toggle .icon {
		transition: none;
	}

	.mega-panel,
	.mega-sub a:hover {
		transform: none;
	}
}

/* Logged-in admins: keep the drawer header below the WordPress toolbar. */
.admin-bar .drawer {
	top: 32px;
}

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