/* ===========================================================================
   Homepage category cards.
   Loaded only on the homepage via pages.extra_css_json.

   Turns the legacy <ul class="categories"> into a responsive grid of cards
   with a colourful icon chip, name, and a single descriptive line. Uses the
   theme :root variables so light/dark both look right. Rotating accent hues
   give the grid colour without needing per-category overrides.
   =========================================================================== */

.box-02 .categories {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

/* The shared template styles .categories li.category as a card (border + bg
   + padding). That IS the single container we keep. Everything below just
   refines it on the homepage: rounded corners + a coloured top stripe.
   The inner <a> is reset to a transparent, full-card click target so we
   don't end up with a card-inside-a-card look. */

.box-02 .category {
    position: relative;               /* anchor for the ::before top stripe */
    overflow: hidden;                 /* clips stripe to the rounded corners */
    border-radius: 14px;
    padding: 1.15rem 0.9rem 0.95rem;
    transition: transform 0.12s ease, box-shadow 0.2s ease, border-color 0.15s ease;
}

/* Coloured top stripe — varies per card via the nth-child rotation below.
   Reuses --qc-fg already set for the icon chip, so stripe + icon agree.
   Slightly taller on hover for a clear "lift" cue. */
.box-02 .category::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;                /* top edge, full width */
    height: 4px;
    background: var(--qc-fg, #2563eb);
    transition: height 0.15s ease;
    z-index: 1;
}

.box-02 .category:hover,
.box-02 .category:focus-within {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md, 0 4px 10px rgba(0, 0, 0, 0.10));
    /* Keep the subtle gray border on hover so the card edge stays calm —
       only the top stripe colours the card. Override the shared template's
       primary-blue hover border. */
    border-color: var(--border-color, #e5e7eb);
}
.box-02 .category:hover::before,
.box-02 .category:focus-within::before {
    height: 6px;
}

/* Inner link: a transparent click target filling the whole card. No bg,
   border, shadow, padding — those all live on the parent .category now. */
.box-02 .category > a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    height: 100%;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    color: var(--text-color, #1f2937);
    text-decoration: none;
    transition: none;
}
.box-02 .category > a:focus-visible { outline: none; }  /* focus ring lives on .category */

.box-02 .category-icon {
    --qc-tint: 37, 99, 235;
    --qc-fg:  #2563eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(var(--qc-tint), 0.12);
    color: var(--qc-fg);
}
.box-02 .category-icon svg { width: 28px; height: 28px; }

.box-02 .category-name {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--secondary-color, #1e40af);
    margin: 0;
}
.box-02 .category > a:hover .category-name { color: var(--primary-color, #2563eb); }

.box-02 .category-desc {
    display: block;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-light, #6b7280);
    margin: 0;
}

/* Rotating accent hues — gives the grid colour without needing per-category
   markup. Set on .category (the <li>) so both the icon chip AND the top
   stripe + hover border of the link inherit the same colour. Six tints
   cycle; with 21 cards each tint appears 3–4 times. */
.box-02 .category:nth-child(6n+1) { --qc-tint: 37, 99, 235;  --qc-fg: #2563eb; } /* blue   */
.box-02 .category:nth-child(6n+2) { --qc-tint: 16, 185, 129; --qc-fg: #059669; } /* green  */
.box-02 .category:nth-child(6n+3) { --qc-tint: 219, 39, 119; --qc-fg: #db2777; } /* pink   */
.box-02 .category:nth-child(6n+4) { --qc-tint: 217, 119, 6;  --qc-fg: #d97706; } /* amber  */
.box-02 .category:nth-child(6n+5) { --qc-tint: 124, 58, 237; --qc-fg: #7c3aed; } /* purple */
.box-02 .category:nth-child(6n)   { --qc-tint: 13, 148, 136; --qc-fg: #0d9488; } /* teal   */

/* In dark theme, brighten the foreground a notch so saturated mid-tones
   stay readable on the dark card and the top stripe stays bright. */
[data-theme="dark"] .box-02 .category:nth-child(6n+1) { --qc-fg: #60a5fa; }
[data-theme="dark"] .box-02 .category:nth-child(6n+2) { --qc-fg: #34d399; }
[data-theme="dark"] .box-02 .category:nth-child(6n+3) { --qc-fg: #f472b6; }
[data-theme="dark"] .box-02 .category:nth-child(6n+4) { --qc-fg: #fbbf24; }
[data-theme="dark"] .box-02 .category:nth-child(6n+5) { --qc-fg: #a78bfa; }
[data-theme="dark"] .box-02 .category:nth-child(6n)   { --qc-fg: #2dd4bf; }

@media (max-width: 480px) {
    .box-02 .categories { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .box-02 .category > a { padding: 0.85rem 0.6rem; }
    .box-02 .category-icon { width: 44px; height: 44px; }
    .box-02 .category-icon svg { width: 24px; height: 24px; }
    .box-02 .category-name { font-size: 0.95rem; }
    .box-02 .category-desc { font-size: 0.78rem; }
}
