/**
 * NeuroTouch Hero Section Styles
 *
 * Custom styling for the NeuroTouch Symmetry Serum hero section pattern
 * Fills viewport width, 8px rounded corners
 * Overlay layout: text overlays image on all breakpoints
 * Desktop: 120px left padding, 0 right padding, max-width 600px content
 * Content column: >= 64px margin top/bottom (left side only)
 * Desktop: Image positioned absolutely, extends across both columns with overflow hidden
 * Mobile gradient: top to bottom; Desktop gradient: left to right
 * Mobile: 250px max button width
 *
 * @package eride
 * @version 2.3.0
 *
 * Changelog:
 * 2.3.0 (2025-12-09) - Cache bust for deployment (matches loader v4.16.0)
 * 2.2.0 (2025-12-09) - Requirements update per NEUROTOUCH-HERO-UPDATE.md
 *       - Updated container max-width from 1400px to 1440px for proper header alignment
 *       - Enhanced gradient with 8 intermediate stops for smoother transition (reduces banding artifacts)
 *       - Applied multi-stop gradient to both desktop (horizontal) and mobile (vertical) layouts
 *       - Improved visual quality with high-fidelity color transitions
 * 2.1.0 - Image extends across columns: Absolute positioning allows image to grow
 *         with viewport width, overflow hidden clips excess for clean edges
 *       - Removed flex constraints on image container (now position: absolute)
 *       - Image uses object-fit: cover with center-left positioning
 * 2.0.0 - CSS Modernization: Migrated to design system variables
 *       - Replaced hardcoded colors with CSS custom properties
 *       - Added transition variables for consistent animations
 *       - Added shadow variables for modal overlay
 *       - Retained !important for WordPress FSE block overrides (necessary)
 *       - Improved maintainability with centralized color management
 */

/* ==========================================================================
   Hero Container - Constrained Gradient with Rounded Corners
   ========================================================================== */

.neurotouch-hero {
    /* Local CSS variables for this component */
    --nt-gradient-start: #444A56;
    --nt-gradient-end: #B9BCC1;
    --nt-accent: #F97316; /* Orange accent for focus/hover */

    position: relative;
    overflow: hidden;
    /* Gradient: Desktop horizontal, Mobile vertical (see @media) */
    /* Multi-stop gradient for smooth transition, reduces banding */
    background: linear-gradient(
        to right,
        var(--nt-gradient-start) 0%,
        #525962 12.5%,
        #616872 25%,
        #6F7682 37.5%,
        #7E8592 50%,
        #8D94A2 62.5%,
        #9CA3B1 75%,
        #AAB1BA 87.5%,
        var(--nt-gradient-end) 100%
    );
    height: 75vh; /* Fixed height */
    display: flex;
    align-items: center;
    justify-content: center;
    /* Fills viewport width on all screen sizes */
    width: 100%;
    /* Rounded corners */
    border-radius: var(--radius-md, 8px);
    /* No horizontal padding on hero - inner container handles alignment */
    padding: 0;
    margin: 0;
}

/* Inner container - fills hero section, aligns with header (1440px max)
   Position relative for absolutely positioned image child */
.neurotouch-inner-container {
    width: 100%;
    max-width: 1440px; /* Match header max-width */
    margin: 0 auto; /* Center the container - aligns with header */
    height: 100%; /* Full height for image stretching */
    display: flex;
    flex-direction: row;
    align-items: center; /* Vertically center content */
    justify-content: flex-start; /* Content starts from left */
    gap: 0; /* No gap needed - image is positioned absolutely */
    /* Horizontal padding matches WordPress root padding for header alignment
       Falls back to 20px if CSS variable not available */
    padding: 0 var(--wp--style--root--padding-right, 20px) 0 var(--wp--style--root--padding-left, 20px);
    position: relative; /* CRITICAL: Establishes positioning context for absolute image */
}

/* ==========================================================================
   Content Styling
   ========================================================================== */

/* Content column - left side, overlays the absolutely positioned image */
.neurotouch-content,
.neurotouch-content.wp-block-group {
    flex: 0 0 auto !important; /* Natural width based on content */
    width: 50% !important; /* Takes left half for text */
    max-width: 600px !important; /* Prevent excessive width, keeps content compact */
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important; /* Center content vertically */
    gap: 8px !important;
    position: relative !important;
    z-index: 2 !important; /* ABOVE the absolutely positioned image */
    /* Desktop: Use padding instead of margin to stay within image bounds */
    padding: 64px 0 !important;
    margin: 0 !important;
    /* Ensure content doesn't overflow image boundaries */
    align-self: center !important;
    max-height: 100% !important;
}

/* ==========================================================================
   Optional Readability Enhancement
   ========================================================================== */
/* Uncomment below to add a subtle backdrop blur to content for better contrast
.neurotouch-content {
    background: rgba(68, 74, 86, 0.15);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 40px;
    border-radius: 8px;
}
*/

/* Innovation Badge */
.neurotouch-badge,
.neurotouch-badge.has-text-color,
.neurotouch-badge.has-background {
    display: inline-block !important;
    width: auto !important;
    max-width: fit-content !important;
    /* Badge margin controlled by content column margin */
    margin-top: 0 !important;
}

/* Title Stack - Two Lines */
/* .neurotouch-title-stack {
    margin-bottom: 24px;
} */

/* Desktop only: Control all element spacing to work with 8px gap */
.neurotouch-badge {
    margin: 0 !important;
}

.neurotouch-title-stack {
    margin: 0 !important;
}

.neurotouch-description {
    margin: 0 !important;
}

.neurotouch-cta-group {
    margin: 0 !important;
}

/* Description */
.neurotouch-description {
    max-width: 500px;
}

/* ==========================================================================
   Image Styling
   ========================================================================== */

/* Image container - EXTENDS across both columns with overflow hidden
   Image is positioned absolutely to break out of flex constraints
   Hero has overflow:hidden so excess is clipped */
.neurotouch-image-container,
.neurotouch-image-container.has-global-padding,
.neurotouch-image-container.is-layout-constrained {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    /* Width extends from roughly center to right edge, with overflow */
    width: 65% !important; /* Extend beyond 50% to allow growth */
    height: 100% !important;
    z-index: 1 !important; /* Below content */
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important; /* Push image to right edge */
}

/* Child elements within image container */
.neurotouch-image-container > * {
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
}

/* Product image figure - full height */
.neurotouch-product-image,
.neurotouch-product-image.wp-block-image,
.neurotouch-product-image.size-full {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    max-width: none !important;
}

/* Product image - GROWS with viewport, height fills section
   Uses min-width to ensure image grows beyond container */
.neurotouch-product-image img {
    height: 100%; /* Full height - touches top and bottom */
    width: auto; /* Width determined by height + aspect ratio */
    min-width: 100%; /* Ensures image fills at minimum */
    max-width: none !important; /* Allow image to grow beyond container */
    object-fit: cover; /* Cover ensures no gaps, crops if needed */
    object-position: center left; /* Keep product centered, crop from right */
    /* Match container border radius */
    border-radius: 0 8px 8px 0; /* Right side rounded corners only */
}

/* ==========================================================================
   Button Styling
   ========================================================================== */

/* Primary Button - Hover Effects */
.neurotouch-btn-primary .wp-block-button__link:hover {
    background-color: var(--color-tw-gray-100, #f3f4f6) !important;
    color: var(--color-tw-gray-800, #1f2937) !important;
    transform: translateY(-2px);
    transition: var(--transition-slow, all 0.3s ease);
}

/* Secondary Button - Fix double border issue */
.neurotouch-btn-secondary {
    border: none !important; /* Remove border from outer container */
}

.neurotouch-btn-secondary .wp-block-button__link {
    border: 2px solid var(--color-base, #ffffff) !important; /* Only white border on link */
    box-shadow: none !important; /* Remove any box-shadow that looks like border */
    outline: none !important;
}

/* Secondary Button - Hover Effects */
.neurotouch-btn-secondary .wp-block-button__link:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: var(--color-base, #ffffff) !important; /* Keep white border on hover */
    transform: translateY(-2px);
    transition: var(--transition-slow, all 0.3s ease);
}

/* CTA Group - Responsive Layout */
.neurotouch-cta-group,
.neurotouch-cta-group.is-layout-flex {
    flex-wrap: wrap;
    /* CTA margin controlled by content column margin */
    margin-bottom: 0 !important;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Tablet (768px - 1024px) - Maintain absolute image positioning */
@media (max-width: 1024px) {
    .neurotouch-hero {
        height: 70vh; /* Shorter height for tablets */
        margin: 0;
        width: 100%;
    }

    .neurotouch-inner-container {
        gap: 0; /* No gap - image is absolute */
        /* Tablet: Use WordPress root padding for header alignment */
        padding: 0 var(--wp--style--root--padding-right, 20px) 0 var(--wp--style--root--padding-left, 20px);
    }

    .neurotouch-content,
    .neurotouch-content.wp-block-group {
        width: 55% !important; /* Slightly wider text area on tablet */
        max-width: 550px !important; /* Slightly smaller max-width on tablet */
        /* Tablet: Use padding to stay within bounds */
        padding: 48px 0 !important;
        margin: 0 !important;
    }

    /* Image container - extend further on tablet for visual impact */
    .neurotouch-image-container,
    .neurotouch-image-container.has-global-padding,
    .neurotouch-image-container.is-layout-constrained {
        width: 60% !important; /* Extend more on tablet */
    }

    .neurotouch-product-image img {
        height: 100%; /* Full height on tablet too */
    }

    /* Reset badge and title spacing for tablet */
    .neurotouch-badge {
        margin-bottom: 12px !important;
    }

    .neurotouch-title-stack {
        margin-top: 0 !important;
        margin-bottom: 20px;
    }

    .neurotouch-title-stack span:first-child {
        font-size: clamp(40px, 7vw, 64px) !important;
    }

    .neurotouch-title-stack span:last-child {
        font-size: clamp(32px, 6vw, 56px) !important;
    }

    .neurotouch-description {
        font-size: 17px !important;
        margin-bottom: 28px !important;
    }
}

/* Mobile (< 768px) - True Overlay Architecture with Aggressive Overrides */
@media (max-width: 768px) {
    .neurotouch-hero {
        min-height: 80vh !important;
        height: auto !important;
        padding: 0 !important;
        position: relative !important;
        margin: 0 !important;
        width: 100% !important;
        /* Mobile gradient: top to bottom */
        /* Multi-stop gradient for smooth transition, reduces banding */
        background: linear-gradient(
            to bottom,
            var(--nt-gradient-start) 0%,
            #525962 12.5%,
            #616872 25%,
            #6F7682 37.5%,
            #7E8592 50%,
            #8D94A2 62.5%,
            #9CA3B1 75%,
            #AAB1BA 87.5%,
            var(--nt-gradient-end) 100%
        ) !important;
    }

    /* Override WordPress inline styles and flex classes */
    .neurotouch-inner-container,
    .neurotouch-inner-container.is-horizontal,
    .neurotouch-inner-container.is-layout-flex,
    .neurotouch-inner-container.is-content-justification-space-between {
        display: block !important; /* Break flex layout completely */
        flex-direction: column !important;
        position: relative !important;
        min-height: 80vh !important;
        height: auto !important;
        padding: clamp(40px, 8vh, 64px) clamp(20px, 4vw, 64px) !important;
        gap: 0 !important;
        width: 100% !important;
        margin: 0 !important;
    }

    /* Content: Positioned relative, centered, high z-index */
    .neurotouch-content,
    .neurotouch-content.is-layout-flex,
    .neurotouch-content.is-vertical,
    .neurotouch-content.wp-block-group {
        position: relative !important;
        z-index: 10 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        flex: none !important;
    }

    /* Image Container: Absolute positioned full background layer */
    .neurotouch-image-container,
    .neurotouch-image-container.is-layout-constrained,
    .neurotouch-image-container.has-global-padding {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 0 !important;
        opacity: 0.7 !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 8px !important;
        overflow: hidden !important;
        display: block !important;
        flex: none !important;
    }

    /* Image figure: Full coverage */
    .neurotouch-product-image,
    .neurotouch-product-image.size-full {
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
    }

    /* Image: Cover background with proper positioning */
    .neurotouch-product-image img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: center !important;
        border-radius: 8px !important;
        display: block !important;
    }

    /* Badge styling */
    .neurotouch-badge {
        font-size: 11px !important;
        padding: 6px 16px !important;
        margin-bottom: 12px !important;
        text-align: center !important;
    }

    /* Title styling - reset desktop spacing adjustments */
    .neurotouch-title-stack {
        margin-top: 0 !important;
        margin-bottom: 16px !important;
        text-align: center !important;
    }

    .neurotouch-title-stack span:first-child {
        font-size: clamp(36px, 9vw, 48px) !important;
    }

    .neurotouch-title-stack span:last-child {
        font-size: clamp(28px, 7vw, 40px) !important;
    }

    /* Description styling */
    .neurotouch-description {
        font-size: 16px !important;
        margin-bottom: 24px !important;
        text-align: center !important;
    }

    /* CTA Group: Stack buttons vertically and center */
    .neurotouch-cta-group,
    .neurotouch-cta-group.is-layout-flex {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 12px !important;
    }

    .neurotouch-cta-group .wp-block-buttons {
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
    }

    .neurotouch-cta-group .wp-block-button {
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
    }

    .neurotouch-cta-group .wp-block-button__link {
        width: 100% !important;
        max-width: 250px !important;
        text-align: center !important;
        padding-left: 24px !important;
        padding-right: 24px !important;
        display: block !important;
    }
}

/* Extra Small Mobile (< 480px) */
@media (max-width: 480px) {
    .neurotouch-content-wrapper {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .neurotouch-badge {
        font-size: 10px !important;
        padding: 5px 14px !important;
    }

    .neurotouch-description {
        font-size: 15px !important;
    }
}

/* ==========================================================================
   Layout Optimization
   ========================================================================== */

/* Ensure content stays within bounds */
.neurotouch-inner-container > * {
    position: relative;
    z-index: 1;
}

/* Ensure gradient extends full width */
.neurotouch-hero {
    width: 100%;
}

/* ==========================================================================
   Video Modal Styles
   ========================================================================== */

/* Modal container - fixed fullscreen overlay */
.neurotouch-video-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-modal, 99999);
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition-opacity, opacity 0.3s ease);
}

.neurotouch-video-modal.active {
    display: flex !important;
    opacity: 1;
}

/* Dark semi-transparent overlay */
.neurotouch-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
}

/* Video container - centered with max constraints */
.neurotouch-video-container {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Close button */
.neurotouch-video-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: transparent;
    border: none;
    color: var(--color-base, #ffffff);
    font-size: 48px;
    line-height: 1;
    cursor: pointer;
    padding: 10px;
    z-index: 2;
    transition: var(--transition-slow, color 0.3s ease), var(--transition-normal, transform 0.2s ease);
    font-weight: var(--font-light, 300);
}

.neurotouch-video-close:hover {
    color: var(--nt-accent, #F97316);
    transform: scale(1.1);
}

/* Video wrapper - maintains aspect ratio */
.neurotouch-video-wrapper {
    position: relative;
    width: 100%;
    max-width: 1200px;
    background: var(--color-contrast, #000000);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}

/* Video element - responsive and centered */
.neurotouch-video-wrapper video {
    width: 100%;
    height: auto;
    display: block;
    max-height: 85vh;
    object-fit: contain;
}

/* Mobile adjustments for video modal */
@media (max-width: 768px) {
    .neurotouch-video-container {
        max-width: 95vw;
        max-height: 95vh;
    }

    .neurotouch-video-close {
        top: -40px;
        font-size: 36px;
        right: 10px;
    }

    .neurotouch-video-wrapper video {
        max-height: 80vh;
    }
}

/* Loading state (optional) */
.neurotouch-video-wrapper.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--color-base, #ffffff);
    border-radius: var(--radius-full, 50%);
    animation: neurotouch-spinner 0.8s linear infinite;
}

@keyframes neurotouch-spinner {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Accessibility Improvements
   ========================================================================== */

/* Focus states for keyboard navigation */
.neurotouch-btn-primary .wp-block-button__link:focus-visible,
.neurotouch-btn-secondary .wp-block-button__link:focus-visible {
    outline: 3px solid var(--nt-accent, #F97316);
    outline-offset: 4px;
}

.neurotouch-video-close:focus-visible {
    outline: 3px solid var(--nt-accent, #F97316);
    outline-offset: 4px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .neurotouch-badge {
        border-width: 3px !important;
    }

    .neurotouch-btn-secondary .wp-block-button__link {
        border-width: 3px !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .neurotouch-btn-primary .wp-block-button__link:hover,
    .neurotouch-btn-secondary .wp-block-button__link:hover {
        transform: none;
        transition: none;
    }
}
