/**
 * Event Photo Galleries
 *
 * Uniform grid: every tile is the same 4:3 box with the photo cropped to
 * fill it, so galleries mixing portrait and landscape shots still read as a
 * tidy grid. The full uncropped image opens in the lightbox.
 */

.srpc-galleries {
    margin: 40px 0;
}

/* Scoped because The Events Calendar's stylesheets load after the theme's and
   recolour headings on single event pages — the gallery heading came out in
   TEC's near-black rather than the club navy. */
.srpc-galleries .srpc-galleries-heading,
.srpc-galleries h2.srpc-galleries-heading {
    font-family: var(--srpc-font-display);
    font-size: var(--srpc-text-2xl, 28px);
    margin: 0 0 24px;
    color: var(--srpc-navy);
}

.srpc-gallery-event {
    margin-bottom: 40px;
}

.srpc-gallery-event-header {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--srpc-rule-soft);
}

.srpc-gallery-event-title {
    font-size: 20px;
    line-height: 1.2;
    margin: 0;
}

.srpc-gallery-event-title a {
    color: var(--srpc-navy);
    text-decoration: none;
}

.srpc-gallery-event-title a:hover {
    color: var(--srpc-orange);
    text-decoration: underline;
}

.srpc-gallery-event-date {
    font-size: 15px;
    color: var(--srpc-steel);
}

/* --- Grid --- */

.srpc-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
}

/* Tiles are <button> elements so they are keyboard-operable, which means
   every global button style on the site lands on them — the theme's, The
   Events Calendar's, and the host plugin's, several of which use !important.
   This rule has to win outright or tiles render with a stray border and
   padding. Focus styling is deliberately left to :focus-visible below. */
.srpc-galleries .srpc-gallery-grid .srpc-gallery-tile,
.srpc-galleries .srpc-gallery-grid .srpc-gallery-tile:hover,
.srpc-galleries .srpc-gallery-grid .srpc-gallery-tile:active {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 4px;
    overflow: hidden;
    background: var(--srpc-rule-soft) !important;
    box-shadow: none !important;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    line-height: 0;
}

/* Positioned rather than sized with height:100%. The tile's height comes from
   aspect-ratio, which is not a definite height, so a percentage height on the
   image resolves to auto and the photo renders at its own ratio — leaving a
   strip of tile background below it. Absolute inset resolves against the
   padding box and fills reliably. */
.srpc-galleries .srpc-gallery-grid .srpc-gallery-tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.srpc-gallery-tile:hover img,
.srpc-gallery-tile:focus-visible img {
    transform: scale(1.06);
}

.srpc-galleries .srpc-gallery-grid .srpc-gallery-tile:focus-visible {
    outline: 3px solid var(--srpc-orange) !important;
    outline-offset: 2px;
}

/* "+N more" overlay on the final visible tile */
.srpc-gallery-more {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 58, 82, 0.72);
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.srpc-galleries-more {
    margin-top: 8px;
}

.srpc-galleries-more-link {
    display: inline-block;
    background: var(--srpc-navy);
    color: #fff !important;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: 600;
    text-decoration: none;
}

.srpc-galleries-more-link:hover {
    background: var(--srpc-orange);
}

/* --- Lightbox --- */

.srpc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.92);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.srpc-lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

.srpc-lightbox img {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 2px;
}

/* Lightbox controls are <button> elements appended to <body>, so Elementor's
   and the host plugin's global button styles reach them the same way they
   reached the gallery tiles. Scoped and forced for the same reason. */
.srpc-lightbox .srpc-lightbox-btn {
    position: absolute;
    background: rgba(255, 255, 255, 0.12) !important;
    border: 0 !important;
    box-shadow: none !important;
    color: #fff !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    line-height: 1;
    font-family: var(--srpc-font-display, sans-serif);
    -webkit-appearance: none;
    appearance: none;
}

.srpc-lightbox .srpc-lightbox-btn:hover,
.srpc-lightbox .srpc-lightbox-btn:focus {
    background: rgba(255, 255, 255, 0.28) !important;
    color: #fff !important;
}

.srpc-lightbox .srpc-lightbox-btn:focus-visible {
    outline: 3px solid var(--srpc-orange, #e35205) !important;
    outline-offset: 2px;
}

.srpc-lightbox-close {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 30px;
}

.srpc-lightbox-prev,
.srpc-lightbox-next {
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 72px;
    border-radius: 4px;
    font-size: 34px;
}

.srpc-lightbox-prev { left: 16px; }
.srpc-lightbox-next { right: 16px; }

.srpc-lightbox-counter {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    letter-spacing: 0.04em;
}

body.srpc-lightbox-open {
    overflow: hidden;
}

/* --- Responsive --- */

@media (max-width: 782px) {
    .srpc-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }

    .srpc-galleries-heading { font-size: 24px; }
    .srpc-gallery-event-title { font-size: 18px; }

    .srpc-lightbox-prev,
    .srpc-lightbox-next {
        width: 42px;
        height: 58px;
        font-size: 26px;
    }

    .srpc-lightbox-prev { left: 6px; }
    .srpc-lightbox-next { right: 6px; }
}

@media (max-width: 420px) {
    .srpc-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* The Elementor section wrapping this has no horizontal padding, so on
       narrow screens the tiles would otherwise sit flush to both edges. */
    .srpc-galleries {
        padding-left: 14px;
        padding-right: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .srpc-gallery-tile img,
    .srpc-lightbox {
        transition: none;
    }

    .srpc-gallery-tile:hover img,
    .srpc-gallery-tile:focus-visible img {
        transform: none;
    }
}

/* The "+N" overflow tile is an <a>, not a <button>, so it needs the same
   reset. It leads to the event page rather than opening the lightbox. */
.srpc-galleries .srpc-gallery-grid a.srpc-gallery-tile--link {
    display: block;
    text-decoration: none;
}
