/* คุม Grid ให้แถวเท่ากัน */
.act-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    grid-auto-rows: 1fr !important;
    gap: 20px !important;
    margin-top: 20px !important;
}

/* ตัวการ์ดขาวๆ */
.act-card {
    display: flex !important;
    flex-direction: column !important;
    background: #fff !important;
    border-radius: 12px !important;
    border: 1px solid #e1e8ed !important;
    overflow: hidden !important;
    transition: transform 0.2s ease;
    height: 100% !important;
}

.act-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* คุมพื้นที่รูปภาพให้เท่ากัน 100% แม้ไม่มีรูป */
.act-img-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* อัตราส่วน 16:9 */
    background: #f8f9fa;
    overflow: hidden;
}

.act-img-wrapper img, .img-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* ส่วนเนื้อหาภายใน */
.act-body {
    padding: 15px !important;
    display: flex !important;
    flex-direction: column !important;
    flex-grow: 1 !important;
}

.act-title {
    font-size: 16px !important;
    font-weight: 700 !important;
    line-height: 1.4 !important;
    margin-bottom: 8px !important;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* ตัดชื่อเรื่องที่ยาวเกิน 2 บรรทัด */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.act-title a {
    color: #333 !important;
    text-decoration: none !important;
}

.act-date {
    font-size: 13px !important;
    color: #888 !important;
    margin-bottom: 10px !important;
}

.act-ex {
    font-size: 14px !important;
    color: #555 !important;
    line-height: 1.5 !important;
    flex-grow: 1 !important;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* ตัดเนื้อหาที่ยาวเกิน 3 บรรทัด */
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* ส่วนข่าวสาร (News Grid) */
.news-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
    grid-auto-rows: 1fr !important; /* บังคับให้แถวสูงเท่ากัน */
    gap: 16px !important;
    margin-top: 14px !important;
}

.news-card {
    display: flex !important;
    flex-direction: column !important;
    text-decoration: none !important;
    border: 1px solid #e7e7e7 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    background: #fff !important;
    height: 100% !important;
    transition: transform 0.2s ease;
}

.news-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* คุมพื้นที่รูปภาพ */
.news-img-wrapper {
    width: 100%;
    height: 160px;
    overflow: hidden;
    background: #f0f0f0;
}

.news-card img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

/* ส่วนของคำบรรยาย */
.news-card .cap {
    padding: 12px !important;
    color: #333 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    flex-grow: 1 !important; /* ยืดพื้นที่สีขาวให้เต็มกล่อง */
    display: flex;
    align-items: flex-start;
}
/* การตั้งค่าสำหรับมือถือเท่านั้น (Mobile Only) */
@media (max-width: 767px) {
    /* ปรับ Grid ให้กลายเป็นแนวนอนแถวเดียว */
    .act-grid, .news-grid {
        display: flex !important; /* เปลี่ยนจาก grid เป็น flex เพื่อเรียงแนวนอน */
        flex-wrap: nowrap !important;
        overflow-x: auto !important; /* เปิดให้เลื่อนซ้ายขวาได้ */
        scroll-snap-type: x mandatory !important; /* ทำให้เลื่อนแล้วหยุดกึ่งกลางกล่องพอดี */
        -webkit-overflow-scrolling: touch; /* ให้เลื่อนลื่นๆ บน iOS */
        gap: 15px !important;
        padding-bottom: 15px !important; /* เผื่อพื้นที่ให้ Scroll bar */
        margin-left: -5px; /* ปรับตำแหน่งให้ดูบาลานซ์ */
        margin-right: -5px;
    }

    /* ซ่อน Scrollbar เพื่อความสวยงาม (ถ้าต้องการ) */
    .act-grid::-webkit-scrollbar, 
    .news-grid::-webkit-scrollbar {
        display: none;
    }

    /* ปรับขนาดกล่องในมือถือ ให้เห็นใบถัดไปนิดๆ เพื่อให้รู้ว่าเลื่อนได้ */
    .act-card, .news-card {
        flex: 0 0 85% !important; /* บังคับให้หนึ่งกล่องกินพื้นที่ 85% ของหน้าจอ */
        scroll-snap-align: center !important; /* ให้กล่องหยุดตรงกลางหน้าจอ */
        height: auto !important;
    }

    /* ปรับความสูงรูปในมือถือให้เล็กลงหน่อยเพื่อประหยัดพื้นที่ */
    .act-img-wrapper, .news-img-wrapper {
        height: 140px !important;
        padding-top: 0 !important; /* ยกเลิก Aspect Ratio เดิมเพื่อใช้ความสูงคงที่ */
    }
}