/*
 * Budha ADT — Category Grid
 *
 * Theme-bound colours: cards inherit from Glozin's `--gz-*` tokens so the
 * grid auto-matches the active theme (no color pickers in the plugin).
 *   surface       → transparent (page bg shows through) by default
 *   card bg       → var(--gz-color-light) — matches the page surface
 *   card fg       → var(--gz-color-dark)
 *   accent / glow → var(--gz-color-primary) — the theme's brand colour
 *   borders       → var(--gz-border-color)
 *
 * Mobile layout: the grid collapses to a single horizontal scroll-snap row.
 * Three+ columns of small dark cards on a phone screen looks like a
 * keyboard, so on ≤600px we let the user flick left/right through cards
 * the same way Instagram stories scroll.
 */

.budha-adt-catgrid {
    --budha-cg-card-radius: 18px;
    --budha-cg-thumb-radius: 12px;
    /* Surface (page chrome) tracks the active Glozin theme — adapts to
       light/dark customizer colour modes. */
    --budha-cg-fg:      var(--gz-color-dark,  #1a1a1a);
    --budha-cg-card-bg: var(--gz-color-light, #ffffff);
    --budha-cg-border:  var(--gz-border-color, rgba(0, 0, 0, 0.08));
    /* Accent locks to the Budha ADT brand green so the grid matches the
       age gate, call button, service highlights, etc. The theme's own
       --gz-color-primary on this site is red (#d0473e) — using it here
       would make the category cards clash with the rest of the plugin. */
    --budha-cg-accent:  var(--budha-accent, #7cc04a);

    color: var(--budha-cg-fg);
    font-family: var(--budha-font, inherit);
    padding: clamp(20px, 4vw, 36px) clamp(12px, 4vw, 28px);
    box-sizing: border-box;
}

/* Surface presets */
.budha-adt-catgrid--panel {
    background: var(--gz-color-dark, #0b0b0b);
    color: var(--gz-color-light, #ffffff);
    border-radius: clamp(14px, 2vw, 22px);
    --budha-cg-fg: var(--gz-color-light, #ffffff);
    --budha-cg-card-bg: rgba(255, 255, 255, 0.06);
    --budha-cg-border: rgba(255, 255, 255, 0.10);
}

.budha-adt-catgrid--transparent {
    background: transparent;
}

.budha-adt-catgrid *,
.budha-adt-catgrid *::before,
.budha-adt-catgrid *::after {
    box-sizing: border-box;
}

.budha-adt-catgrid__inner {
    max-width: 1200px;
    margin: 0 auto;
}

.budha-adt-catgrid__heading {
    margin: 0 0 16px;
    font-size: clamp(15px, 2.2vw, 20px);
    font-weight: 600;
    letter-spacing: 0.01em;
    color: inherit;
    text-align: left;
    opacity: 0.9;
}

/* ---- Grid (desktop / tablet) ---- */

.budha-adt-catgrid__grid {
    display: grid;
    grid-template-columns: repeat(var(--budha-cg-cols-d, 6), minmax(0, 1fr));
    gap: clamp(10px, 1.4vw, 16px);
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (max-width: 1024px) {
    .budha-adt-catgrid__grid {
        grid-template-columns: repeat(var(--budha-cg-cols-t, 4), minmax(0, 1fr));
    }
}

.budha-adt-catgrid__item {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    min-width: 0;
}

/* ---- Card ---- */

.budha-adt-catgrid__card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px 10px 14px;
    background: var(--budha-cg-card-bg);
    border: 1px solid var(--budha-cg-border);
    border-radius: var(--budha-cg-card-radius);
    text-decoration: none;
    color: inherit;
    text-align: center;
    overflow: hidden;
    isolation: isolate;
    transition:
        transform var(--budha-dur, 240ms) var(--budha-ease, ease),
        border-color var(--budha-dur, 240ms) var(--budha-ease, ease),
        background-color var(--budha-dur, 240ms) var(--budha-ease, ease),
        box-shadow var(--budha-dur, 240ms) var(--budha-ease, ease);
}

.budha-adt-catgrid--transparent .budha-adt-catgrid__card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.budha-adt-catgrid__card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: 0 0 0 0 transparent;
    transition: box-shadow var(--budha-dur, 240ms) var(--budha-ease, ease);
}

.budha-adt-catgrid__card:hover,
.budha-adt-catgrid__card:focus-visible {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--budha-cg-accent) 60%, transparent);
    color: inherit;
    outline: none;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.10);
}

.budha-adt-catgrid__card:hover::after,
.budha-adt-catgrid__card:focus-visible::after {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--budha-cg-accent) 40%, transparent) inset;
}

/* ---- Thumb ---- */

.budha-adt-catgrid__thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background:
        radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--budha-cg-accent) 8%, transparent), transparent 60%),
        color-mix(in srgb, var(--budha-cg-fg) 4%, transparent);
    border-radius: var(--budha-cg-thumb-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.budha-adt-catgrid__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 600ms var(--budha-ease, ease);
}

.budha-adt-catgrid__card:hover .budha-adt-catgrid__thumb img {
    transform: scale(1.06);
}

.budha-adt-catgrid__thumb-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: clamp(20px, 3vw, 28px);
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--budha-cg-accent);
    text-transform: uppercase;
    line-height: 1;
    background: linear-gradient(
        135deg,
        color-mix(in srgb, var(--budha-cg-accent) 18%, transparent) 0%,
        color-mix(in srgb, var(--budha-cg-accent) 4%, transparent) 100%
    );
}

/* ---- Variants ---- */

.budha-adt-catgrid--circle .budha-adt-catgrid__thumb {
    border-radius: 50%;
    width: 72%;
    margin: 4px auto 0;
}

.budha-adt-catgrid--rounded .budha-adt-catgrid__thumb {
    border-radius: var(--budha-radius-lg, 22px);
}

/* ---- Label / count ---- */

.budha-adt-catgrid__label {
    font-size: clamp(11px, 1.3vw, 13px);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.01em;
    color: inherit;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
    transition: color var(--budha-dur-fast, 160ms) var(--budha-ease, ease);
}

.budha-adt-catgrid__card:hover .budha-adt-catgrid__label,
.budha-adt-catgrid__card:focus-visible .budha-adt-catgrid__label {
    color: var(--budha-cg-accent);
}

.budha-adt-catgrid__count {
    font-size: 11px;
    font-weight: 500;
    color: color-mix(in srgb, currentColor 55%, transparent);
    line-height: 1;
}

/* ---- Child chips ---- */

.budha-adt-catgrid__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.budha-adt-catgrid__chips li {
    margin: 0;
    padding: 0;
    list-style: none;
}

.budha-adt-catgrid__chip {
    display: inline-block;
    padding: 3px 9px;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    color: inherit;
    background: color-mix(in srgb, var(--budha-cg-fg) 4%, transparent);
    border: 1px solid var(--budha-cg-border);
    border-radius: var(--budha-radius-pill, 9999px);
    text-decoration: none;
    transition:
        background-color var(--budha-dur-fast, 160ms) var(--budha-ease, ease),
        border-color var(--budha-dur-fast, 160ms) var(--budha-ease, ease),
        color var(--budha-dur-fast, 160ms) var(--budha-ease, ease);
}

.budha-adt-catgrid__chip:hover,
.budha-adt-catgrid__chip:focus-visible {
    background: var(--budha-cg-accent);
    color: var(--gz-color-light, #ffffff);
    border-color: var(--budha-cg-accent);
    outline: none;
}

/* ---- Mobile: horizontal scroll-snap rail ---- */

@media (max-width: 600px) {
    .budha-adt-catgrid {
        --budha-cg-card-radius: 14px;
        --budha-cg-thumb-radius: 10px;
        padding: 14px 0;
    }
    .budha-adt-catgrid__inner {
        /* No padding here — the rail extends to viewport edges, and the
           rail itself adds inline padding so cards are flush at the start
           but the last card has breathing room at the end. */
        padding: 0;
    }
    .budha-adt-catgrid__heading {
        text-align: left;
        margin: 0 0 10px;
        padding: 0 16px;
    }

    .budha-adt-catgrid__grid {
        display: flex;
        flex-direction: row;
        gap: 10px;
        padding: 4px 16px 6px;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .budha-adt-catgrid__grid::-webkit-scrollbar {
        display: none;
    }

    .budha-adt-catgrid__item {
        flex: 0 0 calc((100vw - 32px - 24px) / 3.4);
        max-width: 130px;
        min-width: 96px;
        scroll-snap-align: start;
        gap: 4px;
    }

    .budha-adt-catgrid__card {
        padding: 8px 6px 10px;
        gap: 7px;
    }
    .budha-adt-catgrid__label {
        font-size: 11px;
        -webkit-line-clamp: 2;
    }
    .budha-adt-catgrid__count {
        font-size: 10px;
    }
    .budha-adt-catgrid__chip {
        font-size: 9px;
        padding: 2px 6px;
    }

    /* Subtle right-edge fade so the user understands the row scrolls. */
    .budha-adt-catgrid__inner {
        position: relative;
    }
    .budha-adt-catgrid__inner::after {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 24px;
        pointer-events: none;
        background: linear-gradient(
            to right,
            transparent,
            color-mix(in srgb, var(--gz-color-light, #fff) 80%, transparent)
        );
    }
    .budha-adt-catgrid--panel .budha-adt-catgrid__inner::after {
        background: linear-gradient(
            to right,
            transparent,
            color-mix(in srgb, var(--gz-color-dark, #000) 80%, transparent)
        );
    }
}

/* ---- Shop-page header injection ---- */

#page-header.page-header--shop.budha-adt-catgrid-takeover .woocommerce-breadcrumb,
#page-header.page-header--shop.budha-adt-catgrid-takeover .page-header__title,
#page-header.page-header--shop.budha-adt-catgrid-takeover .page-header__description {
    display: none !important;
}

#page-header.page-header--shop.budha-adt-catgrid-takeover .page-header__content {
    padding: 0 !important;
    align-items: stretch !important;
    text-align: left !important;
}

#page-header.page-header--shop.budha-adt-catgrid-takeover {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    background: transparent !important;
}
