/* Mega-menu layout applied by navbar-megamenu.js to the Data,
   Documentation, and Tools navbar dropdowns. Scoped to .ddp-mega so
   regular dropdowns (language switcher, etc.) are untouched.

   Browser support notes:
   - CSS Grid: universal in browsers from 2017 onward.
   - CSS custom properties: universal.
   - :has() (used to swap the divider line under a header onto a
     description that follows): Chrome 105+ / Safari 15.4+ / Firefox 121+.
     Older browsers fall back gracefully — header keeps its own line and
     the description appears below; only the visual ordering differs. */

/* ---------------------------------------------------------------- shell */

.navbar .dropdown-menu.ddp-mega {
  min-width: 820px;
  max-width: 90vw;
  padding: 0.6rem;
}

/* ----------------------------------------------------------------- grid */

.ddp-mega-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.25rem 1.25rem;
  align-items: start;
  width: 100%;
}
.ddp-mega--has-intro .ddp-mega-grid {
  /* Fixed-width intro column on the left, two equal content columns. */
  grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1fr);
}

.ddp-mega-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------- intro column */

.ddp-mega-col--intro {
  /* Hardcoded dark text colors — Bootstrap 5.3's color modes inherit the
     dark navbar's text color into the dropdown otherwise. */
  padding: 0.5rem 0.9rem 0.5rem 0.4rem;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  color: #2C3E50;
}
.ddp-mega-intro-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.1;
  color: #2C3E50;
  margin-bottom: 0.5rem;
}
.ddp-mega-intro-desc {
  font-size: 0.82rem;
  line-height: 1.4;
  color: #5b6770;
  margin-bottom: 0.6rem;
}
.ddp-mega-intro-links {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 0.4rem;
  margin-top: 0.2rem;
}
.ddp-mega-intro-links .dropdown-item {
  display: flex;
  align-items: center;
  padding: 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #1E3A5F;
}
.ddp-mega-intro-links .dropdown-item .bi {
  flex-shrink: 0;
  margin-right: 0.55rem;
  font-size: 1rem;
  color: var(--bs-primary, #0d6efd);
}

/* ------------------------------------------- category headers (in-column) */

/* Quarto emits text-only menu entries as <li class="dropdown-header">. We
   also tag selected dropdown-items with .ddp-mega-section-header so a
   single-link "header" (like "Agency reports") picks up the same heading
   typeface while remaining clickable. */
.ddp-mega-col .dropdown-header,
.ddp-mega-col a.dropdown-item.ddp-mega-section-header {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  text-transform: none;        /* override theme uppercase */
  letter-spacing: 0;
  color: #2C3E50;
  padding: 0.55rem 0.6rem 0.2rem;
  margin: 0.35rem 0 0.6rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  white-space: normal;
}
.ddp-mega-col a.dropdown-item.ddp-mega-section-header {
  text-decoration: none;
}
.ddp-mega-col a.dropdown-item.ddp-mega-section-header:hover,
.ddp-mega-col a.dropdown-item.ddp-mega-section-header:focus {
  color: #1E3A5F;
}
.ddp-mega-col > .dropdown-header:first-child,
.ddp-mega-col > a.ddp-mega-section-header:first-child {
  margin-top: 0;
}
/* When a category description follows immediately, push the dividing line
   down onto the description instead of the header so the description sits
   "above the line". (Requires :has() — falls back to keeping the line on
   the header in older browsers, which is acceptable.) */
.ddp-mega-col .dropdown-header:has(+ .ddp-mega-cat-desc),
.ddp-mega-col a.dropdown-item.ddp-mega-section-header:has(+ .ddp-mega-cat-desc),
.ddp-mega-col a.dropdown-item:has(.ddp-mega-acronym):has(+ .ddp-mega-cat-desc) {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* ----------------------------------------------------- regular dropdown items */

.ddp-mega-col .dropdown-item {
  padding: 0.3rem 0.6rem;
  font-size: 0.9rem;
  white-space: normal;
}

/* Sub-bullet items (rendered with a leading bi-dot icon) get a slightly
   smaller, tighter treatment so they read as children of the agency above. */
.ddp-mega-col .dropdown-item:has(i.bi-dot) {
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  line-height: 1.35;
}

/* ----------------------------------------- acronym + full-name two-line items */

.ddp-mega-acronym {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
}
.ddp-mega-fullname {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.3;
  margin-top: 0.05rem;
  white-space: normal;
  /* Tonal-down of the inherited dropdown-item color rather than a fixed
     gray, so it stays readable if the dropdown text color changes. */
  opacity: 0.62;
}
.ddp-mega-col .dropdown-item:has(.ddp-mega-acronym) {
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}
/* In the Documentation menu the acronym items (ICE / CBP / EOIR / EOUSA)
   ARE the section headers, so they get a divider line below to separate
   them from the sub-bullets they head. In the Data menu the same items
   sit under "Processed data" / "Original data" headers — no extra line. */
.ddp-mega--docs .ddp-mega-col .dropdown-item:has(.ddp-mega-acronym) {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 0.6rem;
}

/* Breathing room above an agency item that starts a new section directly
   after the previous agency's sub-bullets. Navbar dividers are dropped
   by navbar-megamenu.js (columns absorb the grouping), so the only
   signal left in the DOM is "bi-dot item followed by acronym item" —
   that's CBP / EOUSA in the Docs column layouts and EOIR in the Data
   Processed column. Tools items don't use .ddp-mega-acronym and
   single-line agencies in the Original-data column don't follow
   bi-dot siblings, so neither gets matched. */
.ddp-mega-col .dropdown-item:has(i.bi-dot) + .dropdown-item:has(.ddp-mega-acronym) {
  margin-top: 0.75rem;
}

/* ---------------------------------------------------- category description */

.ddp-mega-cat-desc {
  font-size: 0.78rem;
  line-height: 1.35;
  color: #6c757d;
  padding: 0.35rem 0.6rem 0.45rem;
  margin: 0 0 0.6rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* ---------------------------------- viewport-aware horizontal placement */

/* The panel anchors under its trigger via Bootstrap's default
   (.dropdown is position:relative, .dropdown-menu is position:absolute
   with left:0). Rightmost triggers would push the 820px menu past the
   viewport's right edge, so navbar-megamenu.js measures on open and
   applies a negative inline `left` to clamp the panel back inside.
   Mobile (<768px) uses the stacked layout below and skips clamping. */

/* --------------------------------------------------------------- mobile */

/* Below the navbar's collapse breakpoint the mega-menu becomes a vertical
   stack so it works inside Bootstrap's hamburger-collapsed nav. */
@media (max-width: 767.98px) {
  .navbar .dropdown-menu.ddp-mega {
    min-width: 0;
    max-width: none;
  }
  .ddp-mega-grid,
  .ddp-mega--has-intro .ddp-mega-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .ddp-mega-col--intro {
    border-right: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-bottom: 0.6rem;
    margin-bottom: 0.4rem;
  }
}
