/* ==========================================================================
   CMSELL B2B · Stage 21 rev C — All Categories flyout
   1:1 with the live alibaba.com mega panel, measured 2026-11-23 on the
   logged-in site (real DOM + getComputedStyle, screenshots in
   preview/ali-nav-rev/):
     trigger        hover shows a 2px #222 underline; text colour unchanged
     panel          width 100vw-95, height 445, flush under the 40px bar,
                    no shadow / radius / border / page overlay
     left column    360px, white, 1px #DDD divider; rows 50px, photo icon
                    28x28, title 16px/400 #222; active row = bg #F4F4F4 +
                    4px #222 left bar + weight 600 (colour unchanged)
     right column   white, scrollable; units stacked vertically, each
                    margin-top 12px, padding 0 24px; header 20px/500 +
                    right link 14px/400; leaf grid 7/row, leaf 122x150,
                    round 98x98 photo well (real product photo,
                    object-fit cover), caption 14px mt 8px lh 22 centred;
                    leaf hover scales the photo 1.2x; "view all" card is
                    the LAST cell.
   Colour note: Alibaba panel text is rgb(34,34,34) — intentionally not the
   site token --cm-ink (#121A22). Fixed per measured value (rule 4 layer:
   panel-internal replica colour, annotated here as required).
   Breakpoints mirror home.css: 1280 / 1120 / 960 / 720.
   ========================================================================== */

/* Icon sprite + reusable icon element (view-all card still uses a line icon) */
.cm-nav-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.cm-nico { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Panel-local replica ink + hover grey (measured values) */
.cm-mega--tree {
	--nav-ink: #222;
	--nav-hover: #F4F4F4;
}

/* --------------------------------------------------------------------------
   Trigger — hover underline (measured: 2px solid #222, full button width)
   -------------------------------------------------------------------------- */
.cm-cat__btn { position: relative; }
.cm-cat__btn::after {
	content: '';
	position: absolute; left: 0; right: 0; bottom: 2px;
	height: 2px; background: var(--nav-ink, #222);
	transform: scaleX(0);
	transition: transform .15s var(--cm-ease, ease);
}
.cm-cat__btn:hover { color: var(--nav-ink, #222); }
.cm-cat__btn:hover::after,
.cm-cat__btn[aria-expanded='true']::after { transform: scaleX(1); }

/* --------------------------------------------------------------------------
   Panel shell — no outer border / shadow / radius / overlay (as measured)
   -------------------------------------------------------------------------- */
.cm-mega--tree {
	left: -40px;
	top: 100%;
	width: min(1345px, calc(100vw - 95px));
	height: 445px;
	display: none;
	background: var(--cm-surface);
	padding: 0;
	gap: 0;
	overflow: hidden;
}
.cm-mega--tree.is-open { display: flex; }

/* --------------------------------------------------------------------------
   Left column — the L2 directory (360px, scrollable, 1px #DDD divider)
   -------------------------------------------------------------------------- */
.cm-mega--tree .cm-mega__level1 {
	flex: 0 0 360px;
	width: 360px;
	min-width: 0;
	height: 100%;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--cm-surface);
	border-right: 1px solid var(--cm-head-line);
}
.cm-mega--tree .cm-mega__cate {
	display: flex; align-items: center; gap: 8px;
	height: 50px; padding: 0 12px;
	border-left: 4px solid transparent;
	color: var(--nav-ink);
}
.cm-mega--tree .cm-mega__cate:hover,
.cm-mega--tree .cm-mega__cate.is-active { background: var(--nav-hover); }
.cm-mega--tree .cm-mega__cate.is-active { border-left-color: var(--nav-ink); }
.cm-mega--tree .cm-mega__cico {
	flex: 0 0 28px; width: 28px; height: 28px;
	display: block;
}
.cm-mega--tree .cm-mega__cico img {
	width: 28px; height: 28px;
	object-fit: contain; display: block;
}
.cm-mega--tree .cm-mega__ctitle {
	font-size: var(--cm-fs-md); font-weight: 400; color: var(--nav-ink);
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cm-mega--tree .cm-mega__cate:hover .cm-mega__ctitle,
.cm-mega--tree .cm-mega__cate.is-active .cm-mega__ctitle { font-weight: 600; }

/* --------------------------------------------------------------------------
   Right column — units stacked vertically inside a scrollable list
   -------------------------------------------------------------------------- */
.cm-mega--tree .cm-mega__level3 {
	flex: 1 1 auto; min-width: 0;
	height: 100%;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--cm-surface);
}
.cm-mega--tree .cm-mega__unit { margin-top: 12px; padding: 0 24px; }
.cm-mega--tree .cm-mega__unit:first-child { margin-top: 12px; }

.cm-mega--tree .cm-mega__uhead {
	display: flex; align-items: center; justify-content: space-between; gap: 24px;
	height: 26px;
}
.cm-mega--tree .cm-mega__uhead h3 {
	font-size: var(--cm-fs-lg); font-weight: 500; color: var(--nav-ink);
	line-height: 26px; margin: 0;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cm-mega--tree .cm-mega__ulink {
	font-size: var(--cm-fs-base); font-weight: 400; color: var(--nav-ink);
	white-space: nowrap; flex: 0 0 auto;
}
.cm-mega--tree .cm-mega__ulink:hover { color: var(--nav-ink); text-decoration: underline; }

/* Leaf grid — 7 per row, 122x150 cells, 98x98 round photo, 24px row gap */
.cm-mega--tree .cm-mega__leafs {
	display: flex; flex-wrap: wrap; align-content: flex-start;
	gap: 24px 11px;
	margin-top: 24px;
}
.cm-mega--tree .cm-mega__leaf {
	flex: 0 0 122px; width: 122px; height: 150px;
	display: flex; flex-direction: column; align-items: center;
}
.cm-mega--tree .cm-mega__leafico {
	width: 98px; height: 98px;
	border-radius: var(--cm-r-pill);
	overflow: hidden;
	display: block;
	background: var(--cm-surface-2);
}
.cm-mega--tree .cm-mega__leafico img {
	width: 98px; height: 98px;
	object-fit: cover; display: block;
	transition: transform .3s var(--cm-ease, ease);
}
/* measured leaf hover: the photo scales to 1.2 inside the round well */
.cm-mega--tree .cm-mega__leaf:hover .cm-mega__leafico img { transform: scale(1.2); }
.cm-mega--tree .cm-mega__leaftitle {
	margin-top: 8px; max-width: 122px; min-height: 44px;
	font-size: var(--cm-fs-base); font-weight: 400; line-height: 22px;
	color: var(--nav-ink); text-align: center;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* view-all card — LAST cell: grey round well with the grid line icon */
.cm-mega--tree .cm-mega__leaf--all .cm-mega__leafico {
	display: grid; place-items: center;
	color: var(--cm-ink-2);
}

/* --------------------------------------------------------------------------
   Responsive — aligned with home.css breakpoints
   -------------------------------------------------------------------------- */
@media (max-width: 1280px) {
	.cm-mega--tree { left: -40px; width: calc(100vw - 80px); }
	.cm-mega--tree .cm-mega__level1 { flex-basis: 320px; width: 320px; }
}
@media (max-width: 1120px) {
	.cm-mega--tree .cm-mega__level1 { flex-basis: 300px; width: 300px; }
}
@media (max-width: 960px) {
	.cm-mega--tree .cm-mega__level1 { flex-basis: 260px; width: 260px; }
	.cm-mega--tree .cm-mega__unit { padding: 0 16px; }
}
@media (max-width: 720px) {
	/* .cm-navbar is hidden by home.css; the drawer takes over. */
	.cm-mega--tree { display: none !important; }
}
