/* ============================================================================
   categories.css  -  the category directory (categories.cfm) and the heading
   block of a category page (category.cfm).

   Built on the css/foundations.css tokens and .oct-* primitives rather than the
   legacy base, which centres everything inside .fixedwidth and sizes h2 larger
   than h1. Everything here is left-aligned on purpose: these are lists to scan.
   ========================================================================== */

/* ---- browse category tiles ---- */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--oct-space-3);
    margin: var(--oct-space-4) 0 var(--oct-space-6);
    text-align: left;
}
.cat-tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: var(--oct-space-3) var(--oct-space-4);
    text-decoration: none;
    color: inherit;
    border-left: 4px solid #ff3200;
    transition: transform .12s ease, box-shadow .12s ease;
}
.cat-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}
.cat-tile-name {
    font-size: var(--oct-text-lg, 18px);
    font-weight: 700;
    line-height: 1.25;
    color: #35003a;
}
.cat-tile-count {
    font-size: var(--oct-text-sm, 15px);
    opacity: .75;
}

/* ---- type-to-find ---- */
.cat-find {
    margin: var(--oct-space-4) auto var(--oct-space-2);
    max-width: 620px;
    text-align: center;
}
.cat-find label {
    display: block;
    margin: 0 0 6px;
    font-size: var(--oct-text-sm, 15px);
    font-weight: 600;
}
/* 18px, matching the site's input scale - a search box that renders smaller
   than the body text reads as a secondary control, and this one is the fastest
   route into 686 entries. */
.cat-find input[type="search"] {
    width: 100%;
    padding: 12px 16px;
    font-size: 18px;
    line-height: 1.3;
    border: 2px solid #ccc;
    border-radius: 6px;
    background: #fff;
}
.cat-find input[type="search"]:focus {
    outline: none;
    border-color: #ff3200;
}
.cat-find-status {
    min-height: 1.4em;      /* reserve the line so the page does not jump */
    margin: 6px 0 0;
    font-size: 14px;
    opacity: .75;
}
/* Once there is a query the count stops being a hint and becomes the feedback
   that the box is working, so it stops whispering. */
.is-searching .cat-find-status {
    opacity: 1;
    font-weight: 600;
    color: #35003a;
}
/* The blurb is orientation for someone arriving; while they are typing it is
   just distance between the box and the answer. */
.is-searching .cat-head .oct-prose { display: none; }
.cat-find-empty {
    margin: var(--oct-space-3) 0 var(--oct-space-6);
    text-align: center;
}

/* ---- the A-Z product type list ---- */
.cat-types-head { margin: var(--oct-space-6) 0 4px; text-align: left; }
.cat-types-sub  { margin: 0 0 var(--oct-space-3); text-align: left; opacity: .8; }

/* Multi-column rather than a grid: the list is alphabetical, and columns keep
   it readable at 669 entries without turning into a wall. */
.cat-type-list {
    list-style: none;
    margin: 0 0 var(--oct-space-6);
    padding: 0;
    columns: 4 260px;
    column-gap: var(--oct-space-5);
    text-align: left;
}
.cat-type-list li {
    break-inside: avoid;
    padding: 3px 0;
    font-size: var(--oct-text-sm, 15px);
    line-height: 1.45;
}
.cat-type-list a { text-decoration: none; }
.cat-type-list a:hover { text-decoration: underline; }
.cat-type-count {
    opacity: .55;
    font-size: 13px;
    margin-left: 6px;
}

/* ---- page heading block ----
   Centred to sit with the breadcrumb above it, which style.css centres
   (.breadcrumb is a flex row with justify-content: center). .oct-page
   left-aligns its contents, so each of these has to say so explicitly - and
   .oct-h1 is display:block width:auto, so it needs the text-align rather than
   a margin:auto. The lists below stay left-aligned: they are for scanning. */
.cat-head { text-align: center; }
.cat-head .oct-h1,
.cat-head .oct-h2 { text-align: center; }
.cat-head .oct-prose { margin-left: auto; margin-right: auto; }
.cat-head .oct-prose p { text-align: center; }

.cat-intro {
    margin: 0 auto var(--oct-space-3);
    max-width: var(--oct-measure);
    text-align: center;
    font-size: var(--oct-text-md, 16px);
}
.cat-scope {
    margin: 0 0 var(--oct-space-4);
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.cat-scope-cta {
    margin: 0 0 var(--oct-space-4);
    text-align: center;
    font-size: var(--oct-text-sm, 15px);
}
/* "Change" reuses the vehicle-bar button from the search page so the control
   reads the same wherever a vehicle is named. */
.cat-scope .svb-change {
    border: 1px solid currentColor;
    background: transparent;
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 14px;
    cursor: pointer;
}
.cat-scope .svb-change:hover { background: rgba(0, 0, 0, .06); }

@media only screen and (max-width: 700px) {
    .cat-type-list { columns: 1; }
    .cat-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

    /* THE MOBILE PROBLEM this solves: 17 category tiles are about nine rows on a
       phone, so the part-type matches were changing far below the fold and the
       box looked broken. Pinning the input to the top of the viewport while a
       query is active means the list visibly redraws directly underneath it.

       Sticky only while searching: a search box that follows you down a page you
       are simply reading is an annoyance, not a feature. */
    .is-searching .cat-find {
        position: sticky;
        top: 0;
        z-index: 5;
        margin-top: 0;
        padding: 10px 0 8px;
        background: #fff;
        box-shadow: 0 6px 12px -8px rgba(0, 0, 0, .35);
    }
    /* The label is redundant once the box has focus and text in it, and on a
       phone it is a whole line of the sticky bar. */
    .is-searching .cat-find label { display: none; }

    /* Tighter tiles while filtering, so a couple of category matches cannot
       push the part-type matches off the screen again. */
    .is-searching .cat-grid { gap: var(--oct-space-2); margin-bottom: var(--oct-space-3); }
    .is-searching .cat-tile { padding: var(--oct-space-2) var(--oct-space-3); }
    .is-searching .cat-tile-name { font-size: 16px; }
}
