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

.works-section {
    padding: 56px 14px;
    background: linear-gradient(180deg, #f9fafb, #eef2f7);
}

.works-title {
    text-align: center;
    font-size: 26px;
    font-weight: 900;
    color: #0f172a;
    margin-bottom: 26px;
}

@media (min-width:768px) {
    .works-section {
        padding: 80px 20px;
    }

    .works-title {
        font-size: 34px;
        margin-bottom: 40px;
    }
}

/* =========================
   GRID — แก้ปัญหาแถวสุดท้ายโหว่
========================= */

.works-grid {
    max-width: 1280px;
    margin: auto;
    display: grid;
    gap: 14px;

    /* mobile = 2 */
    grid-template-columns: repeat(2, 1fr);
}

/* tablet */
@media (min-width:640px) {
    .works-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

/* laptop+ desktop — auto balance */
@media (min-width:1024px) {
    .works-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 20px;
    }
}

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

.work-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    background: #000;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
    transition: .28s;
}

@media (hover:hover) {
    .work-card:hover {
        transform: translateY(-6px);
        box-shadow: 0 18px 36px rgba(0, 0, 0, .18);
    }
}

/* =========================
   IMAGE RATIO — มือถือไม่ยาว
========================= */

.work-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    transition: transform .4s;
}

@media (hover:hover) {
    .work-card:hover .work-img {
        transform: scale(1.08);
    }
}

/* =========================
   OVERLAY
========================= */

.work-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .65));
    display: flex;
    align-items: end;
    justify-content: center;
    color: white;
    font-weight: 700;
    opacity: 0;
    transition: .25s;
    padding-bottom: 12px;
    font-size: 13px;
    pointer-events: none;
}

/* desktop hover */
@media (hover:hover) {
    .work-card:hover .work-overlay {
        opacity: 1;
    }
}

/* mobile always show */
@media (hover:none) {
    .work-overlay {
        opacity: .9;
    }
}

/* =========================
   PAGINATION — Responsive จริง
========================= */

.pager {
    margin-top: 28px;
    text-align: center;
}

/* mobile size */
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 32px;
    height: 32px;
    margin: 3px;

    border-radius: 10px;
    background: white;
    box-shadow: 0 3px 8px rgba(0, 0, 0, .08);
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    color: #0f172a;
    transition: .2s;
}

.page-btn.active {
    background: #111827;
    color: white;
}

/* desktop size */
@media (min-width:768px) {
    .pager {
        margin-top: 40px;
    }

    .page-btn {
        min-width: 42px;
        height: 42px;
        margin: 5px;
        font-size: 15px;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
    }

    .page-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 18px rgba(0, 0, 0, .15);
    }
}

.page-dot {
    display: inline-block;
    padding: 6px 4px;
    color: #64748b;
    font-weight: 700;
    font-size: 13px;
}

/* =========================
   LIGHTBOX — mobile tuned
========================= */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .94);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.lightbox img {
    max-width: 95%;
    max-height: 84%;
    border-radius: 14px;
}

/* buttons */
.lb-close,
#lbPrev,
#lbNext {
    background: rgba(255, 255, 255, .14);
    border: none;
    color: white;
    border-radius: 12px;
    cursor: pointer;
    backdrop-filter: blur(6px);
}

/* mobile buttons */
.lb-close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 18px;
    padding: 8px 10px;
}

#lbPrev,
#lbNext {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 22px;
    padding: 10px 12px;
}

#lbPrev {
    left: 6px;
}

#lbNext {
    right: 6px;
}

/* desktop buttons */
@media (min-width:768px) {
    .lb-close {
        font-size: 24px;
        padding: 10px 14px;
        top: 16px;
        right: 16px;
    }

    #lbPrev,
    #lbNext {
        font-size: 30px;
        padding: 14px 16px;
    }
}

#lbCounter {
    position: absolute;
    bottom: 12px;
    color: white;
    font-weight: 700;
    font-size: 13px;
    background: rgba(255, 255, 255, .18);
    padding: 6px 12px;
    border-radius: 999px;
}

.hidden {
    display: none;
}