/**
 * Popular Categories Section
 *
 * Full-bleed image cards arranged in a responsive grid.
 * Each card has a dark gradient overlay with the category
 * name and recipe count pinned to the bottom.
 *
 * @package CozyRecipes
 */

/* ========================================
   SECTION
======================================== */

.popular-categories-section {
    padding: 4rem 0;
    background: #f8f8f8;
}

.popular-categories-section .section-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.popular-categories-section .section-title {
    font-size: 2rem;
    font-weight: 700;
    color: #222;
    margin-bottom: 0.5rem;
}

.popular-categories-section .section-subtitle {
    font-size: 1.05rem;
    color: #666;
    margin: 0;
}

/* ========================================
   GRID
======================================== */

.popular-categories-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}

@media (max-width: 991px) {
    .popular-categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

@media (max-width: 640px) {
    .popular-categories-section {
        padding: 2.5rem 0;
    }

    .popular-categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .popular-categories-section .section-title {
        font-size: 1.5rem;
    }
}

/* ========================================
   CARD
======================================== */

.pop-cat-card {
    position: relative;
    display: block;
    border-radius: 14px;
    overflow: hidden;
    aspect-ratio: 3 / 4;      /* portrait card — like Pinterest */
    text-decoration: none;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.10);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #e0e0e0;       /* placeholder while image loads */
}

.pop-cat-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

/* ── Image layer ──────────────────────────────── */

.pop-cat-img {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center center;
    transition: transform 0.45s ease;
    will-change: transform;
}

.pop-cat-card:hover .pop-cat-img {
    transform: scale(1.07);
}

/* ── Gradient overlay ─────────────────────────── */

.pop-cat-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.00)  30%,
        rgba(0, 0, 0, 0.55)  70%,
        rgba(0, 0, 0, 0.80) 100%
    );
    transition: opacity 0.3s ease;
}

.pop-cat-card:hover .pop-cat-overlay {
    opacity: 0.9;
}

/* ── Text info ────────────────────────────────── */

.pop-cat-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.25rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.pop-cat-name {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    margin: 0;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    /* clamp long names to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pop-cat-count {
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
}

/* ── Small screens ────────────────────────────── */

@media (max-width: 640px) {
    .pop-cat-card {
        border-radius: 10px;
    }

    .pop-cat-info {
        padding: 0.9rem 0.75rem 0.75rem;
    }

    .pop-cat-name {
        font-size: 0.875rem;
    }

    .pop-cat-count {
        font-size: 0.72rem;
    }
}

@media (max-width: 400px) {
    .popular-categories-grid {
        gap: 0.5rem;
    }
}

/* ========================================
   PRINT
======================================== */

@media print {
    .popular-categories-section {
        break-inside: avoid;
    }

    .pop-cat-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .pop-cat-overlay {
        display: none;
    }

    .pop-cat-info {
        position: static;
        color: #222;
        padding: 0.5rem 0 0;
    }

    .pop-cat-name,
    .pop-cat-count {
        color: #222;
        text-shadow: none;
    }
}
