/*
 * Interactive Gallery behaviour support: an inline slider and a full-screen photo viewer. Every rule applies only after
 * gallery-viewer.js marks a carrier interactive, so server-rendered and AMP Galleries keep the static grid of
 * gallery.css. The rules share the `image-gallery` cascade layer with gallery.css: a host that lists this layer before
 * its own layers restyles every class here with ordinary selectors; the neutral appearance is only a working default.
 */
@layer image-gallery {
    .gallery--interactive .gallery__stage {
        position: relative;
        overflow: hidden;
        border-radius: 0.75rem;
        background: #111417;
    }

    .gallery--interactive .gallery__items {
        display: flex;
        gap: 0;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }

    .gallery--interactive .gallery__items::-webkit-scrollbar {
        display: none;
    }

    .gallery--interactive .gallery__item {
        flex: 0 0 100%;
        scroll-snap-align: center;
        scroll-snap-stop: always;
    }

    .gallery--interactive .gallery__link {
        display: block;
        aspect-ratio: 3 / 2;
        cursor: zoom-in;
    }

    .gallery--interactive .gallery__link img {
        width: 100%;
        height: 100%;
        max-width: none;
        object-fit: contain;
    }

    .gallery--interactive .gallery__item figcaption {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .gallery--interactive .gallery__image-status {
        margin: 0;
        padding: 1rem;
        color: #f4f6f7;
    }

    .gallery__nav, .gallery__expand, .gallery-viewer__button {
        display: inline-grid;
        place-items: center;
        width: 2.75rem;
        height: 2.75rem;
        padding: 0;
        border: 0;
        border-radius: 50%;
        color: #fff;
        background: rgb(10 14 16 / 0.55);
        cursor: pointer;
        backdrop-filter: blur(6px);
        transition: background-color 160ms ease, opacity 160ms ease, transform 160ms ease;
    }

    .gallery__nav svg, .gallery__expand svg, .gallery-viewer__button svg {
        width: 1.25rem;
        height: 1.25rem;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .gallery__nav:hover, .gallery__expand:hover, .gallery-viewer__button:hover {
        background: rgb(10 14 16 / 0.8);
    }

    .gallery__nav:focus-visible, .gallery__expand:focus-visible, .gallery-viewer__button:focus-visible,
    .gallery-viewer__original:focus-visible, .gallery__thumbnail:focus-visible, .gallery--interactive .gallery__link:focus-visible {
        outline: 3px solid #6cc6d2;
        outline-offset: 2px;
    }

    .gallery--interactive .gallery__link:focus-visible {
        outline-offset: -3px;
    }

    .gallery__nav {
        position: absolute;
        top: 50%;
        translate: 0 -50%;
    }

    .gallery__nav--previous {
        inset-inline-start: 0.75rem;
    }

    .gallery__nav--next {
        inset-inline-end: 0.75rem;
    }

    .gallery__nav:disabled {
        opacity: 0;
        pointer-events: none;
    }

    .gallery__expand {
        position: absolute;
        top: 0.75rem;
        inset-inline-end: 0.75rem;
    }

    .gallery__counter {
        position: absolute;
        bottom: 0.75rem;
        inset-inline-start: 0.75rem;
        padding: 0.25rem 0.625rem;
        border-radius: 999px;
        color: #fff;
        background: rgb(10 14 16 / 0.55);
        font: 600 0.8125rem / 1.4 inherit;
        font-variant-numeric: tabular-nums;
        pointer-events: none;
    }

    .gallery__caption {
        min-height: 1.5em;
        margin: 0.75rem 0 0;
        color: inherit;
        font-size: 0.9375rem;
        line-height: 1.5;
        text-align: start;
    }

    .gallery__caption:empty {
        display: none;
    }

    .gallery__thumbnails {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.75rem;
        padding: 0.25rem;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .gallery__thumbnail {
        flex: 0 0 auto;
        width: 4.5rem;
        aspect-ratio: 4 / 3;
        padding: 0;
        overflow: hidden;
        border: 0;
        border-radius: calc(0.75rem / 2);
        background: #111417;
        opacity: 0.55;
        cursor: pointer;
        transition: opacity 160ms ease, box-shadow 160ms ease;
    }

    .gallery__thumbnail img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .gallery__thumbnail:hover {
        opacity: 0.85;
    }

    .gallery__thumbnail[aria-current="true"] {
        opacity: 1;
        box-shadow: 0 0 0 2px #2b8a9a;
    }

    @media (hover: none) and (pointer: coarse) {
        .gallery__nav {
            display: none;
        }

        .gallery__thumbnail {
            width: 3.75rem;
        }
    }

    /* Full-screen viewer. */
    :root.gallery-viewer-lock {
        overflow: hidden;
        scrollbar-gutter: stable;
    }

    .gallery-viewer {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        margin: 0;
        padding: 0;
        overflow: hidden;
        border: 0;
        color: #fff;
        background: transparent;
        font-family: inherit;
    }

    .gallery-viewer::backdrop {
        background: transparent;
    }

    .gallery-viewer__backdrop {
        position: absolute;
        inset: 0;
        background: rgb(8 11 13 / 0.96);
    }

    .gallery-viewer__viewport {
        position: absolute;
        inset: 0;
        overflow: hidden;
        touch-action: none;
        user-select: none;
        -webkit-user-select: none;
    }

    .gallery-viewer__track {
        display: flex;
        height: 100%;
        will-change: transform;
    }

    .gallery-viewer__track[data-animating] {
        transition: transform 320ms cubic-bezier(0.22, 0.8, 0.24, 1);
    }

    .gallery-viewer__slide {
        position: relative;
        display: grid;
        flex: 0 0 100%;
        place-items: center;
        overflow: hidden;
    }

    .gallery-viewer__image {
        display: block;
        max-width: none;
        transform-origin: 50% 50%;
        cursor: zoom-in;
        -webkit-user-drag: none;
    }

    .gallery-viewer[data-zoomed] .gallery-viewer__image {
        cursor: grab;
    }

    .gallery-viewer[data-zoomed] .gallery-viewer__image:active {
        cursor: grabbing;
    }

    .gallery-viewer__bar {
        position: absolute;
        inset: 0 0 auto;
        display: flex;
        gap: 0.5rem;
        align-items: center;
        padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) 2rem max(0.75rem, env(safe-area-inset-left));
        background: linear-gradient(rgb(0 0 0 / 0.55), transparent);
        pointer-events: none;
    }

    .gallery-viewer__bar > * {
        pointer-events: auto;
    }

    .gallery-viewer__counter {
        padding-inline: 0.25rem;
        font-size: 0.9375rem;
        font-weight: 600;
        font-variant-numeric: tabular-nums;
    }

    .gallery-viewer__status {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        color: rgb(255 255 255 / 0.75);
        font-size: 0.8125rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .gallery-viewer__original {
        display: inline-flex;
        gap: 0.375rem;
        align-items: center;
        height: 2.75rem;
        padding-inline: 0.875rem;
        border-radius: 999px;
        color: #fff;
        background: rgb(255 255 255 / 0.12);
        font-size: 0.875rem;
        font-weight: 600;
        text-decoration: none;
        transition: background-color 160ms ease;
    }

    .gallery-viewer__original:hover {
        background: rgb(255 255 255 / 0.22);
    }

    .gallery-viewer__original svg {
        width: 1rem;
        height: 1rem;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .gallery-viewer .gallery-viewer__button {
        background: rgb(255 255 255 / 0.12);
    }

    .gallery-viewer .gallery-viewer__button:hover {
        background: rgb(255 255 255 / 0.24);
    }

    .gallery-viewer__nav {
        position: absolute;
        top: 50%;
        translate: 0 -50%;
    }

    .gallery-viewer__nav--previous {
        inset-inline-start: max(1rem, env(safe-area-inset-left));
    }

    .gallery-viewer__nav--next {
        inset-inline-end: max(1rem, env(safe-area-inset-right));
    }

    .gallery-viewer__nav:disabled {
        opacity: 0;
        pointer-events: none;
    }

    .gallery-viewer__caption {
        position: absolute;
        inset: auto 0 0;
        max-height: 40%;
        margin: 0;
        padding: 2.5rem max(1.25rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
        overflow-y: auto;
        background: linear-gradient(transparent, rgb(0 0 0 / 0.7) 2.5rem);
        font-size: 0.9375rem;
        line-height: 1.5;
        text-align: center;
    }

    .gallery-viewer__caption:empty {
        display: none;
    }

    .gallery-viewer__bar, .gallery-viewer__nav, .gallery-viewer__caption {
        transition: opacity 200ms ease;
    }

    .gallery-viewer[data-chrome="hidden"] :is(.gallery-viewer__bar, .gallery-viewer__nav, .gallery-viewer__caption),
    .gallery-viewer[data-zoomed] .gallery-viewer__caption {
        opacity: 0;
        pointer-events: none;
    }

    .gallery-viewer[data-zoomed] .gallery-viewer__nav {
        opacity: 0.35;
    }

    @media (hover: none) and (pointer: coarse) {
        .gallery-viewer__nav {
            display: none;
        }
    }

    /* Component display values above must not reveal controls the script hides. */
    .gallery--interactive [hidden], .gallery-viewer [hidden] {
        display: none;
    }

    @media (prefers-reduced-motion: reduce) {
        .gallery-viewer__track[data-animating], .gallery__nav, .gallery__thumbnail,
        .gallery-viewer__bar, .gallery-viewer__nav, .gallery-viewer__caption {
            transition: none;
        }
    }
}
