/* ========================================
   ENTRY LAYOUT - index.html & main.html
   Shared: main#content, test-container, globe, loading overlay,
   main menu, zoom controls. Extracted from inline <style> for DRY.
   ======================================== */

/* Ensure main element properly contains containers */
main#content {
    position: relative;
    /* Flex sibling of side panels: explicit 0 so panels (z-index 540) stack above the map + image overlay */
    z-index: 0;
}

/* Test container styling - for Menu Components */
.test-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    width: 100%;
    height: 100%;
    padding: 0;
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1; /* Lower than buttons */
    pointer-events: none; /* Allow clicks to pass through to buttons */
}

/* Allow pointer events on test-container children */
.test-container > * {
    pointer-events: auto;
}

/* Globe container should take full space when visible */
#globe-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

/* Lift canvas above bottom pagination strip when timeline is active but dock is not in use */
body:has(footer.timeline-loaded):not(:has(#paginationDock)) #globe-container {
    bottom: 108px;
}

/*
 * Pagination dock sits below .layout-container; flex layout clears the dock — no extra bottom inset.
 */
body:has(footer.timeline-loaded):has(#paginationDock) #globe-container {
    bottom: 0;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000; /* Fully black (100% opacity) */
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
    /* Block interaction while visible; otherwise clicks hit the frozen globe underneath. */
    pointer-events: auto;
}

.loading-status-overlay {
    background: transparent; /* Backgroundless */
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.loading-gif {
    /* Larger, responsive loading graphic */
    width: clamp(260px, 40vw, 460px);
    height: auto;
    max-width: 460px;
    max-height: 460px;
    margin-bottom: 20px;
}

.loading-status-overlay h3 {
    margin-top: 0;
    color: #2196F3;
    text-align: center;
    margin-bottom: 15px;
}

.loading-progress-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

.loading-progress-bar {
    height: 100%;
    background: #ffffff;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.loading-status-overlay #overlayStatusContent {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-status-overlay .test-status-item {
    text-align: center;
    padding: 10px;
    background: transparent;
}

/* Main menu button layout - for Menu Components */
.main-menu-buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 30px;
    width: 100%;
    height: 100%;
    min-height: 100%;
    padding: 0;
    position: relative;
    background: var(--bg-secondary);
    isolation: isolate;
}

/* Button wrapper with external label */
.main-menu-btn-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 900px;
}

/* External dark label - positioned at bottom of button */
.main-menu-external-label {
    background: rgba(0, 0, 0, 0.75);
    width: 100%;
    height: 60px;
    padding: 4px 16px;
    border-radius: 0 0 12px 12px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: none;
    border-top: 2px solid rgba(255, 255, 255, 0.93);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    position: relative;
    z-index: 10;
}

.main-menu-external-label__desc {
    color: white;
    font-size: 24px;
    font-weight: 500;
    line-height: 1.4;
    position: relative;
    z-index: 20;
    transition: opacity 0.15s ease;
}

.main-menu-btn {
    --thumb-skew: -11deg;
    width: 100%;
    aspect-ratio: 1.4;
    max-height: 550px;
    border: none;
    border-top: 12px solid rgba(255, 255, 255, 0.93);
    border-bottom: 12px solid rgba(255, 255, 255, 0.93);
    border-left: 0;
    border-right: 0;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transform: skewX(var(--thumb-skew));
    transform-origin: center center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    box-sizing: border-box;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
}

.main-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-top-color: rgba(255, 186, 80, 0.95);
    border-bottom-color: rgba(255, 186, 80, 0.95);
    transform: skewX(var(--thumb-skew)) translateY(-2px) scale(1.02);
    box-shadow: 0 0 16px rgba(255, 255, 255, 0.12), 0 10px 24px rgba(0, 0, 0, 0.35);
}

body.color-palette-gray .main-menu-btn:hover {
    border-top-color: rgba(255, 102, 0, 0.95);
    border-bottom-color: rgba(255, 102, 0, 0.95);
}

.main-menu-image-container {
    width: 110%;
    margin-left: -5%;
    margin-top: -10px;
    background: transparent;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
    height: calc(100% - 60px);
    min-height: 0;
    transform: skewX(11deg) scale(1.1);
    transform-origin: top center;
    position: relative;
}

body.color-palette-gray .main-menu-image-container {
    background: transparent;
}

/* Bottom scrim for text readability */
.main-menu-image-container::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58%;
    pointer-events: none;
    z-index: 1;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.88) 0%,
        rgba(0, 0, 0, 0.55) 38%,
        rgba(0, 0, 0, 0.18) 72%,
        transparent 100%
    );
}

.main-menu-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 0;
    display: block;
    background: #fff;
}

.main-menu-label-container {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 60px;
    z-index: 2;
    background: transparent;
    display: flex;
    flex-direction: column;
    padding: 0 12px 12px 12px;
    box-sizing: border-box;
    transform: skewX(11deg);
    width: 110%;
    margin-left: -5%;
}

body.color-palette-gray .main-menu-label-container {
    background: transparent;
}

.main-menu-label {
    width: 100%;
    color: white;
    font-size: 44px;
    font-weight: 600;
    padding: 0 8px 8px 8px;
    margin: 0;
    border-radius: 0;
    text-align: center;
    transition: all 0.3s ease;
    box-sizing: border-box;
    letter-spacing: 0.5px;
    text-shadow: 0 3px 8px rgba(0, 0, 0, 0.7);
}

.main-menu-description {
    width: 100%;
    color: rgba(255, 255, 255, 0.9);
    font-size: 24px;
    font-weight: 400;
    padding: 0 16px 4px 16px;
    margin: 0;
    border-radius: 0;
    text-align: center;
    transition: all 0.3s ease;
    box-sizing: border-box;
    line-height: 1.5;
    display: block;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

@media (max-width: 768px) {
    body .test-container {
        flex-direction: column !important;
    }

    body .main-menu-buttons {
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        gap: 15px;
        padding: 15px;
        align-items: center;
        justify-content: center;
        overflow-y: auto;
        max-height: 100%;
        width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
    }

    body .main-menu-buttons-row {
        flex-direction: column !important;
        gap: 15px !important;
        width: 100% !important;
    }

    body .main-menu-btn-wrapper {
        max-width: 100%;
        width: 100%;
        flex-direction: column !important;
        display: flex !important;
    }

    body .main-menu-btn {
        display: block !important;
        max-width: 100%;
        width: 100%;
        min-height: 180px;
        max-height: 220px;
        aspect-ratio: auto;
        flex: none;
        position: relative;
    }

    /* Hide description and external label on mobile, show only name label */
    .main-menu-description {
        display: none;
    }

    .main-menu-external-label {
        display: none;
    }

    .main-menu-image-container {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        transform: none;
        border-radius: 0;
        overflow: hidden;
    }

    .main-menu-btn img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center;
    }

    .main-menu-label-container {
        position: absolute;
        bottom: 10px;
        left: 0;
        right: 0;
        width: 100%;
        margin-left: 0;
        transform: none;
        z-index: 2;
    }

    .main-menu-label {
        font-size: 24px;
        padding: 4px 8px;
    }

    /* Portrait mode: even smaller for narrow screens */
    @media (max-width: 480px) {
        .main-menu-buttons {
            gap: 12px;
            padding: 12px;
        }

        .main-menu-btn {
            min-height: 140px;
            max-height: 180px;
        }

        .main-menu-label {
            font-size: 20px;
        }
    }
}

/* Zoom Controls — bottom-right row; same right inset as .dock-globe-rail--right / Events strip (--dock-globe-rail-edge-inset 42px) */
.zoom-controls {
    position: fixed;
    left: auto;
    right: max(42px, env(safe-area-inset-right));
    top: auto;
    transform: none;
    /* Match .dock-globe-rail--left / --right vertical position */
    bottom: calc(
        var(--footer-height, 65px)
        + var(--pagination-dock-height, 240px)
        + var(--dock-globe-rail-gap, 10px)
        + var(--dock-rail-lift-into-border, 0px)
        + var(--dock-rail-side-extra, 30px)
    );
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    z-index: 150; /* Above globe but below event slide (200) and overlays */
    pointer-events: none; /* Allow clicks to pass through container */
}

.zoom-btn {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    /* Uses palette tokens (blue default; gray / crimson / nulled from body.color-palette-*) */
    background: var(--btn-primary-bg);
    color: white;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    pointer-events: auto; /* Enable clicks on buttons */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    user-select: none;
    line-height: 1;
}

.zoom-btn:hover:not(:disabled) {
    background: var(--btn-primary-bg-hover);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.zoom-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.zoom-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* Horizontal row: zoom out → reset → zoom in (left to right) */
.zoom-out-btn {
    order: 1;
}

.zoom-reset-btn {
    order: 2;
}

.zoom-in-btn {
    order: 3;
}

/* Hide zoom controls initially */
.zoom-controls {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Ensure globe UI stays behind loading overlay */
.loading-overlay.active ~ #app-container .dev-sun-yaw-panel,
.loading-overlay.active ~ #app-container .dock-globe-rail,
.loading-overlay.active ~ #app-container .test-container,
.loading-overlay.active ~ #app-container #zoomControls,
.loading-overlay.active ~ #app-container .zoom-btn,
.loading-overlay.active ~ #globe-container .dev-sun-yaw-panel,
.loading-overlay.active ~ #globe-container .dock-globe-rail,
.loading-overlay.active ~ #globe-container #zoomControls,
.loading-overlay.active ~ #globe-container .zoom-btn,
body:has(.loading-overlay.active) .dev-sun-yaw-panel,
body:has(.loading-overlay.active) .dock-globe-rail,
/* Hide all globe UI when loading overlay is active */
body:has(.loading-overlay.active) .dev-sun-yaw-panel,
body:has(.loading-overlay.active) .dock-globe-rail,
body:has(.loading-overlay.active) .test-container,
body:has(.loading-overlay.active) #zoomControls,
body:has(.loading-overlay.active) .zoom-btn,
body:has(.loading-overlay.active) .globe-control-btn,
body:has(.loading-overlay.active) .time-control-slider {
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Show zoom controls when visible */
.zoom-controls.visible {
    opacity: 1;
    pointer-events: auto; /* Buttons are clickable */
}

/* Mobile: same bottom band as dock rails; compact row on the right */
@media (max-width: 768px) {
    .zoom-controls {
        left: auto !important;
        right: max(42px, env(safe-area-inset-right)) !important;
        top: auto !important;
        transform: none !important;
        flex-direction: row !important;
        bottom: calc(var(--footer-height, 65px) + 24px) !important;
    }

    body:has(#paginationDock) .zoom-controls {
        bottom: calc(
                var(--footer-height, 65px)
                + var(--pagination-dock-height, 240px)
                + var(--dock-globe-rail-gap, 10px)
                + var(--dock-rail-lift-into-border, 0px)
                + var(--dock-rail-side-extra, 30px)
            )
            !important;
    }

    .zoom-btn {
        width: 44px !important;
        height: 44px !important;
        font-size: 26px !important;
    }
}
