/**
 * Background System Styles
 * Infrastructure for Three.js animations, images, and videos
 */

/* =============================================================================
   CANVAS ANIMATION (Three.js)
   ============================================================================= */

.background-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    display: block;
}

/* Hide if disabled */
.canvas-animations-disabled .background-canvas {
    display: none;
}

/* =============================================================================
   BACKGROUND IMAGE
   ============================================================================= */

.background-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* iOS fix: background-attachment: fixed doesn't work well on iOS */
@supports (-webkit-touch-callout: none) {
    .background-image {
        background-attachment: scroll;
    }
}

/* =============================================================================
   BACKGROUND VIDEO
   ============================================================================= */

.background-video {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
    object-fit: cover;
    /* Ensure video always covers viewport */
    min-width: 100%;
    min-height: 100%;
}

/* =============================================================================
   OVERLAY
   ============================================================================= */

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* =============================================================================
   CUSTOM PAGE CLASSES (examples)
   ============================================================================= */

/* User can add custom styles for page-specific classes */
/* Example:
.home-animation {
    opacity: 0.8;
}

.about-animation {
    filter: blur(2px);
}

.hero-background {
    filter: brightness(0.8);
}
*/

/* =============================================================================
   REDUCED MOTION
   ============================================================================= */

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .background-canvas,
    .background-video {
        /* Pause animations for users who prefer reduced motion */
        animation-play-state: paused !important;
    }

    .background-video {
        /* Show poster instead of video */
        display: none;
    }
}

/* =============================================================================
   SPACE ANIMATION UI ELEMENTS
   ============================================================================= */

/* Speed boost zone indicators */
.space-boost-zone {
    position: fixed;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: linear-gradient(to center, rgba(79, 70, 229, 0.3), transparent);
}

.space-boost-zone.active {
    opacity: 1;
}

.space-boost-zone.top {
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to bottom, rgba(79, 70, 229, 0.3), transparent);
}

.space-boost-zone.bottom {
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to top, rgba(79, 70, 229, 0.3), transparent);
}

.space-boost-zone.left {
    left: 0;
    top: 0;
    bottom: 0;
    width: 100px;
    background: linear-gradient(to right, rgba(79, 70, 229, 0.3), transparent);
}

.space-boost-zone.right {
    right: 0;
    top: 0;
    bottom: 0;
    width: 100px;
    background: linear-gradient(to left, rgba(79, 70, 229, 0.3), transparent);
}

/* Object tooltips */
.space-tooltip {
    position: fixed;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 4px;
    font-size: 14px;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.space-tooltip.visible {
    opacity: 1;
}

[data-bs-theme="light"] .space-tooltip {
    background: rgba(255, 255, 255, 0.9);
    color: #1f2937;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Audio mute button */
.space-audio-mute {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 1000;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.space-audio-mute:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.space-audio-mute.muted {
    background: rgba(239, 68, 68, 0.5);
    border-color: rgba(239, 68, 68, 0.8);
}

[data-bs-theme="light"] .space-audio-mute {
    background: rgba(255, 255, 255, 0.5);
    color: #1f2937;
    border-color: rgba(0, 0, 0, 0.2);
}

[data-bs-theme="light"] .space-audio-mute:hover {
    background: rgba(255, 255, 255, 0.7);
}

[data-bs-theme="light"] .space-audio-mute.muted {
    background: rgba(239, 68, 68, 0.7);
    color: white;
}

/* Tech grid overlay (light theme only) */
.space-tech-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    background-image:
        linear-gradient(rgba(209, 213, 219, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(209, 213, 219, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
}

[data-bs-theme="light"] .space-tech-grid {
    opacity: 1;
}

/* Warp jump screen flash */
.space-warp-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3), transparent);
    opacity: 0;
    transition: opacity 0.1s ease;
}

.space-warp-flash.active {
    opacity: 1;
}

/* Speed indicator (optional) */
.space-speed-indicator {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

[data-bs-theme="light"] .space-speed-indicator {
    background: rgba(255, 255, 255, 0.5);
    color: #1f2937;
}

/* Cooldown indicator */
.space-cooldown {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 8px;
    font-size: 18px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.space-cooldown.visible {
    opacity: 1;
}

/* Performance warning */
.space-performance-warning {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 12px 16px;
    background: rgba(245, 158, 11, 0.9);
    color: white;
    border-radius: 4px;
    font-size: 14px;
    z-index: 1000;
    display: none;
}

.space-performance-warning.visible {
    display: block;
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    .background-canvas,
    .background-image,
    .background-video,
    .background-overlay,
    .space-boost-zone,
    .space-tooltip,
    .space-audio-mute,
    .space-tech-grid,
    .space-warp-flash,
    .space-speed-indicator,
    .space-cooldown,
    .space-performance-warning {
        display: none !important;
    }
}
