/*!
 * Zardis Toolkit — header menu cascade
 * Scoped to `.zardis-nav` (top-level items emitted by class-menus.php).
 * The theme's own walker builds the markup; this file only styles the
 * three-level cascade and never touches `.wd-nav > li > a` globally.
 */

/* ---------- level 2: product types ---------- */

/* Rows inside our shop dropdown only. */
.zardis-nav .wd-sub-menu > .zardis-nav-type > a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	min-height: 40px;
	padding-block: 0;
	font-weight: 600;
}

/* The walker prints a chevron via the theme font for items with children. */
.zardis-nav .wd-sub-menu > .zardis-nav-type.menu-item-has-children > a::after {
	flex: 0 0 auto;
	margin-inline-start: auto;
	opacity: .55;
}

@media (min-width: 1025px) {
	.zardis-nav .wd-sub-menu > .zardis-nav-type:hover > a,
	.zardis-nav .wd-sub-menu > .zardis-nav-type:focus-within > a {
		background-color: var(--ztk-gold-soft, #f6edda);
		color: var(--ztk-ink, #1d2327);
	}
}

/* ---------- level 3: weight leaves ---------- */

/*
 * The theme already reveals `ul.wd-dropdown` from
 * `.wd-event-hover:hover > .wd-dropdown`, so no JS is needed. We only make
 * the panel a card and keep 24 rows from running off the viewport.
 *
 * Specificity note: the theme positions the flyout with
 * `.wd-dropdown-menu.wd-design-default .wd-dropdown` (three classes). Both
 * selectors below carry four, so they win regardless of load order.
 */
@media (min-width: 1025px) {
	.zardis-nav .wd-dropdown-menu.wd-design-default .sub-sub-menu,
	.zardis-nav .wd-dropdown-menu.wd-design-default .wd-dropdown.sub-sub-menu {
		/*
		 * Drop the theme's 20px gap margin. It bridges that gap with a
		 * `::after` strip, but `overflow: auto` below clips pseudo-elements,
		 * so a gap would make the panel unreachable by hover. Flush against
		 * the parent row there is nothing to bridge.
		 */
		margin: 0;
		padding: 6px;
		min-width: 220px;
		max-height: min(70vh, 480px);
		overflow-x: hidden;
		overflow-y: auto;
		overscroll-behavior: contain;
		background-color: var(--ztk-surface, #fff);
		border-radius: var(--ztk-radius-sm, 9px);
		box-shadow:
			inset 0 0 0 1px var(--ztk-gold, #c9a247),
			0 14px 34px rgba(0, 25, 68, .14);
		/* Room for the scrollbar on the inline end without shifting rows. */
		scrollbar-width: thin;
		scrollbar-color: rgba(201, 162, 71, .55) transparent;
	}

	.zardis-nav .wd-dropdown-menu.wd-design-default .sub-sub-menu::-webkit-scrollbar {
		width: 8px;
	}

	.zardis-nav .wd-dropdown-menu.wd-design-default .sub-sub-menu::-webkit-scrollbar-thumb {
		background-color: rgba(201, 162, 71, .55);
		border-radius: 999px;
	}
}

.zardis-nav .sub-sub-menu .zardis-nav-leaf > a {
	display: flex;
	align-items: center;
	min-height: 40px;
	padding-block: 0;
	padding-inline: 12px;
	border-radius: calc(var(--ztk-radius-sm, 9px) - 3px);
	font-size: 13px;
	line-height: 1.5;
	white-space: nowrap;
	transition: background-color .16s ease, color .16s ease;
}

.zardis-nav .sub-sub-menu .zardis-nav-leaf > a:hover,
.zardis-nav .sub-sub-menu .zardis-nav-leaf > a:focus-visible,
.zardis-nav .sub-sub-menu .zardis-nav-leaf.current-menu-item > a {
	background-color: var(--ztk-gold-soft, #f6edda);
	color: var(--ztk-gold-deep, #a9862f);
}

/* ---------- horizontal product list inside «فروشگاه» ---------- */

/*
 * The two coin types now list their real products. On desktop the products are
 * laid out as horizontal, wrapping columns inside the dropdown panel; on
 * phones the same list stays a single vertical column, which is what a thumb
 * can actually scroll.
 */
.zardis-nav .zardis-nav-products > .wd-dropdown-menu .sub-sub-menu {
	display: grid;
	grid-template-columns: repeat(var(--zardis-product-cols, 2), minmax(0, 1fr));
	gap: 4px 10px;
	max-height: none;
	overflow: visible;
}

.zardis-nav .sub-sub-menu .zardis-nav-product > a {
	display: flex;
	align-items: center;
	min-height: 36px;
	padding-inline: 10px;
	border-radius: calc(var(--ztk-radius-sm, 9px) - 4px);
	font-size: 12.5px;
	line-height: 1.45;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.zardis-nav .sub-sub-menu .zardis-nav-product > a:hover,
.zardis-nav .sub-sub-menu .zardis-nav-product > a:focus-visible,
.zardis-nav .sub-sub-menu .zardis-nav-product.current-menu-item > a {
	background-color: var(--ztk-gold-soft, #f6edda);
	color: var(--ztk-gold-deep, #a9862f);
}

/* The trailing «مشاهده بیشتر» button spans the whole list width. */
.zardis-nav .zardis-nav-products > .wd-dropdown-menu .sub-sub-menu .zardis-nav-more {
	grid-column: 1 / -1;
	margin-block-start: 6px;
	padding-block-start: 8px;
	border-block-start: 1px solid var(--ztk-line, rgba(0, 25, 68, .12));
}

.zardis-nav .sub-sub-menu .zardis-nav-more > a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 34px;
	padding-inline: 14px;
	border-radius: 999px;
	background: var(--ztk-gold-soft, #f6edda);
	color: var(--ztk-navy, #001944);
	font-size: 12.5px;
	font-weight: 700;
	text-align: center;
	white-space: nowrap;
}

.zardis-nav .sub-sub-menu .zardis-nav-more > a::after {
	content: "";
	inline-size: 6px;
	block-size: 6px;
	border-inline-end: 1.6px solid currentColor;
	border-block-start: 1.6px solid currentColor;
	transform: rotate(45deg);
}

.zardis-nav .sub-sub-menu .zardis-nav-more > a:hover,
.zardis-nav .sub-sub-menu .zardis-nav-more > a:focus-visible {
	background: var(--ztk-gold, #c9a247);
	color: #14181c;
}

@media (max-width: 1024px) {
	.wd-nav-mobile .zardis-nav .zardis-nav-more > a {
		inline-size: 100%;
		min-height: 44px;
	}
}

/* Wider viewports fit more columns without shrinking the labels. */
@media (min-width: 1200px) {
	.zardis-nav .zardis-nav-products > .wd-dropdown-menu .sub-sub-menu {
		--zardis-product-cols: 3;
	}
}

/* Phone / tablet drawer: one column, full-width rows. */
@media (max-width: 1024px) {
	.zardis-nav .zardis-nav-products > .wd-dropdown-menu .sub-sub-menu,
	.wd-nav-mobile .zardis-nav .zardis-nav-products > .sub-sub-menu {
		display: block;
		grid-template-columns: none;
	}

	.wd-nav-mobile .zardis-nav .zardis-nav-product > a {
		white-space: normal;
		overflow: visible;
		text-overflow: clip;
		min-height: 44px;
	}
}

/* ---------- mobile ---------- */

/*
 * In the mobile drawer the walker emits no absolute panel: rows are plain
 * accordion entries opened by the theme's own slideDown(). Keep them compact
 * and indent the weight level so the cascade reads as a hierarchy at 360px.
 */
.wd-nav-mobile .zardis-nav > a {
	font-weight: 600;
}

.wd-nav-mobile .zardis-nav .zardis-nav-leaf > a {
	min-height: 40px;
	padding-block: 0;
	padding-inline-start: 34px;
	font-size: 13px;
}

@media (max-width: 1024px) {
	.zardis-nav .zardis-nav-type > a {
		min-height: 44px;
		padding-block: 0;
	}

	.zardis-nav .zardis-nav-leaf > a {
		white-space: normal;
		overflow-wrap: anywhere;
	}
}

/* ---------- mobile social slots → useful shortcuts ------------------ */

/*
 * Woodmart's bottom toolbar, not `.mobile-nav`, owns the site's WhatsApp and
 * Instagram slots. The module marker is added only after a slot is replaced;
 * disabled features and unrelated toolbars therefore retain the theme layout.
 * Keep the theme's 55px bar height (and its existing page-content clearance).
 */
@media (max-width: 1024px) {
	.zardis-mobile-toolbar.wd-toolbar {
		gap: 8px;
		padding-inline: 16px;
		overflow-x: hidden;
	}

	.zardis-mobile-toolbar.wd-toolbar > div,
	.zardis-mobile-toolbar.wd-toolbar > a {
		flex: 1 1 0;
		min-width: 0;
	}

	.zardis-mobile-toolbar .zardis-mobile-toolbar__item {
		--wd-tools-icon: none;
	}

	.zardis-mobile-toolbar.wd-toolbar .zardis-mobile-toolbar__link {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 3px;
		box-sizing: border-box;
		min-width: 44px;
		min-height: 44px;
		padding: 3px 4px;
		border-radius: var(--ztk-radius-sm, 9px);
		background: var(--ztk-gold-soft, #f6edda);
		color: var(--ztk-navy, #001944);
		transition: background-color .16s ease;
	}

	.zardis-mobile-toolbar .zardis-mobile-toolbar__icon {
		flex: 0 0 auto;
		width: 22px;
		height: 22px;
	}

	.zardis-mobile-toolbar.wd-toolbar .zardis-mobile-toolbar__label {
		position: static;
		display: block;
		max-width: 100%;
		padding: 0;
		color: inherit;
		font-family: inherit;
		font-size: 12px;
		font-weight: 700;
		line-height: 1.25;
	}

	.zardis-mobile-toolbar.wd-toolbar .zardis-mobile-toolbar__link:hover,
	.zardis-mobile-toolbar.wd-toolbar .zardis-mobile-toolbar__link:active {
		background: var(--ztk-gold, #c9a247);
		color: var(--ztk-navy, #001944);
	}

	.zardis-mobile-toolbar.wd-toolbar .zardis-mobile-toolbar__link:focus-visible {
		outline: 2px solid var(--ztk-navy, #001944);
		outline-offset: 1px;
		background: var(--ztk-gold, #c9a247);
	}
}

@media (prefers-reduced-motion: reduce) {
	.zardis-mobile-toolbar.wd-toolbar .zardis-mobile-toolbar__link {
		transition: none;
	}
}

/* ---------- horizontal (mega) panel -------------------------------- */

/*
 * The top-level «فروشگاه» item is emitted with the theme's `sized` design
 * (class-menus.php → item_design_meta()), which makes Mega_Menu_Walker build
 *   .wd-dropdown-menu.wd-design-sized > .container > ul.wd-sub-menu.wd-grid-f-inline
 * and lay the two product types out as side-by-side columns.
 *
 * The theme's own `--wd-col-lg`, padding and shadow are tuned for its demo
 * layouts, so we pin the width and the column widths to our own values.
 */
@media (min-width: 1025px) {
	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu.wd-design-sized {
		--wd-dropdown-width: 520px;
		inset-inline-start: 50%;
		translate: -50% 0;
	}

	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu > .container {
		max-width: none;
	}

	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu .wd-sub-menu.wd-grid-f-inline {
		display: flex;
		flex-wrap: nowrap;
		align-items: flex-start;
		gap: 8px;
		--wd-f-basis: 0;
	}

	/* Each product type is one column. */
	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu .wd-sub-menu.wd-grid-f-inline > li {
		flex: 1 1 0;
		min-width: 0;
		margin: 0;
	}

	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu .wd-sub-menu.wd-grid-f-inline > li > a {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 8px;
		padding: 10px 12px;
		border-radius: 10px;
		background: var(--ztk-surface-alt, #f7f8fa);
		font-size: 13.5px;
		font-weight: 800;
		color: var(--ztk-navy, #001944);
		white-space: nowrap;
	}

	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu .wd-sub-menu.wd-grid-f-inline > li > a:hover,
	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu .wd-sub-menu.wd-grid-f-inline > li > a:focus {
		background: var(--ztk-gold-soft, #f6edda);
		color: var(--ztk-navy, #001944);
	}

	/* Weights are a two-column list under each type, not another flyout. */
	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu .wd-sub-menu.wd-grid-f-inline > li > .sub-sub-menu {
		position: static;
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 2px;
		width: auto;
		min-width: 0;
		max-height: 260px;
		margin: 6px 0 0;
		padding: 4px;
		overflow-y: auto;
		opacity: 1;
		visibility: visible;
		transform: none;
		box-shadow: none;
		background: transparent;
		border-radius: 0;
	}

	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu .wd-sub-menu.wd-grid-f-inline > li > .sub-sub-menu > li {
		margin: 0;
	}

	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu .wd-sub-menu.wd-grid-f-inline > li > .sub-sub-menu a {
		display: block;
		padding: 6px 8px;
		border-radius: 6px;
		font-size: 12.5px;
		line-height: 1.6;
		color: var(--ztk-ink-soft, #5a6169);
		white-space: nowrap;
	}

	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu .wd-sub-menu.wd-grid-f-inline > li > .sub-sub-menu a:hover,
	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu .wd-sub-menu.wd-grid-f-inline > li > .sub-sub-menu a:focus {
		background: var(--ztk-gold-soft, #f6edda);
		color: var(--ztk-gold-deep, #a9862f);
	}
}

/* Mobile keeps the theme's drill-down; no mega layout there. */
@media (max-width: 1024px) {
	.zardis-nav.menu-mega-dropdown > .wd-dropdown-menu.wd-design-sized {
		translate: none;
		inset-inline-start: auto;
	}
}
