/* ============================================
   Mega Menu + Regular Dropdown
   ============================================ */

/* Top-level menu list */
.wl-header__menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 8px;
}

/* Top-level items — mega parents use position: static so dropdown
   references .wl-header__inner (position: relative) for full-width */
.wl-header__menu > li {
  position: relative;
}

.wl-header__menu > li.menu-item-has-megamenu {
  position: static;
}

.wl-header__menu > li > a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background var(--motion-fast), color var(--motion-fast);
  white-space: nowrap;
}

.wl-header__menu > li > a:hover,
.wl-header__menu > li:hover > a {
  background: rgba(255,255,255,0.12);
  color: var(--color-gold-soft);
}

.wl-megamenu__arrow {
  font-size: 10px;
  transition: transform var(--motion-fast);
}

.wl-header__menu > li:hover > a .wl-megamenu__arrow {
  transform: rotate(180deg);
}

/* ============================================
   Regular Dropdown (sub-menu)
   ============================================ */
.wl-header__menu .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  list-style: none;
  margin: 0;
  padding: 8px 0;
  background: #fff;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--motion-base), transform var(--motion-base), visibility var(--motion-base);
  z-index: 100;
}

.wl-header__menu > li:hover > .sub-menu,
.wl-header__menu > li.open > .sub-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.wl-header__menu .sub-menu li {
  margin: 0;
}

.wl-header__menu .sub-menu a {
  display: block;
  padding: 10px 20px;
  font-size: var(--fs-sm);
  color: var(--color-fg-2);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--motion-fast), color var(--motion-fast);
}

.wl-header__menu .sub-menu a:hover {
  background: var(--color-surface);
  color: var(--color-fg);
}

/* ============================================
   Mega Dropdown — full-width card grid
   ============================================ */

/* Mega dropdown container — full width of header inner */
.wl-megamenu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  transform: translateY(8px);
  background: #fff;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--motion-base), transform var(--motion-base), visibility var(--motion-base);
  z-index: 100;
}

/* Show mega — controlled by JS .open class (with delay on close to bridge the gap) */
.wl-header__menu > li.menu-item-has-megamenu.open > .wl-megamenu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.wl-megamenu__inner {
  padding: 24px;
}

.wl-megamenu__grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* Mega menu card item */
.wl-megamenu__item {
  /* grid child */
}

.wl-megamenu__link {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-fg);
  transition: background var(--motion-fast);
  overflow: hidden;
}

.wl-megamenu__link:hover {
  background: var(--color-surface);
}

.wl-megamenu__thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  overflow: hidden;
  background: #e5e5e5;
}

.wl-megamenu__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--motion-base);
}

.wl-megamenu__link:hover .wl-megamenu__thumb img {
  transform: scale(1.05);
}

.wl-megamenu__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 10px 12px;
  min-width: 0;
}

.wl-megamenu__title {
  font-size: 18px;
  font-weight: var(--fw-semibold);
  color: var(--color-fg);
  line-height: 1.3;
}

.wl-megamenu__desc {
  font-size: var(--fs-sm);
  color: var(--color-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Scrolled header adjustments --- */
.wl-header--scrolled .wl-header__menu > li > a {
  color: var(--color-fg-2);
}

.wl-header--scrolled .wl-header__menu > li > a:hover {
  color: var(--color-fg);
  background: rgba(0,0,0,0.06);
}

.wl-header--scrolled .sub-menu a {
  color: var(--color-fg-2);
}

/* --- Responsive --- */
@media (max-width: 1100px) {
  .wl-header__menu {
    flex-direction: column;
    gap: 0;
    padding: 16px 0;
  }

  .wl-header__menu > li {
    position: relative;
  }

  .wl-header__menu > li > a {
    color: var(--color-fg);
    padding: 12px 16px;
    width: 100%;
  }

  .wl-header--scrolled .wl-header__menu > li > a {
    color: var(--color-fg);
  }

  /* Regular dropdown on mobile */
  .wl-header__menu .sub-menu {
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    border: none;
    box-shadow: none;
    border-radius: 0;
    background: transparent;
    min-width: 0;
    display: none;
    padding: 0 0 0 16px;
  }

  .wl-header__menu > li.open > .sub-menu {
    display: block;
  }

  .wl-header__menu .sub-menu a {
    padding: 10px 0;
    font-size: var(--fs-sm);
    color: var(--color-fg-2);
  }

  /* Mega menu on mobile */
  .wl-megamenu {
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    border: none;
    box-shadow: none;
    border-radius: 0;
    background: transparent;
    min-width: 0;
    display: none;
    padding-left: 16px;
  }

  .wl-header__menu > li.menu-item-has-megamenu.open > .wl-megamenu {
    display: block;
  }

  .wl-megamenu__inner {
    padding: 0 0 8px 0;
  }

  .wl-megamenu__grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .wl-megamenu__thumb {
    width: 40px;
    height: 40px;
  }
}
