/* === GRID LAYOUT === */
.cpg-gallery-grid {
    display: grid;
    gap: 20px;
    max-width: 1230px;   /* cap parent width */
    margin: 0 auto;      /* center grid */
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    align-items: start;  /* prevent other cards from stretching */
    transition: 0.3s;
}

/* Responsive breakpoints */
@media (max-width: 767px) {
    .cpg-gallery-grid {
        grid-template-columns: 1fr; /* 1 card per row on mobile */
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .cpg-gallery-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 cards per row on tablets */
    }
}

@media (min-width: 992px) {
    .cpg-gallery-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 cards per row on desktop */
    }
    
    .cpg-gallery-card {
        min-height: 410px;
    }
}

/* === CARD STYLING === */
.cpg-gallery-card {
    border: 1px solid #eee;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 4px 4px 13px 5px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    cursor: pointer;
    padding: 15px;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1;
}

.cpg-gallery-card:hover {
    transform: scale(1.03);
    z-index: 10; /* bring hovered card above others */
}

/* Thumbnail image */
.cpg-gallery-thumb {
    width: 100%;
    padding-top: 66.66%; /* 3:2 ratio */
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    border-radius: 10px;
    height: 275px;
}

.cpg-gallery-featured-link:hover .cpg-gallery-thumb {
    transform: none !important;
}

.cpg-gallery-featured-link {
    display: block;
    overflow: hidden;
}

/* === INFO SECTION === */
.cpg-gallery-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
    max-height: 120px;          /* restrict height initially */
    overflow: hidden;
    transition: max-height 0.3s ease; /* smooth expansion */
}

/* Title */
.cpg-gallery-title {
    font-size: 20px;
    font-family: bpg_banner_extrasquare_caps!important;
    margin: 10px 0px 8px 0px;
    cursor: pointer;

    /* clamp to 2 lines with ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4em;
    max-height: 2.8em; /* 2 lines * line-height */

    transition: max-height 0.3s ease, color 0.3s ease;
}

.cpg-gallery-title:hover {
    color: var(--e-global-color-01dff2d);
}

/* On hover over the card, expand info and show full title (desktop/tablet) */
.cpg-gallery-card:hover .cpg-gallery-info {
    max-height: 500px; /* expand smoothly to fit full content */
}

.cpg-gallery-card:hover .cpg-gallery-title {
    -webkit-line-clamp: unset;   /* remove clamp */
    max-height: 500px;           /* expand smoothly */
    overflow: visible;
}

/* === Mobile override: always show full title === */
@media (max-width: 767px) {
    .cpg-gallery-info {
        max-height: none;       /* no restriction */
        overflow: visible;
    }
    .cpg-gallery-title {
        -webkit-line-clamp: unset; /* remove clamp */
        max-height: none;          /* let it expand naturally */
        overflow: visible;
    }
}

/* Divider + meta block wrapper */
.cpg-gallery-meta-block {
    margin-top: auto; /* keep meta pinned at bottom */
    height: auto;
}

/* Divider line */
.cpg-divider {
    height: 1px;
    background: #ddd;
    margin: 4px 0;
}

/* Meta row: date + count */
.cpg-gallery-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #666;
}

.cpg-gallery-date {
    color: #888;
    font-family: "bpg_banner_extrasquare_caps"!important;
    font-size: 14px;
}

.cpg-gallery-count {
    font-weight: 500;
    color: #333;
    font-family: "bpg_banner_extrasquare_caps"!important;
    font-size: 14px;
}

/* Hidden images for Fancybox */
.cpg-hidden-images {
    display: none;
}
