/* Image loading optimization */
img {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

img.loaded {
    opacity: 1;
}

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

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

/* Responsive loading */
@media (max-width: 640px) {
    .loading-logo-img {
        width: 150px;
    }

    .loading-text {
        font-size: 1.25rem;
    }

    .loading-subtitle {
        font-size: 0.875rem;
    }
}

/* Screen Reader Only - Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.focus\:not-sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Custom Animation Classes */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-on-scroll.animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Custom animations with delays */
.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
    opacity: 0;
}

.animate-slide-up {
    animation: slideUp 0.8s ease-out forwards;
    opacity: 0;
}

.animate-slide-left {
    animation: slideLeft 0.8s ease-out forwards;
    opacity: 0;
}

.animate-slide-right {
    animation: slideRight 0.8s ease-out forwards;
    opacity: 0;
}

.animate-scale-in {
    animation: scaleIn 0.6s ease-out forwards;
    opacity: 0;
}

/* Performance optimization for animations */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .animate-bounce-gentle,
    .animate-float,
    .animate-pulse-glow,
    .animate-shimmer {
        animation: none !important;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus styles for accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #B59E55;
    outline-offset: 2px;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #2C3E50;
}

::-webkit-scrollbar-thumb {
    background: #B59E55;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #C5AE65;
}

/* Loading states */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Form validation styles */
.form-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.form-success {
    border-color: #22c55e !important;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1) !important;
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem !important;
        line-height: 1.1;
    }

    .hero-subtitle {
        font-size: 1.125rem !important;
        line-height: 1.5;
    }

    /* Better touch targets */
    button,
    a,
    input,
    select,
    textarea {
        min-height: 44px;
    }

    /* Prevent zoom on input focus */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --brand-gold: #FFD700;
        --foreground: #FFFFFF;
        --background: #000000;
        --border: #FFFFFF;
    }
}

/* Print styles */
@media print {
    .no-print,
    .fixed,
    nav,
    footer,
    button,
    .animate-on-scroll {
        display: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }

    h1, h2, h3, h4, h5, h6 {
        color: #000;
        page-break-after: avoid;
    }

    p, div {
        orphans: 3;
        widows: 3;
    }

    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 80%;
    }
}

/* Enhanced error states */
.error-message {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.success-message {
    color: #22c55e;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Loading spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Optimized image loading */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Better focus management for skip links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #B59E55;
    color: #000;
    padding: 8px;
    border-radius: 4px;
    text-decoration: none;
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 6px;
}

/* Ensure proper contrast ratios */
.text-sophisticated-gray {
    color: #9CA3AF; /* Meets WCAG AA standard */
}

.text-muted-foreground {
    color: #9CA3AF; /* Meets WCAG AA standard */
}

/* Enhanced button states */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Better form field spacing */
.form-field {
    margin-bottom: 1.5rem;
}

.form-field:last-child {
    margin-bottom: 0;
}

/* Enhanced card hover effects */
.card-enhanced {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
}

.card-enhanced:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Performance optimizations */
.gpu-accelerated {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Video optimizations */
video {
    width: 100%;
    height: auto;
    background-color: #000;
}

video::-webkit-media-controls-panel {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Responsive typography */
.responsive-text {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    line-height: 1.6;
}

.responsive-heading {
    font-size: clamp(1.5rem, 4vw, 3rem);
    line-height: 1.2;
}

/* Better list styling */
ul, ol {
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Enhanced table styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #455A64;
}

th {
    background-color: #374151;
    font-weight: 600;
}

/* Better blockquote styling */
blockquote {
    border-left: 4px solid #B59E55;
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: #9CA3AF;
}

/* Enhanced code styling */
code {
    background-color: #374151;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875em;
}

pre {
    background-color: #374151;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
}

pre code {
    background: none;
    padding: 0;
}

/* Better selection styling */
::selection {
    background-color: #B59E55;
    color: #000;
}

::-moz-selection {
    background-color: #B59E55;
    color: #000;
}

/* Improved placeholder styling */
::placeholder {
    color: #6B7280;
    opacity: 1;
}

::-moz-placeholder {
    color: #6B7280;
    opacity: 1;
}

::-webkit-input-placeholder {
    color: #6B7280;
    opacity: 1;
}

/* Better hr styling */
hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, #455A64, transparent);
    margin: 2rem 0;
}

/* Enhanced tooltip styles */
.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem;
    background-color: #000;
    color: #fff;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
}

.tooltip:hover::before {
    opacity: 1;
}

/* Better fieldset styling */
fieldset {
    border: 1px solid #455A64;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
}

legend {
    font-weight: 600;
    padding: 0 0.5rem;
    color: #B59E55;
}

/* Video Container Styling */
.video-container {
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    background: #1e293b;
    border: 1px solid #475569;
    position: relative;
}

/* Video Player Styling - Basic styling only */
#reels-video {
    border-radius: 1rem;
    background: #000;
}

/* Mobile Video Optimizations */
@media (max-width: 768px) {
    #reels-video {
        max-height: 70vh;
        object-fit: cover;
    }

    .video-container {
        padding: 0 1rem;
    }

    /* Ensure touch targets are adequate */
    #video-overlay,
    #play-button,
    #sound-toggle {
        min-height: 44px;
        min-width: 44px;
    }

    /* Better mobile video controls */
    .video-controls {
        padding: 0.5rem;
    }

    /* Prevent video from being too tall on mobile */
    .mobile-video-container {
        max-height: 80vh;
        overflow: hidden;
    }
}

/* Touch optimizations */
.touch-manipulation {
    touch-action: manipulation;
}

/* Enhanced Plyr volume controls visibility */
.plyr--video .plyr__controls {
    opacity: 1 !important;
    visibility: visible !important;
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.7) 100%) !important;
}

.plyr--video .plyr__control--overlaid {
    display: none !important;
}

/* Hide large play button completely */
.plyr--video .plyr__control[data-plyr="play"][aria-label*="Play"] {
    display: none !important;
}

.plyr__control--overlaid {
    display: none !important;
}

/* Hide all large play buttons and overlays */
.plyr__control[data-plyr="play"].plyr__control--overlaid,
.plyr__control--overlaid[data-plyr="play"],
.plyr--video .plyr__control--overlaid,
.plyr--playing .plyr__control--overlaid {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.plyr--video .plyr__control[data-plyr="mute"] {
    color: white !important;
    opacity: 1 !important;
}

.plyr--video .plyr__control[data-plyr="mute"]:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

.plyr--video .plyr__control[data-plyr="mute"] svg {
    fill: white !important;
    color: white !important;
    width: 18px !important;
    height: 18px !important;
}

.plyr--video .plyr__volume {
    min-width: 100px !important;
    margin-right: 12px !important;
}

.plyr--video .plyr__volume input[type="range"] {
    background: rgba(212, 175, 55, 0.3) !important;
    height: 6px !important;
    border-radius: 3px !important;
}

.plyr--video .plyr__volume input[type="range"]::-webkit-slider-thumb {
    background: #d4af37 !important;
    border: 2px solid white !important;
    border-radius: 50% !important;
    width: 16px !important;
    height: 16px !important;
}

/* Force all controls to be visible */
.plyr--video .plyr__control {
    color: white !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.plyr--video .plyr__control svg {
    fill: white !important;
    stroke: white !important;
    color: white !important;
}

/* Mobile-specific volume control enhancements */
@media (max-width: 768px) {
    .plyr--video .plyr__controls {
        padding: 12px !important;
        background: rgba(0, 0, 0, 0.8) !important;
    }
    
    .plyr--video .plyr__control[data-plyr="mute"] {
        min-width: 44px !important;
        min-height: 44px !important;
        touch-action: manipulation !important;
        color: white !important;
    }
    
    .plyr--video .plyr__control[data-plyr="mute"] svg {
        fill: white !important;
        width: 20px !important;
        height: 20px !important;
    }
    
    .plyr--video .plyr__volume {
        min-width: 80px !important;
        flex: 1 !important;
    }
    
    .plyr--video .plyr__control[data-plyr="fullscreen"] {
        background: rgba(212, 175, 55, 0.7) !important;
        border: 1px solid white !important;
        border-radius: 4px !important;
    }
    
    .plyr--video .plyr__control[data-plyr="fullscreen"] svg {
        fill: white !important;
        stroke: white !important;
    }
}

/* Better mobile spacing */
@media (max-width: 640px) {
    .quality-of-life-section {
        padding: 3rem 1rem;
    }

    .quality-benefits-list {
        gap: 1rem;
    }

    .benefit-item {
        padding: 1rem;
    }
}

/* Ultra-aggressive mobile video performance optimizations */
@media (max-width: 768px) {
    video {
        will-change: transform;
        backface-visibility: hidden;
        min-height: 250px;
        /* Maximum hardware acceleration */
        transform: translateZ(0);
        transform: translate3d(0, 0, 0);
        /* Optimize rendering for speed */
        image-rendering: optimizeSpeed;
        image-rendering: -webkit-optimize-contrast;
        image-rendering: optimize-contrast;
        /* Force immediate loading */
        content-visibility: visible !important;
        contain: layout style paint;
        /* Force GPU acceleration */
        -webkit-transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        -webkit-perspective: 1000;
        /* Optimize video decoding */
        -webkit-video-decoder-type: hardware;
        /* Prioritize loading */
        loading: eager !important;
        /* Disable video effects for faster loading */
        filter: none;
        /* Network hints for video streaming */
        video-preload: auto;
        /* Optimize video memory usage */
        image-orientation: none;
        /* Reduce CPU overhead */
        -webkit-video-decoder: accelerated;
        /* Force immediate buffering */
        -webkit-media-buffering-policy: live;
        /* Optimize network loading */
        -webkit-media-preload: auto;
        /* Reduce render complexity */
        -webkit-appearance: none;
        /* Force immediate paint */
        -webkit-transform-style: preserve-3d;
    }
    
    /* Ultra-priority loading for video container */
    .video-container {
        contain-intrinsic-size: 320px 568px;
        content-visibility: auto;
    }
    
    /* Make video container take more space on mobile */
    .video-container {
        width: 100% !important;
        max-width: calc(100vw - 2rem) !important;
        /* Optimize container rendering */
        contain: layout style paint;
    }
    
    /* Instagram Reels aspect ratio for mobile */
    .plyr__video-wrapper {
        aspect-ratio: 9/16;
        min-height: 400px;
        max-height: 70vh;
        /* Performance optimizations */
        transform: translateZ(0);
        backface-visibility: hidden;
    }
}

/* Plyr Video Player Customization */
.video-container {
    position: relative;
    overflow: hidden;
}

/* Plyr player styling */
.plyr {
    border-radius: 0.75rem;
}

.plyr--video {
    background: #1e293b;
}

/* Custom Plyr controls */
.plyr__control--overlaid {
    background: rgba(212, 175, 55, 0.9) !important;
    color: white !important;
    border: 2px solid rgba(212, 175, 55, 1) !important;
}

.plyr__control--overlaid:hover {
    background: rgba(212, 175, 55, 1) !important;
}

.plyr__controls {
    background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0.4), transparent);
    color: white;
}

.plyr__control.plyr__tab-focus,
.plyr__control:hover,
.plyr__control[aria-expanded=true] {
    background: rgba(212, 175, 55, 0.8) !important;
    color: white !important;
}

.plyr__progress__played {
    background: #d4af37 !important;
}

.plyr__volume__display {
    color: white;
}

/* Hide Plyr branding */
.plyr__poster {
    background-size: cover;
    background-position: center;
}

/* Ensure video maintains aspect ratio */
.plyr__video-wrapper {
    border-radius: 0.75rem;
}

/* Mobile video optimizations - Instagram Reels format */
@media (max-width: 640px) {
    .video-container {
        margin: 0 auto;
        border-radius: 0.75rem !important;
        max-width: 320px;
        min-height: 500px;
        aspect-ratio: 9/16;
    }
    
    .video-container::after {
        height: 45px;
        border-radius: 0 0 0.75rem 0.75rem;
    }
    
    /* Instagram Reels style video */
    .video-container video {
        min-height: 500px;
        height: auto;
        width: 100%;
        object-fit: cover;
        aspect-ratio: 9/16;
    }
    
    .video-container .plyr {
        min-height: 500px;
        aspect-ratio: 9/16;
    }
    
    .video-container .plyr__video-wrapper {
        min-height: 500px;
        aspect-ratio: 9/16;
    }
}

@media (max-width: 480px) {
    .video-container {
        margin: 0 -0.5rem;
        max-width: calc(100vw - 1rem);
        min-height: 280px;
    }
    
    .video-container video {
        min-height: 280px;
        height: auto;
        width: 100%;
        object-fit: cover;
    }
    
    .video-container .plyr {
        min-height: 280px;
    }
    
    .video-container .plyr__video-wrapper {
        min-height: 280px;
    }
}

/* Force immediate volume button visibility on page load */
.plyr--video .plyr__control[data-plyr="mute"] {
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
    position: relative !important;
    z-index: 10 !important;
    background: rgba(181, 158, 85, 0.9) !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
}

/* Fallback emoji icon when SVG is missing */
.plyr--video .plyr__control[data-plyr="mute"]:empty::before {
    content: "🔊" !important;
    font-size: 16px !important;
    display: block !important;
    opacity: 1 !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

.plyr--video .plyr__control[data-plyr="mute"][aria-pressed="true"]:empty::before {
    content: "🔇" !important;
}
