/* All-sky camera + lightbox (ported from legacy index) */

.skies-obs-allsky-frame {
    display: flex;
    justify-content: center;
    margin: 10px 0 12px;
}

.skies-obs-allsky-frame .image-wrapper {
    width: 100%;
    max-width: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.image-wrapper {
    position: relative;
    width: 90%;
    max-width: 1200px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.image-wrapper:hover {
    transform: scale(1.02);
}

.allsky-image {
    width: 100%;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: block;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(0,0,0,0.7) 0%, transparent 30%, transparent 70%, rgba(0,0,0,0.7) 100%);
    border-radius: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
}

.image-wrapper:hover .image-overlay {
    opacity: 1;
}

.time-overlay {
    background: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.click-hint {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
}
/* Enhanced Lightbox Styles with Fullscreen Support */
.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
    box-sizing: border-box;
}

/* Force remove any browser default fullscreen borders */
.lightbox-modal:fullscreen,
.lightbox-modal:-webkit-full-screen,
.lightbox-modal:-moz-full-screen,
.lightbox-modal.fullscreen-active {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* More aggressive border removal for all fullscreen elements */
.lightbox-modal:fullscreen *,
.lightbox-modal:-webkit-full-screen *,
.lightbox-modal:-moz-full-screen *,
.lightbox-modal.fullscreen-active * {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Force fullscreen image to be truly edge-to-edge */
.lightbox-modal:fullscreen .lightbox-image,
.lightbox-modal:-webkit-full-screen .lightbox-image,
.lightbox-modal:-moz-full-screen .lightbox-image,
.lightbox-modal.fullscreen-active .lightbox-image {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    object-fit: cover !important;
    z-index: 10000 !important;
}

.lightbox-modal.fullscreen-active {
    background-color: rgba(0, 0, 0, 1);
    backdrop-filter: none;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
}

.lightbox-modal:fullscreen {
    background-color: rgba(0, 0, 0, 1);
    backdrop-filter: none;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
}

.lightbox-modal:-webkit-full-screen {
    background-color: rgba(0, 0, 0, 1);
    backdrop-filter: none;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
}

.lightbox-modal:-moz-full-screen {
    background-color: rgba(0, 0, 0, 1);
    backdrop-filter: none;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
}

/* Ensure body has no margins in fullscreen */
body:has(.lightbox-modal.fullscreen-active),
body:has(.lightbox-modal:fullscreen),
body:has(.lightbox-modal:-webkit-full-screen),
body:has(.lightbox-modal:-moz-full-screen) {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
}

.lightbox-modal.active {
    display: flex !important;
    align-items: stretch;
    justify-content: center;
    padding: 0;
    min-height: 100dvh;
    min-height: 100vh;
}

/* Fullscreen modal alignment */
.lightbox-modal.fullscreen-active.active,
.lightbox-modal:fullscreen.active,
.lightbox-modal:-webkit-full-screen.active,
.lightbox-modal:-moz-full-screen.active {
    align-items: stretch;
    justify-content: stretch;
}

.lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Fullscreen content container */
.lightbox-modal.fullscreen-active .lightbox-content,
.lightbox-modal:fullscreen .lightbox-content,
.lightbox-modal:-webkit-full-screen .lightbox-content,
.lightbox-modal:-moz-full-screen .lightbox-content {
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
    box-shadow: none;
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    font-size: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
    z-index: 10001;
}

/* Fullscreen close button positioning */
.lightbox-modal.fullscreen-active .lightbox-close,
.lightbox-modal:fullscreen .lightbox-close,
.lightbox-modal:-webkit-full-screen .lightbox-close,
.lightbox-modal:-moz-full-screen .lightbox-close,
.lightbox-modal.active .lightbox-close {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    z-index: 10003;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    opacity: 0.6;
    transition: opacity 1s ease, background 0.3s ease, transform 0.2s ease;
    pointer-events: auto;
    cursor: pointer;
}

/* Simplified auto-hide close button in fullscreen */
.lightbox-modal.fullscreen-active.hide-ui .lightbox-close {
    opacity: 0 !important;
    /* Keep pointer events enabled so button remains clickable when hidden */
    pointer-events: auto !important;
}

.lightbox-modal.fullscreen-active:not(.hide-ui) .lightbox-close {
    opacity: 0.6 !important;
    pointer-events: auto !important;
}

.lightbox-modal.fullscreen-active:not(.hide-ui):hover .lightbox-close,
.lightbox-modal.fullscreen-active:not(.hide-ui) .lightbox-close:hover {
    opacity: 1 !important;
    background: rgba(255, 0, 0, 0.8) !important;
    transform: scale(1.1) !important;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-image-container {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    max-width: 100%;
    max-height: calc(95vh - 80px);
}

.lightbox-modal.fullscreen-active .lightbox-image-container,
.lightbox-modal:fullscreen .lightbox-image-container,
.lightbox-modal:-webkit-full-screen .lightbox-image-container,
.lightbox-modal:-moz-full-screen .lightbox-image-container {
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    overflow: visible;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
    box-shadow: none;
    position: absolute;
    top: 0;
    left: 0;
}

/* Lightbox open (non-fullscreen): fill viewport so image is full-screen */
.lightbox-modal.active .lightbox-content {
    max-width: 100vw;
    max-height: 100vh;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0;
}
.lightbox-modal.active .lightbox-image-container {
    flex: 1;
    min-height: 0;
    max-height: 100vh;
    max-height: 100dvh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
}
.lightbox-modal.active .lightbox-image {
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
}

.lightbox-modal.fullscreen-active .lightbox-image,
.lightbox-modal:fullscreen .lightbox-image,
.lightbox-modal:-webkit-full-screen .lightbox-image,
.lightbox-modal:-moz-full-screen .lightbox-image {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: center center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    display: block;
    transition: transform 0.3s ease;
    cursor: grab;
}

.lightbox-image:active {
    cursor: grabbing;
}

.lightbox-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
}

/* Fullscreen overlay positioning – keep date/time and auto-update in view */
.lightbox-modal.fullscreen-active .lightbox-overlay,
.lightbox-modal:fullscreen .lightbox-overlay,
.lightbox-modal:-webkit-full-screen .lightbox-overlay,
.lightbox-modal:-moz-full-screen .lightbox-overlay,
.lightbox-modal.active .lightbox-overlay {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    z-index: 10002;
    opacity: 0.8;
    transition: opacity 1s ease;
}

/* Simplified auto-hide overlay in fullscreen */
.lightbox-modal.fullscreen-active.hide-ui .lightbox-overlay {
    opacity: 0 !important;
    pointer-events: none !important;
}

.lightbox-modal.fullscreen-active:not(.hide-ui) .lightbox-overlay {
    opacity: 0.8 !important;
    pointer-events: auto !important;
}

.lightbox-modal.fullscreen-active:not(.hide-ui):hover .lightbox-overlay {
    opacity: 1 !important;
}

.lightbox-timestamp {
    background: rgba(0, 0, 0, 0.4);
    color: #ffffff;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.lightbox-status {
    display: flex;
    align-items: center;
    gap: 15px;
}

.auto-update-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 255, 0, 0.2);
    color: #00ff00;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 0, 0.3);
    animation: pulse 2s infinite;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #00ff00;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.lightbox-controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Fullscreen controls positioning */
.lightbox-modal.fullscreen-active .lightbox-controls,
.lightbox-modal:fullscreen .lightbox-controls,
.lightbox-modal:-webkit-full-screen .lightbox-controls,
.lightbox-modal:-moz-full-screen .lightbox-controls,
.lightbox-modal.active .lightbox-controls {
    position: fixed;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0;
    z-index: 10002;
    background: rgba(0, 0, 0, 0.4);
    padding: 15px 20px;
    border-radius: 30px;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    opacity: 0.6;
    transition: opacity 1s ease;
}

/* Simplified auto-hide controls in fullscreen */
.lightbox-modal.fullscreen-active.hide-ui .lightbox-controls {
    opacity: 0 !important;
    pointer-events: none !important;
}

.lightbox-modal.fullscreen-active:not(.hide-ui) .lightbox-controls {
    opacity: 0.6 !important;
    pointer-events: auto !important;
}

.lightbox-modal.fullscreen-active:not(.hide-ui):hover .lightbox-controls,
.lightbox-modal.fullscreen-active:not(.hide-ui) .lightbox-controls:hover {
    opacity: 1 !important;
}

.zoom-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 16px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    min-width: 55px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}

.zoom-btn:active {
    transform: translateY(0);
}

.lightbox-help {
    margin-top: 15px;
    text-align: center;
    opacity: 0.8;
}

/* Fullscreen help positioning */
.lightbox-modal.fullscreen-active .lightbox-help,
.lightbox-modal:fullscreen .lightbox-help,
.lightbox-modal:-webkit-full-screen .lightbox-help,
.lightbox-modal:-moz-full-screen .lightbox-help {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0;
    z-index: 10002;
    opacity: 0.8;
    transition: opacity 1s ease;
}

/* Simplified auto-hide system for fullscreen UI */
.lightbox-modal.fullscreen-active.hide-ui .lightbox-help {
    opacity: 0 !important;
    pointer-events: none !important;
}

.lightbox-modal.fullscreen-active:not(.hide-ui) .lightbox-help {
    opacity: 0.8 !important;
    pointer-events: auto !important;
}

.lightbox-modal.fullscreen-active:not(.hide-ui):hover .lightbox-help {
    opacity: 1 !important;
}

/* Hide how-to / tap & pinch help text in lightbox – keep fullscreen view clean */
.lightbox-modal .lightbox-help {
    display: none !important;
}

.lightbox-help p {
    color: #cccccc;
    font-size: 0.9rem;
    margin: 0;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .skies-obs-allsky-frame .image-wrapper {
        width: 100%;
        max-width: none;
    }

    .skies-obs-allsky-frame .allsky-image {
        min-height: 55vh;
        object-fit: contain;
    }

    /* Enhanced mobile lightbox controls for better touch experience */
    .lightbox-close {
        top: 1rem;
        right: 1rem;
        font-size: 2rem;
        width: 3.5rem;
        height: 3.5rem;
        line-height: 3.5rem;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.4) !important;
        backdrop-filter: blur(10px);
        border: 2px solid rgba(255, 255, 255, 0.3);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
    }
    
    .lightbox-close:active {
        transform: scale(0.95);
        background: rgba(0, 0, 0, 0.5) !important;
    }
    
    .lightbox-controls {
        padding: 1rem;
        gap: 0.75rem;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(15px);
        border-radius: 20px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    }
    
    .zoom-btn {
        padding: 0.75rem 1rem;
        font-size: 1.1rem;
        min-width: 3.5rem;
        min-height: 3.5rem;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.1);
        border: 2px solid rgba(255, 255, 255, 0.2);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .zoom-btn:active {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 0.2);
    }
    
    .lightbox-timestamp {
        font-size: 0.85rem;
        padding: 0.75rem 1rem;
        border-radius: 12px;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .lightbox-help {
        padding: 0.75rem 1rem;
        border-radius: 12px;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .lightbox-help p {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
    
    /* Improved touch targets for mobile */
    .lightbox-image {
        touch-action: pan-x pan-y pinch-zoom;
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        -webkit-user-drag: none;
    }
    
    /* Better mobile fullscreen experience */
    .lightbox-modal.fullscreen-active {
        background: #000000 !important;
    }
    
    .lightbox-modal.fullscreen-active .lightbox-image {
        max-width: 100vw !important;
        max-height: 100vh !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain;
    }
    
    /* Mobile-specific fullscreen controls positioning */
    .lightbox-modal.fullscreen-active .lightbox-controls {
        bottom: 2rem;
        padding: 1rem 1.5rem;
        gap: 1rem;
    }
    
    .lightbox-modal.fullscreen-active .zoom-btn {
        min-width: 4rem;
        min-height: 4rem;
        font-size: 1.3rem;
    }
    
    .lightbox-modal.fullscreen-active .lightbox-close {
        width: 4rem;
        height: 4rem;
        font-size: 2.2rem;
        line-height: 4rem;
    }
    
    .lightbox-modal.fullscreen-active .lightbox-help {
        bottom: 8rem;
        padding: 1rem 1.5rem;
    }
    
    /* Lightbox fills viewport on open (even when native fullscreen fails) */
    .lightbox-modal.active {
        align-items: stretch;
        justify-content: center;
        padding: 0;
        min-height: 100dvh;
        min-height: 100vh;
    }
    .lightbox-modal.active .lightbox-content {
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        width: 100%;
        height: 100%;
        min-height: 100dvh;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        padding: 0;
    }
    .lightbox-modal.active .lightbox-image-container {
        flex: 1;
        min-height: 0;
        max-height: 100vh;
        max-height: 100dvh;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .lightbox-modal.active .lightbox-image {
        width: 100%;
        height: 100%;
        max-width: 100vw;
        max-height: 100vh;
        object-fit: contain;
    }
    
    /* Lightbox fullscreen: rotate image 90° on mobile so the circle is big; stays rotated when phone is turned to landscape */
    .lightbox-modal.active .lightbox-image,
    .lightbox-modal.fullscreen-active .lightbox-image {
        width: 100dvh !important;
        width: 100vh !important;
        height: auto !important;
        max-height: 100vw !important;
        transform: rotate(-90deg);
        transform-origin: center center;
        object-fit: contain;
    }
    @media (max-width: 768px) and (orientation: landscape) {
        .lightbox-modal.active .lightbox-image,
        .lightbox-modal.fullscreen-active .lightbox-image {
            width: auto !important;
            max-width: 100dvh !important;
            max-width: 100vh !important;
            height: 100vw !important;
            max-height: none !important;
            transform: rotate(-90deg);
        }
    }
}
