/* ===========================================================================
   Unified 3-level megamenu — matches Figma.
   Typography (Figma Dev Mode):
     L2 heading : Switzer Variable, Medium 500, 36px, lh 110%, ls -5%, UPPERCASE
     L3 link    : Helvetica/Arial, Regular 400, 18px, lh 140%, ls 0
     Bottom bar : Switzer Variable, Medium 500, 20px, ls -1px
   =========================================================================== */

/* Panel (desktop) — contained width + centered, identical to the old dropdown
   (max-width 1440 minus the 58px gutters), so the dark backdrop dims the page
   on the sides/below just like the legacy menu. */
.sharks-megamenu {
  position: fixed;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: calc(1440px - 116px);
  background: #ffffff;
  border-bottom: 1px solid #BBBAB6;
  padding: 56px 58px 0;
  z-index: 99;
  /* No drop shadow: it bled upward onto the header as a grey strip. */
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.site-header.megamenu-open .sharks-megamenu {
  opacity: 1;
  visibility: visible;
}

/* Columns */
.sharks-megamenu__cols {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 48px;
  padding-bottom: 40px;
}

.sharks-megamenu__col {
  min-width: 0;
}

/* L2 heading */
.sharks-megamenu__heading {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 18px;
  margin-bottom: 24px;
  border-bottom: 1px solid #BBBAB6;
  font-family: 'Switzer', var(--font-heading);
  font-weight: 500;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  color: #000000;
  text-decoration: none;
  white-space: nowrap; /* keep arrow + heading on one line */
}

/* L3 links */
.sharks-megamenu__links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Reset the global `li { margin-bottom: 8px }` so only the gap applies */
.sharks-megamenu__links-item,
.sharks-megamenu__sublinks li {
  margin: 0;
}

.sharks-megamenu__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'Helvetica', Arial, sans-serif;
  font-weight: 400;
  font-size: 18px;
  line-height: 1.4;
  color: #000000;
  text-decoration: none;
}

/* L4 sublinks (rare) */
.sharks-megamenu__sublinks {
  list-style: none;
  margin: 10px 0 0;
  padding: 0 0 0 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sharks-megamenu__sublink {
  font-family: 'Helvetica', Arial, sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.4;
  color: #000000;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.sharks-megamenu__sublink:hover {
  opacity: 1;
}

/* Keep text black on hover (override the theme's global a:hover colour) */
.sharks-megamenu__heading:hover,
.sharks-megamenu__heading:focus,
.sharks-megamenu__link:hover,
.sharks-megamenu__link:focus,
.sharks-megamenu__footer-link:hover,
.sharks-megamenu__footer-link:focus {
  color: #000000;
}

/* Arrow that slides in on hover, pushing the text right (matches today's menu) */
.sharks-megamenu__arrow {
  display: inline-flex;
  align-items: center;
  width: 0;
  overflow: hidden;
  opacity: 0;
  color: #000000;
  flex-shrink: 0; /* never let a wide heading squeeze/clip the arrow */
  transition: width 0.25s ease, opacity 0.25s ease;
}

.sharks-megamenu__arrow svg {
  display: block;
}

.sharks-megamenu__arrow--lg svg { width: 34px; height: 34px; }
.sharks-megamenu__arrow--sm svg { width: 20px; height: 20px; }

.sharks-megamenu__heading:hover .sharks-megamenu__arrow--lg {
  width: 40px;
  opacity: 1;
}

.sharks-megamenu__link:hover .sharks-megamenu__arrow--sm {
  width: 24px;
  opacity: 1;
}

/* Bottom bar */
.sharks-megamenu__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 0;
  border-top: 1px solid #BBBAB6;
}

.sharks-megamenu__tagline {
  font-family: 'Switzer', var(--font-heading);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -1px;
  text-transform: uppercase;
  color: #000000;
}

.sharks-megamenu__footer-link {
  font-family: 'Switzer', var(--font-heading);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -1px;
  color: #000000;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Header colour inversion while the panel is open (mirrors .submenu-open) */
.site-header.megamenu-open {
  background: #ffffff;
  transition: background 0.3s ease;
}
.site-header.megamenu-open .site-logo,
.site-header.megamenu-open .site-nav__menu > li > a,
.site-header.megamenu-open .site-nav__toggle,
.site-header.megamenu-open .site-cta {
  color: #000000;
}
.site-header.megamenu-open .site-logo__image {
  filter: brightness(0) saturate(100%);
}
.site-header.megamenu-open .site-cta {
  border-color: #000000;
}

/* The mega item keeps the dark page-dimming backdrop (rgba(0,0,0,.5)) from the
   base .menu-item-has-children::after rule — identical to the old dropdown — so
   the rest of the page greys out behind the contained panel. */

/* Old single-column dropdown (e.g. Tööd): same clean-white treatment on every
   page. Remove the drop shadow that bled grey onto the header bar on hover.
   Lives here (not header.css) because megamenu.css is cache-busted via filemtime(). */
.site-nav__menu .sharks-mega-menu,
.site-nav__menu .sub-menu {
  box-shadow: none !important;
}

/* Desktop: the mega item must NOT show the old per-item dropdown */
@media (min-width: 1366px) {
  .site-nav__menu .menu-item.has-megamenu > .sub-menu,
  .site-nav__menu .menu-item.has-megamenu > .sharks-mega-menu {
    display: none !important;
  }
}

/* Mobile/tablet: hide the unified panel; native nested accordion is used instead */
@media (max-width: 1365px) {
  .sharks-megamenu {
    display: none !important;
  }

  /* 3-level accordion: indent + de-emphasise each deeper level for hierarchy */
  .site-nav .sub-menu .sub-menu a,
  .site-nav .sub-menu-container .sub-menu a {
    padding-left: 40px !important;
    font-size: 18px !important;
    text-transform: none !important;
  }

  /* Allow an expanded parent to grow when a nested level opens (avoid clipping) */
  .site-nav .menu-item-has-children.is-open > .sub-menu {
    max-height: 2000px !important;
  }

  /* Pin each parent's chevron to its own row, not centred in the tall open <li> */
  .site-nav__menu .menu-item-has-children > .submenu-toggle {
    bottom: auto !important;
    height: 64px !important; /* top-level row height */
  }
  .site-nav__menu .sub-menu .menu-item-has-children > .submenu-toggle {
    height: 53px !important; /* nested category row height */
  }

  /* "You are here": highlight the current page in the mobile menu */
  .site-nav__menu .current-menu-item > a,
  .site-nav__menu .current_page_item > a {
    text-decoration: underline !important;
    text-underline-offset: 5px !important;
    opacity: 1 !important;
  }

  /* Remove the full-width underline bar (a::after) on mobile so the current item
     shows ONLY the text underline above — not a doubled full-width line. */
  .site-nav__menu a::after {
    display: none !important;
  }

  /* The last item already has a bottom separator; drop the mobile CTA's top
     border so the last line isn't doubled. */
  .site-nav__mobile-cta {
    border-top: none !important;
  }

  /* Faster, more reliable taps on iOS (removes 300ms delay / click flakiness) */
  .site-nav__menu a {
    touch-action: manipulation;
  }

  /* Keep the cookie reopen button in the bottom-left even when the burger menu is
     open. The old rule (header.css) moved it to top-left, where it covered the
     logo and looked like the logo had turned into the cookie icon. */
  body.sharks-mobile-menu-open .sharks-cookie-floating-wrap {
    top: auto !important;
    bottom: 18px !important;
    left: 16px !important;
    right: auto !important;
  }

  /* Show the site logo (white SVG) above the open menu overlay, top-left. The nav
     overlay is z-index 9999 and was covering it. */
  body.sharks-mobile-menu-open .site-logo {
    position: relative;
    z-index: 10000;
  }

  /* Mobile menu overlay: pitch black, matching the desktop hero/header (#000),
     instead of the bluish dark-grey #0c1415. */
  .site-nav {
    background: #000000 !important;
  }

  /* Sticky top bar: an opaque black strip behind the fixed logo + X so the
     scrolling menu content slides under it instead of running over the logo.
     Must be position:sticky (NOT fixed): the nav has a transform, which would
     make a fixed child scroll away with the content. The bar is the nav's first
     flex item and provides the top spacing (so we zero the nav's padding-top).
     z-index sits above the scrolling items but below the logo/X (10000). */
  .site-nav {
    padding-top: 0 !important;
  }
  .site-nav.is-active::before {
    content: '';
    display: block;
    position: sticky;
    top: 0;
    height: 100px;
    margin: 0 -24px; /* counter the nav's 24px horizontal padding → full width */
    background: #000000;
    z-index: 5000;
    flex: 0 0 auto;
  }

  /* Once open, drop the residual transform (translateX(0)). The slide-in still
     animates (translateX(-100%) → none interpolates to 0), but with no transform
     the close X can be position:fixed and stay on the sticky bar while scrolling. */
  .site-nav.is-active {
    transform: none !important;
  }
  .site-nav.is-active .site-nav__close {
    position: fixed !important;
    top: 26px !important;
    right: 20px !important;
    z-index: 10001 !important;
  }
}
