/* ==========================================================================
   Megamenu Styles — Desktop + Mobile
   Depends on css2/theme.css for CSS custom properties (--color-*)
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. Shared / Base
   -------------------------------------------------------------------------- */

.wm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
  pointer-events: none;
}

.wm-backdrop.wm-active {
  opacity: 1;
  visibility: visible;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   1. Desktop Dropdown (shared base for mega + narrow)
   -------------------------------------------------------------------------- */

.wm-dropdown {
  position: fixed;
  z-index: 9999;
  background: #ffffff;
  border-top: 3px solid var(--color-accent, #e57200);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 200ms ease-out, transform 200ms ease-out, visibility 200ms ease-out;
  pointer-events: none;
  box-sizing: border-box;
}

.wm-dropdown.wm-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.wm-dropdown.wm-closing {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 150ms ease-in, transform 150ms ease-in, visibility 150ms ease-in;
}

/* Focus outline for all interactive elements */
.wm-dropdown a:focus-visible,
.wm-dropdown [role="menuitem"]:focus-visible {
  outline: 2px solid var(--color-accent-400, #ff8c22);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --------------------------------------------------------------------------
   2. Megamenu Layout (>=6 items)
   -------------------------------------------------------------------------- */

.wm-dropdown.wm-mega {
  max-width: 1200px;
  width: max-content;
  padding: 0;
}

.wm-mega-body {
  padding: 24px 32px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0 32px;
  box-sizing: border-box;
}

/* Category block */
.wm-category {
  margin-bottom: 20px;
  break-inside: avoid;
}

.wm-category-heading {
  display: block;
  font-family: Poppins, Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-gray-900, #0f172a);
  text-decoration: none;
  margin-bottom: 6px;
  padding: 2px 0;
  transition: color 150ms ease;
}

.wm-category-heading:hover {
  color: var(--color-primary, #002b49);
  text-decoration: underline;
}

.wm-subcategories {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wm-subcategories li {
  margin: 0;
  padding: 0;
}

.wm-subcategories a {
  display: block;
  font-family: Inter, Helvetica, sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--color-gray-700, #334155);
  text-decoration: none;
  padding: 3px 0;
  transition: color 150ms ease, text-decoration 150ms ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wm-subcategories a:hover {
  color: var(--color-accent, #e57200);
  text-decoration: underline;
}

/* CTA footer bar */
.wm-mega-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 32px;
  background: var(--color-accent-light, #fef5ec);
  border-top: 1px solid var(--color-gray-200, #e2e8f0);
  border-radius: 0 0 8px 8px;
  text-decoration: none;
  transition: background 150ms ease;
}

.wm-mega-footer:hover {
  background: var(--color-accent-200, #f5c090);
}

.wm-mega-footer span {
  font-family: Poppins, Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent, #e57200);
  line-height: 1;
}

.wm-mega-footer svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-accent, #e57200);
  fill: none;
  stroke-width: 2.5;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   3. Narrow Dropdown (<6 items)
   -------------------------------------------------------------------------- */

.wm-dropdown.wm-narrow {
  min-width: 200px;
  max-width: 320px;
  padding: 8px 0;
}

.wm-narrow-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wm-narrow-list li {
  margin: 0;
  padding: 0;
}

.wm-narrow-list li:not(:last-child) {
  border-bottom: 1px solid var(--color-gray-200, #e2e8f0);
}

.wm-narrow-list a {
  display: block;
  padding: 10px 20px;
  font-family: Poppins, Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--color-gray-900, #0f172a);
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease;
  line-height: 1.4;
}

.wm-narrow-list a:hover {
  background: var(--color-gray-100, #f1f5f9);
  color: var(--color-accent, #e57200);
}

/* --------------------------------------------------------------------------
   4. Desktop nav-item indicator (chevron for items with dropdowns)
   -------------------------------------------------------------------------- */

@media (min-width: 1024px) {
  .wm-has-dropdown > a::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    margin-left: 5px;
    margin-bottom: 2px;
    vertical-align: middle;
    transition: transform 200ms ease;
  }

  .wm-has-dropdown.wm-nav-active > a::after {
    transform: rotate(-135deg);
    margin-bottom: -2px;
  }
}

/* --------------------------------------------------------------------------
   5. Hamburger Button (mobile only)
   -------------------------------------------------------------------------- */

.wm-hamburger {
  display: none;
  position: relative;
  width: 24px;
  height: 24px;
  padding: 10px;
  box-sizing: content-box;
  cursor: pointer;
  background: none;
  border: none;
  z-index: 10001;
  -webkit-tap-highlight-color: transparent;
}

.wm-hamburger span {
  display: block;
  position: absolute;
  left: 10px;
  width: 24px;
  height: 2px;
  background: #ffffff;
  border-radius: 2px;
  transition: transform 300ms ease, opacity 200ms ease, top 300ms ease;
}

.wm-hamburger span:nth-child(1) { top: 14px; }
.wm-hamburger span:nth-child(2) { top: 22px; }
.wm-hamburger span:nth-child(3) { top: 30px; }

/* Animate to X */
.wm-hamburger.wm-active span:nth-child(1) {
  top: 22px;
  transform: rotate(45deg);
}

.wm-hamburger.wm-active span:nth-child(2) {
  opacity: 0;
}

.wm-hamburger.wm-active span:nth-child(3) {
  top: 22px;
  transform: rotate(-45deg);
}

@media (max-width: 1023px) {
  .wm-hamburger {
    display: block;
  }
}

/* --------------------------------------------------------------------------
   6. Mobile Slide-In Panel
   -------------------------------------------------------------------------- */

.wm-mobile-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 85vw;
  max-width: 380px;
  background: #ffffff;
  z-index: 10000;
  transform: translateX(100%);
  transition: transform 300ms ease-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
}

.wm-mobile-panel.wm-open {
  transform: translateX(0);
}

/* Mobile backdrop (reuses .wm-backdrop but higher z-index context via panel) */
.wm-mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms ease, visibility 300ms ease;
  pointer-events: none;
}

.wm-mobile-backdrop.wm-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Panel header */
.wm-mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-gray-200, #e2e8f0);
  flex-shrink: 0;
}

.wm-mobile-header-title {
  font-family: Poppins, Helvetica, Arial, sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-gray-900, #0f172a);
  line-height: 1;
}

.wm-mobile-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.wm-mobile-close svg {
  width: 20px;
  height: 20px;
  stroke: var(--color-gray-700, #334155);
  stroke-width: 2;
  fill: none;
}

/* Panel scroll area — holds the sliding views */
.wm-mobile-scroll {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.wm-mobile-views {
  display: flex;
  transition: transform 300ms ease;
  height: 100%;
}

.wm-mobile-view {
  min-width: 100%;
  max-width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Back button */
.wm-mobile-back {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  background: var(--color-gray-100, #f1f5f9);
  border: none;
  border-bottom: 1px solid var(--color-gray-200, #e2e8f0);
  cursor: pointer;
  font-family: Poppins, Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-gray-700, #334155);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.wm-mobile-back svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-gray-700, #334155);
  stroke-width: 2.5;
  fill: none;
  flex-shrink: 0;
}

/* Nav rows */
.wm-mobile-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wm-mobile-nav-item {
  border-bottom: 1px solid var(--color-gray-200, #e2e8f0);
}

.wm-mobile-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font-family: Poppins, Helvetica, Arial, sans-serif;
  font-size: 16px;
  font-weight: 400;
  color: var(--color-gray-900, #0f172a);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 150ms ease;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.wm-mobile-nav-link:active {
  background: var(--color-gray-100, #f1f5f9);
}

/* Chevron for drill-down items */
.wm-mobile-chevron {
  width: 16px;
  height: 16px;
  stroke: var(--color-gray-500, #64748b);
  stroke-width: 2;
  fill: none;
  flex-shrink: 0;
}

/* "View All" link in drill-down */
.wm-mobile-view-all {
  display: block;
  padding: 12px 20px;
  font-family: Poppins, Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent, #e57200);
  text-decoration: none;
  border-bottom: 1px solid var(--color-gray-200, #e2e8f0);
  transition: background 150ms ease;
}

.wm-mobile-view-all:active {
  background: var(--color-gray-100, #f1f5f9);
}

.wm-mobile-sub-link {
  display: block;
  padding: 10px 20px 10px 32px;
  font-family: Inter, Helvetica, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--color-gray-900, #0f172a);
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

.wm-mobile-sub-link:active {
  background: var(--color-gray-100, #f1f5f9);
  color: var(--color-accent, #e57200);
}

/* --------------------------------------------------------------------------
   7. Responsive — hide desktop dropdowns on mobile, hide hamburger on desktop
   -------------------------------------------------------------------------- */

@media (max-width: 1023px) {
  /* Hide all desktop dropdowns */
  .wm-dropdown {
    display: none !important;
  }

  .wm-backdrop {
    display: none !important;
  }

  /* Hide the desktop nav items (replaced by hamburger menu) */
  .nav-section,
  .dn-nav-main-container {
    display: none !important;
  }

  /* Ensure the header can contain the hamburger */
  .site-header-inner {
    position: relative;
  }
}

@media (min-width: 1024px) {
  /* Hide mobile elements */
  .wm-mobile-panel,
  .wm-mobile-backdrop,
  .wm-hamburger {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   10. Mobile panel — Auth links (top)
   -------------------------------------------------------------------------- */
.wm-mobile-auth {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-gray-200, #e2e8f0);
  flex-shrink: 0;
}

.wm-mobile-auth a {
  font-family: Poppins, Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  padding: 4px 0;
  transition: color 150ms ease;
}

.wm-mobile-auth a:first-child {
  color: var(--color-accent, #e57200);
}

.wm-mobile-auth a:last-child {
  color: var(--color-gray-500, #64748b);
}

.wm-mobile-auth-divider {
  width: 1px;
  height: 16px;
  background: var(--color-gray-200, #e2e8f0);
  margin: 0 16px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   11. Mobile panel — Contact section (bottom)
   -------------------------------------------------------------------------- */
.wm-mobile-contact {
  flex-shrink: 0;
  border-top: 1px solid var(--color-gray-200, #e2e8f0);
  background: var(--color-gray-50, #f8fafc);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wm-mobile-contact a {
  text-decoration: none;
  transition: color 150ms ease;
}

.wm-mobile-contact-phone {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wm-mobile-contact-phone svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-gray-500, #64748b);
  fill: none;
  flex-shrink: 0;
}

.wm-mobile-contact-phone a {
  font-family: Poppins, Helvetica, Arial, sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-accent, #e57200);
}

.wm-mobile-contact-address {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.wm-mobile-contact-address svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-gray-500, #64748b);
  fill: none;
  flex-shrink: 0;
  margin-top: 1px;
}

.wm-mobile-contact-address a {
  font-family: Inter, Helvetica, sans-serif;
  font-size: 13px;
  color: var(--color-gray-700, #334155);
}

.wm-mobile-contact-hours {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wm-mobile-contact-hours svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-gray-500, #64748b);
  fill: none;
  flex-shrink: 0;
}

.wm-mobile-contact-hours-text {
  font-family: Inter, Helvetica, sans-serif;
  font-size: 13px;
  color: var(--color-gray-700, #334155);
  display: flex;
  align-items: center;
  gap: 6px;
}

.wm-mobile-contact-hours-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.wm-mobile-contact-hours-dot--open {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.wm-mobile-contact-hours-dot--closed {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

/* --------------------------------------------------------------------------
   12. Landscape compact mode
   -------------------------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 500px) {
  .wm-mobile-header {
    padding: 8px 16px;
  }

  .wm-mobile-close {
    width: 28px;
    height: 28px;
  }

  .wm-mobile-nav-link {
    padding: 10px 20px;
    font-size: 14px;
  }

  .wm-mobile-auth {
    padding: 8px 16px;
  }

  .wm-mobile-contact {
    padding: 12px 16px;
  }

  .wm-mobile-back {
    padding: 10px 16px;
  }

  .wm-mobile-view-all {
    padding: 10px 16px;
  }

  .wm-mobile-sub-link {
    padding: 8px 16px 8px 28px;
    font-size: 14px;
  }
}

/* --------------------------------------------------------------------------
   8. Prevent body scroll when mobile panel is open
   -------------------------------------------------------------------------- */

body.wm-mobile-open {
  overflow: hidden !important;
}

/* --------------------------------------------------------------------------
   9. Print — hide all menu components
   -------------------------------------------------------------------------- */

@media print {
  .wm-dropdown,
  .wm-backdrop,
  .wm-mobile-panel,
  .wm-mobile-backdrop,
  .wm-hamburger {
    display: none !important;
  }
}
