:root {
    --gap: 14px;
}

/* ===== IMAGE LIGHTBOX ===== */
#imgLightbox {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    text-shadow: 2px 2px 4px #000;
    z-index: 9999;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

#imgLightbox.active {
    opacity: 1;
    pointer-events: auto;
    touch-action: none;
}

/* Disable native long-press behind lightbox */
body.lightbox-open img:not(#lightboxImg) {
    pointer-events: none;
}

/* ===== IMAGE ===== */
#imgLightbox img {
    will-change: transform;
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);

    width: 80vw;
    min-width: 320px;
    max-width: 800px;
    height: auto;
    max-height: 70vh;

    object-fit: contain;
    /*box-shadow: 0px 0px 25px rgba(0, 0, 0, 0.95);*/
    cursor: default;
    image-rendering: pixelated;
}

/* ===== SHARED CONTROL STYLE ===== */
.lb-control {
    font-family: icon;
    color: #fff;
    background: #0008;
    border: 2px solid;
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.1s ease, transform 0.1s ease;
}

/* hover */
.lb-control:hover {
    opacity: 1;
}

/* active press effect */
.lb-control:active {
    transform: scale(0.9);
}

/* ===== NAV ARROWS ===== */
.lb-btn {
    display: flex;
    justify-content: center;
    align-items: center;

    padding: 40px 0;
    font-size: 50px;
    z-index: 2;
}

.lb-btn.prev { left: 20px }
.lb-btn.next { right: 20px }

/* ===== BUTTONS ===== */
/* ZOOM */
#lbZoomControls {
    position: absolute;
    top: 15px;
    left: 15px;
    display: flex;
    gap: var(--gap);
    z-index: 3;
}

#lbZoomControls .lb-control {
    width: 70px;
    height: 70px;
    font-size: 40px;
}

/* reset hidden by default */
#zoomReset {
    display: none;
}

/* ROTATION */
#lbRotateControls {
    position: absolute;
    top: 100px;
    left: 15px;
    display: flex;
    gap: var(--gap);
    z-index: 3;
}

#lbRotateControls .lb-control {
    width: 70px;
    height: 70px;
    font-size: 36px;
}

/* ===== FLIP ===== */
#lbFlipControls {
    position: absolute;
    top: 185px;
    left: 15px;
    display: flex;
    gap: var(--gap);
    z-index: 3;
}

#lbFlipControls .lb-control {
    width: 70px;
    height: 70px;
    font-size: 36px;
}

/* ===== BOTTOM RIGHT ACTION CONTROLS ===== */
#lbActionControls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: var(--gap);
    z-index: 3;
    flex-direction: row;
}

#lbActionControls .lb-control {
    width: 70px;
    height: 70px;
    font-size: 35px;
}

/* ===== INFO PANEL ===== */
#lbInfo {
    position: fixed;
    top: 15px;
    right: 15px;
    max-width: 75vw;
    min-height: 42px;
    text-align: right;
    font-family: icon;
    color: #fff;
    background: rgba(0,0,0,0.5);
    padding: 5px;
    border-radius: 7px;
    z-index: 3;
}

#lightboxCaption {
    display: block;
    font-size: 30px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: text;
}

[data-theme="orange"] #lightboxCaption {
    font-size: 25px;
}

[data-theme="shimeji"] #lightboxCaption {
    font-size: 20px;
}

#lightboxCounter {
    display: block;
    margin-top: 6px;
    font-size: 20px;
    opacity: 0.5;
    font-weight: bold;
    user-select: none;
}

#lightboxResolution,
#lightboxFilesize {
    display: block;
    font-size: 20px;
    opacity: 0.5;
    font-weight: bold;
    user-select: none;
    margin-top: 2px;
}

/* ===== KEYBINDS DISPLAY ===== */
#lbKeybinds {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);

    font-family: var(--font-primary);
    text-align: center;
    color: #fff;
    background: rgba(0,0,0,0.6);
    padding: 10px 10px;
    border-radius: 7px;
    
    text-shadow: 2px 2px 4px #000;
    font-size: 16px;
    z-index: 3;
}

/* keep formatting tight + aligned */
.lb-kb-title {
    font-size: 30px;
    font-weight: bold;
    margin: 10px !important;
}

/* ===== ART META (BOTTOM LEFT) ===== */
#lbArtMeta {
    position: fixed;
    bottom: 20px;
    left: 20px;

    font-family: var(--font-primary);
    color: #fff;
    background: rgba(0,0,0,0.5);
    padding: 5px 8px;
    border-radius: 7px;

    text-shadow: 2px 2px 4px #000;
    z-index: 3;
    user-select: none;
}

#lbArtMeta span {
    display: block;
    font-size: 25px;
    opacity: 1;
    font-weight: normal;
}

[data-theme="shimeji"] #lbArtMeta span {
    font-size: 19px;
}

/* ===== ZOOM % ===== */
#lbZoomPercent {
    position: absolute;
    bottom: 30px;
    padding: 4px 8px;
    font-size: 25px;
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.6s ease;
    font-family: var(--font-primary);
    color: #fff;
    background: #0000004D;
    border-radius: 10px;
    width: 75px;
    text-align: center;
    border: 1.5px solid #FFFFFF4D;
}

#lbZoomPercent.show {
  opacity: 1;
}

/* utility */
.hidden {
    display: none !important;
}

/* ===== FOCUS MODE TRANSITIONS ===== */
#lbZoomControls,
#lbRotateControls,
#lbFlipControls,
#lbActionControls .lb-control,
#lbInfo,
#lbArtMeta,
#lbZoomPercent,
#lbKeybinds,
.lb-btn {
    transition: opacity 0.15s ease;
}

/* hidden in focus */
#imgLightbox.lightbox-focus #lbZoomControls,
#imgLightbox.lightbox-focus #lbRotateControls,
#imgLightbox.lightbox-focus #lbFlipControls,
#imgLightbox.lightbox-focus #lbActionControls .lb-control:not(#lbFocusToggle),
#imgLightbox.lightbox-focus #lbInfo,
#imgLightbox.lightbox-focus #lbArtMeta,
#imgLightbox.lightbox-focus #lbZoomPercent,
#imgLightbox.lightbox-focus #lbKeybinds,
#imgLightbox.lightbox-focus .lb-btn {
    opacity: 0;
    pointer-events: none;
}

#imgLightbox.lightbox-focus #lbFocusToggle {
    opacity: 0.5;
    pointer-events: auto;
}
#imgLightbox.lightbox-focus #lbFocusToggle:hover {
    opacity: 1;
}

/* darker background */
#imgLightbox.lightbox-focus {
    background: rgba(0,0,0,1) !important;
}