/*
 Theme Name:   KDS WM
 Theme URI:    https://webbycrown.com
 Description:  A child theme of Storefront customized for KDS WM
 Author:       WebbyCrown
 Author URI:   https://webbycrown.com/
 Template:     storefront
 Version:      1.0.0
 Text Domain:  storefront-child
*/

/* Mobile drawer backdrop — hidden on desktop; mobile rules below show when .is-active */
.kds-mobile-nav-overlay {
	display: none !important;
}

/* Site branding - full width, logo centered (desktop; mobile overrides below) */
.site-branding,
.woocommerce-active .site-header .site-branding {
	width: 100% !important;
	float: none;
	margin: 0 !important;
	text-align: center;
}
.home.blog .site-header, .home.page:not(.page-template-template-homepage) .site-header, .home.post-type-archive-product .site-header {
  margin-bottom: 2.235801032em !important;
}
/* Mobile header: logo + menu on one row, tighter spacing */
@media (max-width: 767px) {
	/* Overlay is the first child inside #page; masthead must stack above it so the drawer is clickable */
	#page {
		position: relative;
	}

	#masthead.site-header {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		column-gap: 0.75rem;
		row-gap: 0.5rem;
		padding: 0.65em 1em;
		box-sizing: border-box;
		position: relative;
		z-index: 100020;
	}

	/* Flatten Storefront wrappers so branding and nav share one flex row */
	#masthead.site-header > .col-full,
	#masthead.site-header > .storefront-primary-navigation,
	#masthead.site-header .storefront-primary-navigation > .col-full {
		display: contents;
	}

	#masthead .site-branding {
		order: 2;
		flex: 1 1 0;
		min-width: 0;
		width: auto !important;
		max-width: calc(100% - 7.5rem);
		margin: 0 !important;
		text-align: start;
		align-self: center;
	}

	/*
	 * Let the nav flex item grow to fill space beside the logo. If it stays only as wide
	 * as the menu button, .handheld-navigation stays narrow and overflow:hidden clips the
	 * dropdown when .toggled (Storefront uses max-height + overflow on .handheld-navigation).
	 */
	#masthead #site-navigation.main-navigation,
	#masthead .main-navigation {
		order: 3;
		flex: 1 1 0;
		min-width: 0;
		width: auto !important;
		max-width: none;
		float: none !important;
		clear: none !important;
		margin: 0 !important;
		align-self: stretch;
		/* Fixed children must use the viewport, not a transformed ancestor */
		transform: none !important;
		filter: none !important;
		perspective: none !important;
	}

	#masthead .main-navigation .menu-toggle {
		float: right;
		margin: 0;
	}

	/* Only handheld panel (.handheld-navigation or WP fallback div.menu) — not the desktop ul */
	#masthead .main-navigation .primary-navigation {
		display: none !important;
	}

	/* Full-screen dim (script toggles .is-active with Storefront .toggled) */
	.kds-mobile-nav-overlay {
		display: none;
	}

	.kds-mobile-nav-overlay.is-active {
		display: block !important;
		position: fixed;
		inset: 0;
		z-index: 100010;
		background: rgba(0, 0, 0, 0.55);
		-webkit-tap-highlight-color: transparent;
	}

	body.kds-mobile-nav-open {
		overflow: hidden;
		touch-action: none;
	}

	/*
	 * Slide-in drawer: Storefront handheld = .handheld-navigation; WP page fallback = direct child div.menu.
	 * Both need the same fixed panel + transform (fallback has no .handheld-navigation class).
	 */
	#masthead .main-navigation .handheld-navigation,
	#masthead #site-navigation.main-navigation > div.menu {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		width: min(88vw, 22rem);
		max-height: none !important;
		height: 100vh;
		height: 100dvh;
		margin: 0;
		padding: calc(0.75rem + env(safe-area-inset-top, 0)) 1rem calc(0.75rem + env(safe-area-inset-bottom, 0));
		box-sizing: border-box;
		clear: none;
		z-index: 1;
		background: #fff;
		box-shadow: 4px 0 32px rgba(0, 0, 0, 0.18);
		overflow-x: hidden;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		transform: translateX(-100%);
		visibility: hidden;
		pointer-events: none;
		transition: transform 0.3s ease, visibility 0.3s ease !important;
		border-radius: 0;
	}

	body.rtl #masthead .main-navigation .handheld-navigation,
	body.rtl #masthead #site-navigation.main-navigation > div.menu {
		left: auto;
		right: 0;
		transform: translateX(100%);
		box-shadow: -4px 0 32px rgba(0, 0, 0, 0.18);
	}

	#masthead .main-navigation.toggled .handheld-navigation,
	#masthead .main-navigation.toggled > div.menu {
		transform: translateX(0);
		visibility: visible;
		pointer-events: auto;
		max-height: none !important;
		min-height: 100vh;
		min-height: 100dvh;
		opacity: 1;
	}

	#masthead .main-navigation.toggled .handheld-navigation .nav-menu,
	#masthead .main-navigation.toggled .handheld-navigation ul.menu,
	#masthead .main-navigation.toggled > div.menu > ul {
		margin: 0;
		padding: 0;
		list-style: none;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		gap: 0;
		border: 1px solid rgba(0, 0, 0, 0.1);
		border-radius: 8px;
		background: #fff;
		box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
	}

	#masthead .main-navigation.toggled .handheld-navigation .nav-menu > .menu-item,
	#masthead .main-navigation.toggled .handheld-navigation ul.menu > .menu-item,
	#masthead .main-navigation.toggled > div.menu > ul > li {
		margin: 0;
		border-radius: 0;
		overflow: visible;
		border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	}

	#masthead .main-navigation.toggled .handheld-navigation .nav-menu > .menu-item:last-child,
	#masthead .main-navigation.toggled .handheld-navigation ul.menu > .menu-item:last-child,
	#masthead .main-navigation.toggled > div.menu > ul > li:last-child {
		margin-bottom: 0;
		border-bottom: none;
	}

	#masthead .main-navigation.toggled .handheld-navigation .nav-menu > .menu-item > a,
	#masthead .main-navigation.toggled .handheld-navigation ul.menu > .menu-item > a,
	#masthead .main-navigation.toggled > div.menu > ul > li > a {
		display: block;
		padding: 10px 1rem;
		min-height: 3rem;
		box-sizing: border-box;
		font-size: 1.05rem;
		font-weight: 500;
		line-height: 1.45;
		color: #1a1a1a;
		text-decoration: none;
		-webkit-tap-highlight-color: rgba(0, 0, 0, 0.06);
		transition: background 0.15s ease, color 0.15s ease;
	}

	/* Rows with sub-menus: link + expand button (Storefront) */
	#masthead .main-navigation.toggled .handheld-navigation .menu-item-has-children {
		position: relative;
		padding-bottom: 0.15rem;
	}

	#masthead .main-navigation.toggled .handheld-navigation .menu-item-has-children > a {
		padding-right: 3rem;
	}

	#masthead .main-navigation.toggled .handheld-navigation .dropdown-toggle {
		position: absolute;
		top: 0;
		right: 0;
		width: 3rem;
		min-height: 3rem;
		margin: 0;
		padding: 0;
		border: none;
		background: transparent;
		cursor: pointer;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	#masthead .main-navigation.toggled .handheld-navigation .nav-menu > .menu-item > a:hover,
	#masthead .main-navigation.toggled .handheld-navigation .nav-menu > .menu-item > a:focus,
	#masthead .main-navigation.toggled .handheld-navigation ul.menu > .menu-item > a:hover,
	#masthead .main-navigation.toggled .handheld-navigation ul.menu > .menu-item > a:focus,
	#masthead .main-navigation.toggled > div.menu > ul > li > a:hover,
	#masthead .main-navigation.toggled > div.menu > ul > li > a:focus {
		background: rgba(0, 0, 0, 0.06);
		color: #000;
		outline: none;
	}

	#masthead .main-navigation.toggled .handheld-navigation .nav-menu > .menu-item.current-menu-item > a,
	#masthead .main-navigation.toggled .handheld-navigation .nav-menu > .menu-item.current_page_item > a,
	#masthead .main-navigation.toggled .handheld-navigation ul.menu > .menu-item.current-menu-item > a,
	#masthead .main-navigation.toggled .handheld-navigation ul.menu > .menu-item.current_page_item > a,
	#masthead .main-navigation.toggled > div.menu > ul > li.current-menu-item > a,
	#masthead .main-navigation.toggled > div.menu > ul > li.current_page_item > a {
		background: rgba(0, 0, 0, 0.07);
		font-weight: 600;
	}

	/* Collapsed: no extra box spacing (Storefront uses max-height/visibility; padding was adding gap) */
	#masthead .main-navigation.toggled .handheld-navigation .sub-menu {
		list-style: none;
		padding: 0;
		margin: 0;
		border: none;
		background: transparent;
	}

	/* Expanded only — JS adds .toggled-on (see navigation.js) */
	#masthead .main-navigation.toggled .handheld-navigation .sub-menu.toggled-on {
		display: flex;
		flex-direction: column;
		gap: 0;
		padding: 0;
		margin: 0;
		border-radius: 0;
		background: rgba(0, 0, 0, 0.04);
		border-top: 1px solid rgba(0, 0, 0, 0.08);
		border-left: 3px solid rgba(0, 0, 0, 0.18);
		box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
	}

	#masthead .main-navigation.toggled .handheld-navigation .sub-menu.toggled-on .menu-item {
		border-bottom: 1px solid rgba(0, 0, 0, 0.06);
	}

	#masthead .main-navigation.toggled .handheld-navigation .sub-menu.toggled-on .menu-item:last-child {
		border-bottom: none;
	}

	#masthead .main-navigation.toggled .handheld-navigation .sub-menu .menu-item {
		margin: 0;
		border-radius: 0;
	}

	#masthead .main-navigation.toggled .handheld-navigation .sub-menu.toggled-on .menu-item > a {
		display: block;
		padding: 0.9rem 1rem 0.9rem 1.15rem;
		min-height: 2.85rem;
		box-sizing: border-box;
		font-size: 0.98rem;
		font-weight: 400;
		line-height: 1.45;
		color: #333;
	}

	#masthead .main-navigation.toggled .handheld-navigation .sub-menu.toggled-on .menu-item > a:hover,
	#masthead .main-navigation.toggled .handheld-navigation .sub-menu.toggled-on .menu-item > a:focus {
		background: rgba(0, 0, 0, 0.05);
		color: #111;
	}

	/* Deeper nesting: spacing only when that level is expanded */
	#masthead .main-navigation.toggled .handheld-navigation .sub-menu.toggled-on .sub-menu.toggled-on {
		margin: 0;
		padding: 0;
		border-top: 1px solid rgba(0, 0, 0, 0.07);
		border-left: 3px solid rgba(0, 0, 0, 0.12);
		background: rgba(0, 0, 0, 0.02);
	}

	body.rtl #masthead .main-navigation.toggled .handheld-navigation .menu-item-has-children > a {
		padding-right: 1rem;
		padding-left: 3rem;
	}

	body.rtl #masthead .main-navigation.toggled .handheld-navigation .dropdown-toggle {
		right: auto;
		left: 0;
	}

	#masthead .secondary-navigation,
	#masthead .subscribe-and-connect-connect {
		order: 10;
		flex: 1 0 100%;
		width: 100%;
		text-align: center;
	}

	#masthead .site-search {
		order: 11;
		flex: 1 0 100%;
	}

	.site-branding .custom-logo {
		max-height: 56px;
		width: auto;
		height: auto;
	}

	.woocommerce-active .site-header .site-branding {
		float: none;
	}

	/* Storefront bottom bar (search / account / cart) on small screens */
	.storefront-handheld-footer-bar {
		display: none !important;
	}
}

@media (min-width: 768px) {
	.woocommerce-active .site-header .site-branding {
		width: 100% !important;
		float: none;
		margin: 0 !important;
	}

	/* Main navigation - full width, centered menu */
	.woocommerce-active .site-header .main-navigation {
		width: 100% !important;
		float: none;
		margin: 0 !important;
		clear: both;
	}

	.woocommerce-active .site-header .main-navigation .primary-navigation,
	.woocommerce-active .site-header .main-navigation .nav-menu {
		display: flex;
		justify-content: center;
		flex-wrap: wrap;
	}
}

.site-branding .custom-logo-link {
	display: inline-block;
}

.site-branding .custom-logo {
	max-height: 80px;
	width: auto;
	height: auto;
}

/* Shop / category archive: product search below page title */
.kds-archive-product-search {
	margin: 0 0 1.618em;
	max-width: 32em;
}

.kds-archive-product-search .woocommerce-product-search {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
	align-items: stretch;
}

.kds-archive-product-search .woocommerce-product-search .search-field {
	flex: 1 1 12em;
	min-width: 0;
}

/* Hide sale badge */
.onsale {
	display: none !important;
}

/* Hide site search */
.site-search {
	display: none !important;
}

/* Hide site header cart */
#site-header-cart {
	display: none !important;
}

/* Remove sidebar and make primary content full width */
#secondary {
	display: none !important;
}

#primary.content-area {
	width: 100% !important;
	float: none !important;
	margin: 0 !important;
	padding: 0 !important;
}

/* Age verification gate */
html.kds-age-gate-open,
body.kds-age-gate-open {
	overflow: hidden;
}

.kds-age-gate {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.25em;
	box-sizing: border-box;
}

.kds-age-gate[hidden] {
	display: none !important;
}

.kds-age-gate__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
}

.kds-age-gate__box {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 28em;
	background: #fff;
	padding: 2em 1.75em 1.75em;
	text-align: center;
	box-shadow: 0 0.25em 2em rgba(0, 0, 0, 0.2);
	border-radius: 4px;
	font-family: inherit;
}

.kds-age-gate__title {
	margin: 0 0 0.75em;
	font-size: 1.35em;
	font-weight: 700;
	color: #111;
	line-height: 1.25;
}

.kds-age-gate__text {
	margin: 0 0 1.5em;
	font-size: 1em;
	font-weight: 400;
	color: #111;
	line-height: 1.5;
}

.kds-age-gate__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.65em;
	justify-content: center;
}

.kds-age-gate__btn {
	flex: 1 1 10em;
	min-width: 0;
	padding: 0.85em 1em;
	font-size: 0.8em;
	font-weight: 600;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	color: #fff;
	transition: opacity 0.15s ease;
}

.kds-age-gate__btn:hover,
.kds-age-gate__btn:focus {
	opacity: 0.92;
}

.kds-age-gate__btn:focus {
	outline: 2px solid #333;
	outline-offset: 2px;
}

.kds-age-gate__btn--primary {
	background: #1a1a1a;
}

.kds-age-gate__btn--secondary {
	background: #9a9a9a;
}
