/**
 * Mega Menu CSS Fixes
 * Ensures mega menu works properly in responsive developer mode
 * and across all devices
 */

/* ============================================
   BASE MEGA MENU STYLES
   ============================================ */

.ga-mega-menu-container {
    position: relative;
    z-index: 9999 !important;
}

.ga-mega-menu {
    position: fixed !important;
    left: 0;
    right: 0;
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 9998 !important;
    max-height: 80vh;
    overflow-y: auto;
    transform: translateY(-10px);
}

/* Active/visible state */
.ga-mega-menu.active {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

/* Inner container */
.ga-mega-menu-inner {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
}

/* Close button */
.ga-mega-menu-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 10;
    transition: all 0.3s ease;
}

.ga-mega-menu-close:hover {
    transform: rotate(90deg);
    opacity: 0.7;
}

/* ============================================
   MENU TRIGGER STYLING
   ============================================ */

/* Make menu items clickable in responsive mode */
.ga-secondary-menu li {
    position: relative;
    cursor: pointer;
}

/* Visual indicator for dropdown items */
.ga-secondary-menu li:has(.ga-mega-menu-trigger)::after,
.ga-secondary-menu li a[href="#"]::after,
.ga-secondary-menu li a[href*="bulls"]::after,
.ga-secondary-menu li a[href*="shop"]::after,
.ga-secondary-menu li a[href*="special"]::after {
    content: "▼";
    font-size: 10px;
    margin-left: 5px;
    display: inline-block;
    transition: transform 0.3s ease;
}

/* Rotate arrow when menu is open */
.ga-secondary-menu li.menu-open::after {
    transform: rotate(180deg);
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Tablet and mobile (up to 1024px) */
@media (max-width: 1024px) {
    .ga-mega-menu {
        position: absolute !important;
        top: 100% !important;
        width: 100%;
        max-height: 70vh;
    }
    
    .ga-mega-menu-inner {
        padding: 20px;
    }
    
    /* Stack menu columns on smaller screens */
    .ga-mega-menu-content {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    
    /* Make touch targets larger */
    .ga-secondary-menu li a {
        padding: 12px 15px;
        display: block;
    }
    
    /* Prevent accidental link navigation on touch */
    .ga-secondary-menu li a[href="#"] {
        pointer-events: none;
    }
    
    .ga-secondary-menu li {
        pointer-events: auto;
    }
}

/* Mobile (up to 768px) */
@media (max-width: 768px) {
    .ga-mega-menu {
        position: fixed !important;
        top: 0 !important;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .ga-mega-menu-inner {
        padding: 60px 15px 30px;
        min-height: 100vh;
    }
    
    .ga-mega-menu-close {
        position: fixed;
        top: 15px;
        right: 15px;
        background: #fff;
        border: 1px solid #ddd;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Full width menu items on mobile */
    .ga-mega-menu-list {
        padding: 0;
    }
    
    .ga-mega-menu-list li {
        border-bottom: 1px solid #eee;
    }
    
    .ga-mega-menu-list a {
        display: block;
        padding: 15px 10px;
        color: #333;
        text-decoration: none;
    }
    
    .ga-mega-menu-list a:hover {
        background: #f5f5f5;
    }
}

/* ============================================
   SERVICES MEGA MENU SPECIFIC
   ============================================ */

.ga-services-menu-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.ga-service-card {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ga-service-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* ============================================
   SHOP MEGA MENU SPECIFIC
   ============================================ */

.ga-shop-menu-content {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
    justify-content: center;
}

.ga-shop-section {
    flex: 1;
    min-width: 250px;
}

.ga-shop-section-centered {
    max-width: 1000px;
    margin: 0 auto;
}

.ga-shop-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

.ga-shop-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
    margin-top: 15px;
}

.ga-shop-header {
    text-align: center;
    margin-bottom: 20px;
}

.ga-shop-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ga-shop-list li {
    margin-bottom: 10px;
}

.ga-shop-subheading a {
    font-weight: 500;
    color: #003c71;
    text-decoration: none;
    transition: color 0.3s ease;
}

.ga-shop-subheading a:hover {
    color: #0d2847;
    text-decoration: underline;
}

@media (max-width: 1024px) {
    .ga-shop-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .ga-shop-columns {
        grid-template-columns: 1fr;
    }

    .ga-shop-grid-4 {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/* ============================================
   SHOP CASCADING DROPDOWN
   --------------------------------------------
   The Shop menu is no longer a full-width strip — it's a compact dropdown
   anchored under the "Shop" secondary-nav link. We piggyback on the existing
   .ga-mega-menu open/close JS but override width/positioning so it renders
   as a normal 220px dropdown. mega-menu.js sets `left` to the Shop link's
   offsetLeft (see updateMenuPosition()).
   ============================================ */

#ga-shop-mega-menu.ga-shop-cascade-menu {
    width: 240px;
    /* left is set inline by JS in updateMenuPosition() */
    right: auto;             /* base rule has right:0 which fights width:240 */
    background: transparent;
    box-shadow: none;
    max-height: none;        /* base rule caps at 80vh — kills our flyout */
    overflow: visible;       /* base rule has overflow-y:auto which implicitly
                                makes overflow-x:auto too (CSS spec), clipping
                                the right-opening flyout and adding scrollbars */
}

#ga-shop-mega-menu.ga-shop-cascade-menu .ga-mega-menu-inner {
    max-width: none;
    margin: 0;
    padding: 0;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: visible;
}

/* Suppress the page-dim ::before overlay attached to every .ga-mega-menu.
   It assumes a 100vw strip — but because .ga-mega-menu has a transform set,
   its fixed-positioned ::before is sized relative to the dropdown (240px),
   producing a grey column running down the page under the dropdown. */
#ga-shop-mega-menu.ga-shop-cascade-menu::before {
    display: none;
}

/* Hide the close (X) — a compact dropdown closes on mouse-out, no button needed */
#ga-shop-mega-menu.ga-shop-cascade-menu .ga-mega-menu-close {
    display: none;
}

/* Top-level list */
.ga-shop-cascade {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}

.ga-shop-cascade-item {
    position: relative; /* anchor for the flyout */
}

.ga-shop-cascade-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    color: #003c71;
    font-weight: 500;
    font-size: 15px;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.ga-shop-cascade-link:hover,
.ga-shop-cascade-item:hover > .ga-shop-cascade-link {
    background: #f5f7fa;
    color: #00a77e;
    text-decoration: none;
}

#ga-shop-mega-menu .ga-shop-cascade-link:focus,
#ga-shop-mega-menu .ga-shop-cascade-link:focus-visible,
#ga-shop-mega-menu .ga-shop-flyout a:focus,
#ga-shop-mega-menu .ga-shop-flyout a:focus-visible {
    outline: none;
    box-shadow: none;
}

/* Suppress browser default focus outline on secondary-nav top-level links
   (Shop / Special Offers / etc.) to match the rest of the header chrome */
.ga-secondary-menu a:focus,
.ga-secondary-menu a:focus-visible,
.ga-secondary-menu li:focus,
.ga-secondary-menu li:focus-visible {
    outline: none;
    box-shadow: none;
}

.ga-shop-cascade-arrow {
    flex-shrink: 0;
    color: #6b7280;
    transition: color 0.2s ease, transform 0.2s ease;
}

.ga-shop-cascade-item:hover .ga-shop-cascade-arrow {
    color: #00a77e;
    transform: translateX(2px);
}

/* Flyout sub-menu */
.ga-shop-flyout {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    position: absolute;
    top: -8px; /* align with parent ul's top padding */
    left: 100%;
    min-width: 220px;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.ga-shop-cascade-item:hover > .ga-shop-flyout,
.ga-shop-cascade-item:focus-within > .ga-shop-flyout {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
}

.ga-shop-flyout li {
    margin: 0;
}

.ga-shop-flyout a {
    display: block;
    padding: 10px 18px;
    color: #003c71;
    font-size: 14px;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.ga-shop-flyout a:hover {
    background: #f5f7fa;
    color: #00a77e;
    text-decoration: none;
}

/* Narrow desktops / tablets: flip the flyout to open leftward.
   The parent Shop dropdown is anchored near the right of the nav (JS sets
   left to Shop's offsetLeft), so on viewports below ~1280px a right-opening
   flyout clips the page edge — text like "Injection and Drench" or
   "Liquid Nitrogen Tank" gets cut off. Opening leftward always has room
   because the cascade itself sits well inside the viewport. */
@media (max-width: 1280px) {
    .ga-shop-flyout {
        left: auto;
        right: 100%;
        transform: translateX(8px); /* reverse the entry-animation offset */
    }

    .ga-shop-cascade-item:hover > .ga-shop-flyout,
    .ga-shop-cascade-item:focus-within > .ga-shop-flyout {
        transform: translateX(0);
    }
}

@media (max-width: 1024px) {
    #ga-shop-mega-menu.ga-shop-cascade-menu {
        width: 220px;
    }

    .ga-shop-flyout {
        min-width: 200px;
    }
}

/* Mobile: base .ga-mega-menu rule at <=992px already sets display:none, so
   the dropdown is hidden on mobile — the WP menu's "Shop" link remains as a
   plain top-level link. No mobile-specific cascade styles needed. */

/* ============================================
   SPECIALS MEGA MENU SPECIFIC
   ============================================ */

.ga-specials-menu-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.ga-catalogue-card {
    text-align: center;
    transition: all 0.3s ease;
}

.ga-catalogue-card:hover {
    transform: translateY(-5px);
}

.ga-catalogue-image img {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Promotion-driven mega menu cards: image + product title + customer
   message + CTA. Sits in the same auto-fit grid as the legacy SOM/static
   cards so promo cards line up alongside Member Specials + Newsletter. */
.ga-promo-card {
    display: flex;
    flex-direction: column;
}

/* Constrain promo product image to 185px tall so cards align with the
   Member Specials proportions, regardless of the source image dimensions.
   Scoped to .ga-promo-card so the Member Specials card itself isn't
   affected by the height constraint. */
.ga-promo-card .ga-catalogue-image {
    margin-bottom: 10px;
    height: 185px;
    overflow: hidden;
    border-radius: 4px;
}

.ga-promo-card .ga-catalogue-image a {
    display: block;
    width: 100%;
    height: 100%;
}

.ga-promo-card .ga-catalogue-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0; /* parent already rounded */
}

.ga-promo-card-title {
    margin: 0 0 8px;
    padding: 0 6px;
    font-size: 15px;
    line-height: 1.3;
    font-weight: 700;
    color: #003c71;
    text-align: center;
}

.ga-promo-message {
    margin: 0 0 12px;
    padding: 0 6px;
    font-size: 13px;
    line-height: 1.4;
    color: #333;
    text-align: center;
    flex-grow: 1;
}

/* Slideshow crossfade — image swap is instant in the DOM, the opacity
   transition gives a 300ms fade-out/in either side. */
.ga-promo-card .ga-promo-slide-image,
.ga-promo-card-title {
    transition: opacity 0.3s ease;
}

.ga-promo-card .ga-promo-slide-image.is-fading,
.ga-promo-card-title.is-fading {
    opacity: 0;
}

/* ============================================
   DEVELOPER TOOLS SPECIFIC FIXES
   ============================================ */

/* When in responsive mode, ensure proper display */
@media screen and (max-width: 99999px) {
    .ga-mega-menu {
        will-change: transform, opacity;
    }
    
    /* Force GPU acceleration for smoother animations */
    .ga-mega-menu.active {
        transform: translateZ(0) translateY(0);
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus styles */
.ga-mega-menu a:focus,
.ga-mega-menu button:focus,
.ga-secondary-menu li:focus-within {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* Screen reader only text */
.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;
}

/* ============================================
   ANIMATION ENHANCEMENTS
   ============================================ */

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.ga-mega-menu.active {
    animation: slideDown 0.3s ease forwards;
}

.ga-mega-menu:not(.active) {
    animation: slideUp 0.3s ease forwards;
}

/* ============================================
   Z-INDEX MANAGEMENT
   ============================================ */

/* Ensure proper stacking order */
.ga-header {
    position: relative;
    z-index: 1000;
}

.ga-secondary-nav-container {
    position: relative;
    z-index: 201;
}

.ga-mega-menu-container {
    position: relative;
    z-index: 9999;
}

.ga-mega-menu {
    z-index: 9998;
}

/* Overlay for mobile */
@media (max-width: 768px) {
    body.mega-menu-open::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9997;
    }
}

/* ============================================
   BULLS MEGA MENU — SIRE SEARCH CTA COLUMN
   Layout only; button uses standard .ga-section-btn .ga-view-all-btn
   ============================================ */
.ga-mega-menu-column--cta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
}
.ga-mega-menu-column--cta .ga-mega-menu-cta-text {
    font-size: 15px;
    line-height: 1.5;
    color: #444;
    margin: 0;
}
.ga-mega-menu-column--cta .ga-mega-menu-cta-image,
.ga-mega-menu-cta-image {
    display: block;
    width: 100%;
    height: auto;
    max-width: 320px !important;
    margin-top: 20px !important;
    border-radius: 6px;
    object-fit: cover;
}