/* Shared native WordPress gallery presentation; the media IDs live in the shortcode. */
.kk-gallery .gallery {
    display: grid;
    grid-template-columns: repeat(var(--kk-gallery-columns, 4), minmax(0, 1fr));
    gap: 10px;
    clear: both;
    margin: 0;
    padding: 0;
}
.kk-gallery .gallery .gallery-item {
    float: none;
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    text-align: center;
}
.kk-gallery .gallery-icon { margin: 0; }
.kk-gallery .gallery-icon a { display: block; aspect-ratio: 1; overflow: hidden; cursor: zoom-in; }
.kk-gallery .gallery-icon img { display: block; width: 100%; height: 100%; margin: 0; border: 0; object-fit: cover; transition: transform .3s; }
.kk-gallery .gallery-icon a:hover img { transform: scale(1.04); }
.kk-gallery .gallery-icon a:focus-visible { outline: 3px solid #e8412c; outline-offset: 3px; }
.kk-gallery :is(br, .gallery-caption) { display: none; }
@media (max-width: 900px) { .kk-gallery:not([data-columns="1"]) .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .kk-gallery .gallery { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { .kk-gallery .gallery-icon img { transition: none; } }
/* Native modal dialog keeps focus inside the viewer and the page behind it inert. */
html.kk-gallery-open {
    overflow: hidden;
}

.kk-gallery-dialog {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 16px clamp(12px, 3vw, 48px);
    border: 0;
    background: rgb(12 12 12 / 97%);
    color: #fff;
    font: inherit;
    overflow: hidden;
}

.kk-gallery-dialog[open] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 12px;
}

.kk-gallery-dialog::backdrop {
    background: #0c0c0c;
}

.kk-gallery-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.kk-gallery-counter {
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

.kk-gallery-control {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid rgb(255 255 255 / 50%);
    border-radius: 50%;
    background: rgb(0 0 0 / 65%);
    color: #fff;
    font: 300 40px/1 Arial, sans-serif;
    cursor: pointer;
}

.kk-gallery-control:hover {
    background: var(--kk-color-accent, #e8412c);
}

.kk-gallery-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
    touch-action: pan-y pinch-zoom;
}

.kk-gallery-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.kk-gallery-status {
    padding: 0 60px;
    font-size: 16px;
}

.kk-gallery-previous,
.kk-gallery-next {
    position: absolute;
    top: calc(50% - 24px);
}

.kk-gallery-previous {
    left: 0;
}

.kk-gallery-next {
    right: 0;
}

.kk-gallery-caption {
    min-height: 1.5em;
    max-height: 4.5em;
    overflow: auto;
    text-align: center;
    font-size: 16px;
    line-height: 1.5;
}

.kk-gallery-dialog .kk-gallery-counter,.kk-gallery-dialog .kk-gallery-caption { margin: 0; color: #fff; }
.kk-gallery-control:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.kk-gallery-control[hidden],.kk-gallery-image[hidden],.kk-gallery-status[hidden] { display: none; }
