/*
 * Category merge (task #59508/#59509): the header menu's dropdowns (CategoryMenu), in the look of
 * the restyled category and product pages: a light panel with white rounded cards, orange labels
 * like the filter cards (shop-list.css), the colours and shapes of site-restyle.css (:root
 * --ps-*). Loaded only while the new structure is on (CategoryMenu::assets()), after style.css,
 * responsive.css and site-restyle.css. Desktop from 981px, mobile below it (as site.js and
 * responsive.css).
 *
 * The dropdown's markup (CategoryMenu.php) has no h4 and no ul as its direct child, so the old
 * menu's rules (#menu .menu .dropdown > ul …, .dropdown h4) don't reach into it; the rules here
 * only style that markup and, on mobile, the slide-out menu around it.
 */

/* ======================================== shared ======================================== */
#menu .menu .dropdown.cm-dd {line-height: 1.4; text-align: left; font-family: 'Ubuntu', sans-serif;}
#menu .cm-dd ul,
#menu .cm-dd li {margin: 0; padding: 0; list-style: none; background: none;}

/* labels: as the filter cards' ("SOBIVUS", "KAUBAMÄRK"), over a line that sets them off */
#menu .cm-dd .cm-title {
	margin: 0 0 10px; padding: 0 0 9px; border-bottom: 1px solid var(--ps-line);
	font-family: 'Ubuntu', sans-serif; font-size: 12px; line-height: 1.4; font-weight: 700;
	letter-spacing: .09em; text-transform: uppercase; color: var(--ps-orange);
}
/* subheadings (Üleriided, Spordijalatsid): ink, normal case, with an orange bar (as the size
   tables' active tab); the text lines up with the links */
#menu .cm-dd .cm-heading {
	margin: 0 0 4px -11px; padding: 0 0 0 8px; border-left: 3px solid var(--ps-orange);
	font-family: 'Ubuntu', sans-serif; font-size: 15px; line-height: 20px; font-weight: 700;
	letter-spacing: 0; text-transform: none; color: var(--ps-ink);
}

/* the links */
#menu .cm-dd .cm-list a {
	display: block; padding: 4px 8px; margin: 0 -8px; border-radius: var(--ps-r-sm);
	font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ps-ink); text-decoration: none;
	transition: background-color .15s, color .15s;
}
#menu .cm-dd .cm-list a:hover {background: var(--ps-tint); color: var(--ps-orange); text-decoration: none;}
#menu .cm-dd a:focus-visible,
#menu .cm-dd button:focus-visible {outline: none; box-shadow: inset 0 0 0 2px var(--ps-orange);}

/* the featured-brands collapse (site.js toggles .brands-expanded on .brands-col) */
#menu .cm-dd .brands-col:not(.brands-expanded) > .cm-list.brands-all,
#menu .cm-dd .brands-col.brands-expanded > .cm-list.brands-featured {display: none;}
#menu .menu .dropdown.cm-dd .brands-toggle {
	display: inline-block; clear: none; margin: 10px 0 0; padding: 0; font-size: 13px; line-height: 20px; font-weight: 700;
	text-transform: none; text-decoration: none; color: var(--ps-orange);
	/* only the colour: style.css transitions every property of links, visibility too, which kept
	   this link focusable for 0.2s after its dropdown had closed */
	transition: color .15s;
}
#menu .menu .dropdown.cm-dd .brands-toggle:hover {color: var(--ps-orange-dark); text-decoration: underline;}

/* ======================================== desktop ======================================== */
@media only screen and (min-width: 981px) {
	/* keyboard: a top focused from the keyboard opens its dropdown like hover does (the JS sets
	   .cm-kb-open; not :focus-within, which a mouse click on a rail entry kept open) */
	#menu .menu > li.cm-kb-open > a + .dropdown {opacity: 1; visibility: visible; margin-top: 0;}

	/* the panel: as wide as the page content (.wrapper), hanging from the menu bar like the
	   home slider (rounded bottom corners, an orange edge at the top), never taller than the
	   screen below the header. Grey behind the white cards so they stand apart. */
	#menu .menu .dropdown.cm-dd {
		--cm-inset: 40px;
		left: max(var(--cm-inset), calc(50% - 675px)); right: max(var(--cm-inset), calc(50% - 675px));
		background: var(--ps-line-strong); border: 0; border-top: 3px solid var(--ps-orange);
		border-radius: 0 0 var(--ps-r-lg) var(--ps-r-lg);
		box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
		max-height: calc(100vh - 133px); overflow-y: auto; overscroll-behavior: contain; cursor: default;
	}
	.sticky #menu .menu .dropdown.cm-dd {max-height: calc(100vh - 50px);}

	/* While a dropdown shows, the page below the menu bar is dimmed: one layer for the whole
	   menu (not one per dropdown), so moving from top to top keeps it steady instead of
	   cross-fading. It hangs from the bottom of #menu, under the dropdowns (z-index -1 in
	   #menu's stacking context) and away from the header and the menu bar; it takes no clicks,
	   and moving onto it leaves the top, which closes the dropdown as before. Browsers without
	   :has() just don't dim. */
	#menu .menu::after {
		content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 100vh; z-index: -1;
		background: rgba(17, 17, 17, .55); pointer-events: none;
		opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
	}
	#menu .menu:has(> li:hover > .dropdown, > li.cm-kb-open > .dropdown)::after {opacity: 1; visibility: visible;}
	#menu .cm-dd .cm-dd-inner {display: flex; align-items: stretch; gap: 16px; padding: 18px;}

	/* a column: a white card, as wide as its share of list columns (--cm-cols) */
	#menu .cm-dd .cm-card {
		flex: var(--cm-cols, 1) 1 0; min-width: 0; padding: 16px 20px 18px;
		background: #fff; border: 1px solid #cfcfcb; border-radius: var(--ps-r-lg);
	}
	#menu .cm-dd .cm-list {columns: var(--cm-cols, 1); column-gap: 24px;}
	#menu .cm-dd .cm-list > li {break-inside: avoid;}

	/* a column with subheadings (Rõivad, Jalatsid): groups in sub-columns, never cut in half */
	#menu .cm-dd .cm-groups {display: flex; gap: 24px;}
	#menu .cm-dd .cm-sub {flex: 1 1 0; min-width: 0;}
	#menu .cm-dd .cm-group + .cm-group {margin-top: 16px;}
	#menu .cm-dd .cm-group .cm-list {columns: 1;}

	/* Spordivahendid: the rail card on the left (one grid row per entry), the active entry's
	   panel card beside it. The last row (1fr) takes up a panel taller than the rail, so both
	   cards end level without measuring anything. */
	#menu .cm-dd-rail .cm-rail {
		display: grid; grid-template-columns: 290px minmax(0, 1fr);
		grid-template-rows: repeat(var(--cm-rows), auto) 1fr; column-gap: 16px; flex: 1 1 auto; min-width: 0;
	}
	#menu .cm-dd-rail .cm-rail::before {
		content: ""; grid-column: 1; grid-row: 1 / -1;
		background: #fff; border: 1px solid #cfcfcb; border-radius: var(--ps-r-lg);
	}
	#menu .cm-dd-rail .cm-rail > li.cm-rail-entry {display: contents;}
	#menu .cm-dd-rail .cm-rail-tab {
		grid-column: 1; grid-row: var(--cm-row); position: relative;
		display: flex; align-items: center; justify-content: space-between; gap: 10px;
		width: auto; margin: 0 6px; padding: 8px 14px; border: 0; border-radius: var(--ps-r);
		background: transparent; font-family: 'Ubuntu', sans-serif; font-size: 14px; line-height: 20px; font-weight: 500;
		color: var(--ps-ink); text-align: left; text-transform: none; cursor: pointer;
		transition: background-color .15s, color .15s;
	}
	#menu .cm-dd-rail .cm-rail > li:first-child > .cm-rail-tab {margin-top: 6px;}
	#menu .cm-dd-rail .cm-rail > li:last-child > .cm-rail-tab {margin-bottom: 6px;}
	#menu .cm-dd-rail .cm-rail-tab::after {
		content: ""; flex: none; width: 6px; height: 6px; margin-right: 2px;
		border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); opacity: .35;
	}
	#menu .cm-dd-rail .cm-rail-tab:hover {background: var(--ps-tint); color: var(--ps-orange);}
	/* the active entry: solid orange with white text, as the active top and page number */
	#menu .cm-dd-rail .cm-rail > li.cm-active > .cm-rail-tab {background: var(--ps-orange); color: #fff; font-weight: 700;}
	#menu .cm-dd-rail .cm-rail > li.cm-active > .cm-rail-tab:focus-visible {box-shadow: inset 0 0 0 2px var(--ps-ink);}
	#menu .cm-dd-rail .cm-rail > li.cm-active > .cm-rail-tab::after {opacity: 1;}

	#menu .cm-dd-rail .cm-panel {
		display: none; grid-column: 2; grid-row: 1 / -1; min-width: 0; padding: 16px 20px 18px;
		background: #fff; border: 1px solid #cfcfcb; border-radius: var(--ps-r-lg);
	}
	#menu .cm-dd-rail .cm-rail > li.cm-active > .cm-panel {display: block;}
	/* columns of about 210px, not stretched across the panel */
	#menu .cm-dd-rail .cm-panel .cm-list {max-width: calc(var(--cm-cols, 1) * 236px);}
	/* a little denser: Spordialad (70+ links) fits a 1366×768 screen with room to grow */
	#menu .cm-dd-rail .cm-panel .cm-list a {padding-top: 3px; padding-bottom: 3px;}
}

@media only screen and (min-width: 981px) and (max-width: 1200px) {
	#menu .menu .dropdown.cm-dd {--cm-inset: 15px;}
	#menu .cm-dd-rail .cm-rail {grid-template-columns: 230px minmax(0, 1fr);}
}

/* ======================================== mobile ======================================== */
@media only screen and (max-width: 980px) {
	/* the slide-out menu: wider (long names fit on one line), light like the pages, and the
	   page behind it doesn't scroll (one scrollbar); room at the end and no chat bubble or
	   "back to top" button over the last items while it is open */
	:root {--cm-drawer: min(320px, calc(100vw - 70px));}
	#menu .menu {
		width: var(--cm-drawer); right: calc(-1 * var(--cm-drawer)); padding-bottom: 32px;
		background: var(--ps-soft); overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
	}
	body.active {right: var(--cm-drawer); left: calc(-1 * var(--cm-drawer)); overflow: hidden;}
	body.active.sticky #menu {right: var(--cm-drawer); left: calc(-1 * var(--cm-drawer));}
	body.active #menu .menu {right: 0;}
	/* the strip of page beside the open menu is dimmed like the page under a desktop dropdown;
	   under #menu (z-index 99) and the header (100), so the cart, search and close button
	   stay bright, and it takes no taps */
	body::after {
		content: ""; position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 98;
		background: rgba(17, 17, 17, .55); opacity: 0; visibility: hidden; pointer-events: none;
		transition: opacity .2s, visibility .2s;
	}
	body.active::after {opacity: 1; visibility: visible;}
	body.active #back-top,
	body.active .tw-chat,
	body.active iframe[title^="Askly"] {display: none !important;}

	/* the top items */
	#menu .menu > li > a,
	#menu .menu > li:hover > a {background: #fff; color: var(--ps-ink); border-bottom: 1px solid var(--ps-line);}
	#menu .menu > li.active > a {background: #fff; color: var(--ps-orange);}
	#menu .menu > li.open > a {background: var(--ps-tint); color: var(--ps-orange); border-bottom-color: var(--ps-tint-line);}
	#menu .menu > li.pp-icon > a {color: var(--ps-orange);}
	#menu .menu > li > a .menu-arrow {background-image: url(../img/expand-arrow-black.svg); opacity: .45;}
	#menu .menu > li.open > a .menu-arrow {opacity: .8;}
	#menu .menu > li:not(.menu-secondary) + li.menu-secondary {border-top: 0; margin-top: 8px;}
	#menu .menu > li.menu-secondary > a,
	#menu .menu > li.menu-secondary:hover > a {background: transparent; color: var(--ps-text); border-bottom: 0;}

	/* an open top: its sections as white cards on the light background */
	#menu .menu .dropdown.cm-dd {padding: 8px 10px 4px; background: var(--ps-soft); border-bottom: 1px solid var(--ps-line);}
	#menu .cm-dd .cm-dd-inner {display: block;}
	#menu .cm-dd .cm-card,
	#menu .cm-dd .cm-group:not(.cm-group-plain),
	#menu .cm-dd .cm-rail > li.cm-rail-entry {
		display: block; margin: 0 0 6px; padding: 0; background: #fff; border: 1px solid var(--ps-line); border-radius: var(--ps-r); overflow: hidden;
	}
	/* Rõivad / Jalatsid: top -> subheading -> items (the column's own title "Kategooriad" is skipped) */
	#menu .cm-dd .cm-card.cm-card-grouped {background: none; border: 0; border-radius: 0; overflow: visible;}
	#menu .cm-dd .cm-card-grouped > .cm-title {display: none;}
	#menu .cm-dd .cm-group-plain {margin: 0 0 6px; background: #fff; border: 1px solid var(--ps-line); border-radius: var(--ps-r);}

	/* the section toggles: a card's title, a subheading, a rail entry */
	#menu .cm-dd .cm-card:not(.cm-card-grouped) > .cm-title,
	#menu .cm-dd .cm-heading,
	#menu .cm-dd .cm-rail-tab {
		display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin: 0;
		padding: 12px 14px; border: 0; background: transparent; cursor: pointer; text-align: left;
		font-family: 'Ubuntu', sans-serif; font-size: 15px; line-height: 20px; font-weight: 500;
		letter-spacing: 0; text-transform: none; color: var(--ps-ink);
	}
	#menu .cm-dd .cm-card:not(.cm-card-grouped) > .cm-title::after,
	#menu .cm-dd .cm-heading::after,
	#menu .cm-dd .cm-rail-tab::after {
		content: ""; flex: none; width: 7px; height: 7px; margin: -4px 3px 0 0;
		border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); opacity: .45;
		transition: transform .2s;
	}
	#menu .cm-dd .open > .cm-title,
	#menu .cm-dd .open > .cm-heading,
	#menu .cm-dd .open > .cm-rail-tab {color: var(--ps-orange); font-weight: 700;}
	#menu .cm-dd .open > .cm-title::after,
	#menu .cm-dd .open > .cm-heading::after,
	#menu .cm-dd .open > .cm-rail-tab::after {margin-top: 4px; transform: rotate(-135deg); opacity: 1;}

	/* closed sections show only their toggle */
	#menu .cm-dd .cm-card:not(.cm-card-grouped):not(.open) > .cm-list,
	#menu .cm-dd .cm-card:not(.open) > .brands-toggle,
	#menu .cm-dd .cm-group:not(.cm-group-plain):not(.open) > .cm-list,
	#menu .cm-dd .cm-rail > li:not(.open) > .cm-panel {display: none;}
	#menu .cm-dd .cm-panel {padding: 0;}
	#menu .cm-dd .cm-panel > .cm-title {display: none;}

	/* the links: one column, rows easy to tap */
	#menu .cm-dd .cm-list {columns: 1; padding: 0 0 6px;}
	#menu .cm-dd .cm-list a {margin: 0; padding: 9px 14px 9px 22px; border-radius: 0; font-size: 15px;}
	#menu .cm-dd .cm-list a:hover {background: var(--ps-soft);}
	#menu .cm-dd .cm-group-plain .cm-list {padding: 6px 0;}
	#menu .menu .dropdown.cm-dd .brands-toggle {margin: 0 0 12px 22px;}
}

/* ===================== menu headings with a page (task #59697, CategoryHeading) ===================== */
/* in the menu: the heading text is the link (desktop); "Vaata kõiki" opens it on mobile */
#menu .cm-dd .cm-heading a,
#menu .cm-dd .cm-title a {color: inherit; text-decoration: none;}
#menu .cm-dd .cm-list > li.cm-all {display: none;}
@media only screen and (min-width: 981px) {
	#menu .cm-dd .cm-heading a:hover {color: var(--ps-orange); text-decoration: underline;}
	#menu .cm-dd .cm-title a::after {content: " \203A"; letter-spacing: 0;}
	#menu .cm-dd .cm-title a:hover {color: var(--ps-orange-dark); text-decoration: underline;}
}
@media only screen and (max-width: 980px) {
	#menu .cm-dd .cm-list > li.cm-all {display: block;}
	#menu .cm-dd .cm-list > li.cm-all a {font-weight: 700; color: var(--ps-orange);}
}

/* a Rõivad / Jalatsid heading's page: the category pills on their row (the "Kellele" control below them) */
.cm-heading-filters {margin: 0 0 12px;}
.cm-heading-filters .landing-quick-links {margin: 0;}
.cm-heading-filters .landing-quick-links small {margin-left: 5px; font-weight: 400; opacity: .75;}

/* The gender choice "Kellele: Kõik | Mehed | Naised | Lapsed" (CategoryGender::control()): one control, always
   on its own row, on category pages, gender landing pages and heading pages */
.cm-gender-row {display: block; clear: both; margin: 0 0 20px;}
.cm-gender {display: inline-flex; flex-wrap: nowrap; gap: 2px; margin: 0; padding: 3px; list-style: none; background: var(--ps-soft); border: 1px solid var(--ps-line-strong); border-radius: 999px;}
.cm-gender li {margin: 0; padding: 0; list-style: none;}
.cm-gender .cm-gender-label {padding: 6px 4px 6px 10px; font-size: 13px; line-height: 1.4; color: #7a7a7a; white-space: nowrap;}
.cm-gender a {display: block; padding: 6px 14px; border-radius: 999px; font-size: 13px; line-height: 1.4; font-weight: 600; color: var(--ps-text); white-space: nowrap; text-decoration: none;}
.cm-gender a:hover {color: var(--ps-orange);}
.cm-gender a.active {background: var(--ps-ink); color: #fff;}
.cm-gender a:focus-visible {outline: none; box-shadow: 0 0 0 2px var(--ps-orange);}

/* a Spordivahendid group's page: category tiles, then its newest products; no filter column */
#content:has(.cm-hub) > .sidebar {display: none;}
#content:has(.cm-hub) > .page-content {width: 100%; float: none; margin-left: 0; padding-left: 0;}
.cm-hub-tiles {display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin: 0 0 36px; padding: 0; list-style: none;}
.cm-hub-tiles a {display: block; height: 100%; padding: 12px 12px 14px; background: #fff; border: 1px solid var(--ps-line); border-radius: var(--ps-r-card); transition: box-shadow .2s, border-color .2s, transform .2s;}
.cm-hub-tiles a:hover {border-color: var(--ps-tint-line); box-shadow: 0 10px 26px rgba(0, 0, 0, .08); transform: translateY(-2px);}
.cm-hub-tiles .cm-hub-img {aspect-ratio: 282 / 205; margin-bottom: 12px; border-radius: var(--ps-r); background: #fff center / contain no-repeat;}
.cm-hub-tiles strong {display: block; font-size: 15px; line-height: 1.3; font-weight: 700; color: var(--ps-ink);}
.cm-hub-tiles em {display: block; margin-top: 4px; font-style: normal; font-size: 13px; color: #7a7a7a;}
.cm-hub-tiles a:hover strong {color: var(--ps-orange);}
.cm-hub-new {margin-top: 0;}

@media only screen and (max-width: 980px) {
	.cm-heading-filters {margin-bottom: 10px;}
	.cm-heading-filters .landing-quick-links {flex-wrap: nowrap; overflow-x: auto; margin: 0 -15px 0 0; padding-right: 15px; scrollbar-width: none;}
	.cm-heading-filters .landing-quick-links li {flex: none;}
	.cm-gender {display: flex; width: 100%; box-sizing: border-box;}
	.cm-gender li {flex: 1 1 0; text-align: center;}
	.cm-gender .cm-gender-label {display: none;}
}
@media only screen and (max-width: 640px) {
	.cm-hub-tiles {grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;}
	.cm-hub-tiles a {padding: 8px 8px 10px; border-radius: 12px;}
	.cm-hub-tiles strong {font-size: 14px;}
}

/* Gender buttons and landing quick links without the brand block (task #59509), as the brand hubs' */
.landing-quick-links {display: flex; flex-wrap: wrap; gap: 8px; margin: 15px 0; padding: 0; list-style: none;}
.landing-quick-links a {display: inline-block; padding: 6px 14px; border: 1px solid #E56524; border-radius: 20px; color: #E56524; font-weight: bold;}
.landing-quick-links a:hover,
.landing-quick-links a.active {background: #E56524; color: #fff;}
