/**
 * Scroll Sequence Pro - Frontend Styles
 * Optimized for performance and cross-browser compatibility
 */

/* Base Container Styles */
.ssp-scroll-sequence-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Elementor specific height inheritance */
.elementor-widget-scroll-sequence-pro .ssp-scroll-sequence-container {
    height: 100%;
}

/* Sticky Scroll Wrapper */
.ssp-scroll-wrapper {
    position: relative;
    width: 100%;
}

.ssp-sticky-container {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* Ensure the sticky container maintains its natural flow position */
    margin-top: 0;
}

/* Ensure the wrapper maintains document flow */
.ssp-scroll-wrapper {
    position: relative;
    display: block;
}

/* When inside sticky container, make sure sequence fills viewport */
.ssp-sticky-container .ssp-scroll-sequence-container {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
}

/* Elementor editor compatibility */
.elementor-editor-active .ssp-scroll-wrapper {
    height: auto !important;
}

.elementor-editor-active .ssp-sticky-container {
    position: relative;
    height: auto;
}

/* Mobile adjustments for sticky scroll */
@media (max-width: 768px) {
    .ssp-sticky-container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }
}

.ssp-scroll-sequence {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    border-radius: 4px;
}

.ssp-scroll-sequence canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Text Overlays Container */
.ssp-text-overlays {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Ensure overlays container fills the scroll sequence */
.ssp-scroll-sequence .ssp-text-overlays {
    position: absolute;
    inset: 0;
}

/* Individual Text Overlay */
.ssp-text-overlay {
    position: absolute;
    padding: 12px 20px;
    border-radius: 6px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
    transform: translate3d(0, 0, 0); /* Force GPU acceleration */
}

/* Transitions only for non-scroll-synced animations */
.ssp-text-overlay:not(.ssp-scroll-synced) {
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Removed unused CSS animations - now using JavaScript-driven scroll animations */

/* Instant Loading - No visible loading states */
.ssp-scroll-sequence {
    /* Remove any loading indicators for instant display */
    background: #000;
}

/* Error States */
.ssp-scroll-sequence.error {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f8f8;
    color: #666;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ssp-scroll-sequence.error::after {
    content: "Failed to load sequence";
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ssp-text-overlay {
        padding: 8px 16px;
        font-size: 14px;
        max-width: 90%;
        white-space: normal;
        word-wrap: break-word;
    }
    
    /* Reduce motion for mobile users who prefer it */
    @media (prefers-reduced-motion: reduce) {
        .ssp-text-overlay {
            transition: opacity 0.2s ease;
        }
    }
}

@media (max-width: 480px) {
    .ssp-text-overlay {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* High DPI Display Optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .ssp-scroll-sequence canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .ssp-scroll-sequence.loading {
        background: linear-gradient(45deg, #333 25%, transparent 25%), 
                    linear-gradient(-45deg, #333 25%, transparent 25%), 
                    linear-gradient(45deg, transparent 75%, #333 75%), 
                    linear-gradient(-45deg, transparent 75%, #333 75%);
    }
    
    .ssp-scroll-sequence.loading::after,
    .ssp-scroll-sequence.error::after {
        color: #ccc;
    }
    
    .ssp-scroll-sequence.error {
        background: #1a1a1a;
    }
}

/* Performance Optimizations */
.ssp-scroll-sequence {
    /* GPU acceleration */
    transform: translateZ(0);
    will-change: transform;
    
    /* Optimize rendering */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
    
    /* Prevent selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    
    /* Prevent drag */
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

.ssp-scroll-sequence * {
    /* Optimize child elements */
    box-sizing: border-box;
}

/* Accessibility */
.ssp-scroll-sequence[aria-label]::before {
    content: attr(aria-label);
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Focus indicators for keyboard navigation */
.ssp-scroll-sequence:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .ssp-scroll-sequence {
        display: none;
    }
}

/* Custom Properties for Easy Theming */
:root {
    --ssp-overlay-bg: transparent;
    --ssp-overlay-text: inherit;
    --ssp-overlay-border-radius: 6px;
    --ssp-animation-duration: 0.4s;
    --ssp-animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Allow customization through CSS variables */
.ssp-text-overlay {
    background-color: var(--ssp-overlay-bg);
    color: var(--ssp-overlay-text);
    border-radius: var(--ssp-overlay-border-radius);
    transition-duration: var(--ssp-animation-duration);
    transition-timing-function: var(--ssp-animation-easing);
}

/* Utility classes for common customizations */
.ssp-overlay-no-backdrop {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.ssp-overlay-transparent {
    background-color: transparent !important;
}

.ssp-overlay-solid {
    background-color: rgba(0, 0, 0, 0.9) !important;
}

.ssp-overlay-light {
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #333 !important;
}

/* Container aspect ratios */
.ssp-aspect-16-9 {
    aspect-ratio: 16 / 9;
}

.ssp-aspect-4-3 {
    aspect-ratio: 4 / 3;
}

.ssp-aspect-1-1 {
    aspect-ratio: 1 / 1;
}

.ssp-aspect-21-9 {
    aspect-ratio: 21 / 9;
}