/**
 * Mega Menu styles.
 * Lives inside .site-header__nav alongside .site-header__menu (wp_nav_menu).
 */

.gs-mega-menu {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.gs-mega-menu__item { position: static; }

.gs-mega-menu__top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: var(--gs-radius-sm);
  color: var(--gs-white);
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  transition: background .15s, color .15s;
  text-shadow: var(--gs-text-shadow-hero);
  cursor: pointer;
}

.gs-mega-menu__item:hover > .gs-mega-menu__top,
.gs-mega-menu__item:focus-within > .gs-mega-menu__top,
.gs-mega-menu__top:hover {
  text-decoration: underline solid var(--gs-orange);
  text-decoration-thickness: 4px;
  text-underline-offset: 8px;
}

.site-header.is-scrolled .gs-mega-menu__top,
.site-header--solid .gs-mega-menu__top {
  color: var(--gs-text);
  text-shadow: none;
}

/* Caret (chevron) */
.gs-mega-menu__caret {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-bottom: 3px;
  transition: transform .2s ease;
}
.gs-mega-menu__item--has-panel.is-open > .gs-mega-menu__top .gs-mega-menu__caret {
  transform: rotate(-135deg);
  margin-bottom: 0;
  margin-top: 3px;
}

/* Panel — centered card under the header (anchored to viewport width via .site-header) */
.gs-mega-menu__panel {
  position: absolute;
  top: 100%;
  left: 50%;
  width: 900px;
  max-width: calc(100vw - 32px);
  background: var(--gs-white);
  border-radius: 12px;
  box-shadow: var(--gs-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 8px);
  transition: opacity .2s ease, visibility .2s ease, transform .2s ease;
  z-index: 20;
}
/* Invisible bridge so cursor can cross the gap from the trigger to the panel */
.gs-mega-menu__panel::before {
  content: "";
  position: absolute;
  top: -32px;
  left: 0;
  right: 0;
  height: 32px;
}

.gs-mega-menu__item--has-panel:hover > .gs-mega-menu__panel,
.gs-mega-menu__item--has-panel:focus-within > .gs-mega-menu__panel {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.gs-mega-menu__panel-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  padding: 32px;
}

/* Wide layout — single full-width heading + 2-column link grid */
.gs-mega-menu__panel--wide_links .gs-mega-menu__panel-inner {
  grid-template-columns: 1fr;
}
.gs-mega-menu__panel--wide_links .gs-mega-menu__links {
  display: block;
  column-count: 2;
  column-gap: 32px;
}
.gs-mega-menu__panel--wide_links .gs-mega-menu__links > li {
  break-inside: avoid;
}

/* Heading row with optional inline CTA — heading in col 1, CTA in col 2
   (lining up with the link grid below); single underline spans the full row. */
.gs-mega-menu__col-head-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 32px;
  align-items: baseline;
  padding-bottom: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid #C0C0C0;
}
/* Heading + CTA inside the row don't carry their own border — the row has it. */
.gs-mega-menu__col-head-row .gs-mega-menu__col-heading {
  border-bottom: 0;
  padding-bottom: 0;
  margin: 0;
}
.gs-mega-menu__col-cta {
  color: var(--gs-blue);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color .15s ease;
}
.gs-mega-menu__col-cta:hover { color: var(--gs-orange); }
.gs-mega-menu__col-cta::after {
  content: "→";
  display: inline-block;
  margin-left: 6px;
  color: var(--gs-orange);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity .2s ease, transform .2s ease;
}
.gs-mega-menu__col-cta:hover::after {
  opacity: 1;
  transform: translateX(0);
}

.gs-mega-menu__col-heading {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #000;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #C0C0C0;
}
.gs-mega-menu__col-heading[aria-hidden="true"] { border-bottom-color: transparent; }

.gs-mega-menu__links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gs-mega-menu__links a {
  display: block;
  padding: 8px 0;
  color: var(--gs-blue);
  text-decoration: none;
  font-size: 16px;
  font-weight: 800;
  transition: color .15s ease;
}
.gs-mega-menu__links a:hover {
  color: var(--gs-orange);
}

.gs-mega-menu__link-label {
  display: inline-block;
  position: relative;
}
.gs-mega-menu__link-label::after {
  content: "→";
  display: inline-block;
  margin-left: 6px;
  color: var(--gs-orange);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity .2s ease, transform .2s ease;
}
.gs-mega-menu__links a:hover .gs-mega-menu__link-label::after {
  opacity: 1;
  transform: translateX(0);
}

.gs-mega-menu__link-desc {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 400;
  color: var(--gs-text);
  opacity: 0.7;
  line-height: 1.4;
}
.gs-mega-menu__links a:hover .gs-mega-menu__link-desc {
  color: #000;
  opacity: 1;
}

/* Featured column */
.gs-mega-menu__col--featured {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}
.gs-mega-menu__feat-card {
  background: var(--gs-light);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.10);
}
.gs-mega-menu__feat-image {
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.10);
}
.gs-mega-menu__feat-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gs-mega-menu__feat-heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--gs-text-dark);
  margin: 0 0 8px;
}
.gs-mega-menu__feat-desc {
  font-size: 16px;
  color: var(--gs-text);
  line-height: 1.5;
  margin: 0 0 16px;
}
.gs-mega-menu__feat-cta {
  align-self: flex-start;
  color: var(--gs-blue);
  font-weight: 600;
  text-decoration: none;
  font-size: 16px;
}
.gs-mega-menu__feat-cta::after {
  content: "→";
  display: inline-block;
  margin-left: 6px;
  color: var(--gs-orange);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity .2s ease, transform .2s ease;
}
.gs-mega-menu__feat-cta:hover { color: var(--gs-orange); }
.gs-mega-menu__feat-cta:hover::after {
  opacity: 1;
  transform: translateX(0);
}

@media (max-width: 1280px) {
  .gs-mega-menu__top { font-size: 16px; }
}

@media (min-width: 1381px) {
  .gs-mega-menu { gap: 12px; }
  .gs-mega-menu__top { font-size: 20px; }
}

/* Mobile — match the existing nav breakpoint at 1200px.
   Visually mirror .site-header__menu so wp_nav_menu items and mega menu items
   share the same look inside the slide-down panel. */
@media (max-width: 1200px) {
  .gs-mega-menu {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    padding: 8px 24px 0;
  }
  .gs-mega-menu__item { border-bottom: 1px solid var(--gs-border); }

  .gs-mega-menu__top {
    width: 100%;
    justify-content: space-between;
    padding: 16px 0;
    color: var(--gs-text);
    text-shadow: none;
    font-size: 20px;
    border-radius: 0;
  }
  .site-header.is-scrolled .gs-mega-menu__top,
  .site-header--solid .gs-mega-menu__top { color: var(--gs-text); }
  .gs-mega-menu__item:hover > .gs-mega-menu__top,
  .gs-mega-menu__item:focus-within > .gs-mega-menu__top,
  .gs-mega-menu__top:hover {
    text-decoration: none;
    color: var(--gs-orange);
  }

  /* Panel becomes an inline accordion */
  .gs-mega-menu__panel {
    position: static;
    width: auto;
    max-width: none;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    opacity: 1;
    visibility: hidden;
    transform: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease, visibility .25s ease, margin .25s ease;
    border-left: 4px solid var(--gs-orange);
  }
  .gs-mega-menu__panel::before { display: none; }

  /* Disable hover/focus-within auto-open on mobile — only .is-open (set by JS) opens the panel */
  .gs-mega-menu__item--has-panel:hover > .gs-mega-menu__panel,
  .gs-mega-menu__item--has-panel:focus-within > .gs-mega-menu__panel {
    opacity: 1;
    visibility: hidden;
    transform: none;
    max-height: 0;
  }

  .gs-mega-menu__item--has-panel.is-open > .gs-mega-menu__panel {
    visibility: visible;
    max-height: 1500px;
    margin: 0 0 12px;
  }

  /* Mobile caret: right when closed, down when open */
  .gs-mega-menu__caret {
    transform: rotate(-45deg);
    margin: 0;
  }
  .gs-mega-menu__item--has-panel.is-open > .gs-mega-menu__top .gs-mega-menu__caret {
    transform: rotate(45deg);
    margin: 0;
  }
  .gs-mega-menu__panel-inner {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 8px 0 12px 16px;
  }
  .gs-mega-menu__col-heading { font-size: 16px; margin-bottom: 8px; }
  .gs-mega-menu__col-heading[aria-hidden="true"] { display: none; }
  @media (max-width: 767px) {
    .gs-mega-menu__col-heading,
    .gs-mega-menu__col-cta { border-bottom: 0; padding-bottom: 0; }
    .gs-mega-menu__col-heading { margin-bottom: 0; margin-top: 12px; }
    .gs-mega-menu__col-head-row { grid-template-columns: 1fr; gap: 8px 0; }
    .gs-mega-menu__feat-card,
    .gs-mega-menu__feat-image { display: none; }
    .gs-mega-menu__panel-inner { gap: 0; }
  }
  .gs-mega-menu__links a { font-size: 16px; padding: 6px 0; }
  .gs-mega-menu__link-desc { font-size: 14px; }
  .gs-mega-menu__panel--wide_links .gs-mega-menu__links { column-count: 1; }
}

/* Tablet — restore desktop-style 2-column layout inside the panel
   (the panel itself stays as an inline accordion at this breakpoint). */
@media (min-width: 768px) and (max-width: 1200px) {
  .gs-mega-menu { padding: 8px 40px 0; }
  .gs-mega-menu__panel { border-left: 0; }
  .gs-mega-menu__panel-inner {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    padding: 16px 16px 20px;
  }
  .gs-mega-menu__panel--wide_links .gs-mega-menu__panel-inner {
    grid-template-columns: 1fr;
  }
  .gs-mega-menu__panel--wide_links .gs-mega-menu__links {
    column-count: 2;
  }
}
