/* =========================================================
   COLOUR & WRITE FOR KIDS
   WORKSHEETS PAGE — REFINED V2
========================================================= */


/* =========================================================
   PAGE HEADER / GENERAL STRIP
========================================================= */

.page-header {

    width: 100%;
    min-height: 125px;

    box-sizing: border-box;

    display: flex;
    align-items: center;

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

    padding: 24px 40px;

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

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


.page-header .container {

    width: 100%;
    max-width: 1200px;

    margin: 0 auto;

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

    gap: 30px;
}


.page-header h1 {

    margin: 0 0 6px;

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

    color: var(--heading);

    line-height: 1.2;
}


.page-header p {

    margin: 0;

    max-width: 800px;

    font-size: 17px;

    color: var(--text-muted);

    line-height: 1.5;
}


/* =========================================================
   WORKSHEET LIBRARY
========================================================= */

.worksheet-library {

    width: 100%;
    max-width: 1200px;

    margin: 40px auto 70px;

    padding: 0 20px;

    box-sizing: border-box;
}


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

.worksheet-row {

    position: relative;

    display: flex;
    align-items: center;

    gap: 30px;

    background: var(--surface);

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

    border-radius: 24px;

    padding: 24px;

    margin-bottom: 24px;

    overflow: hidden;

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

    /*
       Category colour is supplied by JavaScript
       through the --category-color variable.
    */
    --category-color: #4DA3FF;

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


/*
   IMPORTANT:
   No ::before top strip.
   No border-top colour.
*/


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

.worksheet-row:hover {

    transform: translateY(-4px);

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

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


/* =========================================================
   WORKSHEET IMAGE AREA
========================================================= */

.worksheet-thumb {

    position: relative;

    width: 210px;
    height: 155px;

    flex: 0 0 210px;

    display: flex;

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

    padding: 10px;

    box-sizing: border-box;

    background: var(--surface);

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

    border-radius: 22px;

    overflow: hidden;

    box-shadow:
        0 0 0 2px var(--border),
        0 8px 18px rgba(0, 0, 0, 0.12);

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


/* =========================================================
   INNER IMAGE FRAME
========================================================= */

.worksheet-thumb::before {

    content: "";

    position: absolute;

    inset: 7px;

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

    border-radius: 15px;

    pointer-events: none;

    z-index: 2;
}


/* =========================================================
   IMAGE
========================================================= */

.worksheet-thumb img {

    width: 100%;
    height: 100%;

    display: block;

    object-fit: contain;

    border-radius: 14px;

    position: relative;

    z-index: 1;

    transition:
        transform 0.3s ease;
}


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

.worksheet-row:hover .worksheet-thumb {

    transform: translateY(-2px);

    box-shadow:
        0 0 0 2px var(--border),
        0 10px 22px rgba(0, 0, 0, 0.16);
}


.worksheet-row:hover .worksheet-thumb img {

    transform: scale(1.04);
}


/* =========================================================
   WORKSHEET CONTENT
========================================================= */

.worksheet-details {

    flex: 1;

    min-width: 0;
}


.worksheet-details h3 {

    margin: 0 0 9px;

    font-size: 27px;

    font-weight: 800;

    line-height: 1.25;

    color: var(--heading);

    transition:
        color 0.25s ease;
}


/*
   Category colour on title hover.
   No coloured card border.
*/

.worksheet-row:hover .worksheet-details h3 {

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


.worksheet-meta {

    margin-bottom: 12px;

    font-size: 15px;

    line-height: 1.5;

    color: var(--text-muted);

    font-weight: 700;
}


.worksheet-details p {

    margin: 0;

    color: var(--text-muted);

    line-height: 1.7;

    font-size: 16px;
}


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

.worksheet-action {

    flex-shrink: 0;

    display: flex;

    align-items: center;
}


/* =========================================================
   VIEW WORKSHEET BUTTON
========================================================= */

.worksheet-btn {

    display: inline-flex;

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

    min-width: 155px;

    padding: 14px 24px;

    box-sizing: border-box;

    background: var(--category-color);

    color: #ffffff;

    text-decoration: none;

    border: 2px solid var(--category-color);

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

    font-size: 15px;

    font-weight: 800;

    white-space: nowrap;

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

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


/* =========================================================
   BUTTON HOVER
========================================================= */

.worksheet-btn:hover {

    background: var(--category-color);

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

    color: #ffffff;

    transform: translateY(-3px);

    filter: brightness(0.92);

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


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

.empty-state {

    text-align: center;

    padding: 80px 20px;

    color: var(--text);
}


.empty-state h2 {

    margin: 0 0 12px;

    color: var(--heading);

    font-size: 28px;
}


.empty-state p {

    margin: 0;

    color: var(--text-muted);

    line-height: 1.7;

    font-size: 16px;
}


/* =========================================================
   PAGINATION
========================================================= */

.pagination {

    display: flex;

    justify-content: center;

    align-items: center;

    gap: 9px;

    margin: 45px 0 60px;

    padding: 0 15px;

    flex-wrap: wrap;
}


.pagination button {

    min-width: 44px;

    height: 44px;

    padding: 0 14px;

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

    border-radius: 12px;

    background: var(--surface);

    color: var(--text);

    cursor: pointer;

    font-family: inherit;

    font-size: 15px;

    font-weight: 800;

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


.pagination button:hover {

    background: var(--primary);

    color: #ffffff;

    border-color: var(--primary);

    transform: translateY(-2px);

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


.pagination button.active {

    background: var(--primary);

    color: #ffffff;

    border-color: var(--primary);

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


.page-info {

    font-weight: 800;

    color: var(--text-muted);

    margin: 0 8px;
}


/* =========================================================
   RESULTS COUNT
========================================================= */

.results-count {

    max-width: 1200px;

    margin: 25px auto 0;

    padding: 0 20px;

    box-sizing: border-box;

    font-size: 16px;

    color: var(--text-muted);

    font-weight: 700;
}


/* =========================================================
   DARK MODE
========================================================= */

[data-theme="dark"] .worksheet-row {

    background: var(--surface);

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


[data-theme="dark"] .worksheet-row:hover {

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


[data-theme="dark"] .worksheet-thumb {

    background: #f8fafc;

    border-color: #f8fafc;

    box-shadow:
        0 0 0 2px var(--border),
        0 8px 18px rgba(0, 0, 0, 0.35);
}


[data-theme="dark"] .worksheet-thumb::before {

    border-color: #d7dee8;
}


[data-theme="dark"] .worksheet-row:hover .worksheet-thumb {

    border-color: #f8fafc;

    box-shadow:
        0 0 0 2px var(--border),
        0 10px 24px rgba(0, 0, 0, 0.45);
}


[data-theme="dark"] .pagination button {

    background: var(--surface);

    border-color: var(--border);

    color: var(--text);
}


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

@media (max-width: 900px) {

    .page-header {

        min-height: 115px;

        padding: 22px 25px;
    }


    .page-header h1 {

        font-size: 34px;
    }


    .page-header p {

        font-size: 16px;
    }


    .worksheet-row {

        flex-direction: column;

        text-align: center;

        gap: 20px;

        padding: 25px;
    }


    .worksheet-thumb {

        width: 220px;

        height: 160px;

        flex-basis: 160px;
    }


    .worksheet-details {

        width: 100%;
    }


    .worksheet-details h3 {

        font-size: 25px;
    }


    .worksheet-action {

        width: 100%;

        justify-content: center;
    }
}


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

@media (max-width: 768px) {

    .page-header {

        min-height: 145px;

        padding: 25px 20px;

        text-align: center;
    }


    .page-header .container {

        flex-direction: column;

        justify-content: center;

        gap: 8px;
    }


    .page-header h1 {

        font-size: 32px;
    }


    .page-header p {

        font-size: 16px;

        line-height: 1.5;
    }


    .worksheet-library {

        margin: 25px auto 50px;

        padding: 0 15px;
    }


    .worksheet-row {

        padding: 22px 18px;

        gap: 18px;

        margin-bottom: 20px;

        border-radius: 22px;
    }


    .worksheet-thumb {

        width: 210px;

        height: 155px;

        flex-basis: 155px;

        padding: 10px;

        border-radius: 20px;
    }


    .worksheet-thumb::before {

        inset: 7px;

        border-radius: 14px;
    }


    .worksheet-details h3 {

        font-size: 23px;

        margin-bottom: 8px;
    }


    .worksheet-meta {

        font-size: 14px;

        margin-bottom: 10px;
    }


    .worksheet-details p {

        font-size: 15px;

        line-height: 1.65;
    }


    .worksheet-action {

        width: 100%;

        margin-top: 2px;
    }


    .worksheet-btn {

        width: 100%;

        max-width: 300px;

        min-width: 0;

        padding: 13px 20px;

        font-size: 15px;
    }


    .results-count {

        padding: 0 15px;

        font-size: 15px;

        text-align: center;
    }


    .pagination {

        margin: 35px 15px 50px;

        gap: 7px;
    }


    .pagination button {

        min-width: 42px;

        height: 42px;

        padding: 0 11px;

        font-size: 14px;
    }


    .page-info {

        width: 100%;

        text-align: center;

        margin: 0 0 5px;
    }
}


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

@media (max-width: 480px) {

    .page-header {

        min-height: 135px;

        padding: 22px 15px;
    }


    .page-header h1 {

        font-size: 29px;
    }


    .page-header p {

        font-size: 15px;
    }


    .worksheet-library {

        padding: 0 12px;
    }


    .worksheet-row {

        padding: 20px 15px;

        border-radius: 20px;
    }


    .worksheet-thumb {

        width: 190px;

        height: 140px;

        flex-basis: 140px;
    }


    .worksheet-details h3 {

        font-size: 21px;
    }


    .worksheet-details p {

        font-size: 14px;
    }


    .worksheet-btn {

        max-width: none;

        padding: 13px 18px;
    }


    .pagination button {

        min-width: 40px;

        height: 40px;

        padding: 0 9px;

        font-size: 13px;
    }


    .empty-state {

        padding: 60px 20px;
    }
}


/* =========================================================
   WORKSHEETS PAGE HERO
   COMPACT V2 STRIP
========================================================= */

.worksheets-hero {

    width: 100%;

    height: 210px;

    min-height: 0;

    box-sizing: border-box;

    display: flex;

    align-items: center;

    justify-content: center;

    text-align: center;

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

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

    padding: 20px;

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


.worksheets-hero .container {

    width: 100%;

    max-width: 1200px;

    margin: 0 auto;
}


.worksheets-hero h1 {

    margin: 0 0 10px;

    font-size: 44px;

    font-weight: 800;

    line-height: 1.15;

    color: var(--heading);
}


.worksheets-hero p {

    max-width: 900px;

    margin: 0 auto;

    font-size: 18px;

    line-height: 1.5;

    color: var(--text-muted);
}


/* =========================================================
   HERO RESPONSIVE
========================================================= */

@media (max-width: 900px) {

    .worksheets-hero {

        height: 190px;

        padding: 18px;
    }


    .worksheets-hero h1 {

        font-size: 38px;
    }


    .worksheets-hero p {

        font-size: 17px;
    }
}


@media (max-width: 768px) {

    .worksheets-hero {

        height: 175px;

        padding: 15px;
    }


    .worksheets-hero h1 {

        font-size: 32px;

        margin-bottom: 8px;
    }


    .worksheets-hero p {

        font-size: 16px;

        line-height: 1.45;
    }
}


@media (max-width: 480px) {

    .worksheets-hero {

        height: 160px;

        padding: 12px;
    }


    .worksheets-hero h1 {

        font-size: 29px;
    }


    .worksheets-hero p {

        font-size: 15px;
    }
}


/* =========================================================
   FINAL SAFETY RULES
   ---------------------------------------------------------
   These ensure no worksheet card gets an accidental
   coloured top border or pseudo-element from older CSS.
========================================================= */

.worksheet-row {

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

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

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

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


.worksheet-row::before {

    display: none !important;

    content: none !important;
}


.worksheet-row:hover {

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

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

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

    border-left-color: var(--border) !important;
}


/* =========================================================
   CATEGORY COLOUR
   ---------------------------------------------------------
   Category colour is ONLY used for:
   1. Worksheet title hover
   2. View Worksheet button
   ========================================================= */

.worksheet-row .worksheet-btn {

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

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

    color: #ffffff !important;
}


.worksheet-row .worksheet-btn:hover {

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

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

    color: #ffffff !important;

    filter: brightness(0.92);
}


.worksheet-row:hover .worksheet-details h3 {

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