/* ============================================================
   DERRICK ADVISORY — TOOLS CONTEXT NAVIGATION
   Restructures the top navigation's "Tools" item into a context
   menu grouped into three sections (Financial Tools / Customer
   Management / Insurance Operations). One config object in
   assets/js/mega-nav.js drives both the desktop click-to-reveal
   panel and the mobile in-menu accordion — add an item there and
   it appears in both places automatically.

   Reuses design-system.css tokens (--navy-*, --gold-*, --t-*, --s-*)
   so it matches the existing nav exactly — no new colors, fonts,
   or spacing scale introduced.
   ============================================================ */

/* ── Primary nav trigger (the "Tools" button in .da-nav-links) ── */
.da-nav-trigger {
  appearance: none;
  background: none;
  border: none;
  font: inherit;
  font-size: var(--t-sm);
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.01em;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px; /* was 5px — a touch more breathing room before the caret */
  transition: color var(--t-fast);
  position: relative;
}

.da-nav-trigger:hover { color: var(--white); }

.da-nav-caret-sm {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
  transition: transform var(--t-fast);
  opacity: 0.65;
}

.da-nav-trigger[aria-expanded="true"] { color: var(--white); }
.da-nav-trigger[aria-expanded="true"] .da-nav-caret-sm { transform: rotate(180deg); opacity: 1; }

.da-nav-trigger.da-active {
  color: var(--white);
  font-weight: 700; /* brighter/more prominent active state — same white, more weight */
}

/* Same -4px offset as .da-nav-links a.da-active::after in
   design-system.css, so the Tools trigger's active underline sits at
   the same height as every plain nav link's — not the old orphaned
   file's -22px, which sat far enough below the text to look
   disconnected from the nav bar entirely. */
.da-nav-trigger.da-active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0; right: 0;
  height: 2px;
  background: var(--gold-400);
  border-radius: 2px;
}

/* ── Desktop panel: backdrop + panel shell (Apple/MS-Docs style
   click-to-reveal, not hover) ── */
.da-mega-backdrop {
  position: fixed;
  inset: 0;
  top: var(--nav-h);
  background: rgba(3, 10, 26, 0.38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 280ms ease, visibility 280ms ease;
  z-index: 210;
}

.da-mega-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.da-mega-panel {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  z-index: 220;
  background: rgba(5, 15, 34, 0.98);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 260ms ease, transform 260ms ease, visibility 260ms ease;
  max-height: calc(100vh - var(--nav-h));
  overflow-y: auto;
}

.da-mega-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.da-mega-inner {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding: clamp(28px, 3.5vw, 44px) clamp(var(--s-5), 5vw, var(--s-12));
}

.da-mega-eyebrow {
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-300);
  margin-bottom: 20px;
}

/* ── Tools groups: three named sections, each a plain link list
   (a professional workspace directory, not marketing cards) ── */
.da-tools-groups {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(24px, 3vw, 40px);
}

.da-tools-group-title {
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.da-tools-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255,255,255,0.82);
  padding: 10px 0;
  transition: color var(--t-fast), transform var(--t-fast);
}

.da-tools-link:hover,
.da-tools-link:focus-visible {
  color: var(--gold-300);
  transform: translateX(3px);
  outline: none;
}

.da-tools-link.is-current {
  color: var(--white);
}

.da-tools-link.is-current::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-400);
  flex-shrink: 0;
}

/* ── Mobile: accordion toggle + nested panel inside #mobile-menu ── */
/* Deliberately NOT sharing the .mobile-nav-link class here — each
   page's inline hamburger script attaches a "close the whole
   overlay" click handler to every .mobile-nav-link, which is right
   for a real link but wrong for this in-place accordion toggle.
   Styled to match .da-mobile-menu a exactly instead (see
   design-system.css) so it's visually indistinguishable. */
.da-mobile-tools-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
  font-size: var(--t-2xl);
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  padding: var(--s-4) 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  transition: color var(--t-fast);
}

.da-mobile-tools-toggle:hover { color: var(--gold-300); }

.da-mobile-tools-toggle .da-nav-caret-sm {
  width: 13px;
  height: 13px;
  opacity: 0.55;
}

.da-mobile-tools-toggle[aria-expanded="true"] { color: var(--white); }
.da-mobile-tools-toggle[aria-expanded="true"] .da-nav-caret-sm { transform: rotate(180deg); opacity: 1; }

.da-mobile-tools-panel {
  padding: var(--s-2) 0 var(--s-4) var(--s-4);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.da-mobile-tools-panel[hidden] { display: none; }

.da-mobile-tools-group { padding: var(--s-3) 0; }

.da-mobile-tools-group-title {
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  margin-bottom: 6px;
}

.da-mobile-tools-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-base, 1rem);
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  padding: var(--s-2) 0;
}

.da-mobile-tools-link:hover { color: var(--gold-300); }

.da-mobile-tools-link.is-current { color: var(--white); }

.da-mobile-tools-link.is-current::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-400);
  flex-shrink: 0;
}

/* ── Responsive: desktop panel only above the same 768px breakpoint
   where .da-nav-links (and its Tools trigger) is visible; the
   mobile accordion lives inside #mobile-menu, which only exists
   below that breakpoint — see design-system.css's .da-nav-links /
   .da-nav-toggle media rule. ── */
@media (max-width: 768px) {
  .da-mega-backdrop,
  .da-mega-panel { display: none; }
}

@media (max-width: 900px) {
  .da-tools-groups { grid-template-columns: 1fr; gap: 22px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .da-mega-panel, .da-mega-backdrop, .da-nav-caret-sm, .da-tools-link {
    transition-duration: 0.01ms !important;
  }
}
