/* ═══════════════════════════════════════════════════════════════════
   TRIHEAD MEGA MENU
   All rules scoped to .tmm-nav.
   Colour tokens are CSS custom properties set as inline style by the
   widget's build_css_vars() method and can be overridden per instance.
═══════════════════════════════════════════════════════════════════ */

/* ── Token defaults ─────────────────────────────────────────────── */
.tmm-nav {
  --tmm-link:       #2e2b26;
  --tmm-link-hover: #c84b18;
  --tmm-accent:     #c84b18;
  --tmm-dd-bg:      #ffffff;
  --tmm-dd-text:    #2e2b26;
  --tmm-dd-hover:   #c84b18;
  --tmm-dd-border:  #e4e0d8;
  --tmm-panel-bg:   #ffffff;
  --tmm-mob-bg:     #ffffff;
  --tmm-mob-link:   #2e2b26;
  --tmm-mob-accent: #c84b18;
  --tmm-hamburger:  #2e2b26;
}

/* ── Nav wrapper ────────────────────────────────────────────────── */
/*
 * position:relative is the positioning context that mega panels
 * (wide + full) anchor to. Do NOT remove it.
 * Everything else (background, padding, sticky) is handled by the
 * Elementor container this widget sits in.
 */
.tmm-nav {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

/* ── Desktop menu list ──────────────────────────────────────────── */
.tmm-menu {
  display: flex;
  align-items: center;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  gap: 2rem;
}

/* Defeat any theme that sets list-style on li elements */
.tmm-menu li,
.tmm-dropdown li,
.tmm-mobile__list li {
  list-style: none !important;
}

/* ── Top-level items ────────────────────────────────────────────── */
.tmm-item {
  position: relative; /* anchor for auto-width panels & standard dropdowns */
}

/* Wide and full panels escape the item and anchor to .tmm-nav */
.tmm-item.mega-wide,
.tmm-item.mega-full {
  position: static;
}

/* ── Nav links ──────────────────────────────────────────────────── */
.tmm-item > a {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  color: var(--tmm-link);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s;
  cursor: pointer;
}

.tmm-item > a:hover,
.tmm-item.open > a {
  color: var(--tmm-link-hover);
}

/* Chevron arrow */
.tmm-chevron {
  display: inline-block;
  width: 0.32em;
  height: 0.32em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-0.1em);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.tmm-item:hover > a .tmm-chevron,
.tmm-item.open  > a .tmm-chevron {
  transform: rotate(-135deg) translateY(0.1em);
}

/* ── Standard dropdown ──────────────────────────────────────────── */
.tmm-dropdown {
  position: absolute;
  top: 100%;         /* flush — no gap, so hover never breaks */
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  min-width: 200px;
  list-style: none;
  margin: 0;
  padding: 0.4rem 0;
  background: var(--tmm-dd-bg);
  border: 1px solid var(--tmm-dd-border);
  border-top: 2px solid var(--tmm-accent);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 200;
}

.tmm-item:hover        > .tmm-dropdown,
.tmm-item:focus-within > .tmm-dropdown,
.tmm-item.open         > .tmm-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* Dropdown child links */
.tmm-child a {
  display: block;
  padding: 0.5rem 1.25rem;
  color: var(--tmm-dd-text);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

.tmm-child a:hover {
  color: var(--tmm-dd-hover);
  background: rgba(0, 0, 0, 0.04);
}

/* ── Mega panel — shared base ───────────────────────────────────── */
.tmm-panel {
  position: absolute;
  top: 100%;         /* flush — no gap */
  background: var(--tmm-panel-bg);
  border: 1px solid var(--tmm-dd-border);
  border-top: 2px solid var(--tmm-accent);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 200;
  overflow: hidden;
}

.tmm-item:hover        > .tmm-panel,
.tmm-item:focus-within > .tmm-panel,
.tmm-item.open         > .tmm-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* AUTO — anchored to the item (position:relative on .tmm-item) */
.tmm-panel--auto {
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  min-width: 480px;
  max-width: calc(100vw - 3rem);
}
.tmm-item:hover        > .tmm-panel--auto,
.tmm-item:focus-within > .tmm-panel--auto,
.tmm-item.open         > .tmm-panel--auto {
  transform: translateX(-50%) translateY(0);
}

/* WIDE — fixed width, centred on .tmm-nav (position:static on .tmm-item) */
.tmm-panel--wide {
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: 860px;
  max-width: calc(100vw - 3rem);
}
.tmm-item:hover        > .tmm-panel--wide,
.tmm-item:focus-within > .tmm-panel--wide,
.tmm-item.open         > .tmm-panel--wide {
  transform: translateX(-50%) translateY(0);
}

/* FULL — edge-to-edge across .tmm-nav */
.tmm-panel--full {
  left: 0;
  right: 0;
  transform: translateY(4px);
}
.tmm-item:hover        > .tmm-panel--full,
.tmm-item:focus-within > .tmm-panel--full,
.tmm-item.open         > .tmm-panel--full {
  transform: translateY(0);
}

/* Panel inner padding (overridden by widget Dimensions control) */
.tmm-panel__inner {
  padding: 1.5rem 2rem;
}

/* Side-by-side layout when both child links AND a template are present */
.tmm-panel__inner.has-children.has-template {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

/* Auto-rendered WP child links column */
.tmm-panel__children {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  min-width: 160px;
  flex-shrink: 0;
}

.tmm-panel__child-item {
  list-style: none !important;
}

.tmm-panel__child-item a {
  display: block;
  padding: 0.45rem 0.75rem;
  color: var(--tmm-dd-text);
  text-decoration: none;
  white-space: nowrap;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.tmm-panel__child-item a:hover {
  color: var(--tmm-dd-hover);
  background: rgba(0, 0, 0, 0.04);
}

/* Template fills remaining space in side-by-side layout */
.tmm-panel__template {
  flex: 1;
  min-width: 0;
}

/* Let Elementor template content fill the panel naturally */
.tmm-panel .elementor               { margin: 0; }
.tmm-panel .elementor-section,
.tmm-panel .e-con                   { width: 100% !important; }

/* ── Hamburger ──────────────────────────────────────────────────── */
.tmm-hamburger {
  display: none; /* shown via per-widget media query */
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.25rem;
  height: 2.25rem;
  background: none;
  border: 1px solid var(--tmm-hamburger);
  border-radius: 3px;
  padding: 0.4rem;
  cursor: pointer;
  color: var(--tmm-hamburger);
  flex-shrink: 0;
}

.tmm-hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

/* Animate to × when panel is open */
.tmm-nav.is-open .tmm-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.tmm-nav.is-open .tmm-hamburger span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.tmm-nav.is-open .tmm-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Dim overlay (behind mobile panel) ─────────────────────────── */
.tmm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 298;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.tmm-nav.is-open .tmm-overlay {
  opacity: 1;
  pointer-events: auto;
}

/* ── Mobile slide-in panel ──────────────────────────────────────── */
.tmm-mobile {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 92vw);
  background: var(--tmm-mob-bg);
  z-index: 299;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

.tmm-nav.is-open .tmm-mobile {
  transform: translateX(0);
}

/* Panel header (close button) */
.tmm-mobile__head {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--tmm-dd-border);
  flex-shrink: 0;
}

.tmm-mobile__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--tmm-mob-link);
  border-radius: 3px;
  transition: background 0.15s;
}
.tmm-mobile__close:hover { background: rgba(0, 0, 0, 0.06); }
.tmm-mobile__close svg   { width: 1.1rem; height: 1.1rem; }

/* Nav list */
.tmm-mobile__list {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  flex: 1;
}

.tmm-mobile__item {
  border-bottom: 1px solid var(--tmm-dd-border);
}
.tmm-mobile__item:last-child { border-bottom: none; }

.tmm-mobile__row {
  display: flex;
  align-items: center;
}

.tmm-mobile__link {
  flex: 1;
  display: block;
  padding: 0.9rem 1.25rem;
  color: var(--tmm-mob-link);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  transition: color 0.15s;
}
.tmm-mobile__link:hover { color: var(--tmm-mob-accent); }

/* Accordion toggle */
.tmm-mobile__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--tmm-mob-link);
  flex-shrink: 0;
  padding: 0;
  transition: color 0.15s;
}
.tmm-mobile__toggle svg {
  width: 1rem;
  height: 1rem;
  transition: transform 0.25s ease;
}
.tmm-mobile__item.is-open .tmm-mobile__toggle       { color: var(--tmm-mob-accent); }
.tmm-mobile__item.is-open .tmm-mobile__toggle svg   { transform: rotate(180deg); }

/* Child links */
.tmm-mobile__children {
  display: none;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.03);
  border-top: 1px solid var(--tmm-dd-border);
}
.tmm-mobile__item.is-open .tmm-mobile__children { display: flex; }

.tmm-mobile__child {
  display: block;
  padding: 0.7rem 1.25rem 0.7rem 2rem;
  color: var(--tmm-dd-text);
  text-decoration: none;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--tmm-dd-border);
  transition: color 0.15s, background 0.15s;
}
.tmm-mobile__child:last-child { border-bottom: none; }
.tmm-mobile__child:hover {
  color: var(--tmm-mob-accent);
  background: rgba(0, 0, 0, 0.04);
}

/* ── Body scroll lock ───────────────────────────────────────────── */
body.tmm-locked { overflow: hidden; }

/* ── Editor placeholder ─────────────────────────────────────────── */
.tmm-placeholder {
  padding: 2rem;
  text-align: center;
  background: #f8f8f8;
  border: 2px dashed #ddd;
  color: #999;
  font-size: 0.875rem;
  border-radius: 4px;
}

/* ═══════════════════════════════════════════════════════════════════
   OPEN ANIMATION TYPES
   Class added to Elementor widget wrapper via prefix_class.
   Default (slide-down) = existing translateY behaviour — no rules needed.
═══════════════════════════════════════════════════════════════════ */

/* ── Fade — opacity only, no transform offset ───────────────────── */
.tmm-dd-anim-fade .tmm-dropdown,
.tmm-dd-anim-fade .tmm-item:hover        > .tmm-dropdown,
.tmm-dd-anim-fade .tmm-item:focus-within > .tmm-dropdown,
.tmm-dd-anim-fade .tmm-item.open         > .tmm-dropdown {
  transform: translateX(-50%);
}

.tmm-dd-anim-fade .tmm-panel--auto,
.tmm-dd-anim-fade .tmm-panel--wide,
.tmm-dd-anim-fade .tmm-item:hover        > .tmm-panel--auto,
.tmm-dd-anim-fade .tmm-item:focus-within > .tmm-panel--auto,
.tmm-dd-anim-fade .tmm-item.open         > .tmm-panel--auto,
.tmm-dd-anim-fade .tmm-item:hover        > .tmm-panel--wide,
.tmm-dd-anim-fade .tmm-item:focus-within > .tmm-panel--wide,
.tmm-dd-anim-fade .tmm-item.open         > .tmm-panel--wide {
  transform: translateX(-50%);
}

.tmm-dd-anim-fade .tmm-panel--full,
.tmm-dd-anim-fade .tmm-item:hover        > .tmm-panel--full,
.tmm-dd-anim-fade .tmm-item:focus-within > .tmm-panel--full,
.tmm-dd-anim-fade .tmm-item.open         > .tmm-panel--full {
  transform: none;
}

/* ── Scale — grow in from slightly small ────────────────────────── */
.tmm-dd-anim-scale .tmm-dropdown {
  transform: translateX(-50%) scale(0.95);
  transform-origin: top center;
}
.tmm-dd-anim-scale .tmm-item:hover        > .tmm-dropdown,
.tmm-dd-anim-scale .tmm-item:focus-within > .tmm-dropdown,
.tmm-dd-anim-scale .tmm-item.open         > .tmm-dropdown {
  transform: translateX(-50%) scale(1);
}

.tmm-dd-anim-scale .tmm-panel--auto,
.tmm-dd-anim-scale .tmm-panel--wide {
  transform: translateX(-50%) scale(0.97);
  transform-origin: top center;
}
.tmm-dd-anim-scale .tmm-item:hover        > .tmm-panel--auto,
.tmm-dd-anim-scale .tmm-item:focus-within > .tmm-panel--auto,
.tmm-dd-anim-scale .tmm-item.open         > .tmm-panel--auto,
.tmm-dd-anim-scale .tmm-item:hover        > .tmm-panel--wide,
.tmm-dd-anim-scale .tmm-item:focus-within > .tmm-panel--wide,
.tmm-dd-anim-scale .tmm-item.open         > .tmm-panel--wide {
  transform: translateX(-50%) scale(1);
}

.tmm-dd-anim-scale .tmm-panel--full {
  transform: scale(0.98);
  transform-origin: top center;
}
.tmm-dd-anim-scale .tmm-item:hover        > .tmm-panel--full,
.tmm-dd-anim-scale .tmm-item:focus-within > .tmm-panel--full,
.tmm-dd-anim-scale .tmm-item.open         > .tmm-panel--full {
  transform: scale(1);
}

/* ═══════════════════════════════════════════════════════════════════
   HOVER NUDGE
   .tmm-nudge-yes        = enabled
   .tmm-nudge-dir-right  = nudge right
   .tmm-nudge-dir-left   = nudge left
   --tmm-nudge           = distance (CSS var set via Elementor selectors)
═══════════════════════════════════════════════════════════════════ */

.tmm-nudge-yes .tmm-child a,
.tmm-nudge-yes .tmm-panel__child-item a {
  transition: color 0.15s, background 0.15s, transform 0.2s ease;
}

.tmm-nudge-yes.tmm-nudge-dir-right .tmm-child a:hover,
.tmm-nudge-yes.tmm-nudge-dir-right .tmm-panel__child-item a:hover {
  transform: translateX(var(--tmm-nudge, 6px));
}

.tmm-nudge-yes.tmm-nudge-dir-left .tmm-child a:hover,
.tmm-nudge-yes.tmm-nudge-dir-left .tmm-panel__child-item a:hover {
  transform: translateX(calc(-1 * var(--tmm-nudge, 6px)));
}

/* ═══════════════════════════════════════════════════════════════════
   NUMBERED ITEMS
   .tmm-numbered-yes = enabled
   Numbers use CSS counters — no markup changes required.
═══════════════════════════════════════════════════════════════════ */

.tmm-numbered-yes .tmm-dropdown {
  counter-reset: tmm-dd-n;
}
.tmm-numbered-yes .tmm-dropdown .tmm-child {
  counter-increment: tmm-dd-n;
}
.tmm-numbered-yes .tmm-dropdown .tmm-child a::before {
  content: counter(tmm-dd-n, decimal-leading-zero);
  display: inline-block;
  margin-right: 0.7em;
  opacity: 0.45;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.tmm-numbered-yes .tmm-panel__children {
  counter-reset: tmm-panel-n;
}
.tmm-numbered-yes .tmm-panel__child-item {
  counter-increment: tmm-panel-n;
}
.tmm-numbered-yes .tmm-panel__child-item a::before {
  content: counter(tmm-panel-n, decimal-leading-zero);
  display: inline-block;
  margin-right: 0.7em;
  opacity: 0.45;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
