.jl-gallery {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 3rem 0 2rem 0;
}

.jl-gallery-view {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.jl-gallery-image-wrap {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .5rem;
}

.jl-gallery-img {
    width: 800px;
    max-width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.jl-gallery-btn {
    background: #eee;
    border: 1px solid #ccc;
    padding: .4rem .8rem;
    font-size: 1.6rem;
    cursor: pointer
}

.jl-gallery-meta {
    font-size: 0.95rem;
    color: #222;
    margin-top: .5rem;
    text-align: left;
}

.jl-gallery-title {
    margin: 0 0 .25rem 0
}

.jl-gallery-details {
    color: #666;
    font-size: .9rem
}

.jl-gallery-controls {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    display: flex;
    gap: .25rem;
}

.jl-gallery {
    position: relative;
}

/* Tiles grid */
.jl-gallery-tiles .jl-tiles-grid {
    /* Use a wrapping flexbox so each tile height is fixed and width adjusts to image aspect ratio */
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

.jl-tile {
    list-style: none;
    margin: 0;
    background: #fff;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    /* Let the tile width size to its contents; keep consistent height via the link */
    display: inline-flex;
    flex-direction: column;
    align-items: stretch;
}

.jl-tile-link {
    display: block;
}

.jl-tile-caption {
    padding: .5rem;
    font-size: .9rem;
}

.jl-tile-title {
    font-weight: 600;
    color: var(--primary) !important;
    text-decoration: none
}

.jl-tile-dim {
    color: #666;
    font-size: .85rem;
}

/* .jl-tiles-grid rules are defined earlier; no-op removed to avoid empty ruleset */

/* Tile sizing: consolidated CSS variables for gallery dimensions */
/* Note: These match the Hugo template resize parameters */
:root {
    --jl-tile-height: 150px;
    /* matches Hugo x150 resize */
    --jl-tile-max-width: 300px;
    /* matches Hugo 300x resize fallback */
    --gallery-thumb-height: 150px;
    /* Hugo template reference */
    --gallery-thumb-max-width: 300px;
    /* Hugo template reference */
    --gallery-display-max-width: 1600px;
    /* Hugo template reference */
    --pswp-padding-percent: 15;
    /* PhotoSwipe lightbox padding as percentage of viewport */
}

@media (max-width: 600px) {
    :root {
        --jl-tile-height: 150px;
        --jl-tile-max-width: 300px;
    }
}

/* Make the anchor act as the image box with fixed height; center the image inside */
.jl-tile-link {
    display: block;
    /* keep semantic clickable area */
}

/* The visual image container that forces tile height and centers the image */
.jl-tile .jl-tile-img-wrap {
    height: var(--jl-tile-height);
    max-width: var(--jl-tile-max-width);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    /* remove grey bands */
    padding: 0;
    /* ensure no extra vertical padding */
    line-height: 0;
    /* remove inline-gap whitespace */
    overflow: hidden;
}

.jl-tile-img {
    /* Fill the tile height, preserve aspect ratio (no cropping) */
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    object-position: center center;
    display: block;
}

/* Remove extra spacing inside the tile and caption so image fills the visual box */
.jl-tile,
.jl-tile-caption,
.jl-tile-link {
    padding: 0;
    margin: 0;
}

/* Hide captions in gallery grid view when showcaptions=false */
.jl-gallery-hide-captions .jl-tile-caption {
    display: none;
}


/* Ensure PhotoSwipe v5 captions are visible and styled */
.pswp__ui .pswp__caption,
.pswp__caption,
.pswp__caption__center,
.pswp-caption-title,
.pswp-caption-meta {
    display: block !important;
    color: #000000 !important;
    text-align: center !important;
}

/* Slight spacing for caption text */
.pswp-caption-title {
    margin-bottom: .25rem;
    font-weight: 600;
    font-size: 0.85rem;
}

.pswp-caption-meta {
    font-size: 0.75rem;
    color: #ebebeb00;
}

/* Custom caption box injected by our uiRegister handler */
.pswp__custom-caption {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 16px;
    background: #e9e9e900;
    color: #333;
    padding: 6px 10px;
    border-radius: 4px;
    max-width: calc(100% - 40px);
    text-align: center;
    font-size: 0.85rem;
}

/* Caption background for white lightbox */
.pswp-bg-white .pswp__custom-caption {
    background: #ffffff00;
}

/* Caption background for grey lightbox */
.pswp-bg-grey .pswp__custom-caption {
    background: #ffffff00;
}

/* Hide caption when image is zoomed in */
.pswp--zoomed-in .pswp__custom-caption {
    display: none !important;
}

/* PhotoSwipe lightbox background - default grey */
.pswp,
.pswp__bg,
.pswp__ui {
    background: #ebebeb !important;
}

.pswp__bg {
    background-color: #ebebeb !important;
    opacity: 1 !important;
}

/* PhotoSwipe lightbox background - white option */
.pswp.pswp-bg-white,
.pswp-bg-white.pswp,
.pswp.pswp-bg-white .pswp__bg,
.pswp-bg-white .pswp__bg,
.pswp.pswp-bg-white .pswp__ui,
.pswp-bg-white .pswp__ui {
    background: #ffffff !important;
    background-color: #ffffff !important;
}

/* PhotoSwipe lightbox background - grey option */
.pswp.pswp-bg-grey,
.pswp-bg-grey.pswp,
.pswp.pswp-bg-grey .pswp__bg,
.pswp-bg-grey .pswp__bg,
.pswp.pswp-bg-grey .pswp__ui,
.pswp-bg-grey .pswp__ui {
    background: #ebebeb !important;
    background-color: #ebebeb !important;
}

/* Reduce caption size on small height viewports (mobile landscape, etc.) */
@media screen and (max-height: 600px) {
    .pswp__custom-caption {
        font-size: 0.7rem !important;
        padding: 4px 8px !important;
        bottom: 8px !important;
    }

    .pswp-caption-title {
        font-size: 0.7rem !important;
        line-height: 1.3;
        margin-bottom: 0.1rem !important;
    }

    .pswp-caption-meta {
        font-size: 0.65rem !important;
        line-height: 1.2;
    }
}

/* Even smaller on very small heights */
@media screen and (max-height: 450px) {
    .pswp__custom-caption {
        font-size: 0.6rem !important;
        padding: 3px 6px !important;
        bottom: 4px !important;
    }

    .pswp-caption-title {
        font-size: 0.6rem !important;
        line-height: 1.2;
        margin-bottom: 0.05rem !important;
    }

    .pswp-caption-meta {
        font-size: 0.55rem !important;
        line-height: 1.1;
    }
}

/* Hide caption when zoomed in on small heights to avoid overlap */
@media screen and (max-height: 600px) {
    .pswp--zoomed-in .pswp__custom-caption {
        opacity: 0 !important;
        transition: opacity 0.2s ease;
    }
}