/*
 * Thư viện ảnh.
 *
 * Bám vào markup [gallery] gốc của WordPress — nghĩa là bạn thêm/bớt/sắp xếp
 * ảnh bằng "Thêm Media → Tạo thư viện" như bình thường, không cần plugin và
 * không phải sửa code.
 *
 * Chỉ nạp trên trang thật sự có thư viện ảnh.
 */

.vgh-gal-scope {
    --g-brown: var(--dragon-primary, #4a2c17);
    --g-gold: var(--dragon-accent, #d99a1c);
    --g-muted: var(--dragon-muted, #6b645c);
    --g-line: rgba(74, 44, 23, .13);
    --g-ease: cubic-bezier(.22, .61, .36, 1);
}

/* Bỏ bố cục bảng cũ kỹ mà WordPress dựng sẵn cho [gallery] */
.entry-content .gallery {
    display: grid !important;
    gap: 18px;
    margin: 30px 0 !important;
}

.entry-content .gallery-columns-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.entry-content .gallery-columns-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.entry-content .gallery-columns-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.entry-content .gallery-columns-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.entry-content .gallery-columns-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.entry-content .gallery-item {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    float: none !important;
    padding: 0 !important;
}

.entry-content .gallery-icon {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid var(--g-line);
    background: #efeae2;
}

.entry-content .gallery-icon a { display: block; line-height: 0; }

.entry-content .gallery-item img {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    border: 0 !important;
    transition: transform .7s var(--g-ease);
}

.entry-content .gallery-item:hover img { transform: scale(1.06); }

/* Lớp phủ + biểu tượng kính lúp khi rê chuột */
.entry-content .gallery-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(20, 12, 6, .42) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4.2-4.2M11 8v6M8 11h6'/%3E%3C/svg%3E") center/34px no-repeat;
    opacity: 0;
    transition: opacity .35s var(--g-ease);
    pointer-events: none;
}

.entry-content .gallery-item:hover .gallery-icon::after { opacity: 1; }

.entry-content .gallery-caption {
    display: block;
    margin: 10px 2px 0 !important;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--g-muted);
    text-align: center;
}

/* ------------------------------------------------------------- Khung xem to */
.vgh-lb {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(14, 9, 4, .93);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 60px;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
}

.vgh-lb.mo { opacity: 1; visibility: visible; }

.vgh-lb__img {
    max-width: 100%;
    max-height: calc(100vh - 130px);
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}

.vgh-lb__cap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 22px;
    text-align: center;
    color: rgba(255, 255, 255, .82);
    font-size: 14.5px;
    padding: 0 60px;
}

.vgh-lb__dem {
    position: absolute;
    top: 22px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, .6);
    font-size: 13.5px;
    letter-spacing: .06em;
}

.vgh-lb__nut {
    position: absolute;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .25s ease;
}

.vgh-lb__nut:hover { background: var(--dragon-accent, #d99a1c); color: #2b1a0c; }

.vgh-lb__dong { top: 18px; right: 18px; }
.vgh-lb__truoc { left: 18px; top: 50%; transform: translateY(-50%); }
.vgh-lb__sau  { right: 18px; top: 50%; transform: translateY(-50%); }

/* ---------------------------------------------------------------- Màn hẹp */
@media (max-width: 899px) {
    .entry-content .gallery { gap: 12px; }
    .entry-content .gallery-columns-4,
    .entry-content .gallery-columns-5,
    .entry-content .gallery-columns-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .entry-content .gallery-columns-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .vgh-lb { padding: 16px; }
    .vgh-lb__nut { width: 40px; height: 40px; font-size: 22px; }
    .vgh-lb__truoc { left: 8px; }
    .vgh-lb__sau { right: 8px; }
    .vgh-lb__cap { padding: 0 20px; font-size: 13.5px; }
}

@media (max-width: 549px) {
    .entry-content .gallery,
    .entry-content .gallery-columns-2,
    .entry-content .gallery-columns-3,
    .entry-content .gallery-columns-4,
    .entry-content .gallery-columns-5,
    .entry-content .gallery-columns-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
