/*
 * R2-06 — «Сувенірка» mega menu: WoodMart click-trigger support gap.
 *
 * The "Сувенірка" top-nav item (menu item 49932) uses WoodMart's full-width
 * mega-menu design with a CLICK trigger instead of the theme's default hover
 * trigger, per the client's literal request ("коли натискаємо на Сувенірку").
 * Confirmed live (Playwright, focus + Enter, zero mouse movement) that the
 * theme's own click support has two gaps for a full-width design specifically:
 *
 * 1. VISIBILITY. WoodMart ships:
 *      .wd-nav-header:not(.wd-offsets-calculated) > li > .wd-dropdown
 *        :not(.wd-design-default) { opacity:0; pointer-events:none }
 *    an anti-FOUC guard that only lifts once js/scripts/menu/menuOffsets.js's
 *    recalc() has run — and recalc() is wired ONLY to mouseenter/mousemove on
 *    the nav, never to click or keyboard focus. A user who opens the panel
 *    without first crossing the nav with a real mouse (any keyboard user;
 *    most touch taps) gets `.wd-opened` set correctly by menuSetUp.js but the
 *    panel stays permanently invisible AND unclickable. Measured: opacity
 *    stayed exactly "0" for 1000ms+ after focusing the trigger and pressing
 *    Enter with no mouse movement at all, vs settling to ~1 once a real
 *    mousemove had crossed the nav first.
 *
 * 2. HORIZONTAL POSITION. The same recalc() is also the only place the
 *    theme computes the dropdown's `left` offset — the panel is
 *    `position:absolute` inside its own <li> with `left:auto`, which resolves
 *    to the <li>'s own static position on the page, not the viewport edge.
 *    Without recalc() the panel opens flush with wherever "Сувенірка" sits
 *    (~290px from the left on a 1366px viewport) and extends 100vw further
 *    right, overflowing off-screen. Measured: boundingBox x=288, width=1366
 *    on a 1366px-wide viewport (edge past the fold by ~288px).
 *
 * Fix: stop depending on the hover-only JS for this one panel and pin it to
 * the viewport with `position:fixed`. Originally anchored `top` to WoodMart's
 * own --wd-header-h custom property (css/parts/header-mod-content-calc.min.css,
 * enqueued automatically once `_menu_item_scroll=yes` + full-width meet, per
 * mega-menu-walker.php) on the assumption it tracked sticky/non-sticky header
 * height changes — R2-06c MEASURED live that it does not (it's a constant
 * ~77px regardless of scroll position) and replaced it; see the R2-06c
 * comment below for the correction and the current mechanism.
 *
 * This also gives the panel its own scrollable area sized to the visible
 * viewport: WoodMart's `_menu_item_scroll=yes` item meta only wraps content
 * in a scrollable `.wd-scroll-content` div for the `full-height` design
 * (mega-menu-walker.php start_lvl(), the wrapper markup is emitted only
 * inside the `'full-height' === $this->design` branch) — NOT for
 * `full-width`, which only gets the bare `wd-scroll` class with no matching
 * wrapper. The 9 curated souvenir groups render ~988px tall, taller than a
 * 768–800px viewport, and full-width design has no theme-native way to
 * scroll that on its own — exactly the "structure WoodMart cannot express"
 * case for a child-theme CSS override (see project CLAUDE.md conventions).
 *
 * Владелец 15.08 (п.6): скоуп расширен на пункт 50392 («Каталог») — он
 * переведён на тот же full-width/click механизм, что и «Сувенірка» (49932);
 * все селекторы ниже кроют оба пункта через :is(). Остальные дропдауны
 * не затронуты.
 */
/*
 * R2-06c — replaced --wd-header-h with a JS-measured live anchor.
 *
 * MEASURED live (real scrollTo(0,30), real getBoundingClientRect(), same
 * session that wrote this fix): with the panel closed and the page scrolled
 * 30px, the header's ACTUAL rendered bottom edge is 48px, while
 * `--wd-header-h` computes to a constant ~77px
 * (`calc(.00001px + 76px + .00001px + calc(.00001px + 1px + .00001px))`,
 * unchanged by scroll position). That ~29px delta is the reported 28px gap
 * (R2-06b item 1) — the var never tracked the header at all, scrolled or
 * sticky; it just happened to be close enough at scrollY=0 to go unnoticed.
 * Same disconnect, opposite sign, produced item 2's 18px overlap from the
 * sticky-header state (panel top 60 vs real sticky bottom 78) — two symptoms
 * of one cause, so one fix: stop reading --wd-header-h at all and have
 * merchlab-megamenu.js write the header's live getBoundingClientRect().bottom
 * into --mlmm-header-bottom every time the panel opens and on every
 * scroll/resize while it stays open (see the JS file for that logic). This
 * tracks whatever position/height the header is ACTUALLY in — in-flow,
 * scrolled-but-not-yet-sticky, or truly sticky — instead of a cached number.
 * The 80px fallback below only covers the near-instant window before that JS
 * runs (belt-and-braces, not the mechanism).
 */
.wd-nav-main > :is(li.menu-item-49932, li.menu-item-50392).wd-opened > .wd-dropdown-menu.wd-design-full-width {
	opacity: 1 !important;
	visibility: visible !important;
	pointer-events: auto !important;
	transform: none !important;
	position: fixed !important;
	left: 0 !important;
	right: 0 !important;
	margin: 0 !important;
	top: var(--mlmm-header-bottom, 80px) !important;
	width: 100vw !important;
	max-height: calc(100vh - var(--mlmm-header-bottom, 80px)) !important;
	overflow: hidden;
}

.wd-nav-main > :is(li.menu-item-49932, li.menu-item-50392).wd-opened > .wd-dropdown-menu.wd-design-full-width > .container.wd-entry-content {
	max-height: calc(100vh - var(--mlmm-header-bottom, 80px));
	overflow-y: auto;
	overscroll-behavior: contain;
}

/*
 * R2-06b item 4 — ragged empty grid cells on wide viewports.
 *
 * The walker hardcodes `wd-grid-f-inline` for a full-width mega design
 * (mega-menu-walker.php, no admin-exposed way to pick a different grid mode
 * per item), which gives each depth-1 group column a FIXED, non-growing
 * flex-basis (`.wd-grid-f-inline > .wd-col { flex: 0 0 var(--wd-f-basis,
 * auto) }`, base.min.css). With 10 curated groups at the default 200px
 * column width, wide viewports wrap 6 columns onto row 1 and leave the
 * remaining columns on row 2 short of the container width — measured at
 * 1600x1100: row 1 six 200px columns, row 2 three/four 200px columns
 * flush-left, trailing space empty (containerW 1585, 6*200+5*20=1300 used,
 * ~285px dead on the wrapped row).
 *
 * WoodMart ships exactly the fix for this as a THEME-NATIVE alternate class,
 * `.wd-grid-f-stretch > .wd-col { flex: 1 1 var(--wd-f-basis, 200px) }`
 * (base.min.css) — items grow to fill each flex line, including a short
 * last row, instead of leaving trailing dead space. That class isn't one
 * the walker ever emits for a full-width design, so it can't be turned on
 * via theme settings; replicating its one declaration scoped to this menu
 * item is reusing WoodMart's own pattern, not inventing new layout logic
 * (see project CLAUDE.md: "add child-theme CSS only for structures WoodMart
 * cannot express").
 */
.wd-nav-main > :is(li.menu-item-49932, li.menu-item-50392).wd-opened > .wd-dropdown-menu.wd-design-full-width .wd-sub-menu.wd-grid-f-inline > .wd-col {
	flex: 1 1 var(--wd-f-basis, 200px);
}


/* Сувенірка-1, решение владельца 13.08: «сделать меньше отступы между
 * пунктами меню везде, чтобы всё влазило без скроллинга». Было 988px контента
 * при окне 690px (1366x768) — нижние пять групп открывались только прокруткой
 * за 5px скролбар. Плотность: заголовок 6/4px, пункт 2.5px, контейнер 14px. */
:is(li.menu-item-49932, li.menu-item-50392) .wd-dropdown-menu .wd-sub-menu > li > a {
	padding-top: 6px !important;
	padding-bottom: 4px !important;
	font-size: 13px !important;
	line-height: 1.25 !important;
}
:is(li.menu-item-49932, li.menu-item-50392) .wd-dropdown-menu .wd-sub-menu .wd-sub-menu li a,
:is(li.menu-item-49932, li.menu-item-50392) .wd-dropdown-menu .sub-sub-menu li a {
	padding-top: 2.5px !important;
	padding-bottom: 2.5px !important;
	font-size: 13px !important;
	line-height: 1.3 !important;
}
:is(li.menu-item-49932, li.menu-item-50392) .wd-dropdown-menu .container {
	padding-top: 14px !important;
	padding-bottom: 14px !important;
}
:is(li.menu-item-49932, li.menu-item-50392) .wd-dropdown-menu .wd-sub-menu > li {
	margin-bottom: 10px !important;
}


/* ...продолжение решения владельца: строки держал наш же тач-таргет
 * min-height:44px на каждой ссылке (замерено: fs 13/lh 16.9/pad 2.5, а
 * высота строки всё равно 44). Для указателя-мыши 44px не нужны — ужимаем
 * до 26px; на тач-устройствах (координатный ввод грубый) оставляем 44. */
@media (min-width: 1025px) {
	:is(li.menu-item-49932, li.menu-item-50392) .wd-dropdown-menu a.woodmart-nav-link,
	:is(li.menu-item-49932, li.menu-item-50392) .wd-dropdown-menu .wd-sub-menu a {
		min-height: 26px !important;
		height: auto !important;
	}
	:is(li.menu-item-49932, li.menu-item-50392) .wd-dropdown-menu .wd-sub-menu > li {
		margin-bottom: 6px !important;
	}
}

/* Владелец 15.08 (доработка п.6): у «Каталога» всего два пункта без подпунктов —
 * разнесённые flex-колонки смотрелись пусто. Только для 50392 пункты идут один
 * под другим; «Сувенірка» (49932) остаётся колоночной. !important — чтобы
 * перебить колоночный flex-basis 200px из правила выше по файлу. */
.wd-nav-main > li.menu-item-50392.wd-opened > .wd-dropdown-menu.wd-design-full-width .wd-sub-menu.wd-grid-f-inline {
	flex-direction: column;
	align-items: flex-start;
}
.wd-nav-main > li.menu-item-50392.wd-opened > .wd-dropdown-menu.wd-design-full-width .wd-sub-menu.wd-grid-f-inline > li {
	flex: 0 0 auto !important;
	width: auto;
	max-width: none;
}
