/* =============================================================
   Block: Gallery
   blk-gallery
   ============================================================= */

/* ── Section ─────────────────────────────────────────────────── */

.blk-gallery {
    padding-block: clamp(4.5rem, 9vw, 8rem);
    background: var(--sd-color-white, #ffffff);
}

.blk-gallery__container {
    max-width: var(--sd-container-max, 1440px);
    margin-inline: auto;
    padding-inline: clamp(1.25rem, 5vw, 3.5rem);
}

/* ── Heading ─────────────────────────────────────────────────── */

.blk-gallery__heading {
    font-size: clamp(1.875rem, 4vw, 3rem);
    font-weight: var(--sd-font-weight-bold, 700);
    line-height: var(--sd-line-height-tight, 1.25);
    letter-spacing: -0.025em;
    color: var(--sd-color-primary, #36452f);
    text-align: center;
    margin: 0 0 clamp(2rem, 4vw, 3.5rem);
}

/* ── Grid ────────────────────────────────────────────────────── */

.blk-gallery__grid {
    display: grid;
    gap: clamp(0.5rem, 1vw, 1rem);
}

/* Column modifiers */
.blk-gallery--cols-2 .blk-gallery__grid { grid-template-columns: repeat(2, 1fr); }
.blk-gallery--cols-3 .blk-gallery__grid { grid-template-columns: repeat(3, 1fr); }
.blk-gallery--cols-4 .blk-gallery__grid { grid-template-columns: repeat(4, 1fr); }

/* ── Grid item ───────────────────────────────────────────────── */

.blk-gallery__item {
    overflow: hidden;
    border-radius: var(--sd-radius-md, 0.25rem);
}

/* ── Trigger button ──────────────────────────────────────────── */

.blk-gallery__trigger {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border-radius: inherit;
    outline: none;
}

.blk-gallery__trigger:focus-visible {
    box-shadow: 0 0 0 3px var(--sd-color-cta, #5f7d3a);
}

/* Image */
.blk-gallery__img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    transition: transform 450ms cubic-bezier(0.22, 1, 0.36, 1),
                filter 300ms ease;
}

.blk-gallery__trigger:hover .blk-gallery__img,
.blk-gallery__trigger:focus-visible .blk-gallery__img {
    transform: scale(1.04);
    filter: brightness(0.88);
}

/* Zoom icon overlay */
.blk-gallery__zoom-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 250ms ease;
    pointer-events: none;
}

.blk-gallery__zoom-icon svg {
    width: 28px;
    height: 28px;
    color: var(--sd-color-white, #ffffff);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.blk-gallery__trigger:hover .blk-gallery__zoom-icon,
.blk-gallery__trigger:focus-visible .blk-gallery__zoom-icon {
    opacity: 1;
}

/* ── Empty state ─────────────────────────────────────────────── */

.blk-gallery__empty {
    text-align: center;
    color: var(--sd-color-text-light, #525252);
    font-size: var(--sd-font-size-base, 1rem);
    padding: 3rem;
}

/* ── Lightbox ─────────────────────────────────────────────────── */

.blk-gallery__lightbox {
    position: fixed;
    inset: 0;
    z-index: var(--sd-z-index-modal, 1050);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease;
    outline: none;
}

.blk-gallery__lightbox--open {
    opacity: 1;
    pointer-events: auto;
}

/* Backdrop */
.blk-gallery__lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 10, 0.92);
    cursor: pointer;
}

/* Inner panel */
.blk-gallery__lb-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: min(92vw, 1100px);
    max-height: 92dvh;
    width: 100%;
    padding-inline: 3.5rem; /* space for prev/next buttons */
}

/* Image wrap */
.blk-gallery__lb-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 80dvh;
    width: 100%;
}

.blk-gallery__lb-img {
    max-width: 100%;
    max-height: 80dvh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--sd-radius-md, 0.25rem);
    display: block;
    box-shadow: var(--sd-shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.2));
}

/* Close button */
.blk-gallery__lb-close {
    position: absolute;
    top: -3rem;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--sd-radius-full, 9999px);
    color: var(--sd-color-white, #ffffff);
    cursor: pointer;
    transition: background 200ms ease, transform 200ms ease;
    outline: none;
    padding: 0;
}

.blk-gallery__lb-close svg {
    width: 18px;
    height: 18px;
}

.blk-gallery__lb-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.blk-gallery__lb-close:focus-visible {
    box-shadow: 0 0 0 3px var(--sd-color-cta, #5f7d3a);
}

/* Prev / Next buttons */
.blk-gallery__lb-prev,
.blk-gallery__lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--sd-radius-full, 9999px);
    color: var(--sd-color-white, #ffffff);
    cursor: pointer;
    transition: background 200ms ease, transform 200ms ease;
    outline: none;
    padding: 0;
}

.blk-gallery__lb-prev { left: 0; }
.blk-gallery__lb-next { right: 0; }

.blk-gallery__lb-prev svg,
.blk-gallery__lb-next svg {
    width: 20px;
    height: 20px;
}

.blk-gallery__lb-prev:hover,
.blk-gallery__lb-next:hover {
    background: rgba(255, 255, 255, 0.25);
}

.blk-gallery__lb-prev:hover { transform: translateY(-50%) translateX(-2px); }
.blk-gallery__lb-next:hover { transform: translateY(-50%) translateX(2px); }

.blk-gallery__lb-prev:focus-visible,
.blk-gallery__lb-next:focus-visible {
    box-shadow: 0 0 0 3px var(--sd-color-cta, #5f7d3a);
    transform: translateY(-50%);
}

/* Caption */
.blk-gallery__lb-caption {
    margin-top: 0.875rem;
    font-size: var(--sd-font-size-sm, 0.875rem);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    max-width: 60ch;
    line-height: var(--sd-line-height-normal, 1.5);
}

/* Counter */
.blk-gallery__lb-counter {
    font-size: var(--sd-font-size-xs, 0.75rem);
    color: rgba(255, 255, 255, 0.45);
    margin-top: 0.375rem;
    letter-spacing: 0.06em;
}

/* Body scroll lock when lightbox is open */
body.blk-gallery-open {
    overflow: hidden;
}

/* ── Responsive ─────────────────────────────────────────────── */

/* Tablet: collapse columns */
@media (max-width: 1023px) {
    .blk-gallery--cols-4 .blk-gallery__grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 767px) {
    .blk-gallery--cols-3 .blk-gallery__grid,
    .blk-gallery--cols-4 .blk-gallery__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 479px) {
    .blk-gallery--cols-2 .blk-gallery__grid,
    .blk-gallery--cols-3 .blk-gallery__grid,
    .blk-gallery--cols-4 .blk-gallery__grid { grid-template-columns: 1fr; }

    .blk-gallery__lb-inner {
        padding-inline: 2.75rem;
    }

    .blk-gallery__lb-prev,
    .blk-gallery__lb-next {
        width: 2.25rem;
        height: 2.25rem;
    }
}
