/* ========================================
   COLOUR & WRITE FOR KIDS
   CATEGORIES — V2
   CLEAN FINAL VERSION
======================================== */


/* ========================================
   CATEGORY PAGE
======================================== */

.category-page {
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    padding: 20px 20px 45px;
    box-sizing: border-box;
}


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

.category-page .category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
}


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

.category-card {
    --category-color: #4DA3FF;

    position: relative;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    min-height: 255px;
    padding: 28px 22px 25px;

    box-sizing: border-box;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 24px;

    text-align: center;
    text-decoration: none;

    color: var(--heading);

    overflow: hidden;

    box-shadow: var(--shadow-card);

    transition:
        background-color 0.3s ease,
        border-color 0.3s ease,
        color 0.3s ease,
        transform 0.3s ease,
        box-shadow 0.3s ease;
}


/* ========================================
   CATEGORY COLOUR STRIP
======================================== */

.category-card::before {
    content: "";

    position: absolute;

    top: 0;
    left: 0;
    right: 0;

    width: 100%;
    height: 7px;

    background: var(--category-color);

    border-radius: 24px 24px 0 0;

    transition:
        height 0.3s ease;
}


/* ========================================
   CATEGORY ARTWORK FRAME
======================================== */

.category-image-frame {
    position: relative;

    width: 130px;
    height: 130px;

    margin: 22px auto 20px;

    padding: 9px;

    box-sizing: border-box;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    background: #ffffff;

    border: 3px solid #e6edf3;
    border-radius: 28px;

    box-shadow:
        0 8px 0 rgba(0, 0, 0, 0.10),
        0 12px 25px rgba(0, 0, 0, 0.10);

    overflow: hidden;

    transition:
        transform 0.25s ease,
        border-color 0.25s ease,
        box-shadow 0.25s ease;
}


/* ========================================
   CATEGORY ARTWORK
======================================== */

.category-image-frame img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: contain;
    object-position: center center;

    margin: 0;

    border-radius: 20px;
}


/* Compatibility with existing markup
   using .category-image directly
======================================== */

.category-image {
    position: relative;

    width: 125px;
    height: 125px;

    margin: 3px auto 18px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    box-sizing: border-box;

    background:
        linear-gradient(
            145deg,
            var(--surface-warm),
            var(--surface-teal)
        );

    border: 4px solid var(--surface);

    border-radius: 32px;

    box-shadow:
        0 5px 0 var(--border),
        0 10px 20px rgba(0, 0, 0, 0.08);

    overflow: hidden;

    transition:
        transform 0.3s ease,
        background 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.3s ease;
}


/* If .category-image contains an image */
.category-image img {
    position: relative;

    z-index: 2;

    display: block;

    width: 88%;
    height: 88%;

    object-fit: contain;
    object-position: center center;

    margin: 0;

    border-radius: 22px;
}


/* ========================================
   DECORATIVE INNER FRAME
======================================== */

.category-image::before {
    content: "";

    position: absolute;

    inset: 7px;

    border: 2px dashed var(--border);

    border-radius: 24px;

    pointer-events: none;

    opacity: 0.8;
}


/* ========================================
   FALLBACK VISUAL
======================================== */

.category-image-fallback {
    font-size: 60px;
    line-height: 1;
}


/* ========================================
   CATEGORY TITLE
======================================== */

.category-card h3 {
    margin: 0;

    color: var(--heading);

    font-size: 22px;
    font-weight: 800;

    line-height: 1.3;

    transition:
        color 0.3s ease;
}


/* ========================================
   CATEGORY SUBTITLE
======================================== */

.category-card p {
    margin: 7px 0 0;

    color: var(--text-muted);

    font-size: 14px;

    line-height: 1.5;

    transition:
        color 0.3s ease;
}


/* ========================================
   CATEGORY CARD HOVER
======================================== */

.category-card:hover {
    background: var(--category-color);

    border-color: var(--category-color);

    transform: translateY(-6px);

    box-shadow:
        0 18px 35px rgba(0, 0, 0, 0.20);
}


.category-card:hover::before {
    height: 10px;
}


.category-card:hover h3 {
    color: #ffffff;
}


.category-card:hover p {
    color: rgba(255, 255, 255, 0.9);
}


/* ========================================
   ARTWORK HOVER
======================================== */

.category-card:hover .category-image {
    transform:
        rotate(-2deg)
        scale(1.04);

    background:
        linear-gradient(
            145deg,
            rgba(255, 255, 255, 0.95),
            rgba(255, 255, 255, 0.70)
        );

    border-color: rgba(255, 255, 255, 0.95);

    box-shadow:
        0 5px 0 rgba(0, 0, 0, 0.08),
        0 12px 24px rgba(0, 0, 0, 0.12);
}


.category-card:hover .category-image img {
    transform: scale(1.08);
}


.category-card:hover .category-image-frame {
    transform: scale(1.06);

    background: #ffffff;

    border-color: #ffffff;

    box-shadow:
        0 8px 0 rgba(0, 0, 0, 0.10),
        0 14px 30px rgba(0, 0, 0, 0.14);
}


/* ========================================
   CATEGORY COLOURS
======================================== */

.category-animals {
    --category-color: #F59E0B;
}

.category-fruits {
    --category-color: #EF4444;
}

.category-alphabet {
    --category-color: #10B981;
}

.category-numbers {
    --category-color: #8B5CF6;
}

.category-shapes {
    --category-color: #3B82F6;
}

.category-colours,
.category-colors {
    --category-color: #F97316;
}

.category-vehicles {
    --category-color: #2563EB;
}

.category-birds {
    --category-color: #EC4899;
}

.category-flowers {
    --category-color: #DB2777;
}

.category-vegetables {
    --category-color: #16A34A;
}

.category-body-parts,
.category-bodyparts {
    --category-color: #7C3AED;
}

.category-community-helpers,
.category-communityhelpers {
    --category-color: #0891B2;
}


/* ========================================
   BACKEND COLOUR
   IMPORTANT:
   JavaScript can override --category-color
   directly on each card.
======================================== */

.category-card[style*="--category-color"] {
    --category-color: var(--category-color);
}


/* ========================================
   FEATURED CATEGORY
======================================== */

.featured-category {
    margin-bottom: 35px;

    padding: 35px;

    background:
        linear-gradient(
            135deg,
            var(--surface-warm),
            var(--surface)
        );

    border: 1px solid var(--border);

    border-radius: var(--radius-card);

    text-align: center;

    box-shadow: var(--shadow-card);

    transition:
        background-color var(--transition),
        border-color var(--transition),
        box-shadow var(--transition);
}


.featured-category h1 {
    margin: 12px 0;

    color: var(--heading);

    font-size: 38px;

    line-height: 1.25;
}


.featured-category p {
    max-width: 650px;

    margin: 0 auto;

    color: var(--text-muted);

    font-size: 17px;

    line-height: 1.7;
}


.featured-category a {
    display: inline-block;

    margin-top: 22px;

    padding: 13px 32px;

    background: var(--primary);

    color: #ffffff;

    border-radius: var(--radius-pill);

    text-decoration: none;

    font-weight: 700;

    transition:
        background-color var(--transition),
        transform var(--transition),
        box-shadow var(--transition);
}


.featured-category a:hover {
    background: var(--primary-dark);

    transform: translateY(-2px);

    box-shadow: var(--shadow-small);
}


/* ========================================
   CATEGORY RESULTS
======================================== */

.category-results {
    width: 100%;
    max-width: 1200px;

    margin: 25px auto 50px;

    padding: 0 20px;

    box-sizing: border-box;
}


.category-results h2 {
    margin: 0 0 25px;

    text-align: center;

    color: var(--heading);

    font-size: 36px;

    line-height: 1.25;
}


/* ========================================
   WORKSHEET RESULTS
======================================== */

#categoryWorksheets {
    display: flex;

    flex-direction: column;

    gap: 20px;

    margin-top: 20px;
}


/* ========================================
   WORKSHEET ROW
   NO BLUE TOP BORDER
======================================== */

.worksheet-row {
    --category-color: #4DA3FF;

    position: relative;

    display: flex;
    align-items: center;

    gap: 20px;

    padding: 20px;

    box-sizing: border-box;

    background: var(--surface);

    border: 1px solid var(--border) !important;

    border-top: 1px solid var(--border) !important;

    border-radius: var(--radius-card);

    box-shadow: var(--shadow-card);

    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease,
        background-color 0.25s ease,
        border-color 0.25s ease;
}


/* ========================================
   WORKSHEET ROW HOVER
======================================== */

.worksheet-row:hover {
    transform: translateY(-3px);

    border-color: var(--category-color) !important;

    border-top-color: var(--category-color) !important;

    box-shadow:
        0 12px 30px rgba(0, 0, 0, 0.12);
}


/* ========================================
   WORKSHEET LIST ITEM
   Compatibility
======================================== */

.worksheet-list-item {
    display: flex;

    align-items: center;

    gap: 20px;

    padding: 20px;

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: var(--radius-card);

    box-shadow: var(--shadow-card);

    transition:
        transform var(--transition),
        box-shadow var(--transition),
        background-color var(--transition),
        border-color var(--transition);
}


.worksheet-list-item:hover {
    transform: translateY(-3px);

    border-color: var(--category-color, var(--primary));

    box-shadow: var(--shadow-hover);
}


/* ========================================
   WORKSHEET THUMBNAIL
======================================== */

.worksheet-list-item .worksheet-thumb,
.worksheet-row .worksheet-thumb {
    width: 150px;
    height: 110px;

    flex-shrink: 0;

    overflow: hidden;

    border-radius: var(--radius-small);
}


.worksheet-list-item .worksheet-thumb img,
.worksheet-row .worksheet-thumb img {
    width: 100%;
    height: 100%;

    object-fit: cover;

    display: block;
}


/* ========================================
   WORKSHEET INFORMATION
======================================== */

.worksheet-details {
    flex: 1;

    min-width: 0;
}


.worksheet-details h3 {
    margin: 0 0 8px;

    color: var(--heading);

    font-size: 22px;

    line-height: 1.35;

    transition:
        color 0.25s ease;
}


.worksheet-meta {
    margin-bottom: 8px;

    color: var(--text-muted);

    font-size: 15px;

    font-weight: 700;
}


.worksheet-details p {
    margin: 0;

    color: var(--text-muted);

    font-size: 16px;

    line-height: 1.6;
}


/* ========================================
   WORKSHEET TITLE HOVER
======================================== */

.worksheet-row:hover
.worksheet-details h3 {
    color: var(--category-color) !important;
}


/* ========================================
   WORKSHEET ACTION
======================================== */

.worksheet-action {
    flex-shrink: 0;
}


/* ========================================
   WORKSHEET BUTTON
   CATEGORY COLOUR
======================================== */

.worksheet-btn {
    display: inline-block;

    padding: 13px 22px;

    background: var(--category-color, var(--primary)) !important;

    color: #ffffff !important;

    border: 1px solid
        var(--category-color, var(--primary)) !important;

    border-radius: var(--radius-button);

    text-decoration: none;

    font-weight: 700;

    white-space: nowrap;

    transition:
        background-color 0.25s ease,
        border-color 0.25s ease,
        transform 0.25s ease,
        box-shadow 0.25s ease,
        filter 0.25s ease;
}


.worksheet-btn:hover {
    background: var(--category-color, var(--primary)) !important;

    border-color: var(--category-color, var(--primary)) !important;

    color: #ffffff !important;

    transform: translateY(-2px);

    box-shadow: var(--shadow-small);

    filter: brightness(0.92);
}


/* ========================================
   WORKSHEET IMAGE HOVER
======================================== */

.worksheet-row .worksheet-thumb {
    transition:
        box-shadow 0.25s ease;
}


.worksheet-row:hover
.worksheet-thumb {
    box-shadow:
        0 0 0 2px var(--category-color),
        0 10px 22px rgba(0, 0, 0, 0.14);
}


/* ========================================
   EMPTY STATE
======================================== */

.empty-state {
    text-align: center;

    padding: 60px 20px;
}


.empty-state h2 {
    margin-bottom: 10px;

    color: var(--heading);
}


.empty-state p {
    color: var(--text-muted);

    line-height: 1.7;
}


/* ========================================
   DARK MODE — CATEGORY IMAGE
======================================== */

[data-theme="dark"] .category-image {
    background:
        linear-gradient(
            145deg,
            #ffffff,
            #f3f7f5
        );

    border-color: #ffffff;

    box-shadow:
        0 5px 0 rgba(255, 255, 255, 0.18),
        0 10px 20px rgba(0, 0, 0, 0.30);
}


[data-theme="dark"] .category-image::before {
    border-color: #d7e2df;

    opacity: 1;
}


/* ========================================
   DARK MODE — IMAGE FRAME
======================================== */

[data-theme="dark"] .category-image-frame {
    background: #f8fbff;

    border-color: #dce8f2;
}


/* ========================================
   DARK MODE — CATEGORY CARD
======================================== */

[data-theme="dark"] .category-card {
    background: var(--surface);
}


[data-theme="dark"] .category-card:hover {
    background: var(--category-color);

    border-color: var(--category-color);
}


[data-theme="dark"] .category-card:hover h3 {
    color: #ffffff;
}


[data-theme="dark"] .category-card:hover p {
    color: rgba(255, 255, 255, 0.92);
}


/* ========================================
   DARK MODE — IMAGE HOVER
======================================== */

[data-theme="dark"]
.category-card:hover
.category-image-frame {
    background: #ffffff;

    border-color: #ffffff;
}


/* ========================================
   TABLET
======================================== */

@media (max-width: 1000px) {

    .category-page {
        padding-left: 25px;
        padding-right: 25px;
    }


    .category-page .category-grid {
        grid-template-columns: repeat(2, 1fr);

        gap: 22px;
    }
}


/* ========================================
   MOBILE
======================================== */

@media (max-width: 768px) {

    .category-page {
        padding: 18px 15px 40px;
    }


    .category-page .category-grid {
        grid-template-columns: 1fr;

        gap: 18px;
    }


    .category-card {
        min-height: 220px;

        padding: 25px 20px 23px;
    }


    .category-image {
        width: 110px;
        height: 110px;

        margin-bottom: 15px;

        border-radius: 28px;
    }


    .category-image-frame {
        width: 115px;
        height: 115px;

        border-radius: 24px;
    }


    .category-image::before {
        border-radius: 20px;
    }


    .category-card h3 {
        font-size: 21px;
    }


    .category-card p {
        font-size: 14px;
    }


    .featured-category {
        padding: 35px 20px;

        margin-bottom: 30px;
    }


    .featured-category h1 {
        font-size: 32px;
    }


    .featured-category p {
        font-size: 16px;
    }


    .category-results {
        margin: 25px auto 40px;

        padding: 0 15px;
    }


    .category-results h2 {
        font-size: 30px;

        margin-bottom: 20px;
    }


    .worksheet-row,
    .worksheet-list-item {
        flex-direction: column;

        text-align: center;

        padding: 20px;
    }


    .worksheet-list-item .worksheet-thumb,
    .worksheet-row .worksheet-thumb {
        width: 180px;
        height: 130px;
    }


    .worksheet-details {
        width: 100%;
    }


    .worksheet-details h3 {
        font-size: 21px;
    }


    .worksheet-action {
        width: 100%;

        margin-top: 5px;
    }


    .worksheet-btn {
        width: 100%;

        box-sizing: border-box;
    }
}


/* ========================================
   SMALL MOBILE
======================================== */

@media (max-width: 480px) {

    .category-page {
        padding-left: 12px;
        padding-right: 12px;
    }


    .category-card {
        min-height: 205px;

        padding: 23px 18px;
    }


    .category-image {
        width: 100px;
        height: 100px;
    }


    .category-image-frame {
        width: 105px;
        height: 105px;

        border-radius: 24px;
    }


    .category-card h3 {
        font-size: 20px;
    }


    .featured-category {
        padding: 30px 18px;
    }


    .featured-category h1 {
        font-size: 29px;
    }


    .featured-category p {
        font-size: 15px;
    }


    .worksheet-list-item .worksheet-thumb,
    .worksheet-row .worksheet-thumb {
        width: 160px;
        height: 115px;
    }


    .worksheet-btn {
        width: 100%;

        box-sizing: border-box;
    }
}


/* ========================================
   VERY SMALL PHONES
======================================== */

@media (max-width: 360px) {

    .category-page {
        padding-left: 10px;
        padding-right: 10px;
    }


    .category-card {
        min-height: 195px;

        padding: 21px 15px;
    }


    .category-image {
        width: 92px;
        height: 92px;
    }


    .category-image-frame {
        width: 95px;
        height: 95px;
    }


    .featured-category {
        padding: 28px 15px;
    }
}


/* ========================================
   REDUCED MOTION
======================================== */

@media (prefers-reduced-motion: reduce) {

    .category-card,
    .category-card::before,
    .category-card h3,
    .category-card p,
    .category-image,
    .category-image img,
    .category-image-frame,
    .category-image-frame img,
    .worksheet-row,
    .worksheet-btn,
    .worksheet-thumb {
        transition: none;
    }
}