/* Desktop presentation for the two-up Works preview. */
.ig-embed-trigger,
.ig-embed-trigger:focus,
.ig-embed-trigger:focus-visible,
.ig-embed-trigger:active {
    outline: 0 !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent;
}

.works-modal__dismiss-zone {
    display: none;
}

/* Arrow controls use solid black discs on desktop without a visible outline. */
.works-modal__nav-arrow {
    background: #000 !important;
    border: 0 !important;
    box-shadow: none !important;
}

/* Never animate frame geometry at any breakpoint. */
.works-modal__frame {
    transition: none !important;
}

.works-modal,
.works-modal__wrapper,
.works-modal__stage {
    overflow: hidden;
    overscroll-behavior: contain;
}

/* Swiping is implemented by the gallery itself. Prevent Safari from turning a
   two-finger gesture on the artwork into page zoom, which can expose the page
   behind the fixed modal. */
.works-modal.active {
    touch-action: none;
}

.works-modal__card img,
.works-modal__card video {
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

html.works-modal-open,
body.works-modal-open {
    overflow: hidden !important;
    overscroll-behavior: none;
    background: #0a0a0a !important;
}

.works-modal__mobile-dots {
    display: none;
}

.works-modal__mobile-dots.is-hidden {
    display: none !important;
}

.works-modal__slide-loader {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}

.works-modal__slide-loader.is-visible {
    opacity: 1;
    visibility: visible;
}

.works-modal__slide-loader-ring {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255, 255, 255, 0.24);
    border-top-color: rgba(255, 255, 255, 0.92);
    border-radius: 50%;
    animation: works-slide-loader-spin 0.8s linear infinite;
}

@keyframes works-slide-loader-spin {
    to { transform: rotate(360deg); }
}

@media (min-width: 769px) {
    /* Arrow circles sit half outside the image edge. Some spreads fill the
       wrapper completely, so wrapper clipping would cut the outer half. */
    .works-modal__wrapper {
        overflow: visible;
    }

    .works-modal__close-btn {
        display: none !important;
    }

    .works-modal__frame {
        gap: 0 !important;
        /* Swap the complete spread atomically; never animate its geometry. */
        transition: none !important;
        transform: translateX(0) !important;
    }

    .works-modal__frame.is-entering,
    .works-modal__frame.is-exiting {
        opacity: 1 !important;
        transform: translateX(0) !important;
    }

    /* Keep navigation at the outer edges of the two-page spread. */
    .works-modal__nav-zone {
        width: auto;
        box-sizing: border-box;
        padding: 0;
    }

    .works-modal__nav-zone--prev {
        justify-content: flex-start !important;
    }

    .works-modal__nav-zone--prev .works-modal__nav-arrow {
        transform: translateX(-50%);
    }

    .works-modal__nav-zone--next {
        justify-content: flex-end !important;
    }

    .works-modal__nav-zone--next .works-modal__nav-arrow {
        transform: translateX(50%);
    }

    /* Transparent close targets keep video dismissible without showing a desktop X. */
    .works-modal__dismiss-zone {
        display: block;
        position: absolute;
        z-index: 4;
        padding: 0;
        border: 0;
        background: transparent;
        cursor: pointer;
    }

    .works-modal__dismiss-zone--top,
    .works-modal__dismiss-zone--bottom {
        left: 96px;
        right: 96px;
        height: 64px;
    }

    .works-modal__dismiss-zone--top {
        top: 0;
    }

    .works-modal__dismiss-zone--bottom {
        bottom: 0;
    }

    .works-modal__dismiss-zone--left,
    .works-modal__dismiss-zone--right {
        top: 64px;
        bottom: 64px;
        width: 64px;
    }

    .works-modal__dismiss-zone--left {
        left: 0;
    }

    .works-modal__dismiss-zone--right {
        right: 0;
    }

    .works-modal__card {
        border-radius: 0 !important;
    }

    .works-modal__card:first-child {
        border-radius: 12px 0 0 12px !important;
    }

    .works-modal__card:last-child {
        border-radius: 0 12px 12px 0 !important;
    }

    .works-modal__card:only-child {
        border-radius: 12px !important;
    }

    .works-modal__card img,
    .works-modal__card video {
        border-radius: inherit !important;
    }

    /* Paired slides are dimensioned to their exact aspect ratios in JS. Fill
       those integer-pixel cards completely so subpixel object-fit rounding
       cannot create a seam between the two halves. */
    .works-modal__card:not(:only-child) img,
    .works-modal__card:not(:only-child) video {
        object-fit: fill !important;
    }
}

@media (max-width: 768px) {
    .works-modal {
        inset: auto;
        top: var(--works-visible-top, 0px);
        left: var(--works-visible-left, 0px);
        width: var(--works-visible-width, 100vw);
        height: var(--works-visible-height, 100dvh);
        min-height: var(--works-visible-height, 100dvh);
        max-height: var(--works-visible-height, 100dvh);
        padding: 16px;
        background: #0a0a0a;
    }

    .works-modal__wrapper {
        min-width: 0;
        min-height: 0;
        max-height: none;
    }

    .works-modal__stage {
        min-width: 0;
        min-height: 0;
    }

    .works-modal__slide-loader {
        inset: 16px;
    }

    .works-modal__nav-zone {
        display: flex !important;
        width: 50% !important;
        opacity: 1 !important;
        z-index: 5;
    }

    .works-modal__nav-arrow {
        display: none !important;
    }

    .works-modal__mobile-dots {
        position: absolute;
        left: 50%;
        bottom: max(40px, calc(env(safe-area-inset-bottom, 0px) + 20px));
        z-index: 12;
        display: flex;
        align-items: center;
        gap: 5px;
        transform: translateX(-50%);
    }

    .works-modal__mobile-dots.is-hidden {
        display: none !important;
    }

    .works-modal__mobile-dot {
        width: 4px;
        height: 4px;
        padding: 0;
        border: 0;
        outline: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.4);
        cursor: pointer;
        transition: none;
        -webkit-tap-highlight-color: transparent;
    }

    .works-modal__mobile-dot:focus,
    .works-modal__mobile-dot:focus-visible {
        outline: 0;
        box-shadow: none;
    }

    .works-modal__mobile-dot.is-active {
        background: #fff;
    }

    .works-modal__mobile-dot:disabled {
        cursor: default;
    }

    /* Keep the arrow hit area, but remove its visible circle on mobile. */
    .works-modal__nav-arrow {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
    }

    /* Keep a comfortable close target while showing only the X glyph. */
    .works-modal__close-btn,
    .works-modal__close-btn:hover {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        transform: none !important;
    }
}
