/* Image gallery block: thumbnail grid + Bootstrap modal/carousel lightbox.
   Loaded by blog_page.html only on posts that use a gallery block. Colours use
   Bootstrap theme vars so light/dark tracks automatically. */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

/* Narrow screens (below Bootstrap's `sm` breakpoint) drop to 2 columns. */
@media (max-width: 575.98px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.gallery-thumb {
    display: block;
    padding: 0;
    margin: 0;
    border: 0;
    background: none;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    cursor: pointer;
    border-radius: var(--bs-border-radius, 0.375rem);
}

.gallery-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.gallery-thumb:hover .gallery-thumb-img,
.gallery-thumb:focus-visible .gallery-thumb-img {
    transform: scale(1.04);
}

/* Readers who ask for less motion get the zoom without the animated tween.
   (Bootstrap's carousel already drops its slide animation on its own.) */
@media (prefers-reduced-motion: reduce) {
    .gallery-thumb-img {
        transition: none;
    }
}

.gallery-thumb:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Lightbox */
.gallery-modal .modal-content {
    background-color: var(--bs-body-bg);
}

.gallery-figure {
    margin: 0;
    text-align: center;
}

.gallery-full-img {
    width: 100%;
    max-height: 80vh;
    object-fit: contain;
    margin-inline: auto;
}

.gallery-figcaption {
    margin-top: 0.75rem;
    color: var(--bs-secondary-color);
    font-size: 0.9rem;
}

.gallery-counter {
    color: var(--bs-secondary-color);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

/* Snappier slide than Bootstrap's default .6s (applies to swipe and controls). */
.gallery-carousel .carousel-item {
    transition: transform 0.2s ease-in-out;
}

/* Keep reduced-motion honored: matching specificity so it still wins over the
   override above (Bootstrap's own reduced-motion rule is only one class deep). */
@media (prefers-reduced-motion: reduce) {
    .gallery-carousel .carousel-item {
        transition: none;
    }
}

/* The default carousel controls sit on light images poorly; give them a chip. */
.gallery-carousel .carousel-control-prev,
.gallery-carousel .carousel-control-next {
    width: 12%;
}

.gallery-carousel .carousel-control-prev-icon,
.gallery-carousel .carousel-control-next-icon {
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    padding: 1.1rem;
    background-size: 45%;
}
