/**
 * Section 4: Premium Categories — Deepak Sales.
 *
 * Mobile-first. Depends on tokens.css + base.css. Reuses existing design
 * tokens only (burgundy/oxblood, cream, gold) — no new global variables.
 * Cards are fully clickable via a stretched link; entrance stagger uses
 * :nth-child (no inline CSS). Architecture mirrors hero.css / the stats band.
 */

/* ==========================================================================
   1. Section shell + decorative backdrop
   ========================================================================== */
.ds-categories {
    position: relative;
    overflow: clip;
    /* padding-top intentionally NOT --ds-section-y: this section follows
       directly after the homepage stats/marquee band, which now already
       provides its own small trailing gap — a full section-rhythm top
       padding here would reopen the gap the marquee refinement just
       closed. padding-bottom keeps the normal shared rhythm. */
    padding-top: var(--ds-space-md);
    padding-bottom: var(--ds-section-y);
    background-color: var(--ds-paper-2);
    isolation: isolate;
}

.ds-categories__backdrop {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: clip;
}

.ds-categories__glow {
    position: absolute;
    top: -18%;
    left: 50%;
    width: 40rem;
    height: 40rem;
    transform: translateX(-50%);
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.7;
    background: radial-gradient(circle, color-mix(in srgb, var(--ds-gold) 30%, transparent), transparent 66%);
}

/* ==========================================================================
   2. Section header
   ========================================================================== */
.ds-categories__head {
    max-width: 44rem;
    margin-bottom: clamp(2rem, 1.25rem + 2.5vw, 3.5rem);
}

.ds-categories__eyebrow {
    margin-bottom: var(--ds-space-sm);
    font-family: var(--ds-font-mono);
    font-size: var(--ds-fs-eyebrow);
    font-weight: var(--ds-fw-label);
    letter-spacing: var(--ds-ls-wide);
    text-transform: uppercase;
    color: var(--ds-oxblood);
}

.ds-categories__title {
    margin-bottom: var(--ds-space-md);
    font-family: var(--ds-font-display);
    font-size: var(--ds-fs-h2);
    font-weight: var(--ds-fw-section);
    line-height: var(--ds-lh-snug);
    letter-spacing: -0.02em;
    color: var(--ds-heading);
}

.ds-categories__lead {
    font-size: var(--ds-fs-lead);
    line-height: var(--ds-lh-body);
    color: var(--ds-muted);
}

/* ==========================================================================
   3. Grid
   ========================================================================== */
.ds-categories__grid {
    display: grid;
    grid-template-columns: 1fr; /* mobile: single column */
    gap: clamp(1rem, 0.6rem + 1.5vw, 1.5rem);
}

/* ==========================================================================
   4. Card
   ========================================================================== */
.ds-categories__card {
    position: relative; /* anchor for the stretched link */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    height: 100%;
    padding: clamp(1.25rem, 1.1rem + 1vw, 2rem); /* 20-32px, was a flat 2rem at every width */
    border: 1px solid var(--ds-border-brand);
    border-radius: var(--ds-radius-lg);
    background-color: var(--ds-surface);
    box-shadow: var(--ds-shadow-sm);
    transition:
        transform var(--ds-dur) var(--ds-ease),
        border-color var(--ds-dur) var(--ds-ease),
        box-shadow var(--ds-dur) var(--ds-ease);
}

.ds-categories__card:hover {
    transform: translateY(-10px);
    border-color: var(--ds-border-brand-hover);
    box-shadow: var(--ds-shadow-brand);
}

/* Keyboard focus lands on the link; surface it on the whole card. */
.ds-categories__card:focus-within {
    border-color: var(--ds-gold);
    box-shadow: var(--ds-shadow-md);
}

/* ---- Icon chip ----------------------------------------------------------- */
.ds-categories__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: var(--ds-space-lg);
    border-radius: var(--ds-radius-md);
    background: var(--ds-gold-tint);
    color: var(--ds-oxblood);
    transition:
        background-color var(--ds-dur) var(--ds-ease),
        color var(--ds-dur) var(--ds-ease),
        transform var(--ds-dur) var(--ds-ease);
}

.ds-categories__icon svg {
    width: 30px;
    height: 30px;
}

/* Real category thumbnail (Products > Categories > Thumbnail in wp-admin),
   when set, fills the same fixed slot the fallback icon used — same size,
   same rounded corners, no other change to the card. */
.ds-categories__icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.ds-categories__card:hover .ds-categories__icon {
    background: var(--ds-oxblood);
    color: var(--ds-gold-soft);
    transform: translateY(-2px);
}

/* ---- Count --------------------------------------------------------------- */
.ds-categories__count {
    margin-bottom: var(--ds-space-xs);
    font-family: var(--ds-font-mono);
    font-size: var(--ds-fs-eyebrow);
    font-weight: var(--ds-fw-label);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #b98a3c;
}

/* ---- Name ----------------------------------------------------------------
   font-size now uses the shared --ds-fs-h3 token (22-26px) instead of a
   hardcoded 2rem/32px that bypassed the type scale entirely and matched
   the (also hardcoded) product-card price. */
.ds-categories__name {
    margin-bottom: var(--ds-space-xs);
    font-family: var(--ds-font-display);
    font-size: var(--ds-fs-h3);
    font-weight: 600;
    line-height: var(--ds-lh-snug);
    color: var(--ds-ink);
    transition: color var(--ds-dur-fast) var(--ds-ease);
}

.ds-categories__card:hover .ds-categories__name {
    color: var(--ds-oxblood);
}

/* ---- Description --------------------------------------------------------- */
.ds-categories__desc {
    flex: 1;
    margin-bottom: var(--ds-space-lg);
    font-size: var(--ds-fs-small);
    line-height: var(--ds-lh-body);
    color: var(--ds-muted);
}

/* ---- Link (stretched over the card) -------------------------------------- */
.ds-categories__link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: auto; /* pin to the bottom regardless of copy length */
    color: var(--ds-oxblood);
    font-size: var(--ds-fs-small);
    font-weight: 600;
}

.ds-categories__link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

.ds-categories__arrow {
    transition: 0.3s;
}

.ds-categories__card:hover .ds-categories__arrow,
.ds-categories__link:hover .ds-categories__arrow {
    transform: translateX(5px);
}

/* Keep the visible focus ring on the link text, not the stretched overlay. */
.ds-categories__link:focus-visible {
    outline: 2px solid var(--ds-focus);
    outline-offset: 3px;
}

/* ==========================================================================
   5. Entrance animation (staggered via :nth-child — no inline CSS).
   Hidden state lives inside the keyframe so cards stay visible if animation
   is disabled.
   ========================================================================== */
@keyframes ds-cat-rise {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.ds-categories__item {
    display: flex;
    animation: ds-cat-rise 0.55s var(--ds-ease) both;
}

.ds-categories__item:nth-child(1) { animation-delay: 0.05s; }
.ds-categories__item:nth-child(2) { animation-delay: 0.12s; }
.ds-categories__item:nth-child(3) { animation-delay: 0.19s; }
.ds-categories__item:nth-child(4) { animation-delay: 0.26s; }
.ds-categories__item:nth-child(5) { animation-delay: 0.33s; }
.ds-categories__item:nth-child(6) { animation-delay: 0.40s; }

/* ==========================================================================
   6. Responsive — 3-up breakpoint aligned to 62em (992px), the theme's
   formal desktop tier (see header.css/hero.css), replacing the previous
   64em guess so this grid steps up in sync with the rest of the layout.
   ========================================================================== */
@media (min-width: 40em) {
    .ds-categories__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 62em) {
    .ds-categories__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================================================
   7. Reduced motion — settle to the final, visible state.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .ds-categories__item {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .ds-categories__card:hover,
    .ds-categories__card:hover .ds-categories__icon,
    .ds-categories__card:hover .ds-categories__arrow,
    .ds-categories__link:hover .ds-categories__arrow {
        transform: none;
    }
}