/*
 * EPR header system: top bar, brand lockup, primary navigation, chevron indicators,
 * dropdown panels and the mobile accordion.
 *
 * Additive stylesheet. It loads after the theme stylesheet and its inline additions and
 * supersedes their header rules through specificity (":root" prefix), so no existing file
 * is edited. Behaviour lives in assets/js/epr-primary-navigation.js.
 *
 * State classes: li.submenu-open, nav.is-open, li.is-flip-end, header.is-stuck.
 * Design tokens: EPR Institutional Heritage. Indicators are chevrons only.
 */

/* =====================================================================
   1. TOP BAR  (contacts left, statement centre, social right)
   ===================================================================== */
:root .epr-topbar {
  position: relative;
  z-index: 32;
  background: var(--epr-ink);
  color: #d6e0e5;
  font-size: .8125rem;
  line-height: 1.2;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
:root .epr-topbar__inner {
  width: min(calc(100% - 48px), var(--epr-content));
  min-height: 40px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 24px;
}
:root .epr-topbar ul {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}
:root .epr-topbar__contacts { justify-content: flex-start; min-width: 0; }
:root .epr-topbar__contacts li { display: flex; align-items: center; min-width: 0; }
:root .epr-topbar__contacts li + li {
  margin-left: 18px;
  padding-left: 18px;
  border-left: 1px solid rgba(255, 255, 255, .16);
}
:root .epr-topbar .epr-topbar__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: #e7eef1;
  font-weight: 500;
  letter-spacing: .01em;
  text-decoration: none;
  white-space: nowrap;
}
:root .epr-topbar .epr-topbar__link:hover {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}
:root .epr-topbar .epr-hs-icon { width: 15px; height: 15px; flex: 0 0 auto; }
:root .epr-topbar .epr-topbar__link .epr-hs-icon { color: var(--epr-accent); }
:root .epr-topbar__statement {
  margin: 0;
  overflow: hidden;
  color: #d6e0e5;
  font-weight: 500;
  letter-spacing: .035em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
:root .epr-topbar__social { justify-content: flex-end; gap: 2px; }
:root .epr-topbar .epr-topbar__social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  color: #d6e0e5;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
:root .epr-topbar .epr-topbar__social a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
:root .epr-topbar .epr-topbar__social .epr-hs-icon { width: 16px; height: 16px; }

/* ---- top bar: responsive ---- */
@media (max-width: 1100px) {
  :root .epr-topbar { font-size: .78rem; }
  :root .epr-topbar__inner { column-gap: 16px; }
}
@media (max-width: 900px) {
  :root .epr-topbar__inner { grid-template-columns: minmax(0, 1fr) auto; }
  :root .epr-topbar__statement { display: none; }
}
@media (max-width: 640px) {
  :root .epr-topbar__inner { width: min(calc(100% - 28px), var(--epr-content)); }
  :root .epr-topbar__contacts li + li { margin-left: 4px; padding-left: 4px; border-left: 0; }
  :root .epr-topbar .epr-topbar__link { width: 40px; justify-content: center; }
  :root .epr-topbar__text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
  :root .epr-topbar .epr-topbar__social a { width: 36px; height: 40px; }
}

/* =====================================================================
   2. HEADER SHELL AND BRAND LOCKUP
   ===================================================================== */
:root .epr-site-header {
  background: #fff;
  border-bottom: 1px solid var(--epr-line);
  box-shadow: none;
  transition: box-shadow .2s ease;
}
:root .epr-site-header.is-stuck { box-shadow: 0 6px 20px rgba(38, 52, 58, .08); }
:root .epr-header-inner { min-height: 84px; gap: clamp(16px, 2.2vw, 36px); }

:root .epr-brand__logo { display: flex; align-items: center; }
:root .epr-brand__logo .custom-logo-link {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--epr-ink);
  text-decoration: none;
}
:root .epr-brand__logo .custom-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 60px;
  max-height: 60px;
  object-fit: contain;
}
:root .epr-wordmark {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding-left: 14px;
  border-left: 1px solid var(--epr-line-strong);
}
:root .epr-wordmark__name {
  color: var(--epr-ink);
  font-family: var(--epr-font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1;
}
:root .epr-wordmark__sub {
  color: var(--epr-secondary);
  font-size: .66rem;
  font-weight: 500;
  letter-spacing: .07em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}
@media (min-width: 1241px) { :root .epr-wordmark { display: flex; } }
@media (min-width: 561px) and (max-width: 900px) { :root .epr-wordmark { display: flex; } }

/* =====================================================================
   3. PRIMARY NAVIGATION: shared
   ===================================================================== */
/* No grey/blue tap flash on touch devices. */
:root .epr-primary-navigation a,
:root .epr-primary-navigation button,
:root .epr-menu-toggle,
:root .epr-topbar a { -webkit-tap-highlight-color: transparent; }

/* Legacy boxed toggle buttons must never render. */
:root .epr-primary-navigation .epr-submenu-toggle { display: none !important; }

/* Chevron indicator (inline SVG inserted by the script) */
:root .epr-primary-navigation .epr-nav-chevron {
  display: inline-flex;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  margin-left: 6px;
  color: currentColor;
  transition: transform .12s ease;
}
:root .epr-primary-navigation .epr-nav-chevron svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
:root .epr-primary-navigation [aria-expanded="true"] > .epr-nav-chevron { transform: rotate(180deg); }

/* Chevron-only button, created only when a parent label is a real link. */
:root .epr-primary-navigation .epr-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 24px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
  color: var(--epr-ink);
  font: inherit;
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
:root .epr-primary-navigation .epr-nav-toggle .epr-nav-chevron { margin-left: 0; }
:root .epr-primary-navigation .epr-nav-toggle:hover { color: var(--epr-accent-deep); }
:root .epr-primary-navigation .epr-nav-toggle:focus-visible,
:root .epr-primary-navigation .epr-primary-menu > li > a:focus-visible {
  outline: 2px solid var(--epr-accent-deep);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Top-level labels.
   ROOT-CAUSE FIX: legacy CSS draws a chevron with ".menu-item-has-children > a:after", but that
   same pseudo-element is the hover underline (absolute, accent background). The two rules merged
   into a 6px accent-blue square rotated 45deg. The underline is redefined here in full so no
   chevron properties can leak into it. */
:root .epr-primary-navigation .epr-primary-menu > li > a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 0;
  color: var(--epr-ink);
  font-size: .9rem;
  font-weight: 500;
  letter-spacing: .005em;
  white-space: nowrap;
}
:root .epr-primary-navigation .epr-primary-menu > li > a[role="button"] { cursor: pointer; }
:root .epr-primary-navigation .epr-primary-menu > li > a:after {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5px;
  width: auto;
  height: 2px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 1px;
  background: var(--epr-accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .18s ease;
}
:root .epr-primary-navigation .epr-primary-menu > li > a:hover,
:root .epr-primary-navigation .epr-primary-menu > li.submenu-open > a,
:root .epr-primary-navigation .epr-primary-menu > li.current-menu-item > a,
:root .epr-primary-navigation .epr-primary-menu > li.current-menu-ancestor > a,
:root .epr-primary-navigation .epr-primary-menu > li.current_page_item > a { color: var(--epr-accent-deep); }
:root .epr-primary-navigation .epr-primary-menu > li:hover > a:after,
:root .epr-primary-navigation .epr-primary-menu > li.submenu-open > a:after,
:root .epr-primary-navigation .epr-primary-menu > li.current-menu-item > a:after,
:root .epr-primary-navigation .epr-primary-menu > li.current-menu-ancestor > a:after,
:root .epr-primary-navigation .epr-primary-menu > li.current_page_item > a:after { transform: scaleX(1); }
/* Legacy pseudo-chevrons inside panels are not used. */
:root .epr-primary-navigation .sub-menu a:after { content: none; }

/* Submenu panel: shared look */
:root .epr-primary-navigation .epr-primary-menu .sub-menu {
  margin: 0;
  padding: 8px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--epr-line);
  border-top: 3px solid var(--epr-accent);
  border-radius: 0 0 4px 4px;
}
:root .epr-primary-navigation .epr-primary-menu .sub-menu a {
  display: block;
  padding: 10px 12px;
  border: 0;
  border-radius: 3px;
  color: var(--epr-ink);
  font-size: .88rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: normal;
}
:root .epr-primary-navigation .epr-primary-menu .sub-menu a:hover,
:root .epr-primary-navigation .epr-primary-menu .sub-menu a:focus-visible {
  background: var(--epr-surface);
  color: var(--epr-accent-deep);
}
:root .epr-primary-navigation .epr-primary-menu .sub-menu a:focus-visible {
  outline: 2px solid var(--epr-accent-deep);
  outline-offset: -2px;
}
:root .epr-primary-navigation .epr-primary-menu .sub-menu .current-menu-item > a {
  color: var(--epr-accent-deep);
  background: var(--epr-surface);
}

/* =====================================================================
   4. PRIMARY NAVIGATION: desktop
   ===================================================================== */
@media (min-width: 901px) {
  /* The menu column spans the full header height, so the pointer never crosses a dead
     zone between a label and its panel. */
  :root .epr-primary-navigation {
    display: flex;
    align-items: stretch;
    align-self: stretch;
    margin-left: auto;
  }
  :root .epr-primary-navigation .epr-primary-menu {
    align-items: stretch;
    gap: clamp(10px, 1.45vw, 22px);
  }
  :root .epr-primary-navigation .epr-primary-menu > li {
    position: relative;
    display: flex;
    align-items: center;
    column-gap: 0;
  }

  /* Panel sits flush under the item (no gap), is always hit-testable, and is hidden with
     visibility so closed links leave the tab order. */
  :root .epr-primary-navigation .epr-primary-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: -14px;
    z-index: 40;
    width: max-content;
    min-width: 250px;
    max-width: 340px;
    max-width: min(340px, calc(100vw - 32px));
    box-shadow: 0 10px 24px rgba(38, 52, 58, .10);
    visibility: hidden;
    opacity: 0;
    transform: none;
    pointer-events: auto;
    transition: opacity .12s ease, visibility 0s linear .12s;
  }
  /* Legacy rules hide closed panels with display:none at some widths; keep them laid out. */
  :root .epr-primary-navigation .epr-primary-menu li.menu-item-has-children:not(.submenu-open) > .sub-menu {
    display: block !important;
  }
  :root .epr-primary-navigation .epr-primary-menu li.submenu-open > .sub-menu {
    visibility: visible;
    opacity: 1;
    transition: opacity .12s ease, visibility 0s linear 0s;
  }
  /* With JavaScript the script owns open/closed state, so CSS hover must not reveal panels. */
  :root.epr-js .epr-primary-navigation .epr-primary-menu li:not(.submenu-open) > .sub-menu {
    visibility: hidden;
    opacity: 0;
  }
  /* Without JavaScript, fall back to hover and focus. */
  :root:not(.epr-js) .epr-primary-navigation .epr-primary-menu li:hover > .sub-menu,
  :root:not(.epr-js) .epr-primary-navigation .epr-primary-menu li:focus-within > .sub-menu {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
  }
  /* Panels near the right edge open leftwards (class set by the script). */
  :root .epr-primary-navigation .epr-primary-menu li.is-flip-end > .sub-menu { left: auto; right: -14px; }

  /* Third level, only if the menu depth is raised later: flyout to the right. */
  :root .epr-primary-navigation .epr-primary-menu .sub-menu li { position: relative; }
  :root .epr-primary-navigation .epr-primary-menu .sub-menu .sub-menu { top: -11px; left: 100%; }
  :root .epr-primary-navigation .epr-primary-menu .sub-menu li.menu-item-has-children { display: flex; align-items: center; }
  :root .epr-primary-navigation .epr-primary-menu .sub-menu li.menu-item-has-children > a { flex: 1 1 auto; }
  :root .epr-primary-navigation .epr-primary-menu .sub-menu li.menu-item-has-children > a[role="button"] {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  :root .epr-primary-navigation .epr-primary-menu .sub-menu .epr-nav-chevron { transform: rotate(-90deg); }
  :root .epr-primary-navigation .epr-primary-menu .sub-menu [aria-expanded="true"] > .epr-nav-chevron { transform: rotate(90deg); }
}
@media (min-width: 901px) and (max-width: 1100px) {
  :root .epr-primary-navigation .epr-primary-menu > li > a { font-size: .8rem; }
  :root .epr-primary-navigation .epr-primary-menu { gap: 10px; }
  :root .epr-primary-navigation .epr-nav-chevron { margin-left: 4px; }
}

/* =====================================================================
   5. MOBILE AND TABLET: menu panel with accordion
   ===================================================================== */
@media (max-width: 900px) {
  :root .epr-header-inner { min-height: 68px; }
  :root .epr-brand__logo .custom-logo { max-width: 48px; max-height: 48px; }
  :root .epr-wordmark__name { font-size: 1.15rem; }

  :root .epr-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin: 0;
    padding: 0 10px 0 14px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    color: var(--epr-ink);
    font: inherit;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
  }
  :root .epr-menu-toggle:hover { background: var(--epr-surface); }
  :root .epr-menu-toggle .epr-menu-toggle__icon { width: 20px; margin-left: 0; gap: 5px; }
  :root .epr-menu-toggle__icon i { height: 2px; transition: transform .15s ease, opacity .15s ease; }
  :root .epr-menu-toggle[aria-expanded="true"] .epr-menu-toggle__icon i:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  :root .epr-menu-toggle[aria-expanded="true"] .epr-menu-toggle__icon i:nth-child(2) { opacity: 0; }
  :root .epr-menu-toggle[aria-expanded="true"] .epr-menu-toggle__icon i:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  :root .epr-primary-navigation { box-shadow: 0 18px 30px rgba(38, 52, 58, .10); }
  :root .epr-primary-navigation .epr-primary-menu > li {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    border-bottom: 1px solid var(--epr-line);
  }
  :root .epr-primary-navigation .epr-primary-menu > li:last-child { border-bottom: 0; }
  :root .epr-primary-navigation .epr-primary-menu > li > a {
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    padding: 12px 4px;
    border-bottom: 0;
    font-size: .95rem;
    white-space: normal;
  }
  :root .epr-primary-navigation .epr-primary-menu > li > a:after { display: none; }
  :root .epr-primary-navigation .epr-primary-menu > li > a[role="button"] { justify-content: space-between; }
  :root .epr-primary-navigation .epr-primary-menu > li > a[role="button"] .epr-nav-chevron {
    width: 14px;
    height: 14px;
    margin-left: 12px;
  }
  :root .epr-primary-navigation .epr-nav-toggle { width: 48px; min-height: 48px; }

  :root .epr-primary-navigation .epr-primary-menu .sub-menu {
    position: static;
    display: none;
    flex: 0 0 100%;
    width: auto;
    min-width: 0;
    max-width: none;
    margin: 0 0 10px 4px;
    padding: 2px 0 2px 12px;
    border: 0;
    border-left: 2px solid var(--epr-line-strong);
    border-radius: 0;
    box-shadow: none;
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: none;
  }
  :root .epr-primary-navigation .epr-primary-menu li.submenu-open > .sub-menu { display: block; }
  /* Beats the legacy hover/focus-within reveal rules. */
  :root.epr-js .epr-primary-navigation .epr-primary-menu li:not(.submenu-open) > .sub-menu { display: none; }
  :root .epr-primary-navigation .epr-primary-menu .sub-menu a { padding: 11px 8px; font-size: .92rem; }
  :root .epr-primary-navigation .epr-primary-menu .sub-menu li.menu-item-has-children { display: block; }
  :root .epr-primary-navigation .epr-primary-menu .sub-menu .epr-nav-chevron { transform: none; }
  :root .epr-primary-navigation .epr-primary-menu .sub-menu [aria-expanded="true"] > .epr-nav-chevron { transform: rotate(180deg); }

  /* Without JavaScript the hamburger cannot work, so show the full menu expanded. */
  :root:not(.epr-js) .epr-menu-toggle { display: none; }
  :root:not(.epr-js) .epr-primary-navigation { display: block; }
  :root:not(.epr-js) .epr-primary-navigation .epr-primary-menu .sub-menu { display: block !important; }
}

@media (prefers-reduced-motion: reduce) {
  :root .epr-site-header,
  :root .epr-primary-navigation .epr-primary-menu .sub-menu,
  :root .epr-primary-navigation .epr-nav-chevron,
  :root .epr-primary-navigation .epr-primary-menu > li > a:after,
  :root .epr-menu-toggle__icon i,
  :root .epr-topbar .epr-topbar__social a { transition: none !important; }
}