/**
 * Custom Photo Gallery - Public Stylesheet
 * Version: 1.5.3
 */
/* 1. จัดการตัวแกลเลอรีหลัก (Container) */
.cpg-gallery {
    display: grid; /* ใช้ Grid Layout เพื่อจัดเรียงรูปภาพ */
    /* * สร้างคอลัมน์ขนาดขั้นต่ำ 150px และขยายให้เต็มพื้นที่ (auto-fill) 
     * ทำให้แกลเลอรีเป็นแบบ Responsive ปรับจำนวนคอลัมน์ตามขนาดหน้าจอ
    */
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px; /* ระยะห่างระหว่างรูปภาพ */
    padding: 0;
    margin: 0;
}

.cpg-item {
    position: relative;
    /* * บังคับให้กรอบของรูปเป็นสี่เหลี่ยมจัตุรัส (อัตราส่วน 1:1)
     * นี่คือส่วนสำคัญที่ทำให้ทุกช่องมีขนาดเท่ากัน
    */
    aspect-ratio: 1 / 1; 
    overflow: hidden; /* ซ่อนส่วนของรูปภาพที่ล้นออกจากกรอบ */
    border-radius: 5px; /* ทำให้ขอบมนเล็กน้อย (ปรับได้ตามชอบ) */
}

.cpg-item img {
    width: 100%; /* ทำให้รูปมีความกว้างเต็มกรอบ */
    height: 100%; /* ทำให้รูปมีความสูงเต็มกรอบ */
    
    /* * หัวใจสำคัญ: ทำให้รูปภาพขยายเต็มพื้นที่กรอบโดยไม่เสียสัดส่วน 
     * โดยจะทำการ crop ส่วนที่เกินออกไปอัตโนมัติ (เหมือน background-size: cover)
    */
    object-fit: cover; 
    
    display: block;
    transition: transform 0.3s ease; /* เพิ่ม Animation ตอนเอาเมาส์มาวาง */
}


.cpg-item:hover img {
    transform: scale(1.1); /* ขยายรูปขึ้นเล็กน้อย */
}

/* --- Lightbox Styles --- */

/* ตัว Overlay หลักของ Lightbox */
#cpg-lightbox-overlay {
    position: fixed; /* แสดงทับเนื้อหาทั้งหมด */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); /* พื้นหลังสีดำโปร่งแสง */
    z-index: 1000; /* ให้แสดงอยู่ชั้นบนสุด */
    
    /* ซ่อนไว้เป็นค่าเริ่มต้น */
    display: none; 
    
    /* จัดให้รูปภาพอยู่ตรงกลางจอ */
    
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

/* รูปภาพที่แสดงใน Lightbox */
.cpg-lightbox-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 5px;
}

/* ปุ่มปิด (X) */
.cpg-close-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    line-height: 40px;
    cursor: pointer;
    transition: background 0.2s ease;
    z-index: 10;
}

.cpg-close-button:hover {
    color: #bbb; /* สีเมื่อเอาเมาส์มาวาง */
}
