/* Video container with text overlay */
.video-container {
    position: relative;
    width: 100%;
    max-width: 1000px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        0 0 50px rgba(255, 255, 255, 0.05);
    opacity: 0;
    transform: scale(0.95);
    animation: fadeInScale 1.2s ease-out 1.4s forwards;
}

/* Text content - positioned over the video */
.text-content {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 2rem;
    z-index: 10;
}

.text-rotator {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem 2rem;
    background: rgba(0, 0, 0, 0.2); /* 20% transparent */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.5),
        0 6px 20px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    opacity: 0.95;
    transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    min-width: 260px;
    height: auto; /* Natural height based on content */
    min-height: auto; /* Remove fixed height constraints */
}

.rotating-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 100%; /* Full width for proper text flow */
    white-space: normal; /* Allow text wrapping on all screens */
    line-height: 1.4; /* Consistent line spacing */
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    pointer-events: none;
}

.rotating-text.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.rotating-text.leaving {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(-15px) scale(0.98);
}

.rotating-text.entering {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(15px) scale(0.98);
}

.rotating-text[data-index="0"] {
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #ffffff 0%, #cccccc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 255, 255, 0.2);
    padding-top: 0.2rem; /* Slightly larger top padding for first text */
}

.rotating-text[data-index="1"],
.rotating-text[data-index="2"],
.rotating-text[data-index="3"] {
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #ffffff 0%, #cccccc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 255, 255, 0.2);
}

/* Semi-transparent overlay for better text readability */
.video-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.3) 0%,
        rgba(0, 0, 0, 0.1) 50%,
        rgba(0, 0, 0, 0.3) 100%
    );
    z-index: 5;
    pointer-events: none;
}

/* Responsive hero image */
.responsive-hero-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    -ms-interpolation-mode: nearest-neighbor;
}

/* Improve image quality on high DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .responsive-hero-image {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Video fallback */
.video-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1rem;
    display: none;
}

.video-fallback.show {
    display: flex;
}

/* Animations */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Maintain single-line text on large screens */
@media (min-width: 769px) {
    .rotating-text {
        white-space: nowrap; /* Single line on large screens */
        width: auto; /* Auto width for single line text */
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .text-content {
        max-width: 100%;
        position: absolute;
        bottom: 20px;
        left: 0;
        width: 100%;
        top: auto;
        transform: none;
    }
    
    .video-container {
        border-radius: 15px;
    }
}

@media (max-width: 480px) {
    .video-container {
        border-radius: 12px;
    }
}

/* Fix overlay for small screens (479px and below) */
@media (max-width: 479px) {
    .text-rotator {
        padding: 1.5rem 1.2rem; /* More flexible padding */
        min-width: 180px; /* Slightly smaller minimum width */
        height: auto; /* Allow natural height based on content */
        min-height: auto; /* Remove any fixed minimum height */
        align-items: center; /* Keep centered alignment */
        justify-content: center; /* Keep centered alignment */
    }
    
    .rotating-text {
        white-space: normal; /* Allow text wrapping */
        line-height: 1.4; /* Better spacing for wrapped text */
        position: absolute; /* Keep absolute positioning for rotation */
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 100%; /* Full width for better text wrapping */
        text-align: center;
    }
    
    .rotating-text.active {
        transform: translate(-50%, -50%) scale(1); /* Keep original transform */
    }
    
    .rotating-text.leaving {
        transform: translate(-50%, -50%) translateY(-15px) scale(0.98); /* Keep original transform */
    }
    
    .rotating-text.entering {
        transform: translate(-50%, -50%) translateY(15px) scale(0.98); /* Keep original transform */
    }
}

/* Hide rotating text on very small screens */
@media (max-width: 400px) {
    .text-content {
        display: none;
    }
}

/* Loading state */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .video-container,
    .text-rotator,
    .rotating-text {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for accessibility */
.responsive-hero-image:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}
