/* =========================================
   1. CONFIGURATION & VARIABLES
   ========================================= */
:root {
    --brand-blue: #002147;   /* Deep Navy */
    --brand-yellow: #ffc107; /* Construction Warning Yellow */
    --text-dark: #212529;
    --text-grey: #6c757d;
    --font-primary: 'Inter', sans-serif;
}

/* =========================================
   2. GLOBAL LAYOUT & RESET
   ========================================= */

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    /* This prevents the side-scroll without killing content */
    overflow-x: hidden; 
}

body {
    font-family: var(--font-primary);
    color: var(--text-dark);
    line-height: 1.7;
    background-color: #fff;
    /* We remove display: flex to prevent content collapse */
}

/* 2. THE CONTENT WRAPPER */
main {
    display: block;
    width: 100%;
    min-height: 60vh; /* Ensures page has substance even if empty */
    position: relative;
}

/* 3. THE FIX FOR BOOTSTRAP ROWS */
/* This is likely what was causing your side-scroll */
.row {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

.container, .container-fluid {
    padding-right: 15px !important;
    padding-left: 15px !important;
    overflow: hidden; /* Clips animations at the container edge */
}

/* =========================================
   3. BRAND UTILITIES
   ========================================= */
.bg-brand-blue { background-color: var(--brand-blue) !important; color: white; }
.text-brand-blue { color: var(--brand-blue) !important; }
.text-brand-yellow { color: var(--brand-yellow) !important; }

/* Top Bar (Phone/Email Strip) */
.top-bar {
    font-size: 0.9rem;
    background-color: #0b1118;
}

/* =========================================
   4. HERO CAROUSEL & OVERLAYS
   ========================================= */
.carousel-item {
    height: 85vh;        /* Desktop height */
    min-height: 600px;   /* Prevents shrinking on mobile */
    background-color: #000;
    position: relative;
}

.carousel-item img {
    height: 100%;
    width: 100%;
    object-fit: cover;
    object-position: center;
}

/* The "Pro" Gradient Overlay: Darker on Left for text readability */
.carousel-item::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 50%, rgba(0,0,0,0.1) 100%);
    z-index: 1;
}

/* Caption Styling */
.carousel-caption {
    bottom: 30%; /* Vertically centered visual sweet spot */
    z-index: 2;  /* Sits above the overlay */
}

.carousel-caption h1, 
.carousel-caption h5, 
.carousel-caption p {
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

/* Hero Buttons - Crisp Text */
.carousel-caption .btn {
    text-shadow: none !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* =========================================
   5. UI COMPONENTS (Cards, Buttons, Dividers)
   ========================================= */

/* Service Cards with Hover Lift */
.service-card {
    transition: all 0.3s ease;
    border-bottom: 4px solid transparent;
}

.service-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 1rem 3rem rgba(0,0,0,.175) !important;
    border-bottom: 4px solid var(--brand-yellow);
}

/* Section Divider Line */
.divider {
    width: 60px;
    height: 4px;
    background-color: var(--brand-yellow);
    margin: 1.5rem 0;
}

/* Primary Call-to-Action Buttons */
.btn-warning {
    background-color: var(--brand-yellow);
    border: none;
    color: #000;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 30px;
    transition: transform 0.2s ease, background-color 0.2s;
}

.btn-warning:hover {
    background-color: #e0a800;
    transform: scale(1.05);
}

/* =========================================
   6. VISUAL EFFECTS (Parallax)
   ========================================= */
.parallax-hero {
    background-attachment: fixed !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: cover !important;
}

/* Disable Parallax on Mobile for Performance */
@media (max-width: 768px) {
    .parallax-hero {
        background-attachment: scroll !important;
    }
}

/* MOBILE HERO TEXT OPTIMIZATION */
@media (max-width: 768px) {
    .carousel-caption {
        bottom: 15%; /* Pulls text down slightly on mobile */
        left: 5%;
        right: 5%;
    }
    
    .carousel-caption h1 {
        font-size: 1.8rem !important; /* Shrinks the massive 5rem headline */
        line-height: 1.2;
    }

    .carousel-caption h5 {
        font-size: 0.9rem !important;
        letter-spacing: 1px;
    }

    .carousel-caption .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

/* =========================================
   7. FINAL OVERFLOW PATCH (Fixes Side Scroll)
   ========================================= */

/* 1. Prevent html/body from expanding horizontally */
html, body {
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

/* 2. Target your <main> wrapper to clip the animation tails */
main {
    overflow-x: hidden;
    width: 100%;
    display: block; /* Ensures it behaves as a block container */
}

/* 3. Neutralize Bootstrap's negative margin leak */
.row {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

/* 4. Disable pointer events for hidden AOS elements 
      (Prevents ghost elements from blocking clicks) */
[data-aos] {
    pointer-events: none;
}
.aos-animate {
    pointer-events: auto;
}

/* --- MODAL LIST ALIGNMENT --- */
.modal-body ul.list-unstyled li {
    display: flex;         /* Creates two columns */
    align-items: flex-start; /* Keeps the icon at the top of the first line */
    margin-bottom: 0.75rem;
}

.modal-body ul.list-unstyled li i {
    flex-shrink: 0;        /* Prevents the icon from getting squashed */
    width: 25px;           /* Sets a fixed "column" width for the icon */
    margin-top: 5px;       /* Fine-tunes the icon's vertical position with the first line */
}

.modal-body img {
    width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: cover;
    border-radius: 4px;
}

/* FORCE PROJECT MODAL LIST ALIGNMENT */
.modal-body li, 
#projects li {
    display: grid !important;
    grid-template-columns: 30px 1fr !important; /* Fixed icon col, flexible text col */
    align-items: start !important;
    margin-bottom: 10px !important;
}

.modal-body li i, 
#projects li i {
    grid-column: 1 !important;
    margin-top: 4px !important; /* Aligns icon with first line of text */
}

.modal-body li span, 
.modal-body li div {
    grid-column: 2 !important;
}

/* Ensure dropdown is visible and not clipped */
.navbar {
    z-index: 1050 !important;
}

.dropdown-menu {
    z-index: 9999 !important;
    /* This prevents the menu from being cut off by containers below it */
    position: absolute !important; 
}

/* Allow the dropdown to overflow out of the main wrapper */
main {
    overflow: visible !important;
}

/* DESKTOP HOVER DROPDOWN */
@media (min-width: 1200px) {
    .nav-item.dropdown:hover .dropdown-menu {
        display: block !important;
        margin-top: 0; /* Prevents a gap that closes the menu */
        opacity: 1;
        visibility: visible;
    }
}

/* Force the Navbar to the absolute top of the stack */
.navbar, .sticky-top {
    position: sticky !important;
    top: 0;
    z-index: 9999 !important;
}

/* Ensure the dropdown menu is not being hidden by the 'main' overflow */
.navbar-collapse {
    overflow: visible !important;
}

.dropdown-menu {
    position: absolute !important;
    z-index: 10000 !important;
}

/* FORCE NAVBAR ABOVE HERO */
.navbar, 
.sticky-top {
    z-index: 10000 !important; /* Extremely high to beat the Hero */
    background-color: #fff !important; /* Ensures the menu is opaque */
}

/* Ensure the Dropdown specifically stays on top of the Carousel */
.dropdown-menu {
    z-index: 10001 !important;
    position: absolute !important;
}

/* THE CULPRIT: Sometimes the Carousel-Fade or AOS creates a 
   new stacking context. This forces the Hero to stay in the back.
*/
#heroCarousel {
    z-index: 1 !important;
    position: relative;
}

/* Ensure the 'main' tag doesn't trap the menu */
main {
    z-index: 5;
    position: relative;
    overflow: visible !important;
}

/* 1. Force Navbar to be the top-most layer on the entire site */
.navbar, .sticky-top {
    z-index: 9999 !important;
    position: sticky !important;
    top: 0;
    /* Ensure no parent containers are clipping this */
    overflow: visible !important;
}

/* 2. Fix the "Behind the Hero" issue */
/* This forces the Hero Carousel to a lower stacking layer */
#heroCarousel, .carousel {
    z-index: 1 !important;
    position: relative;
    /* This removes the 'magic' layer that often blocks dropdowns */
    transform: none !important; 
}

/* 3. Ensure the Dropdown Menu itself is even higher than the Navbar */
.dropdown-menu {
    z-index: 10000 !important;
    display: none; /* Bootstrap will handle showing it */
}

/* 4. The "Safety Mask" - Ensure <main> doesn't cut off the menu */
main {
    z-index: 5 !important;
    position: relative;
    overflow: visible !important; /* CRITICAL: Allows the menu to hang over the edge */
}

/* 5. Force visibility on hover as a fallback if JS is being stubborn */
@media (min-width: 1200px) {
    /* 1. Show the menu on hover */
    .nav-item.dropdown:hover > .dropdown-menu {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        margin-top: 0; 
    }

    /* 2. THE FIX: Hide any dropdown that was "clicked" open when we move to a different item */
    .navbar-nav:hover .dropdown-menu:not(:hover) {
        display: none !important;
    }
}

/* 1. REMOVE THE GUILLOTINE: Allow the menu to spill out of its containers */
.navbar .container, 
.navbar-collapse, 
main {
    overflow: visible !important;
}

/* 2. RE-ESTABLISH THE STACK: Force the Navbar to be the "King" of the page */
.navbar, 
.sticky-top {
    position: sticky !important;
    top: 0;
    z-index: 99999 !important; /* Maximum priority */
}

/* 3. POSITION THE MENU: Ensure it's not relative to a clipped box */
.dropdown-menu {
    position: absolute !important;
    z-index: 100000 !important;
    top: 100%; /* Forces it to start exactly at the bottom of the nav */
    left: 0;
}

/* 4. PUSH THE HERO DOWN THE STACK */
#heroCarousel, 
.carousel-fade, 
.carousel-item {
    z-index: 1 !important;
    /* Remove any transforms that create "magic" layers */
    transform: none !important; 
    perspective: none !important;
}

/* 5. FALLBACK: Force display on hover for Desktop */
@media (min-width: 1200px) {
    li.nav-item.dropdown:hover > .dropdown-menu {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* =========================================
   FIX: MODAL CLICKABILITY & Z-INDEX
   ========================================= */

/* 1. Ensure the Modal Window is the highest element on the page */
.modal {
    z-index: 1060 !important; 
}

/* 2. Ensure the Backdrop is behind the modal but above the Nav/Hero */
.modal-backdrop {
    z-index: 1050 !important;
}

/* 3. When modal is open, temporarily "demote" the navbar so it doesn't block clicks */
body.modal-open .navbar, 
body.modal-open .sticky-top {
    z-index: 1000 !important;
}

/* 4. Allow the modal to be clickable even if 'main' has weird overflow */
.modal-open {
    overflow: hidden;
}

main {
    display: block;
    width: 100%;
    /* Remove z-index and position: relative from here */
    /* This allows modals inside to 'escape' to the top layer */
}

/* =========================================
   GALLERY STYLES (Optimized for Mixed Sizes)
   ========================================= */

.gallery-wrapper {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3; /* Your preferred ratio */
    background-color: var(--brand-blue); /* Professional placeholder while loading */
    border-radius: 8px; /* Smooths out the construction "grit" */
}

.gallery-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensures 700px and 1900px images fill the same box */
    transition: transform 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.gallery-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 33, 71, 0.75); /* Brand Blue with slight darkening */
    color: var(--brand-yellow); /* Yellow icon for high contrast */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: 0.3s ease;
    font-size: 2.5rem;
    pointer-events: none; /* Allows the click to pass through to the <a> tag */
}

.gallery-wrapper:hover img { 
    transform: scale(1.1); /* Slightly more zoom for high-res impact */
}

.gallery-wrapper:hover .gallery-overlay { 
    opacity: 1; 
}

/* GLightbox Spinner - Matches Brand Yellow */
.gloader {
    border-top: 4px solid var(--brand-yellow) !important;
    border-right: 4px solid rgba(255, 255, 255, 0.2) !important;
    border-bottom: 4px solid rgba(255, 255, 255, 0.2) !important;
    border-left: 4px solid rgba(255, 255, 255, 0.2) !important;
}

.btn-brand-blue {
    background-color: var(--brand-blue);
    border: 2px solid var(--brand-blue);
    transition: all 0.3s ease;
}

.btn-brand-blue:hover {
    background-color: transparent;
    color: var(--brand-blue) !important;
    transform: translateY(-3px);
}

@media (min-width: 1200px) and (max-width: 1400px) {
    .navbar-nav .nav-link {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        font-size: 0.95rem; /* Slights shrinks text only on tight desktops */
    }
}

.card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1) !important;
}