/*
 * ET Group Justice sub-nav (nav.etgj-subnav), from the designs. Scoped under .etgj; tokens from justice.css.
 * Items: Justice (home link), Overview, Solutions (Courts, Corrections), Services, Approach, Why ET Group,
 * Projects & Insights, and the Talk to a Justice Specialist button.
 * Desktop (over 1180px): one dark-glass bar, sticky under the theme header (--etg-header-h, measured by justice.js).
 * Solutions opens on click or tap, and on hover with a mouse; Esc closes it and returns focus to the trigger.
 * 1180px and under: a Menu / Close button opens the list as a panel under the bar; Solutions opens in place.
 * Active page: .is-active on the <li> and aria-current="page" on its link (on Courts and Corrections pages the
 * Solutions <li> gets .is-active and the current menu link gets aria-current).
 */
.etgj .etgj-subnav {
  --subnav-bg: rgba(20, 21, 23, .78); --subnav-blur: blur(18px) saturate(1.2);
  position: sticky; top: var(--etg-header-h, 0px); z-index: 400; /* below the theme header so its mega menus overlay */
  font-family: var(--ff); color: var(--ink); border-bottom: 1px solid var(--line);
  transition: box-shadow .2s ease, top .2s ease-in-out;
}
/* The theme header slides back in as position:fixed on scroll-up (body[data-sticky]) and would cover the bar:
   park everything that uses --etg-header-h under it. !important beats the inline value justice.js measured at load. */
body[data-sticky="header"] .etgj, body[data-sticky="header-in"] .etgj { --etg-header-h: var(--hb-offset, 0px) !important; }
/* the glass sits on a layer behind the bar, so the Solutions panel can blur what's under it too */
.etgj .etgj-subnav::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--subnav-bg); -webkit-backdrop-filter: var(--subnav-blur); backdrop-filter: var(--subnav-blur);
}
.etgj .etgj-subnav.is-stuck { box-shadow: 0 6px 24px rgba(0, 0, 0, .3); }
.etgj .etgj-subnav__inner { padding: 0 var(--etgj-edge); display: flex; align-items: center; min-height: var(--subnav-h); }
.etgj .etgj-subnav__home { display: inline-flex; align-items: center; gap: 10px; margin-right: 40px; font: 500 var(--fs-body)/1 var(--ff); color: inherit; text-decoration: none; }
.etgj .etgj-subnav__home::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.etgj .etgj-subnav__list { display: flex; align-items: center; flex: 1; gap: 2px; margin: 0; padding: 0; list-style: none; }
.etgj .etgj-subnav__item > a:not(.etgj-btn) {
  display: block; padding: 21px 12px 18px; border-bottom: 3px solid transparent;
  font-size: var(--fs-small); font-weight: 400; line-height: 22px; color: inherit; opacity: .72; text-decoration: none; white-space: nowrap;
}
.etgj .etgj-subnav__item > a:not(.etgj-btn):hover { opacity: 1; }
.etgj .etgj-subnav__item.is-active > a { opacity: 1; border-bottom-color: transparent; background: var(--accent-grad) left bottom / 100% 3px no-repeat; }
.etgj .etgj-subnav__item--cta { margin-left: auto; }

/* Solutions: Courts and Corrections under one trigger, a caret that turns when open */
.etgj .etgj-subnav__item--menu { position: relative; }
.etgj .etgj-subnav__trigger {
  display: inline-flex; align-items: center; gap: 6px; padding: 21px 12px 18px; border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer;
  font: 400 var(--fs-small)/22px var(--ff); color: inherit; opacity: .72; white-space: nowrap;
}
.etgj .etgj-subnav__trigger::after {
  content: ""; width: 12px; height: 12px; background: currentColor; transition: transform .2s ease;
  -webkit-mask: var(--icon-caret) center / contain no-repeat;
          mask: var(--icon-caret) center / contain no-repeat;
}
.etgj .etgj-subnav__trigger:hover, .etgj .etgj-subnav__trigger[aria-expanded="true"] { opacity: 1; }
.etgj .etgj-subnav__trigger[aria-expanded="true"]::after { transform: rotate(180deg); }
.etgj .etgj-subnav__item--menu.is-active > .etgj-subnav__trigger { opacity: 1; background: var(--accent-grad) left bottom / 100% 3px no-repeat; }
.etgj .etgj-subnav__menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 300px; margin: 0; padding: 8px; list-style: none;
  background: var(--subnav-bg); -webkit-backdrop-filter: var(--subnav-blur); backdrop-filter: var(--subnav-blur);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 30px rgba(0, 0, 0, .3);
  visibility: hidden; opacity: 0; translate: 0 -6px; pointer-events: none;
  transition: opacity .2s ease, translate .28s var(--ease-out), visibility 0s linear .28s;
}
/* keeps the hover unbroken across the gap between the bar and the panel */
.etgj .etgj-subnav__menu::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 14px; }
.etgj .etgj-subnav__item--menu.is-open .etgj-subnav__menu { visibility: visible; opacity: 1; translate: none; pointer-events: auto; transition: opacity .2s ease, translate .28s var(--ease-out), visibility 0s; }
.etgj .etgj-subnav__menu a { display: grid; gap: 2px; padding: 12px 14px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.etgj .etgj-subnav__menu a:hover, .etgj .etgj-subnav__menu a:focus-visible { background: rgba(255, 255, 255, .06); }
.etgj .etgj-subnav__menu-label { font: 500 var(--fs-small)/1.3 var(--ff); }
.etgj .etgj-subnav__menu-desc { font: 400 13px/1.35 var(--ff); color: var(--grey); }
.etgj .etgj-subnav__menu a[aria-current="page"] .etgj-subnav__menu-label { color: var(--ink); }

/* Menu / Close toggle (1180px and under): the two words share one slot and cross-fade */
.etgj .etgj-subnav__toggle {
  display: none; align-items: center; justify-content: center; margin-left: auto; min-height: 44px; min-width: 84px; padding: 0 18px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .24); border-radius: 6px; background: rgba(255, 255, 255, .06);
  font: 500 var(--fs-small)/1 var(--ff); color: inherit; transition: background-color .2s ease, border-color .2s ease;
}
.etgj .etgj-subnav__toggle:hover, .etgj .etgj-subnav__toggle[aria-expanded="true"] { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .36); }
.etgj .etgj-subnav__words { display: grid; line-height: 1.2; }
.etgj .etgj-subnav__words > span { grid-area: 1 / 1; text-align: center; transition: opacity .18s ease; }
.etgj .etgj-subnav__words > span + span { opacity: 0; }
.etgj .etgj-subnav__toggle[aria-expanded="true"] .etgj-subnav__words > span:first-child { opacity: 0; }
.etgj .etgj-subnav__toggle[aria-expanded="true"] .etgj-subnav__words > span + span,
.etgj .etgj-subnav__toggle[aria-expanded="false"] .etgj-subnav__words > span:first-child { opacity: 1; transition: opacity .22s ease .14s; }

@media (max-width: 1180px) {
  .etgj .etgj-subnav__toggle { display: inline-flex; }
  .etgj .etgj-subnav__home { margin-right: 0; min-height: 44px; }
  .etgj .etgj-subnav__list {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    visibility: hidden; opacity: 0; translate: 0 -8px; pointer-events: none;
    transition: opacity .28s ease, translate .42s var(--ease-out), visibility 0s linear .42s;
    padding: 8px var(--gutter) 24px; background: #0C1522; color: var(--ink); border-bottom: 1px solid var(--line);
    box-shadow: 0 16px 30px rgba(0, 0, 0, .4);
    /* never taller than the screen below the bars (landscape phones): scroll inside it */
    max-height: calc(100dvh - var(--subnav-h) - var(--etg-header-h, 0px)); overflow-y: auto; overscroll-behavior: contain;
  }
  .etgj .etgj-subnav.is-open .etgj-subnav__list { visibility: visible; opacity: 1; translate: none; pointer-events: auto; transition: opacity .28s ease, translate .42s var(--ease-out), visibility 0s; }
  .etgj .etgj-subnav__item > a:not(.etgj-btn) { padding: 15px 0 15px 12px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; font-size: var(--fs-body); opacity: 1; }
  .etgj .etgj-subnav__item.is-active > a { border-bottom-color: var(--line); border-left-color: transparent; background: var(--accent-grad-v) left top / 3px 100% no-repeat; }
  /* Solutions in the panel: a row like the others that opens in place */
  .etgj .etgj-subnav__trigger { display: flex; width: 100%; justify-content: space-between; padding: 15px 0 15px 12px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; font-size: var(--fs-body); opacity: 1; }
  .etgj .etgj-subnav__trigger::after { width: 16px; height: 16px; }
  .etgj .etgj-subnav__item--menu.is-active > .etgj-subnav__trigger { background: var(--accent-grad-v) left top / 3px 100% no-repeat; }
  .etgj .etgj-subnav__menu { position: static; display: none; min-width: 0; padding: 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; border: 0; border-radius: 0; box-shadow: none; visibility: visible; opacity: 1; translate: none; pointer-events: auto; transition: none; }
  .etgj .etgj-subnav__item--menu.is-open .etgj-subnav__menu { display: block; }
  .etgj .etgj-subnav__menu a { padding: 14px 0 14px 32px; border-bottom: 1px solid var(--line); border-radius: 0; }
  .etgj .etgj-subnav__menu a:hover { background: none; }
  .etgj .etgj-subnav__menu::before { display: none; }
  .etgj .etgj-subnav__menu-label { font-size: var(--fs-body); font-weight: 400; }
  .etgj .etgj-subnav__menu-desc { display: none; }
  .etgj .etgj-subnav__item--cta { margin: 20px 0 0; }
  .etgj .etgj-subnav__item--cta .etgj-btn { display: flex; width: 100%; }
}
@media (max-width: 960px) {
  .etgj .etgj-subnav__inner { min-height: var(--subnav-h); }
}
@media (prefers-reduced-motion: reduce) {
  .etgj :is(.etgj-subnav, .etgj-subnav__menu, .etgj-subnav__list, .etgj-subnav__words > span),
  .etgj .etgj-subnav__trigger::after { transition: none !important; }
}
