/* Fullscreen zoom step. The work-detail layout stays in each gallery page. */

#lightbox #lightbox-img {
    cursor: zoom-in;
}

#fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: #f6f4f1;
    color: #1c1917;
    opacity: 0;
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    transition: opacity 0.28s ease;
}

#fullscreen.is-active {
    opacity: 1;
}

#fullscreen.hidden {
    display: none;
}

.fullscreen-viewport {
    position: absolute;
    top: max(64px, calc(env(safe-area-inset-top) + 56px));
    right: max(56px, calc(env(safe-area-inset-right) + 52px));
    bottom: max(76px, calc(env(safe-area-inset-bottom) + 68px));
    left: max(56px, calc(env(safe-area-inset-left) + 52px));
    overflow: hidden;
    touch-action: none;
}

#fullscreen-img {
    position: absolute;
    left: 50%;
    top: 50%;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    object-fit: contain;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    opacity: 0;
    cursor: zoom-in;
    box-shadow: 0 18px 50px rgba(28, 25, 23, 0.14);
    image-rendering: auto;
    filter: none;
    -webkit-user-drag: none;
    user-select: none;
    -webkit-touch-callout: none;
    transition: opacity 0.28s ease;
}

#fullscreen-img.is-ready {
    opacity: 1;
}

#fullscreen.is-native #fullscreen-img {
    cursor: default;
}

#fullscreen.is-max-zoom:not(.is-native) #fullscreen-img {
    cursor: grab;
}

#fullscreen.is-panning #fullscreen-img {
    cursor: grabbing;
}

.fullscreen-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 252, 249, 0.94);
    color: #44403c;
    box-shadow: 0 1px 2px rgba(28, 25, 23, 0.06), 0 8px 24px rgba(28, 25, 23, 0.08);
    cursor: pointer;
    font: inherit;
    line-height: 1;
    flex: 0 0 auto;
    transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.fullscreen-btn:hover {
    background: #fff;
    color: #1c1917;
}

.fullscreen-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.fullscreen-btn:focus-visible {
    outline: 2px solid #1c1917;
    outline-offset: 3px;
}

.fullscreen-close,
.fullscreen-nav {
    position: absolute;
    z-index: 6;
}

.fullscreen-close {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
}

.fullscreen-prev {
    top: 50%;
    left: max(8px, env(safe-area-inset-left));
    transform: translateY(-50%);
}

.fullscreen-next {
    top: 50%;
    right: max(8px, env(safe-area-inset-right));
    transform: translateY(-50%);
}

#fullscreen.is-single .fullscreen-nav,
#fullscreen.is-zoomed .fullscreen-nav {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.fullscreen-toolbar {
    position: absolute;
    z-index: 6;
    left: 50%;
    bottom: max(12px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 4px;
    max-width: calc(100% - 16px);
    padding: 6px;
    border-radius: 999px;
    background: rgba(255, 252, 249, 0.94);
    box-shadow: 0 1px 2px rgba(28, 25, 23, 0.06), 0 10px 30px rgba(28, 25, 23, 0.1);
}

.fullscreen-counter {
    flex: 0 0 auto;
    min-width: 3.25rem;
    padding: 0 6px;
    color: #78716c;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-align: center;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.fullscreen-divider {
    flex: 0 0 auto;
    width: 1px;
    height: 18px;
    background: rgba(28, 25, 23, 0.12);
}

@media (max-width: 380px), (max-height: 420px) {
    .fullscreen-btn {
        width: 36px;
        height: 36px;
    }

    .fullscreen-viewport {
        top: max(52px, calc(env(safe-area-inset-top) + 48px));
        right: max(48px, calc(env(safe-area-inset-right) + 44px));
        bottom: max(60px, calc(env(safe-area-inset-bottom) + 54px));
        left: max(48px, calc(env(safe-area-inset-left) + 44px));
    }

    .fullscreen-toolbar {
        bottom: max(8px, env(safe-area-inset-bottom));
        gap: 2px;
        padding: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #fullscreen,
    #fullscreen-img,
    .fullscreen-btn,
    .fullscreen-nav {
        transition: none;
    }
}

@media (forced-colors: active) {
    .fullscreen-btn {
        border: 1px solid ButtonText;
    }
}
