/*
 * Product category navigation — replaces the flat text list.
 *
 * Goals: show hierarchy, show how many products are in each branch, make the current position
 * obvious, and give a real click target instead of a 10px "+".
 */
.cn-nav {
    --cn-accent: var(--color-1st, #9b2321);
    --cn-border: #e7e9ee;
    --cn-text: #2c3340;
    --cn-muted: #8b93a3;
}

/* Header ------------------------------------------------------------------- */
.cn-nav__title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--cn-border);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .01em;
    color: var(--cn-text);
    text-transform: none;
}

.cn-nav__title::after {
    content: '';
    flex: none;
    width: 26px;
    height: 3px;
    border-radius: 3px;
    background: var(--cn-accent);
}

/* Reset link (only while a category filter is on) */
.cn-reset {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--cn-muted);
    text-decoration: none;
}

.cn-reset:hover { color: var(--cn-accent); }

/* Lists -------------------------------------------------------------------- */
.cn-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cn-item { position: relative; }

.cn-row {
    display: flex;
    align-items: stretch;
    border-radius: 3px;
    transition: background-color .15s ease;
}

.cn-row:hover { background: #f6f7f9; }

.cn-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex: 1;
    min-width: 0;
    padding: 10px 10px 10px 12px;
    color: var(--cn-text);
    text-decoration: none;
    line-height: 1.35;
    transition: color .15s ease;
}

.cn-link:hover { color: var(--cn-accent); text-decoration: none; }

.cn-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Product count — the thing the old list was missing entirely. */
.cn-count {
    flex: none;
    min-width: 22px;
    padding: 1px 6px;
    border-radius: 3px;
    background: #f0f1f4;
    color: var(--cn-muted);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    transition: background-color .15s ease, color .15s ease;
}

.cn-row:hover .cn-count { background: #e6e8ec; color: #5a6273; }

/* Expand / collapse button — a real 34px target, not a 10px plus sign. */
.cn-toggle {
    flex: none;
    width: 34px;
    border: none;
    background: none;
    padding: 0;
    color: var(--cn-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
}

.cn-toggle:hover { color: var(--cn-accent); }
.cn-toggle svg { transition: transform .22s ease; }
.cn-item.is-open > .cn-row > .cn-toggle svg { transform: rotate(-180deg); }

/* Top level ---------------------------------------------------------------- */
.cn-list:not(.cn-list--sub) > .cn-item > .cn-row > .cn-link {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .02em;
}

.cn-list:not(.cn-list--sub) > .cn-item + .cn-item {
    border-top: 1px solid #f1f2f5;
}

/* Sub levels — depth is carried by the indent and the lighter type, no guide line. */
.cn-list--sub {
    position: relative;
    margin-left: 12px;
    padding: 2px 0 6px;
}

.cn-list--sub .cn-link {
    padding-top: 7px;
    padding-bottom: 7px;
    padding-left: 14px;
    font-size: 13px;
    font-weight: 500;
    color: #5a6273;
}

.cn-list--sub .cn-link:hover { color: var(--cn-accent); }
.cn-list--sub .cn-count { font-size: 10px; }

/* Third level sits slightly lighter again, so depth is never ambiguous. */
.cn-list--sub .cn-list--sub .cn-link { font-size: 12.5px; color: #6c7484; }

/*
 * Animated open/close with no fixed height: 0fr -> 1fr on a grid row lets the browser animate to
 * the content's natural height, which max-height guessing never does properly.
 */
.cn-sub {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .24s ease;
}

.cn-item.is-open > .cn-sub { grid-template-rows: 1fr; }
.cn-sub__inner { overflow: hidden; }

/* Active state — no left bar; the tint, the red label and the red count carry it. */
.cn-item.is-active > .cn-row {
    background: color-mix(in srgb, var(--cn-accent) 7%, transparent);
}

.cn-item.is-active > .cn-row > .cn-link,
.cn-item.is-active > .cn-row > .cn-link .cn-name {
    color: var(--cn-accent);
    font-weight: 700;
}

.cn-item.is-active > .cn-row .cn-count {
    background: var(--cn-accent);
    color: #fff;
}

/* Browsers without color-mix still get a clear highlight. */
@supports not (background: color-mix(in srgb, red 7%, transparent)) {
    .cn-item.is-active > .cn-row { background: #f7eeee; }
}

/* Keyboard users must see where they are. */
.cn-link:focus-visible,
.cn-toggle:focus-visible {
    outline: 2px solid var(--cn-accent);
    outline-offset: -2px;
    border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .cn-sub, .cn-toggle svg { transition: none; }
}
