/**
 * TUF Shop By Category — front-end styles
 * All rules are scoped under .tuf-sbc to avoid collisions with theme CSS.
 */

.tuf-sbc {
    --red: #DC0000;
    --dark: #454545;
    --mid: #666666;
    --light-bg: #f4f4f4;
    --border: #e5e5e5;
    --white: #ffffff;
}

.tuf-sbc * {
    box-sizing: border-box;
}

.tuf-sbc.cat-section {
    background: var(--white);
    padding: 48px 60px 44px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.tuf-sbc .section-header {
    margin-bottom: 28px;
}

.tuf-sbc .eyebrow {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--red);
    margin-bottom: 6px;
}

.tuf-sbc .section-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    margin: 0 0 6px;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.tuf-sbc .section-header p {
    font-size: 14px;
    color: var(--mid);
    margin: 0 0 14px;
    line-height: 1.5;
}

.tuf-sbc .accent-line {
    width: 40px;
    height: 3px;
    background: var(--red);
}

/* TOP ROW: 4 tiles */
.tuf-sbc .cat-grid-top {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

/* BOTTOM ROW: dynamic columns based on count, max 8 */
.tuf-sbc .cat-grid-bottom {
    display: grid;
    grid-template-columns: repeat(var(--tuf-sbc-bottom-cols, 8), 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

/* SHARED TILE */
.tuf-sbc .cat-tile {
    border: 1.5px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
    text-decoration: none;
    display: block;
    color: inherit;
}

.tuf-sbc .cat-tile:hover,
.tuf-sbc .cat-tile:focus-within {
    border-color: var(--red);
    box-shadow: 0 4px 16px rgba(220, 0, 0, 0.08);
    text-decoration: none;
}

/* Top tile is a div (not <a>) because subcategory pills are their own links */
.tuf-sbc .cat-tile--top {
    display: flex;
    flex-direction: column;
}

.tuf-sbc .cat-tile__media {
    display: block;
    text-decoration: none;
}

/* Images */
.tuf-sbc .cat-img {
    width: 100%;
    height: 150px;
    overflow: hidden;
    display: block;
    background: var(--light-bg);
}

.tuf-sbc .cat-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.tuf-sbc .cat-tile:hover .cat-img img {
    transform: scale(1.04);
}

.tuf-sbc .cat-grid-bottom .cat-img {
    height: 80px;
}

/* Body */
.tuf-sbc .cat-body {
    padding: 12px 14px 14px;
}

.tuf-sbc .cat-grid-bottom .cat-body {
    padding: 8px 10px 12px;
}

/* cat-name (works as both a div and an <a>) */
.tuf-sbc .cat-name {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 6px;
    line-height: 1.3;
    text-decoration: none;
}

.tuf-sbc a.cat-name:hover,
.tuf-sbc a.cat-name:focus {
    text-decoration: underline;
    color: var(--red);
}

.tuf-sbc .cat-grid-bottom .cat-name {
    font-size: 12px;
    margin-bottom: 0;
}

/* Description */
.tuf-sbc .cat-desc {
    font-size: 12px;
    color: var(--mid);
    line-height: 1.55;
    margin-bottom: 10px;
}

.tuf-sbc .cat-grid-bottom .cat-desc {
    margin-bottom: 0;
}

/* Subcategory pills (formerly tags) */
.tuf-sbc .cat-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tuf-sbc .cat-tag {
    font-size: 10px;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 20px;
    background: var(--light-bg);
    color: var(--mid);
    white-space: nowrap;
    line-height: 1.4;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}

.tuf-sbc a.cat-tag:hover,
.tuf-sbc a.cat-tag:focus {
    background: var(--red);
    color: var(--white);
    text-decoration: none;
}

/* Browse all */
.tuf-sbc .browse-all-wrap {
    text-align: center;
}

.tuf-sbc .btn-browse {
    display: inline-block;
    padding: 11px 28px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.2s, color 0.2s;
}

.tuf-sbc .btn-browse:hover,
.tuf-sbc .btn-browse:focus {
    border-color: var(--red);
    color: var(--red);
    text-decoration: none;
}

/* Editor notice */
.tuf-sbc-notice {
    padding: 12px 16px;
    background: #FAEEDA;
    border-left: 3px solid #EF9F27;
    color: #854F0B;
    font-size: 13px;
    line-height: 1.5;
}

/* ── TABLET (1100px and below) ────────────────── */
/* Bottom row drops to 4 columns so tiles don't get too cramped */
@media (max-width: 1100px) {
    .tuf-sbc .cat-grid-bottom {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ── MOBILE / SMALL TABLET (900px and below) ──── */
@media (max-width: 900px) {
    .tuf-sbc.cat-section {
        padding: 32px 16px 28px;
    }

    .tuf-sbc .cat-grid-top {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    /* All bottom tiles remain visible — 3 columns on small tablet */
    .tuf-sbc .cat-grid-bottom {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        margin-bottom: 20px;
    }

    .tuf-sbc .cat-grid-bottom .cat-img {
        height: 70px;
    }

    .tuf-sbc .cat-grid-bottom .cat-desc {
        display: block;
        font-size: 11px;
        margin-top: 4px;
        margin-bottom: 0;
    }

    .tuf-sbc .cat-grid-bottom .cat-body {
        padding: 10px 12px 12px;
    }

    .tuf-sbc .cat-grid-bottom .cat-name {
        margin-bottom: 4px;
    }

    .tuf-sbc .cat-grid-top .cat-img {
        height: 130px;
    }

    /* Trim subcategory pills to first 3 on tighter screens to avoid wrap weirdness */
    .tuf-sbc .cat-grid-top .cat-tag:nth-child(n+4) {
        display: none;
    }
}

/* ── SMALL MOBILE (600px and below) ──────────── */
@media (max-width: 600px) {
    .tuf-sbc .cat-grid-bottom {
        grid-template-columns: repeat(2, 1fr);
    }

    .tuf-sbc .cat-grid-bottom .cat-img {
        height: 80px;
    }
}

/* ── EXTRA SMALL (420px and below) ───────────── */
@media (max-width: 420px) {
    .tuf-sbc.cat-section {
        padding: 24px 12px 24px;
    }

    .tuf-sbc .cat-grid-top {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .tuf-sbc .cat-grid-top .cat-img {
        height: 160px;
    }

    .tuf-sbc .cat-grid-bottom {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .tuf-sbc .cat-grid-bottom .cat-img {
        height: 70px;
    }

    .tuf-sbc .section-header h2 {
        font-size: 22px;
    }
}