/* Catalogue: nested category filter (left column) + results swapped without reloading (assets/js/catalog.js).
   Navy #1B3A5F for structure, orange #E85D04 for the active path and counts. */
/* A category link (…#products) lands here: keep the sticky navbar from hiding the top of the section */
#products { scroll-margin-top: 76px; }

.cat-filter {
    --cf-navy: #1B3A5F;
    --cf-orange: #E85D04;
    position: sticky; top: 96px;
    border: 1px solid rgba(27, 58, 95, .12); border-radius: 1rem; background: #fff;
    box-shadow: 0 10px 30px -20px rgba(15, 37, 64, .45);
}
.cat-filter-head {
    align-items: center; gap: .5rem; padding: 1rem 1.1rem .6rem;
    color: var(--cf-navy); font-weight: 800; font-size: .95rem; letter-spacing: -.01em;
}
.cat-filter-head i { color: var(--cf-orange); }
.cat-filter-body { padding: .25rem .5rem .75rem; max-height: calc(100vh - 140px); overflow: auto; scrollbar-width: thin; }

.cat-tree-list { list-style: none; margin: 0; padding: 0; }
.cat-tree-list .cat-tree-list { display: none; margin: .1rem 0 .25rem; padding-inline-start: .85rem; border-inline-start: 2px solid rgba(27, 58, 95, .08); margin-inline-start: .9rem; }
.cat-tree-item.is-open > .cat-tree-list { display: block; animation: catTreeIn .22s ease-out; }
@keyframes catTreeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.cat-tree-row { display: flex; align-items: center; gap: .15rem; }
.cat-tree-link {
    flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .5rem .65rem; border-radius: .6rem; color: #2B3F57; font-size: .9rem; font-weight: 600; text-decoration: none;
    transition: background-color .15s, color .15s;
}
.cat-tree-item[data-depth="1"] > .cat-tree-row .cat-tree-link { font-size: .86rem; font-weight: 500; }
.cat-tree-item[data-depth="2"] > .cat-tree-row .cat-tree-link,
.cat-tree-item[data-depth="3"] > .cat-tree-row .cat-tree-link { font-size: .82rem; font-weight: 500; color: #4A5D74; }
.cat-tree-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-tree-count {
    flex-shrink: 0; min-width: 1.75rem; padding: .05rem .45rem; border-radius: 999px; text-align: center;
    background: rgba(27, 58, 95, .07); color: var(--cf-navy); font-size: .72rem; font-weight: 700;
}
.cat-tree-link:hover { background: rgba(27, 58, 95, .06); color: var(--cf-navy); }
.cat-tree-link.is-active { background: var(--cf-navy); color: #fff; }
.cat-tree-link.is-active .cat-tree-count { background: var(--cf-orange); color: #fff; }
.cat-tree-link:focus-visible, .cat-tree-toggle:focus-visible { outline: 2px solid var(--cf-orange); outline-offset: 2px; }

.cat-tree-toggle {
    flex-shrink: 0; display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0;
    border: 0; border-radius: .5rem; background: none; color: #7B8BA0; cursor: pointer; transition: background-color .15s, color .15s;
}
.cat-tree-toggle:hover { background: rgba(232, 93, 4, .08); color: var(--cf-orange); }
.cat-tree-toggle i { transition: transform .2s ease; }
.cat-tree-item.is-open > .cat-tree-row > .cat-tree-toggle i { transform: rotate(180deg); }

/* Phones / tablets: the tree folds into one button */
.cat-filter-toggle {
    display: flex; align-items: center; gap: .5rem; width: 100%; padding: .85rem 1rem;
    border: 0; border-radius: 1rem; background: none; color: var(--cf-navy); font-weight: 700; text-align: start;
}
.cat-filter-toggle .bi-funnel { color: var(--cf-orange); }
.cat-filter-current { margin-inline-start: .25rem; padding: .1rem .55rem; border-radius: 999px; background: rgba(232, 93, 4, .1); color: var(--cf-orange); font-size: .78rem; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-filter-toggle .bi-chevron-down { transition: transform .2s ease; }
.cat-filter.is-open .cat-filter-toggle .bi-chevron-down { transform: rotate(180deg); }
@media (max-width: 991.98px) {
    .cat-filter { position: static; }
    .cat-filter-body { max-height: 60vh; border-top: 1px solid rgba(27, 58, 95, .08); }
    .cat-filter.js-ready .cat-filter-body { display: none; } /* folded only when the script can unfold it */
    .cat-filter.js-ready.is-open .cat-filter-body { display: block; }
}

/* Sub-category chips above the results */
.cat-chips { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.cat-chips-label { color: #5F7088; font-size: .82rem; font-weight: 600; margin-inline-end: .2rem; }
.cat-chip {
    display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .75rem; border-radius: 999px;
    border: 1px solid rgba(27, 58, 95, .18); background: #fff; color: #1B3A5F; font-size: .82rem; font-weight: 600; text-decoration: none;
    transition: border-color .15s, background-color .15s, color .15s;
}
.cat-chip span { color: #E85D04; font-weight: 700; font-size: .75rem; }
.cat-chip:hover { border-color: #1B3A5F; background: #1B3A5F; color: #fff; }
.cat-chip:hover span { color: #FFC79E; }

/* Swapping results: a short fade, never a blank page */
.catalog-main { position: relative; min-height: 18rem; transition: opacity .18s ease; }
.catalog-main.is-loading { opacity: .45; pointer-events: none; }
.catalog-main.is-loading::after {
    content: ""; position: absolute; top: 6rem; left: 50%; width: 2.25rem; height: 2.25rem; margin-left: -1.125rem;
    border: 3px solid rgba(27, 58, 95, .15); border-top-color: #E85D04; border-radius: 50%;
    animation: catSpin .7s linear infinite;
}
@keyframes catSpin { to { transform: rotate(360deg); } }
.hm-swap-in { animation: catSwapIn .35s ease-out both; }
.hm-swap-in:nth-child(2) { animation-delay: .03s; } .hm-swap-in:nth-child(3) { animation-delay: .06s; }
.hm-swap-in:nth-child(4) { animation-delay: .09s; } .hm-swap-in:nth-child(5) { animation-delay: .12s; } .hm-swap-in:nth-child(6) { animation-delay: .15s; }
@keyframes catSwapIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.catalog-count { margin-top: .15rem; }

@media (prefers-reduced-motion: reduce) {
    .cat-tree-item.is-open > .cat-tree-list, .hm-swap-in { animation: none; }
    .catalog-main.is-loading::after { animation-duration: 2s; }
}
