/*
 * ─────────────────────────────────────────────────────────────────────────────
 *  WMD Mega Menu  — drop-in CSS for WordPress
 *  Requires: animate.css 4.x  (add to WP via CDN or enqueue)
 *  CDN: https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css
 * ─────────────────────────────────────────────────────────────────────────────
 *
 *  HOW TO USE
 *  1. Enqueue this file in functions.php (or paste in Appearance > Customize > CSS).
 *  2. Enqueue mega-menu.js the same way.
 *  3. Copy the HTML from demo.html into your nav Walker / menu template.
 *  4. Adjust --mm-accent and --mm-text to match your brand.
 * ─────────────────────────────────────────────────────────────────────────────
 */

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --mm-accent:        #029fe4;   /* teal highlight */
  --mm-accent-dark:   #0287c2;
  --mm-heading:       #1e3a5f;   /* dark navy for column headings */
  --mm-text:          #374151;
  --mm-muted:         #6b7280;
  --mm-bg:            #ffffff;
  --mm-border:        #e5e7eb;
  --mm-feature-bg:    #eef6fb;   /* light teal tint for featured panel */
  --mm-radius:        1rem;
  --mm-shadow:        0 24px 56px rgba(0,0,0,0.13);
  --mm-ease:          cubic-bezier(0.16, 1, 0.3, 1);
  --mm-col-gap:       2rem;
  --mm-animate-dur:   0.28s;
}

/* ── Nav item wrapper ─────────────────────────────────────────────────────── */
/*
 *  Add class  .mm-item  to the <li> that contains the trigger + mega panel.
 *  It must be position:relative so the panel anchors correctly.
 */
.mm-item {
  position: static;   /* mega panel is full-width, so we break out of li */
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* ── Trigger button / link ───────────────────────────────────────────────── */
.mm-trigger {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  padding: 0;
  transition: color 0.2s var(--mm-ease);
}
.mm-trigger:hover,
.mm-item.is-open .mm-trigger {
  color: var(--mm-accent);
}

/* Chevron arrow */
.mm-chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.25s var(--mm-ease);
  flex-shrink: 0;
}
.mm-item.is-open .mm-chevron {
  transform: rotate(180deg);
}

/* ── Mega panel ──────────────────────────────────────────────────────────── */
/*
 *  Place  .mm-panel  as a direct child of the <nav> (or the sticky header)
 *  so it can span full width below the bar.
 *  In WordPress, this typically means your Walker outputs it inside the <ul>
 *  but the CSS uses position:fixed off the nav bar — see demo.html.
 */
.mm-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;           /* flush below the sticky nav bar */
  z-index: 9999;
  background: var(--mm-bg);
  border-top: 2px solid var(--mm-accent);
  border-bottom: 1px solid var(--mm-border);
  box-shadow: var(--mm-shadow);
  border-radius: 0 0 var(--mm-radius) var(--mm-radius);

  /* hidden state */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
  transition:
    opacity       var(--mm-animate-dur) var(--mm-ease),
    transform     var(--mm-animate-dur) var(--mm-ease),
    visibility    0s linear             var(--mm-animate-dur);
}

/* open state — toggled by JS (.is-open on .mm-item) for desktop and mobile */
.mm-item.is-open > .mm-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition:
    opacity   var(--mm-animate-dur) var(--mm-ease),
    transform var(--mm-animate-dur) var(--mm-ease),
    visibility 0s linear 0s;
  animation: mmFadeInDown var(--mm-animate-dur) var(--mm-ease) both;
}

.mm-item.is-open .mm-trigger {
  color: var(--mm-accent);
}

.mm-item.is-open .mm-chevron {
  transform: rotate(180deg);
}

@keyframes mmFadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Inner grid ──────────────────────────────────────────────────────────── */
.mm-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr) 260px;
  gap: var(--mm-col-gap);
  align-items: start;
}

/* ── Column ──────────────────────────────────────────────────────────────── */
.mm-col {}

.mm-col-heading {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mm-heading);
  padding-bottom: 0.6rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid var(--mm-accent);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.mm-col-heading svg {
  width: 15px;
  height: 15px;
  color: var(--mm-accent);
  flex-shrink: 0;
}

.mm-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mm-col ul li {
  margin: 0;
  padding: 0;
}

/* ── Menu links ──────────────────────────────────────────────────────────── */
.mm-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  border-radius: 0.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--mm-text);
  text-decoration: none;
  transition:
    color            0.18s var(--mm-ease),
    background-color 0.18s var(--mm-ease),
    transform        0.18s var(--mm-ease);
}
.mm-link:hover {
  color: var(--mm-accent);
  background-color: #f0f9ff;
  transform: translateX(3px);
  text-decoration: none;
}

/* dot bullet before each link */
.mm-link::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mm-border);
  flex-shrink: 0;
  transition: background 0.18s;
}
.mm-link:hover::before {
  background: var(--mm-accent);
}

/* ── Divider between columns ─────────────────────────────────────────────── */
.mm-divider {
  width: 1px;
  align-self: stretch;
  background: var(--mm-border);
  margin: 0 0.25rem;
}

/* ── Featured panel (rightmost column) ──────────────────────────────────── */
.mm-feature {
  background: var(--mm-feature-bg);
  border-radius: 0.75rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mm-feature-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.mm-feature-body {
  padding: 1.1rem 1.25rem 1.25rem;
}

.mm-feature-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mm-accent);
  margin-bottom: 0.4rem;
}

.mm-feature-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--mm-heading);
  line-height: 1.3;
  margin: 0 0 0.5rem;
}

.mm-feature-desc {
  font-size: 0.8rem;
  color: var(--mm-muted);
  line-height: 1.6;
  margin: 0 0 1rem;
}

.mm-feature-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 9999px;
  background: var(--mm-accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  transition:
    background   0.2s var(--mm-ease),
    transform    0.2s var(--mm-ease),
    box-shadow   0.2s var(--mm-ease);
}
.mm-feature-cta:hover {
  background: var(--mm-accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(2,159,228,0.35);
  text-decoration: none;
  color: #fff;
}
.mm-feature-cta svg {
  width: 13px;
  height: 13px;
}

/* ── Footer bar inside mega panel ────────────────────────────────────────── */
.mm-footer {
  border-top: 1px solid var(--mm-border);
  padding: 0.9rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  font-size: 0.8rem;
  color: var(--mm-muted);
}

.mm-footer-all {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  color: var(--mm-accent);
  text-decoration: none;
  transition: gap 0.2s;
}
.mm-footer-all:hover { gap: 0.6rem; text-decoration: none; color: var(--mm-accent-dark); }
.mm-footer-all svg { width: 13px; height: 13px; }

/* ── Overlay backdrop (optional — dims the page behind the panel) ─────────── */
.mm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.18);
  z-index: 49; /* below the sticky header (z-50) so nav is always reachable */
  opacity: 0;
  visibility: hidden;
  transition:
    opacity    var(--mm-animate-dur) var(--mm-ease),
    visibility 0s linear             var(--mm-animate-dur);
}
.mm-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  transition:
    opacity    var(--mm-animate-dur) var(--mm-ease),
    visibility 0s linear 0s;
}

/* ── Responsive: collapse mega panel to simple list on mobile ────────────── */
@media (max-width: 1024px) {
  .mm-panel {
    position: static;
    border-top: none;
    border-bottom: none;
    box-shadow: none;
    border-radius: 0;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    animation: none !important;
    display: none;
  }
  .mm-item.is-open > .mm-panel { display: block; }

  .mm-inner {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0.5rem 1rem;
  }
  .mm-divider { display: none; }
  .mm-feature { display: none; }
  .mm-col { border-bottom: 1px solid var(--mm-border); padding-bottom: 0.5rem; margin-bottom: 0.5rem; }
  .mm-col:last-child { border-bottom: none; }
  .mm-footer { flex-direction: column; align-items: flex-start; }
  .mm-backdrop { display: none; }
}
