/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #fff;
}

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

/* Screens */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Preloader */
#preloader {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #0a0a0a;
    z-index: 1000;
}

.loading-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
}

.loading-progress.indeterminate {
    width: 100% !important;
    background: linear-gradient(90deg, transparent, #667eea, #764ba2, transparent);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.loading-text {
    margin-top: 20px;
    font-size: 14px;
    opacity: 0.6;
}

/* Experience Container */
#experience {
    background: #000;
}

/* Video Layer - Background, always visible */
#video-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #000;
    overflow: hidden;
}

#video-player,
#video-player-b {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none; /* Chromeless - no native controls */
}

#video-player-b {
    opacity: 0;
}

/* Video crossfade transition */
.video-crossfade {
    transition: opacity 0.5s ease;
}

/* Top Bar - Full-width white bar beneath Rive, above video.
   Only visible in Fit.Contain mode (short viewports) where Rive
   canvas doesn't reach the screen edges. */
#top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 9.5vh;
    background: #fff;
    z-index: 5;
    display: none;
}

@media (max-height: 949px) {
    #top-bar {
        display: block;
    }
}

/* Rive Layer - Transparent overlay on top of video */
#rive-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through by default */
    overflow: hidden;
}

#rive-layer.interactive {
    pointer-events: auto; /* Enable when Rive has interactive elements */
}

#rive-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent; /* CRITICAL: Video shows through */
}

/* Rive layer transitions */
#rive-layer.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

#rive-layer.fade-in {
    opacity: 1;
    transition: opacity 0.3s ease-in;
}

/* Legacy: Keep for backward compatibility */
#media-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#video-player.active {
    display: block;
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

#ui-overlay > * {
    pointer-events: auto;
}

/* Progress Bar */
#progress-bar {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
}

.progress-dots {
    display: flex;
    gap: 10px;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.progress-dot.active {
    background: #fff;
    transform: scale(1.2);
}

.progress-dot.completed {
    background: rgba(255, 255, 255, 0.5);
}

/* Continue Prompt */
#continue-prompt {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    opacity: 0.6;
    animation: pulse 2s ease-in-out infinite;
    white-space: nowrap;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* Skip Button */
#skip-button {
    position: absolute;
    bottom: 40px;
    right: 40px;
    padding: 10px 24px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

#skip-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

#skip-button:active {
    transform: scale(0.98);
}

/* Transitions */
.fade-enter {
    opacity: 0;
}

.fade-enter-active {
    opacity: 1;
    transition: opacity 0.4s ease;
}

.fade-exit {
    opacity: 1;
}

.fade-exit-active {
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* ==================== Unsupported Screen Overlay ==================== */
#unsupported-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0e1a;
    z-index: 10000;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

#unsupported-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: auto;
    height: 100%;
    aspect-ratio: 1920 / 1072;
    transform: translateX(-50%) rotate(-90deg);
    background: url('../assets/image/globe-background.webp') center/contain no-repeat;
    opacity: 0.6;
    pointer-events: none;
}

#unsupported-screen .unsupported-phone,
#unsupported-screen .unsupported-tablet {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 40px;
    max-width: 400px;
}

#unsupported-screen svg {
    margin-bottom: 32px;
    opacity: 0.9;
}

.unsupported-title {
    font-size: 18px;
    font-weight: 500;
    line-height: 1.5;
    color: #fff;
    margin-bottom: 16px;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

.unsupported-subtitle {
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

/* Phone: any screen under 768px wide */
@media (max-width: 767px) {
    #unsupported-screen {
        display: flex;
    }
    #unsupported-screen .unsupported-phone {
        display: flex;
    }
}

/* Tablet in portrait: 768px–1023px wide AND portrait orientation */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
    #unsupported-screen {
        display: flex;
    }
    #unsupported-screen .unsupported-tablet {
        display: flex;
    }
}

/* Landscape but still too narrow (768–1023px, landscape) */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
    #unsupported-screen {
        display: flex;
    }
    #unsupported-screen .unsupported-phone {
        display: flex;
    }
}

/* Responsive (small screens that still show experience — kept for edge cases) */
@media (max-width: 768px) {
    #skip-button {
        bottom: 20px;
        right: 20px;
        padding: 8px 16px;
        font-size: 12px;
    }

    #continue-prompt {
        bottom: 80px;
        font-size: 12px;
    }

    #progress-bar {
        bottom: 20px;
    }

    .progress-dot {
        width: 6px;
        height: 6px;
    }
}

/* Touch Device Improvements */
@media (hover: none) {
    #skip-button:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* ==================== Chart Overlay ==================== */
#chart-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 200px;
}

#chart-overlay.hidden {
    display: none !important;
}

.chart-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    cursor: pointer;
}

.chart-close {
    position: absolute;
    top: 10px;
    right: 14px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.chart-close:hover {
    background: rgba(255, 255, 255, 0.18);
}

.chart-container {
    position: relative;
    width: 90%;
    max-width: 1100px;
    max-height: 88vh;
    background: transparent;
    overflow: hidden;
}

.chart-scroll {
    overflow-y: auto;
    max-height: 88vh;
    -webkit-overflow-scrolling: touch;
}

.chart-scroll::-webkit-scrollbar {
    width: 6px;
}

.chart-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.chart-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.chart-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

.chart-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

/* ==================== Debug Bar ==================== */
#debug-bar {
    position: fixed;
    top: 10px;
    left: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 6px;
    padding: 8px 12px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 11px;
    color: #fff;
    z-index: 9999;
    pointer-events: auto;
    backdrop-filter: blur(4px);
}

#debug-bar.hidden {
    display: none !important;
}

.debug-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.debug-row:last-child {
    margin-bottom: 0;
}

.debug-label {
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    font-size: 9px;
    letter-spacing: 0.5px;
}

.debug-value {
    color: #0ff;
    font-weight: 500;
}

.debug-separator {
    color: rgba(255, 255, 255, 0.2);
}

/* State colors */
#debug-state[data-state="idle"] { color: #888; }
#debug-state[data-state="loading"] { color: #ff0; }
#debug-state[data-state="cutscene"] { color: #0f0; }
#debug-state[data-state="transitioning"] { color: #f80; }
#debug-state[data-state="rive"] { color: #0ff; }
#debug-state[data-state="complete"] { color: #f0f; }

/* Video status */
#debug-video-status[data-playing="true"] {
    color: #0f0;
}

#debug-video-status[data-playing="false"] {
    color: #f80;
}

/* Video progress bar */
#debug-video-progress {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-left: 8px;
    position: relative;
    overflow: visible;
}

#debug-video-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0ff, #0f0);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

#debug-video-pause-marker {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: #f00;
    border-radius: 1px;
    display: none;
}

#debug-video-pause-marker.visible {
    display: block;
}

/* Audio volume sliders */
.debug-audio-controls {
    border-top: 1px solid rgba(0, 255, 255, 0.15);
    padding-top: 4px;
    margin-top: 2px;
}

.debug-slider {
    width: 80px;
    height: 4px;
    accent-color: #0ff;
    cursor: pointer;
    vertical-align: middle;
}
