/**
 * Site header + primary mega menu — phase 2: basic desktop CSS.
 *
 * Values extracted from the live site (supermacs.ie, legacy UberMenu):
 *   brand red   #E11400   (rgb 225,20,0)
 *   nav text    #636262   top level / #777 submenu strip
 *   font        "Open Sans", Arial, Helvetica, sans-serif
 *   header bar  fixed, centered, 1000px, radius 0 0 5px 5px,
 *               shadow 0 1px 5px #c5c5c5, logo 150x53 (padding 10px 20px)
 *   top links   16px, padding 23px 16px; current item gets a red "|" marker
 *   CTA         red block hanging below the bar, radius 0 0 8px 8px
 *   cards panel full bar width, white, bottom radius 10px, 3-up cards
 *   list strip  full bar width, light grey, single horizontal row
 *
 * Open/close animations are intentionally absent (final phase). The mobile
 * pattern ("Marble-style" menu) is pending design feedback — placeholder only.
 */

/* ---------------------------------------------------------------- header */

#header {
    /* No flow space reserved: on live the legacy rule
       `#megaMenu-sticky-wrapper { margin-top: -40px !important }` cancels the
       wrapper's own height, so ALL page content (heroes included) starts at
       y=0 underneath the fixed bar. Pages provide their own top padding. */
    height: 0;
    background: transparent;
}

.site-header {
    position: fixed;
    top: 0;
    /* Left-anchored centering (not translateX) so the minimize animation
       shrinks the bar towards the left edge, as on live. */
    left: calc(50% - 500px);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    width: 1000px;
    max-width: 100%;
    background: #fff;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 1px 5px 0 #c5c5c5;
    font-family: "Open Sans", Arial, Helvetica, sans-serif;
    /* NO overflow:hidden here — the submenu panels hang below the bar and
       would be clipped. The nav is hidden instantly on minimize, so nothing
       overflows during the width animation. */
    transition: width 300ms ease;
}

/* Minimized state (scrolled down, pointer outside the bar) — logo only.
   Driven by js/header-menu.js; live shrinks the bar to 200px.
   Two classes make the expansion smooth: '--minimized' animates the width,
   '--nav-hidden' fades the nav. On expand the JS removes '--minimized'
   first and only reveals the nav once the bar is back at full width, so the
   items fade in instead of popping/pushing while the width animates. */
.site-header--minimized {
    width: 200px;
}

.site-header__nav {
    opacity: 1;
    transition: opacity 200ms ease;
}

.site-header--nav-hidden .site-header__nav {
    opacity: 0;
    visibility: hidden;
    transition: opacity 150ms ease, visibility 0s linear 150ms;
}

body.admin-bar .site-header {
    top: 32px;
}

.site-header__logo {
    display: block;
    flex: 0 0 auto;
    padding: 10px 20px;
    line-height: 0;
}

.site-header__logo img {
    width: 150px;
    height: 53px;
}

/* Mobile toggle — hidden on desktop, behaviour arrives with the mobile phase. */
.site-header__toggle {
    display: none;
    background: none;
    border: 0;
    padding: 24px 20px;
    cursor: pointer;
}

.site-header__toggle-bar {
    display: block;
    width: 24px;
    height: 3px;
    margin: 4px 0;
    background: #e11400;
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Accordion toggle buttons (injected by JS) are a mobile-only control. */
.submenu-toggle {
    display: none;
}

/* ------------------------------------------------------------- top level */

.site-header__nav {
    flex: 1 1 auto;
}

.main-menu {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    margin: 0;
    padding: 0;
    list-style: none;
}

.main-menu li {
    list-style: none;
    margin: 0;
}

.main-menu > li > a {
    display: block;
    padding: 23px 16px;
    color: #636262;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
    transition: color 150ms ease;
}

.main-menu > li > a:hover,
.main-menu > li:hover > a {
    color: #e11400;
}

/* Current item — red, regular weight; bold "|" marker tight against the
   label. Absolutely positioned so it floats over the link's left padding and
   never shifts the other menu items when the active page changes. */
.main-menu > li.current-menu-item > a,
.main-menu > li.current-menu-ancestor > a {
    position: relative;
    color: #e11400;
}

.main-menu > li.current-menu-item > a::before,
.main-menu > li.current-menu-ancestor > a::before {
    content: "|";
    position: absolute;
    left: 7px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
}

/* ORDER ONLINE call-to-action — red block flush with the bar top, inset
   11px from the right edge and ending 8px above the bar bottom (live specs:
   label 140x65 at y=0 inside the 73px bar).
   The #header prefix + !important out-specify a legacy UberMenu-era rule in
   the compiled style.css (`#menu-item-4768 a { width:140px !important; ... }`).
   TODO: delete that rule from assets/styles/style.scss on the next Grunt build. */
#header .main-menu > li.menu-item--cta > a {
    padding: 0 11px 0 12px !important;
    width: auto !important;
    height: auto !important;
    top: auto !important;
}

.main-menu > li.menu-item--cta .menu-item__label {
    display: block;
    padding: 22px 12px 18px;
    background: #e11400;
    border-radius: 0 0 8px 8px;
    color: #fff;
    font-family: "Roboto Condensed", Arial, Helvetica, sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
    transition: background-color 150ms ease;
}

.main-menu > li.menu-item--cta:hover .menu-item__label {
    background: #c31100;
}

/* -------------------------------------------------------------- submenus */

.main-menu > li {
    position: static; /* both panel variants span the full bar width */
}

/*
 * Panel open/close animation — replicates the live UberMenu settings
 * (transition "slide", speed 300ms): the panel slides open top-down in 300ms
 * via max-height + overflow hidden.
 *
 * The choreography (400ms forgiving close after the pointer leaves, and
 * "close the previous panel BEFORE opening the next" when switching between
 * items) is driven by js/header-menu.js through the `is-open` class on the
 * top-level li. :focus-within keeps keyboard access working without JS.
 */
.main-menu .sub-menu {
    display: flex;
    visibility: hidden;
    overflow: hidden;
    max-height: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1010;
    margin: 0;
    padding: 0;
    list-style: none;
    background: #f4f4f4; /* grey panel surface, as on live */
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.15);
    border-radius: 2px 2px 10px 10px;
    transition: max-height 300ms ease, visibility 0s linear 300ms;
}

.main-menu > li.is-open > .sub-menu,
.main-menu > li:focus-within > .sub-menu {
    visibility: visible;
    max-height: 420px; /* > tallest panel (cards ~260px); clamps the slide */
    transition: max-height 300ms ease, visibility 0s;
}

/* Variant 1: image-card panel (About Us / Careers / Corporate).
   Fluid by design: cards share the row equally whatever their count. */
/* Live spacing: 16px grey at the panel edges, 32px between cards,
   10px above the images, 15px below (5px card margin + 10px ul padding).
   (.main-menu prefix needed to out-specify the base .main-menu .sub-menu rule.) */
.main-menu .sub-menu--cards {
    flex-wrap: wrap;
    padding: 10px 16px 15px;
    gap: 0 32px;
}

.sub-menu--cards > li {
    flex: 1 1 0;
    min-width: 180px;
    max-width: 340px;
    margin: 5px 0;
}

.sub-menu--cards > li > a {
    display: block;
    text-decoration: none;
}

.menu-item__image {
    display: block;
    line-height: 0;
}

.menu-item__image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Real-text caption replacing the text formerly baked into the images. */
.sub-menu--cards .menu-item__label {
    display: block;
    padding: 9px 10px;
    background: #e11400;
    border-radius: 0 0 6px 6px; /* rounded bottom corners, as in the live artwork */
    color: #fff;
    font-family: "Roboto Condensed", Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.02em;
    transition: background-color 150ms ease;
}

.sub-menu--cards > li > a:hover .menu-item__label {
    background: #c31100;
}

/* Variant 2: horizontal text strip (Store Locator), as on live. */
.main-menu .sub-menu--list {
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
}

.sub-menu--list > li {
    flex: 0 1 auto;
    margin: 5px 0;
}

.sub-menu--list a {
    display: block;
    padding: 5px 8px;
    color: #777;
    font-size: 12px;
    font-weight: 400;
    text-decoration: none;
    white-space: nowrap;
    transition: color 150ms ease;
}

.sub-menu--list a:hover {
    color: #e11400;
}

/* ------------------------------------------------- mobile (PARKED/DISABLED)
   Marble-inspired full-screen menu: compact white bar (logo + hamburger),
   tap opens a full-screen white overlay with big Roboto Condensed links
   that stagger in, accordion submenus and the ORDER ONLINE CTA as a red
   block.

   PARKED until the design is approved: the media query below is impossible
   on purpose (0px), so none of these rules ever apply. To re-enable, change
   it back to (max-width: 1023px) — and remove the "legacy live mobile"
   block at the end of this file. CSS comments do not nest, so this is safer
   than commenting the block out. The matching markup/JS are commented out
   in lib/structural/header.php and js/header-menu.js. */

@media (max-width: 0px) {
    #header {
        height: 0; /* same zero-reserve behaviour as desktop */
    }

    .site-header {
        left: 0;
        width: 100%;
        height: 60px;
        border-radius: 0;
        align-items: center;
        transition: none; /* no minimize-on-scroll on mobile */
    }

    .site-header--minimized {
        width: 100%;
    }

    .site-header--nav-hidden .site-header__nav {
        opacity: 1;
        visibility: visible; /* desktop minimize classes are inert on mobile */
    }

    .site-header__logo {
        padding: 8px 16px;
    }

    .site-header__logo img {
        width: 120px;
        height: auto;
    }

    /* Hamburger — morphs into an X while the menu is open. */
    .site-header__toggle {
        display: block;
        padding: 16px;
    }

    .site-header__toggle-bar {
        transition: transform 250ms ease, opacity 200ms ease;
    }

    body.mobile-menu-open .site-header__toggle-bar:nth-last-child(3) {
        transform: translateY(7px) rotate(45deg);
    }

    body.mobile-menu-open .site-header__toggle-bar:nth-last-child(2) {
        opacity: 0;
    }

    body.mobile-menu-open .site-header__toggle-bar:nth-last-child(1) {
        transform: translateY(-7px) rotate(-45deg);
    }

    body.mobile-menu-open {
        overflow: hidden; /* lock page scroll behind the overlay */
    }

    /* Full-screen overlay under the bar. */
    .site-header__nav {
        display: block;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: #fff;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 4px 0 40px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: opacity 250ms ease, transform 250ms ease, visibility 0s linear 250ms;
    }

    body.mobile-menu-open .site-header__nav {
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: opacity 250ms ease, transform 250ms ease;
    }

    body.admin-bar .site-header__nav {
        top: 92px; /* 60px bar + 32px admin bar */
    }

    /* !important guards against the (retired but possibly still active)
       UberMenu plugin's inline CSS, which hides every ul under
       .responsiveSelectContainer below 960px with display:none !important. */
    .site-header__nav .main-menu {
        display: block !important;
    }

    /* Staggered entrance for the top-level items. */
    .main-menu > li {
        position: relative;
        opacity: 0;
        transform: translateY(12px);
        transition: opacity 300ms ease, transform 300ms ease;
    }

    body.mobile-menu-open .main-menu > li {
        opacity: 1;
        transform: none;
    }

    body.mobile-menu-open .main-menu > li:nth-child(1) { transition-delay: 40ms; }
    body.mobile-menu-open .main-menu > li:nth-child(2) { transition-delay: 90ms; }
    body.mobile-menu-open .main-menu > li:nth-child(3) { transition-delay: 140ms; }
    body.mobile-menu-open .main-menu > li:nth-child(4) { transition-delay: 190ms; }
    body.mobile-menu-open .main-menu > li:nth-child(5) { transition-delay: 240ms; }
    body.mobile-menu-open .main-menu > li:nth-child(6) { transition-delay: 290ms; }
    body.mobile-menu-open .main-menu > li:nth-child(7) { transition-delay: 340ms; }

    /* Big condensed links, Marble-style. */
    .main-menu > li > a {
        font-family: "Roboto Condensed", Arial, Helvetica, sans-serif;
        font-size: 26px;
        font-weight: 700;
        text-transform: uppercase;
        color: #333;
        padding: 16px 64px 16px 24px;
        border-bottom: 1px solid #eee;
        white-space: normal;
    }

    .main-menu > li.current-menu-item > a::before,
    .main-menu > li.current-menu-ancestor > a::before {
        left: 12px;
    }

    /* Accordion toggle for items with a submenu (button injected by JS). */
    .submenu-toggle {
        display: block;
        position: absolute;
        top: 8px;
        right: 12px;
        width: 44px;
        height: 44px;
        background: none;
        border: 0;
        cursor: pointer;
        color: #e11400;
        font-family: "Roboto Condensed", Arial, Helvetica, sans-serif;
        font-size: 30px;
        font-weight: 700;
        line-height: 44px;
        padding: 0;
        transition: transform 250ms ease;
    }

    .submenu-toggle::before {
        content: "+";
    }

    .main-menu > li.is-expanded > .submenu-toggle {
        transform: rotate(45deg); /* "+" becomes an "x"-like close */
    }

    /* Submenus become inline accordions — text only, no images. */
    .main-menu .sub-menu {
        display: block !important; /* see UberMenu guard note above */
        position: static;
        visibility: visible;
        opacity: 1;
        max-height: 0;
        overflow: hidden;
        background: #f7f7f7;
        box-shadow: none;
        border-radius: 0;
        transition: max-height 300ms ease;
    }

    .main-menu > li.is-expanded > .sub-menu {
        max-height: 640px;
    }

    .main-menu .sub-menu > li {
        margin: 0;
        min-width: 0;
        max-width: none;
    }

    .main-menu .sub-menu a {
        display: block;
        padding: 13px 24px 13px 36px;
        color: #636262;
        font-size: 16px;
        font-weight: 400;
        text-decoration: none;
    }

    .menu-item__image {
        display: none; /* card images are a desktop-only treatment */
    }

    .sub-menu--cards .menu-item__label {
        all: unset; /* strip the red caption-bar styling inside the accordion */
    }

    /* ORDER ONLINE — full-width red block at the end of the list. */
    .main-menu > li.menu-item--cta {
        padding: 20px 24px;
        border-bottom: 0;
    }

    #header .main-menu > li.menu-item--cta > a {
        padding: 0 !important;
    }

    .main-menu > li.menu-item--cta .menu-item__label {
        border-radius: 8px;
        text-align: center;
        padding: 16px 12px;
        font-size: 20px;
    }
}

/* -------------------------------------------------- mobile (legacy, ACTIVE)
   Mirrors the live site's responsive pattern (old UberMenu): a white bar
   with logo + select-based menu + store locator shortcut. The legacy rules
   in the compiled style.css style the pieces (#responsive-menu floats the
   children at 33.3%, #select-menu-display gets the grey gradient select,
   #responsive-location-link the locator background image, #menu-logo the
   logo paddings per breakpoint). Markup lives in lib/structural/header.php
   (#responsive-menu block). */

.site-header__responsive {
    flex: 0 0 auto;
}

/* Belt and braces: the legacy style.css hides these on desktop too. */
@media (min-width: 1024px) {
    #select-menu-display,
    #responsive-location-link {
        display: none;
    }
}

@media (max-width: 1023px) {
    #header {
        height: 0; /* same zero-reserve behaviour as desktop */
    }

    .site-header {
        left: 0;
        width: 100%;
        display: block;
        border-radius: 0;
        transition: none; /* no minimize-on-scroll on mobile */
    }

    .site-header--minimized {
        width: 100%; /* desktop minimize class is inert on mobile */
    }

    /* The desktop mega menu nav is not used on mobile (live behaviour:
       the UberMenu ul is hidden below 960px and the select takes over). */
    .site-header__nav {
        display: none !important;
    }

    .site-header__responsive {
        overflow: hidden; /* clears the floated legacy children */
        width: 100%;
    }
}
