/* Lightbox Overlay */
.wpcpl-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow: hidden;
}

.wpcpl-overlay.wpcpl-active {
    opacity: 1;
    visibility: visible;
}

/* Loading Spinner */
.wpcpl-spinner {
    position: absolute;
    top: 50%; left: 50%;
    width: 50px; height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: wpcpl-spin 1s linear infinite;
    z-index: 10;
    display: none;
}

.wpcpl-spinner.wpcpl-active {
    display: block;
}

@keyframes wpcpl-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Accessible Controls & Icons */
.wpcpl-nav-group, .wpcpl-controls {
    display:contents;
}

button#wpcpl-prev, button#wpcpl-next, button#wpcpl-close, .wpcpl-counter {
    position:absolute;
}

button#wpcpl-prev, button#wpcpl-next {
    top:1rem;
    width:10vw;
    height:calc(100% - 2rem);
    z-index:10;
    border-radius:var(--radius);
    &:hover {
        background:color-mix(in oklch, var(--primary-light) 15%, transparent);
        outline:none;
    }
}

button#wpcpl-prev {
    left:1rem;
}

button#wpcpl-next {
    right:1rem;
}

button#wpcpl-close {
    top:2rem;
    right:2rem;
    z-index:20;
}


.wpcpl-counter {
    top:2.5rem;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    user-select: none;
    min-width: 90px;
    text-align: center;
}

.wpcpl-icon-btn {
    background: transparent;
    color: #fff;
    border: none;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.1s ease;
}

.wpcpl-icon-btn:hover, .wpcpl-icon-btn:focus-visible {
    background: rgba(255, 255, 255, 0.2);
    outline: 2px solid #005A9C; /* Accessible focus state */
}

.wpcpl-icon-btn:active {
    transform: scale(0.95);
}

.wpcpl-icon-btn svg {
    width: 24px;
    height: 24px;
}

#wpcpl-close {
    background: rgba(0, 0, 0, 0.6);
}

#wpcpl-close:hover, #wpcpl-close:focus-visible {
    background: rgba(255, 50, 50, 0.8); /* Red hover for close button */
}

/* Dual-Buffer Stage & Canvas Container */
.wpcpl-stage {
    position: relative;
    width: 100%;
    height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpcpl-canvas-wrapper {
    position: absolute;
    display: flex;
    gap: 2px;
    background: #222;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: transform 0.2s ease-out;
    transform: translateX(150vw);
}

.wpcpl-canvas-wrapper canvas {
    max-height: 80vh;
    max-width: 45vw;
    object-fit: contain;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .wpcpl-canvas-wrapper canvas:nth-child(2) {
        display: none !important;
    }
    .wpcpl-canvas-wrapper canvas {
        max-width: 90vw;
    }
    .wpcpl-controls {
        padding: 0 15px;
    }
    .wpcpl-nav-group {
        padding: 4px 12px;
        gap: 10px;
    }
}


/* Navigation Tooltip */
.wpcpl-tooltip {
    position: absolute;
    bottom: 40px;
    background: transparent; /* A nice readable blue */
    color: #fff;
    padding: 12px 24px;
    border: 2px solid white;
    border-radius: 30px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 500;
    z-index: 30;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s ease;
    pointer-events: none; /* Prevents it from blocking clicks */
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.wpcpl-tooltip.wpcpl-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
/* Lock background scrolling when lightbox is open */
.wpcpl-body-locked {
    overflow: hidden !important;
}

@media (max-width: 768px) {
    .wpcpl-tooltip {
        bottom: 20px;
        font-size: 13px;
        padding: 10px 20px;
    }
}