/* Hero Sections - Size-Aware Responsive System */

/* Base hero styles - common to all sizes */
.hero-section,
.hero-banner {
    position: relative;
    overflow: hidden;
    background-color: var(--kaufman-black, #222);
    display: flex;
    align-items: center;
}

/* Universal hero image handling */
.hero-section img,
.hero-banner img,
.carousel-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    filter: brightness(0.8);
}

/* Universal overlay system with flexible content handling */
.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    padding: 2rem 0 3rem 0; /* Extra bottom padding for buttons */
    min-height: 100%;
    overflow: hidden; /* No scrolling */
}

/* Universal content wrapper with adaptive sizing */
.hero-content {
    position: relative;
    z-index: 3;
    width: 100%;
    padding: 0.5rem 0;
}

/* Ensure hero content doesn't overflow */
.hero-content h1,
.hero-content h2,
.hero-content .display-3,
.hero-content .display-4 {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.hero-content p.lead {
    max-width: 100%;
    word-wrap: break-word;
}

/* Button safety system - universal */
.hero-content .btn,
.hero-content a.btn {
    margin-bottom: 0.5rem;
    margin-right: 0.5rem;
}

/* SIZE CATEGORIES */

/* LARGE HEROES: Homepage Carousel, Capabilities, Industries */
.hero-large,
#heroCarousel .hero-section {
    min-height: 450px; /* Increased to handle more content */
    height: auto; /* Allow growth for content */
    max-height: 600px;
}

.hero-large .hero-overlay,
#heroCarousel .hero-overlay {
    padding: 2.5rem 0 3.5rem 0; /* Increased padding for content */
    display: flex;
    align-items: center;
    min-height: 450px;
}

.hero-large .hero-content,
#heroCarousel .hero-content {
    padding: 1.5rem 0;
    width: 100%;
}

/* Specific carousel adjustments */
#heroCarousel .carousel-item {
    min-height: 450px;
    height: auto;
}

#heroCarousel .hero-content h2.display-3 {
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1.2;
    margin-bottom: 1rem;
}

#heroCarousel .hero-content .h3 {
    font-size: clamp(1.2rem, 3vw, 2rem);
    display: block;
    margin-top: 0.5rem;
}

/* MEDIUM HEROES: Contact, About, Gallery, Terms, Privacy, Static Pages */
.hero-medium {
    min-height: 350px; /* Increased for better content handling */
    height: auto;
    max-height: 450px;
}

.hero-medium .hero-overlay {
    padding: 2rem 0 3rem 0; /* Standard padding */
    min-height: 350px;
}

.hero-medium .hero-content {
    padding: 1rem 0;
}

/* COMPACT HEROES: Utility pages if needed */
.hero-compact {
    min-height: 250px;
    max-height: 350px;
}

.hero-compact .hero-overlay {
    padding: 1.5rem 0 2.5rem 0;
}

.hero-compact .hero-content {
    padding: 0.25rem 0;
}

/* RESPONSIVE BEHAVIOR - Maintains size hierarchy */

/* Tablet (768px-991px) */
@media (max-width: 991px) and (min-width: 769px) {
    .hero-large,
    #heroCarousel .hero-section {
        min-height: 350px;
        max-height: 450px;
    }
    
    .hero-medium {
        min-height: 280px;
        max-height: 350px;
    }
    
    .hero-compact {
        min-height: 220px;
        max-height: 300px;
    }
    
    .hero-overlay {
        padding: 2rem 0 3rem 0;
    }
}

/* Mobile Portrait (≤768px) */
@media (max-width: 768px) {
    .hero-large,
    #heroCarousel .hero-section {
        min-height: 350px;
        max-height: 450px;
    }
    
    #heroCarousel .carousel-item {
        min-height: 350px;
    }
    
    .hero-medium {
        min-height: 250px;
        max-height: 320px;
    }
    
    .hero-compact {
        min-height: 200px;
        max-height: 280px;
    }
    
    .hero-overlay {
        padding: 1.5rem 0 2.5rem 0;
        display: block !important; /* Changed from flex to block for narrow screens */
        align-items: unset !important;
    }
    
    .hero-content {
        padding: 0.5rem 0;
        max-height: 100%;
        overflow: hidden;
    }
    
    /* Mobile carousel specific adjustments */
    #heroCarousel .hero-overlay {
        padding: 1.5rem 0 2.5rem 0; /* Balanced space for readable text */
        overflow: hidden !important;
    }
    
    #heroCarousel .hero-content h2.display-3 {
        font-size: clamp(1.6rem, 6vw, 2.2rem) !important;
        line-height: 1.1 !important;
        margin-bottom: 0.5rem !important;
    }
    
    #heroCarousel .hero-content .h3 {
        font-size: clamp(1.1rem, 4vw, 1.4rem) !important;
        margin-top: 0.25rem !important;
    }
    
    #heroCarousel .hero-content p.lead {
        font-size: clamp(0.9rem, 3vw, 1.1rem) !important;
        margin-bottom: 1rem !important;
        line-height: 1.2 !important;
    }
    
    /* Ensure images are visible on mobile with proper layering */
    .hero-section img,
    .hero-banner img,
    .carousel-image {
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        z-index: 0 !important;
    }
    
    /* Ensure overlay and content are above images */
    .hero-overlay {
        z-index: 2 !important;
        position: absolute !important;
        background: rgba(0, 0, 0, 0.3) !important; /* Lighter overlay for better visibility */
        min-height: 100% !important;
        overflow: hidden !important; /* No scrolling */
    }
    
    .hero-content {
        z-index: 3 !important;
        position: relative !important;
        display: block !important;
        visibility: visible !important;
    }
    
    /* Mobile text scaling - Balanced readable text that fits within original heights */
    .hero-content h1,
    .hero-content .display-4 {
        font-size: clamp(1.8rem, 5vw, 2.4rem) !important;
        line-height: 1.1;
        margin-bottom: 0.75rem;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.8) !important;
    }
    
    .hero-content h2 {
        font-size: clamp(1.4rem, 4vw, 1.9rem) !important;
        line-height: 1.1;
        margin-bottom: 0.5rem;
        text-shadow: 2px 2px 4px rgba(0,0,0,0.8) !important;
    }
    
    .hero-content p.lead,
    .hero-content .lead {
        font-size: clamp(1rem, 3vw, 1.2rem) !important;
        line-height: 1.3;
        margin-bottom: 1rem;
        text-shadow: 1px 1px 3px rgba(0,0,0,0.7) !important;
    }
    
    /* Mobile button behavior */
    .hero-content .btn-lg {
        font-size: 1rem;
        padding: 0.75rem 1.5rem;
        margin-bottom: 0.75rem;
        margin-right: 0.5rem;
        box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    }
    
    /* Stack buttons on very small screens */
    .hero-content .d-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    /* Ensure text is visible with strong contrast */
    .hero-content * {
        color: white !important;
    }
}

/* Small Mobile (≤576px) */
@media (max-width: 576px) {
    .hero-large,
    #heroCarousel .hero-section {
        min-height: 380px;
        max-height: 450px;
    }
    
    #heroCarousel .carousel-item {
        min-height: 380px;
    }
    
    .hero-medium {
        min-height: 220px;
        max-height: 280px;
    }
    
    .hero-compact {
        min-height: 180px;
        max-height: 240px;
    }
    
    /* Enhanced carousel spacing for small screens */
    #heroCarousel .hero-overlay {
        padding: 1.5rem 0 2.5rem 0 !important; /* Balanced spacing */
        overflow: hidden !important;
    }
    
    .hero-content h1,
    .hero-content .display-4 {
        font-size: clamp(1.6rem, 6vw, 2.1rem) !important;
    }
    
    .hero-content h2 {
        font-size: clamp(1.3rem, 5vw, 1.8rem) !important;
    }
    
    .hero-content p.lead,
    .hero-content .lead {
        font-size: clamp(1rem, 3.5vw, 1.2rem) !important;
    }
    
    .hero-content .btn {
        min-width: 180px;
        width: auto;
    }
}

/* Very Narrow Screens - Ensure text visibility */
@media (max-width: 480px) {
    .hero-overlay {
        display: block !important;
        position: absolute !important;
        padding: 1rem 0 2rem 0 !important;
        overflow: hidden !important;
    }
    
    #heroCarousel .hero-overlay {
        padding: 1rem 0 2rem 0 !important;
        overflow: hidden !important;
    }
    
    .hero-content {
        position: static !important;
        display: block !important;
        padding: 1rem 0 !important;
    }
    
    /* Ensure content is always visible */
    .hero-content .container {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
}

/* Landscape Mobile & Short Screens */
@media (max-width: 768px) and (max-height: 500px),
       (max-height: 450px) {
    
    .hero-large,
    #heroCarousel .hero-section {
        min-height: 250px;
        max-height: 90vh;
    }
    
    .hero-medium {
        min-height: 200px;
        max-height: 85vh;
    }
    
    .hero-compact {
        min-height: 160px;
        max-height: 80vh;
    }
    
    .hero-overlay {
        padding: 1rem 0 1.5rem 0;
        overflow: hidden; /* No scrolling */
        display: block !important;
    }
    
    .hero-content h1,
    .hero-content .display-4 {
        font-size: clamp(1.3rem, 4vw, 1.8rem) !important;
        margin-bottom: 0.5rem;
    }
    
    .hero-content p.lead,
    .hero-content .lead {
        font-size: clamp(0.85rem, 2vw, 1rem) !important;
        margin-bottom: 1rem;
    }
    
    .hero-content .btn {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }
}

/* Very Tall Screens - Prevent excessive height */
@media (min-height: 900px) {
    .hero-large,
    #heroCarousel .hero-section {
        max-height: 600px;
    }
    
    .hero-medium {
        max-height: 500px;
    }
    
    .hero-compact {
        max-height: 400px;
    }
}

/* Breadcrumb styling for all hero sizes */
.hero-content .breadcrumb,
.hero-banner .breadcrumb,
.hero-section .breadcrumb {
    background-color: transparent !important;
    background: none !important;
    padding: 0 !important;
    margin-bottom: 1rem !important;
    font-size: 0.9rem;
    border-radius: 0 !important;
}

.hero-content .breadcrumb-item + .breadcrumb-item::before,
.hero-banner .breadcrumb-item + .breadcrumb-item::before,
.hero-section .breadcrumb-item + .breadcrumb-item::before {
    color: rgba(255, 255, 255, 0.7);
}

.hero-content .breadcrumb a,
.hero-banner .breadcrumb a,
.hero-section .breadcrumb a {
    text-decoration: none;
    opacity: 0.9;
    color: white !important;
}

.hero-content .breadcrumb a:hover,
.hero-banner .breadcrumb a:hover,
.hero-section .breadcrumb a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Red active breadcrumb for brand consistency across all heroes */
.hero-content .breadcrumb-item.active,
.hero-banner .breadcrumb-item.active,
.hero-section .breadcrumb-item.active {
    color: #dc3545 !important; /* Brand red for current page */
}

/* Breadcrumb dropdown styling - ensure dropdown text is visible */
.hero-content .dropdown-menu,
.hero-banner .dropdown-menu,
.hero-section .dropdown-menu {
    background-color: white !important;
    border: 1px solid rgba(0,0,0,0.15) !important;
    box-shadow: 0 6px 12px rgba(0,0,0,0.175) !important;
}

/* Override inherited white text color from .text-white container */
.hero-content .dropdown-menu .dropdown-item,
.hero-banner .dropdown-menu .dropdown-item,
.hero-section .dropdown-menu .dropdown-item,
.text-white .dropdown-menu .dropdown-item {
    color: #212529 !important; /* Dark text for readability */
    text-decoration: none !important;
}

.hero-content .dropdown-menu .dropdown-item:hover,
.hero-banner .dropdown-menu .dropdown-item:hover,
.hero-section .dropdown-menu .dropdown-item:hover,
.text-white .dropdown-menu .dropdown-item:hover {
    background-color: #f8f9fa !important;
    color: #16181b !important;
}

/* Universal button styling for all heroes - ensure proper colors */
.hero-content .btn-primary,
.hero-banner .btn-primary,
.hero-section .btn-primary {
    background-color: #007bff !important;
    border-color: #007bff !important;
    color: white !important;
}

.hero-content .btn-outline-light,
.hero-banner .btn-outline-light,
.hero-section .btn-outline-light {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: white !important;
    color: white !important;
}

.hero-content .btn-outline-light:hover,
.hero-banner .btn-outline-light:hover,
.hero-section .btn-outline-light:hover {
    background-color: white !important;
    color: #007bff !important;
}

.hero-content .btn-danger,
.hero-banner .btn-danger,
.hero-section .btn-danger {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: white !important;
}

@media (max-width: 768px) {
    .hero-content .breadcrumb {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }
}

/* Specific padding for first two carousel slides */
#heroCarousel .carousel-item:nth-child(1) .hero-overlay,
#heroCarousel .carousel-item:nth-child(2) .hero-overlay {
    padding-top: 3rem;
}

@media (max-width: 768px) {
    #heroCarousel .carousel-item:nth-child(1) .hero-overlay,
    #heroCarousel .carousel-item:nth-child(2) .hero-overlay {
        padding-top: 2.5rem;
    }
}

@media (max-width: 576px) {
    #heroCarousel .carousel-item:nth-child(1) .hero-overlay,
    #heroCarousel .carousel-item:nth-child(2) .hero-overlay {
        padding-top: 2rem;
    }
}

/* Carousel-specific controls positioning */
.carousel-controls-container {
    position: relative;
    z-index: 10;
    margin-top: -60px;
    pointer-events: none;
}

.carousel-controls-wrapper {
    pointer-events: auto;
}

@media (max-width: 576px) {
    .carousel-controls-container {
        margin-top: -50px;
    }
}

/* Animation for hero content */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-content {
    animation: fadeInUp 0.8s ease-out;
}