/* ==========================================================================
   PRIMARY NAV MEGA MENU
   --------------------------------------------------------------------------
   There is no UI Final frame for this state. The UX frame "Avalehe megamenüü"
   sets the structure — four columns of navigation groups beside a featured
   editorial block, on a divider — and everything visible here is the theme's
   existing language rendering it: the search panel's surface, the footer's
   column heading and link list, the catalogue promo's editorial stack. No new
   token, type step or spacing value is introduced.

   The panel hangs from .site-header__main, so it follows the sticky bar rather
   than the full header height once the utility bar has scrolled off — the same
   positioning the drawer uses.
   ========================================================================== */

.mega-menu {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	z-index: 2;
	/* The search panel's surface, exactly: the page's own cream, the nav
	   hairline under it, and the small shadow that lifts it off the page. */
	background-color: var(--color-cream);
	/*
	 * And the search panel's motion, exactly. A grid row animating from 0fr to
	 * 1fr is a real height transition with nothing measured in JavaScript, so
	 * the panel opens to whatever it happens to contain — two columns or four,
	 * with a featured block or without — at the same speed either way.
	 *
	 * The hairline and the shadow start out transparent rather than absent, so
	 * they arrive with the surface instead of snapping on at the end.
	 */
	display: grid;
	grid-template-rows: 0fr;
	border-bottom: 1px solid transparent;
	/*
	 * `top: 100%` is measured from the bar's padding box, so an open panel began
	 * on the bar's own divider and its cream covered it — the one header state
	 * where the line went missing. A transparent top border the same width
	 * steps the surface below the line, and with the clip below the bar's
	 * divider shows through it unchanged, open or closed.
	 */
	border-top: 1px solid transparent;
	/*
	 * Painted inside the border only. Collapsed, the panel is still its own
	 * one-pixel border, and with the background running under it every closed
	 * panel laid a cream stripe exactly over the header's divider — five of
	 * them, all at the bar's foot — which is the pale line that showed between
	 * the header and the hero. Open, nothing changes: the bottom border is coloured
	 * and the surface fills the padding box above it.
	 */
	background-clip: padding-box;
	/* Collapsed, the panel is still a one-pixel box under the bar. It must not
	   be the thing a click at that line lands on. */
	pointer-events: none;
	box-shadow: 0 0 0 0 transparent;
	transition:
		grid-template-rows 260ms cubic-bezier(0.4, 0, 0.2, 1),
		border-color 260ms linear,
		box-shadow 260ms linear;
}

.mega-menu.is-open {
	pointer-events: auto;
	grid-template-rows: 1fr;
	border-bottom-color: var(--color-border-nav);
	box-shadow: var(--shadow-sm);
}

/*
 * The grid row's child has to be able to be zero tall, which means it clips.
 * It also fades and lifts, so the columns arrive with the height rather than
 * being uncovered by it. It only ever clips: it is shorter than its content
 * for the whole opening, so a scrolling viewport here grew a scrollbar for
 * those 260ms and lost it at the end, and every column, the featured product
 * most visibly, jumped ~9px sideways and widened by the scrollbar's 15
 * (4.11.2026). Scrolling is the scroller's job, below.
 */
.mega-menu__viewport {
	overflow: hidden;
	min-height: 0;
	opacity: 0;
	transform: translateY(-8px);
	transition:
		opacity 200ms linear,
		transform 260ms cubic-bezier(0.4, 0, 0.2, 1);
}

.mega-menu.is-open .mega-menu__viewport {
	opacity: 1;
	transform: none;
}

/*
 * A tall panel on a short viewport stays reachable rather than running under
 * the fold with no way to get at the last link. The scroller is always its
 * own height, never the animating one, so it has a scrollbar only when the
 * panel is taller than the screen allows — and then from the first frame.
 */
.mega-menu__scroller {
	max-height: calc(100vh - var(--header-search-offset, 121px) - var(--space-md));
	overflow-y: auto;
}

/*
 * The panel is a header surface, so it is only ever open on a viewport that has
 * the desktop nav. Below 1280 the same information is in the drawer, and the
 * panel must not be reachable even if a stale open state survives a resize.
 */
@media (max-width: 1279px) {

	.mega-menu,
	.mega-menu__scrim {
		display: none;
	}
}

/*
 * The page, dimmed below the bar. Absolutely positioned inside the sticky bar
 * rather than fixed to the viewport, so its top edge follows the bar's underside
 * and it can never creep over the header. It sits behind the
 * panel, which is opaque, so the panel is not dimmed either.
 */
.mega-menu__scrim {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	z-index: 1;
	height: 100vh;
	/* The ink, at the weight the theme already dims with. A neutral black would
	   grey the cream; the ink keeps the page warm as it recedes. */
	background-color: color-mix(in srgb, var(--color-ink) 18%, transparent);
	/* `top: 100%` lands on the bar's divider, not below it — the containing
	   block is the padding box. The same transparent border as the panel keeps
	   the dimming off that line, so it reads the same open as closed. */
	border-top: 1px solid transparent;
	background-clip: padding-box;
	/*
	 * Dimmed and undimmed are the two ends of one fade, so the scrim is hidden
	 * by being transparent rather than by display:none, which has no middle.
	 * Visibility follows at the end of the fade out and at the start of the
	 * fade in, which is what keeps a closed scrim from swallowing clicks.
	 */
	opacity: 0;
	visibility: hidden;
	transition:
		opacity 260ms linear,
		visibility 0s linear 260ms;
}

.mega-menu__scrim.is-visible {
	opacity: 1;
	visibility: visible;
	transition:
		opacity 260ms linear,
		visibility 0s linear 0s;
}

@media (prefers-reduced-motion: reduce) {

	.mega-menu,
	.mega-menu__viewport,
	.mega-menu__scrim {
		transition-duration: 1ms;
	}

	.mega-menu__scrim {
		transition-delay: 0s;
	}
}

.mega-menu__inner {
	display: grid;
	/* The UX splits its twelve columns seven and five. */
	grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
	gap: var(--space-2xl);
	padding-block: var(--space-lg);
	align-items: start;
}

.mega-menu--groups-only .mega-menu__inner {
	grid-template-columns: minmax(0, 1fr);
}

/* --------------------------------------------------------------------------
   NAVIGATION GROUPS

   The footer's column pattern, which is the same idea already solved in this
   theme: a .type-h5 heading over a .type-body-inter list, 8px between links.
   -------------------------------------------------------------------------- */

/*
 * As many columns as the section has groups. A catalogue with four fills the
 * frame's four; one with two is two columns of the same width and rhythm, not
 * two stretched to fill a frame drawn for four.
 */
.mega-menu__groups {
	display: grid;
	grid-template-columns: repeat(var(--mega-columns, 4), minmax(0, 1fr));
	gap: var(--space-lg) var(--space-md);
	align-items: start;
}

/*
 * With no featured block the groups have the whole rail, which would hand two
 * columns 800px each. They keep a navigation measure instead and the panel
 * simply ends where its content does — these are short menus, so what is left
 * beside them reads as a small panel rather than as an empty half.
 */
.mega-menu--groups-only .mega-menu__groups {
	max-width: calc(var(--mega-columns, 4) * 260px);
}

.mega-menu__group {
	display: flex;
	flex-direction: column;
	gap: var(--space-md);
	min-width: 0;
}

.mega-menu__group-title {
	margin: 0;
	/* The theme's headings are italic Libre Caslon by default and .type-h5 sets
	   no style of its own, so an h3 wearing it arrives italic where the footer's
	   h2 does not. Said once, here, rather than in the shared class. */
	font-style: normal;
}

/* The heading is a link to the filter's own panel on the catalogue, where the
   terms a column of six had to leave out are. It reads as the heading it is
   until it is pointed at. */
.mega-menu__group-link {
	color: inherit;
	text-decoration: none;
	transition: color var(--transition-base);
}

.mega-menu__group-link:hover,
.mega-menu__group-link:focus-visible {
	color: var(--color-primary);
}

.mega-menu__links {
	display: flex;
	flex-direction: column;
	gap: var(--space-xs);
	margin: 0;
	padding: 0;
	list-style: none;
}

.mega-menu__link {
	display: block;
	color: var(--color-text);
	text-decoration: none;
	transition: color var(--transition-base);
}

.mega-menu__link:hover,
.mega-menu__link:focus-visible {
	color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   FEATURED

   The catalogue promo's editorial stack — eyebrow, name, sentence, ruled
   action — on the divider the UX draws between the two halves.
   -------------------------------------------------------------------------- */

.mega-menu__featured {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--space-xs);
	min-width: 0;
	padding-inline-start: var(--space-lg);
	border-inline-start: 1px solid var(--color-border-nav);
}

/*
 * Width and height are separate questions for a plate, as they were for the
 * product page's stage. The column is a fluid five twelfths, so on the wide
 * rail a plate holding its 16:9 would stand 386 tall and take the panel past
 * 740 with it. The height stops at 300; the plate letterboxes and the bottle,
 * contained, keeps its size.
 */
.mega-menu__featured-media {
	width: 100%;
	max-height: 300px;
	margin-block-end: var(--space-sm);
	overflow: hidden;
	border-radius: var(--radius-button);
	background-color: var(--color-surface-light);
}

/*
 * The UX draws a landscape plate, and what stands on it here is a bottle: the
 * spotlight's photograph is 464 x 694. Cover crops it to a band of glass, so
 * the plate behaves the way every other product surface in this theme does —
 * the theme draws the warm grey ground and the photograph is contained on it,
 * whole.
 */
.mega-menu__featured-image {
	display: block;
	width: 100%;
	height: 100%;
	/* The plate's own cap, on the image too: on the wide rail a 16:9 box is
	   taller than 300, and clipped by the plate it cut a bottle's foot off.
	   Capped here, contain letterboxes it and the whole bottle stands. */
	max-height: 300px;
	aspect-ratio: 16 / 9;
	object-fit: contain;
}

.mega-menu__featured-label {
	margin: 0;
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--color-primary);
}

.mega-menu__featured-title {
	margin: 0;
	font-family: var(--font-heading);
	font-weight: 400;
	font-size: 22px;
	line-height: 28px;
	color: var(--color-ink);
}

.mega-menu__featured-text {
	margin: 0;
	font-family: var(--font-ui);
	font-weight: 400;
	font-size: 15px;
	line-height: 22px;
	color: var(--color-text);
}

/* A featured bottle's price: the hero card's price type at the column's
   scale, one price only (no struck-through original; see inc/pricing.php). */
.mega-menu__featured-price {
	margin: 0;
	font-family: var(--font-ui);
	font-weight: 700;
	font-size: 18px;
	line-height: 26px;
	color: var(--color-ink);
}

.mega-menu__featured-price ins {
	text-decoration: none;
}

/* The catalogue's own spotlight action: a tracked label on a hairline rule. */
.mega-menu__featured-action {
	margin-block-start: var(--space-xs);
	padding-block-end: 5px;
	border-block-end: 1px solid var(--color-rose);
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: 14px;
	line-height: 20px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--color-ink);
	text-decoration: none;
	transition:
		color var(--transition-base),
		border-color var(--transition-base);
}

/* One tab stop, and the whole block clickable: the action covers it rather
   than a second link wrapping the same destination. */
.mega-menu__featured-action::after {
	content: '';
	position: absolute;
	inset: 0;
}

.mega-menu__featured-action:hover,
.mega-menu__featured-action:focus-visible {
	color: var(--color-primary);
	border-block-end-color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   PROMOTIONAL PICTURE

   The editor's campaign picture in place of the featured product (client
   19.11.2026 p.4). Same column, same divider, same top line as the product's
   plate; the category columns beside it do not move.

   The picture is whatever shape the editor uploaded — a wide banner, a square
   or a bottle-tall poster — and it is shown whole, at its own proportions:
   both sizes auto, capped by the column's width and by a height. Nothing is
   cropped (no cover), nothing is stretched (no fixed box) and there is no
   plate around it to letterbox, so the link and its focus ring are exactly
   the picture. 420 is the featured block's own height at 1440 (443 with its
   writing), so a panel with a picture is no taller than one with a bottle.
   -------------------------------------------------------------------------- */

.mega-menu__promo {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--space-sm);
	max-width: 100%;
	color: var(--color-ink);
	text-decoration: none;
}

.mega-menu__promo-image {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 420px;
	border-radius: var(--radius-button);
}

/* The optional link text: the product's "Vaata toodet", without its stretch
   (the whole link is already the picture and the text). */
.mega-menu__promo-action {
	padding-block-end: 5px;
	border-block-end: 1px solid var(--color-rose);
	font-family: var(--font-ui);
	font-weight: 600;
	font-size: 14px;
	line-height: 20px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--color-ink);
	transition:
		color var(--transition-base),
		border-color var(--transition-base);
}

.mega-menu__promo:hover .mega-menu__promo-action,
.mega-menu__promo:focus-visible .mega-menu__promo-action {
	color: var(--color-primary);
	border-block-end-color: var(--color-primary);
}

/*
 * Short laptop screens. The panel stops at the screen's foot (100vh − 145,
 * above) and scrolls, and the featured column — a plate up to 300 tall, then
 * ~210px of writing, inside 96px of padding — is what overran it: on the
 * client's 1414x645 "VAATA TOODET" ended 12px below the panel's edge, at
 * 1280x600 it was out of sight with no sign that the panel scrolls (visual QA
 * 4.11.2026, #1). Up to 880px tall (820 until 19.11.2026) the panel's padding is 24 for 48 and the
 * plate takes what the screen leaves: 100vh − 440 keeps room for a name of
 * three lines, so 160 at 600, 205 at 645, 300 again from 740. The bottle is
 * contained on the plate, so it only gets smaller.
 */
@media (min-width: 1280px) and (max-height: 880px) {

	.mega-menu__inner {
		padding-block: var(--space-md);
	}

	.mega-menu__featured-media,
	.mega-menu__featured-image {
		max-height: min(300px, max(140px, calc(100vh - 440px)));
	}

	/*
	 * A picture has no writing under it but its optional link text (≈ 50 with
	 * the gap), so it keeps more of the screen: the panel's 153 of header,
	 * 24 + 24 of padding, the link text and the scroller's 24 of margin take
	 * ≈ 270. 315 at 585, 363 at 633, the full 420 from 690.
	 */
	.mega-menu__promo-image {
		max-height: min(420px, max(160px, calc(100vh - 270px)));
	}
}

/* --------------------------------------------------------------------------
   THE NAV ITEM THAT OWNS THE OPEN PANEL

   The header already says "this one" with the ink and the 2px rule it gives a
   current page. An open panel says it the same way rather than inventing a
   second signal.
   -------------------------------------------------------------------------- */

.site-header__menu > li > a[aria-expanded='true'] {
	color: var(--color-primary-dark);
	border-bottom-color: var(--color-primary-dark);
}

/* --------------------------------------------------------------------------
   THE DRAWER

   Below 1280 the drawer is the navigation, and it carries the same hierarchy
   one level shallower. An indented list under the item it belongs to, in the
   drawer's own link language.
   -------------------------------------------------------------------------- */

/*
 * Each section folds: its name is the link to the section, and a 44px chevron
 * at the row's end opens the entries beneath it. The name keeps the row's
 * full height and the chevron's width as padding, so the two targets never
 * overlap.
 */
.site-header__drawer-menu > li {
	position: relative;
}

.site-header__drawer-menu > li > a:has(+ .site-header__drawer-toggle) {
	padding-right: 52px;
}

.site-header__drawer-toggle {
	position: absolute;
	top: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	/* The name's row: 12px + 30px line + 12px (header.css). */
	height: calc(12px * 2 + 30px);
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--color-ink);
	cursor: pointer;
	transition: color var(--transition-base);
}

.site-header__drawer-toggle svg {
	transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.site-header__drawer-toggle[aria-expanded='true'] svg {
	transform: rotate(180deg);
}

.site-header__drawer-toggle:hover,
.site-header__drawer-toggle:focus-visible {
	color: var(--color-primary);
}

.site-header__drawer-groups[hidden] {
	display: none;
}

.site-header__drawer-groups {
	display: flex;
	flex-direction: column;
	/*
	 * The rows carry their own padding to reach a thumb-sized target, so the
	 * gap between them comes off by the same amount: the list reads exactly as
	 * it did, and each link is now worth tapping at.
	 */
	margin: 0 0 var(--space-sm);
	padding: 0 0 0 var(--space-md);
	list-style: none;
}

.site-header__drawer-group {
	display: block;
	/* 10 + 24 line + 10 = 44, which is a finger. The text sits where it did. */
	padding-block: 10px;
	color: color-mix(in srgb, var(--color-text) 75%, transparent);
	text-decoration: none;
	transition: color var(--transition-base);
}

.site-header__drawer-group:hover,
.site-header__drawer-group:focus-visible {
	color: var(--color-primary);
}
