/* Filter row */
.rg-filter-row { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:18px; }
.rg-filter-btn { font-family:'open sans', sans-serif; background:#f1f1f1; border:0; padding:8px 12px; border-radius:999px; cursor:pointer; font-weight:600; }
.rg-filter-btn.rg-active { background:#0073aa; color:#fff; }



/* Grid */
.rg-grid {
    display: grid;
    gap: 16px;
    /* Force 4 items per row that evenly fill the full width */
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive adjustments: 3 columns on medium, 2 on small, 1 on very small */
@media (max-width: 1100px) {
    .rg-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
    .rg-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .rg-grid { grid-template-columns: 1fr; }
}
.rg-item {
    display: flex;
    flex-direction: column;
    text-align: left; /* caption aligns left within its container */
}

.rg-thumb {
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
    transition: transform .18s ease, box-shadow .18s ease;
    /* enforce consistent height for all thumbnails so grid rows align (increased to ~2x) */
    height: 320px;
    width: 100%;
    display: block;
}

.rg-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* fill the thumb area while preserving aspect ratio */
    display: block;
    cursor: pointer;
}

.rg-item:hover .rg-thumb { transform: translateY(-6px); box-shadow: 0 12px 30px rgba(0,0,0,0.12); }

.rg-caption {
    font-family: 'open sans', sans-serif;
    margin-top: 12px;
    font-size: 14px;
    color: #333;
    /* push caption to the bottom of the item container */
    margin-top: auto;
    padding-top: 12px;
}

/* Responsive thumbnail heights */
@media (max-width: 1100px) {
    .rg-thumb { height: 300px; }
}
@media (max-width: 800px) {
    .rg-thumb { height: 280px; }
}
@media (max-width: 480px) {
    .rg-thumb { height: 240px; }
}

/* Category section heading */
.rg-category-section { 
    grid-column: 1 / -1;
    margin-top: 24px;
    margin-bottom: 8px;
}
.rg-category-section:first-of-type { margin-top:0; }
.rg-category-heading {
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: #ffffff;
    background-color: #1d5eb1;
    padding: 12px 20px;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
}


/* Popover */
.rg-pop {
    /* Hidden by default using visibility/opacity to avoid issues with JS display toggles */
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

.rg-pop.rg-visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}
.rg-pop-inner {
    position: relative;
    /* Reduce desktop max size by ~30% (from 1000px -> 700px) to make the popover less dominating */
    max-width: 700px;
    width: 100%;
    /* ensure the inner panel fits within the viewport so flex centering works reliably */
    max-height: calc(100vh - 40px);
    box-sizing: border-box;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Remove scrollbars: keep content sized and use object-fit on the image */
    overflow: hidden;
}
.rg-pop img {
    width: 100%;
    height: auto;
    /* leave room for padding and caption so image doesn't push the panel out of center */
    max-height: calc(100vh - 160px);
    border-radius: 10px;
    display: block;
    object-fit: contain;
}
.rg-pop-close {
    position: absolute;
    /* Place the close button inside the popover so it isn't cut off */
    top: 12px;
    right: 12px;
    background: #fff;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 26px;
    line-height: 38px;
    text-align: center;
    border: 0;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,0.15);
    z-index: 10002;
}
.rg-pop-caption { margin-top:10px; color:#eee; font-size:15px; text-align:center; }