/* ==========================================================================
   Category Navigator for WooCommerce
   Single-class selectors + a zero-specificity reset: easy to override from the theme.
   Tokens: --tcn-accent, --tcn-radius, --tcn-container (set from settings).
   ========================================================================== */

:root {
	--tcn-accent: #d0021b;
	--tcn-radius: 10px;
	--tcn-container: 1280px;
	--tcn-ink: #16181d;
	--tcn-muted: #5f6673;
	--tcn-line: #e4e6ea;
	--tcn-soft: #f5f6f8;
	--tcn-bg: #fff;
	--tcn-shadow: 0 18px 50px -12px rgba(16, 24, 40, .22), 0 4px 12px -4px rgba(16, 24, 40, .08);
	--tcn-ease: cubic-bezier(.2, .7, .2, 1);
}

:where(.tcn-ch, .tcn-mm) *,
:where(.tcn-ch, .tcn-mm) *::before,
:where(.tcn-ch, .tcn-mm) *::after { box-sizing: border-box; }

:where(.tcn-ch, .tcn-mm) ul { list-style: none; margin: 0; padding: 0; }
:where(.tcn-ch, .tcn-mm) a { text-decoration: none; }
:where(.tcn-ch, .tcn-mm) img { display: block; max-width: 100%; height: auto; }

/* ==========================================================================
   1. CATEGORY HEADER
   ========================================================================== */

.tcn-ch {
	margin: 0 0 clamp(24px, 4vw, 40px);
	color: var(--tcn-ink);
}

.tcn-ch__intro { max-width: 820px; margin-bottom: clamp(18px, 3vw, 28px); }

.tcn-ch__back {
	display: inline-flex; align-items: center; gap: 4px;
	margin-bottom: 8px;
	font-size: .875rem; font-weight: 500;
	color: var(--tcn-muted);
	transition: color .15s;
}
.tcn-ch__back:hover { color: var(--tcn-accent); }

.tcn-ch__title {
	margin: 0;
	font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem);
	line-height: 1.1;
	letter-spacing: -.02em;
}

.tcn-ch__meta {
	margin: 10px 0 0;
	font-size: .9rem;
	color: var(--tcn-muted);
}

.tcn-ch__desc { margin-top: 14px; color: var(--tcn-muted); line-height: 1.6; }
.tcn-ch__desc > :last-child { margin-bottom: 0; }

/* Sub-category cards */
.tcn-ch__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
	gap: 16px;
}

.tcn-card {
	display: flex; flex-direction: column; height: 100%;
	background: var(--tcn-bg);
	border: 1px solid var(--tcn-line);
	border-radius: var(--tcn-radius);
	overflow: hidden;
	color: var(--tcn-ink);
	transition: border-color .2s, box-shadow .2s, transform .2s var(--tcn-ease);
}
.tcn-card:hover,
.tcn-card:focus-visible {
	border-color: var(--tcn-accent);
	box-shadow: 0 10px 28px -12px rgba(16, 24, 40, .28);
	transform: translateY(-2px);
	color: var(--tcn-ink);
}
.tcn-card:focus-visible { outline: 2px solid var(--tcn-accent); outline-offset: 2px; }

.tcn-card__media {
	display: block;
	aspect-ratio: 1 / 1;
	padding: 12%;
	background: #fff;
	border-bottom: 1px solid var(--tcn-line);
}
.tcn-card__media img {
	width: 100%; height: 100%;
	object-fit: contain;
	transition: transform .35s var(--tcn-ease);
}
.tcn-card:hover img { transform: scale(1.05); }

.tcn-card__body { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 14px; }
.tcn-card__name { font-weight: 600; font-size: .95rem; line-height: 1.3; }
.tcn-card__count { font-size: .8rem; color: var(--tcn-muted); }

/* Sibling chips (leaf categories) */
.tcn-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tcn-chip {
	display: inline-flex; align-items: center;
	min-height: 38px; padding: 6px 16px;
	border: 1px solid var(--tcn-line); border-radius: 999px;
	background: var(--tcn-bg);
	font-size: .9rem; font-weight: 500; color: var(--tcn-ink);
	transition: border-color .15s, background .15s, color .15s;
}
.tcn-chip:hover { border-color: var(--tcn-accent); color: var(--tcn-accent); }
.tcn-chip[aria-current="page"] { background: var(--tcn-accent); border-color: var(--tcn-accent); color: #fff; }

@media (max-width: 767px) {
	.tcn-ch--m-scroll .tcn-ch__grid {
		grid-template-columns: none;
		grid-auto-flow: column;
		grid-auto-columns: 42%;
		gap: 12px;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: 16px;
		margin-inline: -16px;
		padding: 2px 16px 10px;
		scrollbar-width: none;
	}
	.tcn-ch--m-scroll .tcn-ch__grid::-webkit-scrollbar { display: none; }
	.tcn-ch--m-scroll .tcn-ch__grid > li { scroll-snap-align: start; }

	.tcn-ch--m-grid .tcn-ch__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

	.tcn-card__body { padding: 10px 12px 12px; }
	.tcn-card__name { font-size: .875rem; }

	.tcn-chips {
		flex-wrap: nowrap; overflow-x: auto;
		margin-inline: -16px; padding: 0 16px 6px;
		scrollbar-width: none;
	}
	.tcn-chips::-webkit-scrollbar { display: none; }
	.tcn-chip { white-space: nowrap; }
}

/* ==========================================================================
   2. MEGA MENU — shared
   ========================================================================== */

.tcn-mm { position: relative; display: inline-flex; color: var(--tcn-ink); font-size: 15px; }
.tcn-mm-item { display: flex; align-items: center; }
.tcn-mm--portal { display: block; position: static; }

.tcn-mm__toggle {
	display: inline-flex; align-items: center; gap: 8px;
	min-height: 42px; padding: 8px 16px;
	border: 0; border-radius: var(--tcn-radius);
	background: var(--tcn-accent); color: #fff;
	font: inherit; font-weight: 600; line-height: 1;
	cursor: pointer;
	transition: filter .15s;
}
.tcn-mm__toggle:hover { filter: brightness(1.08); }
.tcn-mm__toggle:focus-visible { outline: 2px solid var(--tcn-accent); outline-offset: 3px; }
.tcn-mm__chev { transition: transform .2s var(--tcn-ease); }
.tcn-mm.is-open .tcn-mm__chev { transform: rotate(180deg); }

.tcn-mm__panel[hidden] { display: none !important; }

.tcn-mm__sheet { background: var(--tcn-bg); color: var(--tcn-ink); }

.tcn-mm a { color: inherit; }
.tcn-mm a:focus-visible,
.tcn-mm button:focus-visible { outline: 2px solid var(--tcn-accent); outline-offset: -2px; }

.tcn-mm__thumb {
	flex: 0 0 auto;
	display: grid; place-items: center;
	width: 40px; height: 40px;
	padding: 4px;
	border-radius: calc(var(--tcn-radius) * .6);
	background: #fff;
	border: 1px solid var(--tcn-line);
	overflow: hidden;
}
.tcn-mm__thumb img { width: 100%; height: 100%; object-fit: contain; }

.tcn-mm__label { flex: 1 1 auto; min-width: 0; }
.tcn-mm__count {
	flex: 0 0 auto;
	font-size: .75rem; font-weight: 500;
	color: var(--tcn-muted);
	background: var(--tcn-soft);
	border-radius: 999px; padding: 2px 8px;
}

.tcn-mm__search { position: relative; flex: 1 1 auto; max-width: 420px; }
.tcn-mm__search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--tcn-muted); pointer-events: none; }
.tcn-mm__q {
	width: 100%; height: 42px;
	padding: 0 14px 0 40px !important;
	border: 1px solid var(--tcn-line) !important;
	border-radius: 999px !important;
	background: var(--tcn-soft) !important;
	font: inherit; color: var(--tcn-ink);
	box-shadow: none !important;
}
.tcn-mm__q:focus { outline: none; border-color: var(--tcn-accent) !important; background: #fff !important; }

.tcn-mm__close, .tcn-mm__backbtn, .tcn-mm__expand {
	display: inline-flex; align-items: center; justify-content: center;
	border: 0; background: none; color: inherit; font: inherit; cursor: pointer; padding: 0;
}

.tcn-mm__all {
	display: inline-flex; align-items: center; gap: 4px;
	font-size: .875rem; font-weight: 600;
	color: var(--tcn-accent) !important;
	white-space: nowrap;
}
.tcn-mm__all:hover { text-decoration: underline; }

.tcn-mm a[aria-current="page"] { color: var(--tcn-accent) !important; font-weight: 600; }

/* Search results */
.tcn-mm__results { padding: 8px; }
.tcn-mm__results a {
	display: flex; flex-direction: column; gap: 2px;
	padding: 10px 14px; border-radius: calc(var(--tcn-radius) * .6);
}
.tcn-mm__results a:hover,
.tcn-mm__results a:focus { background: var(--tcn-soft); outline: none; }
.tcn-mm__results strong { font-weight: 600; }
.tcn-mm__results mark { background: none; color: var(--tcn-accent); font-weight: 700; padding: 0; }
.tcn-mm__path { font-size: .8rem; color: var(--tcn-muted); }
.tcn-mm__empty { padding: 24px 14px; color: var(--tcn-muted); text-align: center; margin: 0; }
.tcn-mm.is-searching .tcn-mm__roots, .tcn-mm.is-searching .tcn-mm__panes { display: none !important; }

/* ==========================================================================
   3. MEGA MENU — desktop (JS adds .is-desktop)
   ========================================================================== */

.tcn-mm.is-desktop .tcn-mm__panel {
	position: fixed;
	left: 0; right: 0;
	top: var(--tcn-top, 80px);
	z-index: 9990;
	padding: 0 20px;
	pointer-events: none;
}
.tcn-mm.is-desktop .tcn-mm__backdrop {
	position: fixed; inset: var(--tcn-top, 80px) 0 0 0;
	background: rgba(16, 24, 40, .32);
	pointer-events: auto;
	animation: tcn-fade .2s ease both;
}
.tcn-mm.is-desktop .tcn-mm__sheet {
	position: relative;
	max-width: var(--tcn-container);
	margin: 8px auto 0;
	border-radius: var(--tcn-radius);
	box-shadow: var(--tcn-shadow);
	overflow: hidden;
	pointer-events: auto;
	display: flex; flex-direction: column;
	max-height: calc(100vh - var(--tcn-top, 80px) - 32px);
	animation: tcn-drop .22s var(--tcn-ease) both;
}
.tcn-mm.is-desktop .tcn-mm__head {
	display: flex; align-items: center; gap: 16px;
	padding: 14px 20px;
	border-bottom: 1px solid var(--tcn-line);
}
.tcn-mm.is-desktop .tcn-mm__heading { font-weight: 700; font-size: 1rem; margin-right: auto; }
.tcn-mm.is-desktop .tcn-mm__close { width: 38px; height: 38px; border-radius: 50%; color: var(--tcn-muted); }
.tcn-mm.is-desktop .tcn-mm__close:hover { background: var(--tcn-soft); color: var(--tcn-ink); }

.tcn-mm.is-desktop .tcn-mm__body {
	display: grid;
	grid-template-columns: 290px minmax(0, 1fr);
	min-height: 0; flex: 1 1 auto;
}
.tcn-mm.is-desktop.is-searching .tcn-mm__body { display: block; overflow-y: auto; }

.tcn-mm.is-desktop .tcn-mm__roots {
	background: var(--tcn-soft);
	border-right: 1px solid var(--tcn-line);
	padding: 10px;
	overflow-y: auto;
	overscroll-behavior: contain;
}
.tcn-mm.is-desktop .tcn-mm__root {
	display: flex; align-items: center; gap: 10px;
	padding: 7px 10px;
	border-radius: calc(var(--tcn-radius) * .6);
	font-weight: 500; line-height: 1.25;
	transition: background .12s, color .12s;
}
.tcn-mm.is-desktop .tcn-mm__root > svg { flex: 0 0 auto; opacity: .45; }
.tcn-mm.is-desktop .tcn-mm__root.is-active {
	background: var(--tcn-bg);
	color: var(--tcn-accent);
	box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
}
.tcn-mm.is-desktop .tcn-mm__root.is-active > svg { opacity: 1; }
.tcn-mm.is-desktop .tcn-mm__root .tcn-mm__thumb { width: 34px; height: 34px; }

.tcn-mm.is-desktop .tcn-mm__panes { overflow-y: auto; overscroll-behavior: contain; }
.tcn-mm.is-desktop .tcn-mm__pane { padding: 20px 24px 28px; animation: tcn-fade .18s ease both; }
.tcn-mm.is-desktop .tcn-mm__backbtn { display: none; }
.tcn-mm.is-desktop .tcn-mm__pane-head {
	display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
	padding-bottom: 14px; margin-bottom: 18px;
	border-bottom: 1px solid var(--tcn-line);
}
.tcn-mm.is-desktop .tcn-mm__pane-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; }
.tcn-mm.is-desktop .tcn-mm__pane-title:hover { color: var(--tcn-accent); }

.tcn-mm.is-desktop .tcn-mm__pane-body { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 28px; }
.tcn-mm.is-desktop .tcn-mm__cols {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
	gap: 22px 24px;
	align-content: start;
}
.tcn-mm.is-desktop .tcn-mm__l2 {
	display: flex; align-items: center; gap: 10px;
	font-weight: 600; line-height: 1.25;
}
.tcn-mm.is-desktop .tcn-mm__l2:hover { color: var(--tcn-accent); }
.tcn-mm.is-desktop .tcn-mm__expand { display: none; }
.tcn-mm.is-desktop .tcn-mm__l3 { margin: 8px 0 0 50px; display: grid; gap: 2px; }
.tcn-mm.is-desktop .tcn-mm__l3 a {
	display: flex; gap: 6px; align-items: center;
	padding: 3px 0; font-size: .9rem; color: var(--tcn-muted); line-height: 1.3;
}
.tcn-mm.is-desktop .tcn-mm__l3 a:hover { color: var(--tcn-accent); }
.tcn-mm.is-desktop .tcn-mm__seeall { font-weight: 600; color: var(--tcn-ink) !important; }

.tcn-mm.is-desktop .tcn-mm__feature {
	position: sticky; top: 0;
	display: flex; flex-direction: column; gap: 10px;
	align-self: start;
	padding: 16px;
	border-radius: var(--tcn-radius);
	background: var(--tcn-soft);
	font-weight: 600; text-align: center;
}
.tcn-mm.is-desktop .tcn-mm__feature img { aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: calc(var(--tcn-radius) * .6); padding: 10%; }

@media (max-width: 1180px) {
	.tcn-mm.is-desktop .tcn-mm__pane-body { grid-template-columns: minmax(0, 1fr); }
	.tcn-mm.is-desktop .tcn-mm__feature { display: none; }
}

/* ==========================================================================
   4. MEGA MENU — mobile drawer with drill-down (JS adds .is-mobile)
   ========================================================================== */

.tcn-mm.is-mobile .tcn-mm__toggle { padding: 8px 12px; }

.tcn-mm.is-mobile .tcn-mm__panel { position: fixed; inset: 0; z-index: 100000; }
.tcn-mm.is-mobile .tcn-mm__backdrop {
	position: absolute; inset: 0;
	background: rgba(16, 24, 40, .45);
	animation: tcn-fade .2s ease both;
}
.tcn-mm.is-mobile .tcn-mm__sheet {
	position: absolute; top: 0; bottom: 0; left: 0;
	width: min(420px, 92vw);
	display: flex; flex-direction: column;
	box-shadow: var(--tcn-shadow);
	animation: tcn-slide .26s var(--tcn-ease) both;
	padding-bottom: env(safe-area-inset-bottom);
}
.tcn-mm.is-mobile .tcn-mm__head {
	display: grid;
	grid-template-columns: 1fr auto;
	grid-template-areas: "title close" "search search";
	align-items: center; gap: 10px 8px;
	padding: 12px 12px 12px 18px;
	border-bottom: 1px solid var(--tcn-line);
}
.tcn-mm.is-mobile .tcn-mm__heading { grid-area: title; font-weight: 700; font-size: 1.1rem; }
.tcn-mm.is-mobile .tcn-mm__close { grid-area: close; width: 44px; height: 44px; border-radius: 50%; }
.tcn-mm.is-mobile .tcn-mm__search { grid-area: search; max-width: none; margin-right: 6px; }

.tcn-mm.is-mobile .tcn-mm__body { position: relative; flex: 1 1 auto; overflow: hidden; }
.tcn-mm.is-mobile.is-searching .tcn-mm__body { overflow-y: auto; }

.tcn-mm.is-mobile .tcn-mm__roots,
.tcn-mm.is-mobile .tcn-mm__panes {
	position: absolute; inset: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	transition: transform .28s var(--tcn-ease), visibility .28s;
	background: var(--tcn-bg);
}
.tcn-mm.is-mobile .tcn-mm__roots { padding: 6px 0; }
.tcn-mm.is-mobile .tcn-mm__panes { transform: translateX(100%); visibility: hidden; }
.tcn-mm.is-mobile.is-drilled .tcn-mm__roots { transform: translateX(-25%); visibility: hidden; }
.tcn-mm.is-mobile.is-drilled .tcn-mm__panes { transform: none; visibility: visible; }

.tcn-mm.is-mobile .tcn-mm__root {
	display: flex; align-items: center; gap: 12px;
	min-height: 56px; padding: 8px 16px 8px 18px;
	font-weight: 500;
	border-bottom: 1px solid var(--tcn-line);
}
.tcn-mm.is-mobile .tcn-mm__root > svg { flex: 0 0 auto; color: var(--tcn-muted); }

.tcn-mm.is-mobile .tcn-mm__pane-head {
	position: sticky; top: 0; z-index: 1;
	display: grid; grid-template-columns: 1fr; gap: 2px; justify-items: start;
	padding: 6px 16px 14px;
	background: var(--tcn-bg);
	border-bottom: 1px solid var(--tcn-line);
}
.tcn-mm.is-mobile .tcn-mm__backbtn {
	gap: 4px; min-height: 44px; margin-left: -6px; padding: 0 6px;
	font-size: .9rem; color: var(--tcn-muted);
}
.tcn-mm.is-mobile .tcn-mm__pane-title { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.tcn-mm.is-mobile .tcn-mm__all { min-height: 32px; }
.tcn-mm.is-mobile .tcn-mm__feature { display: none; }

.tcn-mm.is-mobile .tcn-mm__col { border-bottom: 1px solid var(--tcn-line); }
.tcn-mm.is-mobile .tcn-mm__l2row { display: flex; align-items: stretch; }
.tcn-mm.is-mobile .tcn-mm__l2 {
	flex: 1 1 auto;
	display: flex; align-items: center; gap: 12px;
	min-height: 56px; padding: 8px 8px 8px 18px;
	font-weight: 500;
}
.tcn-mm.is-mobile .tcn-mm__expand {
	flex: 0 0 56px; border-left: 1px solid var(--tcn-line); color: var(--tcn-muted);
}
.tcn-mm.is-mobile .tcn-mm__expand svg { transition: transform .2s var(--tcn-ease); }
.tcn-mm.is-mobile .tcn-mm__expand[aria-expanded="true"] svg { transform: rotate(180deg); }
.tcn-mm.is-mobile .tcn-mm__l3 { display: none; padding: 0 0 10px 70px; background: var(--tcn-soft); }
.tcn-mm.is-mobile .tcn-mm__l3.is-open { display: block; padding-top: 6px; }
.tcn-mm.is-mobile .tcn-mm__l3 a { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: .95rem; }

html.tcn-lock, html.tcn-lock body { overflow: hidden !important; }

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes tcn-fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes tcn-drop  { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes tcn-slide { from { transform: translateX(-100%); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
	:where(.tcn-ch, .tcn-mm) *,
	:where(.tcn-ch, .tcn-mm) *::before,
	:where(.tcn-ch, .tcn-mm) *::after { animation: none !important; transition: none !important; }
}
