/* ================================================================
   IGS – Frontend Gallery Styles  v1.5
   ================================================================ */

/* ── Shimmer animation (dùng chung cho gallery & post card) ─ */
@keyframes igs-shimmer {
    0%   { background-position: 200% center; }
    100% { background-position: -200% center; }
}

/* Mixin placeholder: card container hiển thị shimmer khi ảnh chưa load */
.igs-image-card:not(.igs-img-ready),
.igsp-thumbnail-link:not(.igsp-img-ready) {
    background: linear-gradient(
        90deg,
        #e8e8e8 25%,
        #d4d4d4 50%,
        #e8e8e8 75%
    );
    background-size: 400% 100%;
    animation: igs-shimmer 1.6s ease infinite;
}

/* Dark theme: shimmer tối hơn */
.igs-theme-dark .igs-image-card:not(.igs-img-ready),
.igsp-theme-dark .igsp-thumbnail-link:not(.igsp-img-ready) {
    background: linear-gradient(
        90deg,
        #2a2a2a 25%,
        #363636 50%,
        #2a2a2a 75%
    );
    background-size: 400% 100%;
    animation: igs-shimmer 1.6s ease infinite;
}

/* Khi card đã load xong: tắt shimmer, khôi phục màu nền */
.igs-image-card.igs-img-ready   { animation: none; background: var(--igs-card-bg); }
.igsp-thumbnail-link.igsp-img-ready { animation: none; background: transparent; }

/* ── Ảnh: mặc định ẩn, fade-in khi ready ── */
.igs-image-card img,
.igsp-thumbnail {
    opacity: 0;
    transition: opacity 0.4s ease;
    will-change: opacity;
}
.igs-image-card.igs-img-ready   img { opacity: 1; }
.igsp-thumbnail-link.igsp-img-ready .igsp-thumbnail { opacity: 1; }

/* ── Variables ──────────────────────────────────────────── */
.igs-gallery {
    --igs-cols:       5;
    --igs-gap:        12px;
    --igs-radius:     12px;
    --igs-card-bg:    #fff;
    --igs-heading-c:  #1a5fa8;
    --igs-wrap-bg:    transparent;
    --igs-wrap-pad:   0;
    --igs-btn-bg:     #e53935;
    --igs-btn-c:      #fff;
    --igs-more-c:     #e53935;
    font-family: inherit;
    margin: 0;
    padding: var(--igs-wrap-pad);
    background: var(--igs-wrap-bg);
    position: relative;
}

/* ── Dark theme ─────────────────────────────────────────── */
.igs-theme-dark {
    --igs-heading-c: #f5c518;
    --igs-wrap-bg:   #111;
    --igs-wrap-pad:  16px 20px;
    --igs-card-bg:   transparent;
    --igs-more-c:    #e53935;
    border-radius: 10px;
}

/* ── Header row: tiêu đề + link Xem thêm ──────────────── */
.igs-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 10px;
}
.igs-gallery .igs-heading {
    font-size: 18px;
    font-weight: 700;
    color: var(--igs-heading-c);
    margin: 0;
    padding: 0;
    line-height: 1.3;
    border: none;
}
.igs-gallery .igs-more-link {
    font-size: 14px;
    color: var(--igs-more-c);
    text-decoration: none;
    white-space: nowrap;
    font-weight: 600;
    flex-shrink: 0;
}
.igs-gallery .igs-more-link:hover { text-decoration: underline; }

/* ================================================================
   KIỂU: ROW — hàng ngang, thanh cuộn mỏng
   ================================================================ */
.igs-display-row .igs-images-wrap {
    display: flex;
    gap: var(--igs-gap);
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    -webkit-overflow-scrolling: touch;
}
.igs-display-row .igs-images-wrap::-webkit-scrollbar      { height: 4px; }
.igs-display-row .igs-images-wrap::-webkit-scrollbar-track { background: transparent; }
.igs-display-row .igs-images-wrap::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.igs-display-row .igs-image-card { flex: 0 0 auto; width: 110px; }

/* ================================================================
   KIỂU: GRID — lưới cố định
   ================================================================ */
.igs-display-grid .igs-images-wrap {
    display: grid;
    grid-template-columns: repeat( var(--igs-cols, 5), 1fr );
    gap: var(--igs-gap);
}

/* ================================================================
   KIỂU: SLIDER — kéo ngang, KHÔNG thanh cuộn
   ================================================================ */
.igs-display-slider {
    position: relative;
}
.igs-display-slider .igs-images-wrap {
    display: flex;
    gap: var(--igs-gap);
    overflow-x: scroll;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;

    /* Ẩn hoàn toàn thanh cuộn trên mọi trình duyệt */
    scrollbar-width: none;        /* Firefox */
    -ms-overflow-style: none;     /* IE / Edge cũ */
}
.igs-display-slider .igs-images-wrap::-webkit-scrollbar { display: none; } /* Chrome, Safari */

.igs-display-slider .igs-images-wrap {
    cursor: grab;
    user-select: none;
}
.igs-display-slider .igs-images-wrap.igs-dragging {
    cursor: grabbing;
    scroll-behavior: auto; /* tắt smooth khi đang kéo */
}
/* Chặn click link khi đang drag */
.igs-display-slider .igs-images-wrap.igs-dragging a,
.igs-display-slider .igs-images-wrap.igs-dragging .igs-card-btn {
    pointer-events: none;
}

.igs-display-slider .igs-image-card { flex: 0 0 auto; width: 110px; }

/* ── Nút mũi tên (slider) ── */
.igs-arrows {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
    padding: 0 4px;
}
.igs-arrow {
    pointer-events: all;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    flex-shrink: 0;
}
.igs-arrow:hover { background: rgba(0,0,0,.85); }

/* ================================================================
   CARD — chung cho tất cả kiểu
   ================================================================ */
.igs-gallery .igs-image-card {
    border-radius: var(--igs-radius);
    overflow: hidden;
    background: var(--igs-card-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    transition: transform .2s ease, box-shadow .2s ease;
    border: 1px solid rgba(255,255,255,.08);
    display: flex;
    flex-direction: column;
    align-items: stretch;
}
.igs-gallery .igs-image-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,.2);
}

.igs-gallery .igs-img-link { display: block; line-height: 0; }

.igs-gallery .igs-image-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    -webkit-user-drag: none;
}

/* ── Nút dưới ảnh (Đặt cược →) ── */
.igs-gallery .igs-card-btn {
    display: block;
    text-align: center;
    background: var(--igs-btn-bg);
    color: var(--igs-btn-c) !important;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 4px;
    text-decoration: none !important;
    line-height: 1.2;
    border-radius: 0 0 var(--igs-radius) var(--igs-radius);
    white-space: nowrap;
    transition: filter .15s;
    cursor: pointer;
}
.igs-gallery .igs-card-btn:hover { filter: brightness(1.12); }

/* ── Dark theme card adjustments ── */
.igs-theme-dark .igs-image-card {
    background: #1e1e1e;
    border-color: rgba(255,255,255,.1);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .igs-display-grid .igs-images-wrap {
        grid-template-columns: repeat( max(2, calc(var(--igs-cols, 5) - 2)), 1fr );
    }
    .igs-display-row .igs-image-card,
    .igs-display-slider .igs-image-card {
        width: 90px;
    }
}
@media (max-width: 480px) {
    .igs-display-grid .igs-images-wrap {
        grid-template-columns: repeat( max(2, calc(var(--igs-cols, 5) - 3)), 1fr );
    }
    .igs-gallery .igs-heading { font-size: 15px; }
}

/* ================================================================
   IGSP – POST CATEGORY SHORTCODE
   ================================================================ */

.igsp-wrap {
    --igsp-cols:      3;
    --igsp-gap:       20px;
    --igsp-radius:    10px;
    --igsp-card-bg:   #fff;
    --igsp-heading-c: #1a5fa8;
    --igsp-more-c:    #e53935;
    --igsp-title-c:   #1d2327;
    --igsp-excerpt-c: #555;
    --igsp-btn-bg:    #e53935;
    --igsp-btn-c:     #fff;
    --igsp-meta-c:    #999;
    --igsp-shadow:    0 2px 8px rgba(0,0,0,.1);
    font-family: inherit;
    margin: 0;
}

/* Dark theme */
.igsp-theme-dark {
    --igsp-card-bg:   #1e1e1e;
    --igsp-heading-c: #f5c518;
    --igsp-title-c:   #f0f0f0;
    --igsp-excerpt-c: #bbb;
    --igsp-meta-c:    #777;
    --igsp-shadow:    0 2px 8px rgba(0,0,0,.35);
    background: #111;
    border-radius: 10px;
    padding: 16px 20px;
}

/* ── Header row ── */
.igsp-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 10px;
}
.igsp-wrap .igsp-heading {
    font-size: 18px;
    font-weight: 700;
    color: var(--igsp-heading-c);
    margin: 0;
    padding: 0;
    border: none;
    line-height: 1.3;
}
.igsp-wrap .igsp-more-link {
    font-size: 14px;
    color: var(--igsp-more-c);
    text-decoration: none;
    white-space: nowrap;
    font-weight: 600;
    flex-shrink: 0;
}
.igsp-wrap .igsp-more-link:hover { text-decoration: underline; }

/* ================================================================
   GRID layout
   ================================================================ */
.igsp-display-grid .igsp-posts {
    display: grid;
    grid-template-columns: repeat( var(--igsp-cols, 3), 1fr );
    gap: var(--igsp-gap);
}

.igsp-display-grid .igsp-post-card {
    display: flex;
    flex-direction: column;
    background: var(--igsp-card-bg);
    border-radius: var(--igsp-radius);
    overflow: hidden;
    box-shadow: var(--igsp-shadow);
    transition: transform .2s ease, box-shadow .2s ease;
}
.igsp-display-grid .igsp-post-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
}

.igsp-display-grid .igsp-thumbnail-link { display: block; line-height: 0; }
.igsp-display-grid .igsp-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.igsp-display-grid .igsp-post-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* ================================================================
   LIST layout
   ================================================================ */
.igsp-display-list .igsp-posts {
    display: flex;
    flex-direction: column;
    gap: var(--igsp-gap);
}

.igsp-display-list .igsp-post-card {
    display: flex;
    gap: 0;
    align-items: stretch;
    background: var(--igsp-card-bg);
    border-radius: var(--igsp-radius);
    overflow: hidden;
    box-shadow: var(--igsp-shadow);
    transition: box-shadow .2s ease;
}
.igsp-display-list .igsp-post-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,.18);
}

.igsp-display-list .igsp-thumbnail-link {
    flex-shrink: 0;
    width: 160px;
    display: block;
    line-height: 0;
}
.igsp-display-list .igsp-thumbnail {
    width: 160px;
    height: 100%;
    min-height: 120px;
    object-fit: cover;
    display: block;
}

.igsp-display-list .igsp-post-body {
    padding: 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ── Nội dung chung cho cả hai layout ── */
.igsp-wrap .igsp-post-meta {
    font-size: 12px;
    color: var(--igsp-meta-c);
    margin-bottom: 6px;
}

.igsp-wrap .igsp-post-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 8px;
    line-height: 1.4;
    color: var(--igsp-title-c);
    border: none;
    padding: 0;
}
.igsp-wrap .igsp-post-title a {
    color: inherit;
    text-decoration: none;
}
.igsp-wrap .igsp-post-title a:hover { text-decoration: underline; }

.igsp-wrap .igsp-post-excerpt {
    font-size: 13px;
    color: var(--igsp-excerpt-c);
    line-height: 1.55;
    margin-bottom: 12px;
    flex: 1;
}

.igsp-wrap .igsp-read-btn {
    display: inline-block;
    align-self: flex-start;
    margin-top: auto;
    background: var(--igsp-btn-bg);
    color: var(--igsp-btn-c) !important;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 20px;
    text-decoration: none !important;
    white-space: nowrap;
    transition: filter .15s;
}
.igsp-wrap .igsp-read-btn:hover { filter: brightness(1.12); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .igsp-display-grid .igsp-posts {
        grid-template-columns: repeat( max(2, calc(var(--igsp-cols, 3) - 1)), 1fr );
    }
    .igsp-display-grid .igsp-thumbnail { height: 140px; }
    .igsp-display-list .igsp-thumbnail-link { width: 120px; }
    .igsp-display-list .igsp-thumbnail { width: 120px; }
}
@media (max-width: 480px) {
    .igsp-display-grid .igsp-posts {
        grid-template-columns: repeat( max(1, calc(var(--igsp-cols, 3) - 1)), 1fr );
    }
    .igsp-display-list .igsp-post-card { flex-direction: column; }
    .igsp-display-list .igsp-thumbnail-link { width: 100%; }
    .igsp-display-list .igsp-thumbnail { width: 100%; height: 180px; min-height: unset; }
    .igsp-display-list .igsp-post-body { padding: 12px; }
    .igsp-wrap .igsp-heading { font-size: 15px; }
}

/* ================================================================
   AUTO-PLAY PROGRESS BAR
   ================================================================ */
.igs-progress-bar {
    height: 3px;
    background: rgba(0,0,0,.12);
    border-radius: 0 0 10px 10px;
    overflow: hidden;
    margin-top: 8px;
}
.igs-theme-dark .igs-progress-bar {
    background: rgba(255,255,255,.12);
}
.igs-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--igs-btn-bg, #e53935);
    border-radius: inherit;
    /* transition được set bằng JS */
}
