/* Shared site header and grouped navigation (v35). One Menu button beside the site name on every page.
   >= 721 px: right-aligned dropdown with all three groups open. <= 720 px: full-width sheet with collapsible groups.
   Replaces the per-page header/nav/accent-bar rules that used to live in styles.css, bmi.css, hrz.css and meditation.css.
   No images, no inline style, no stored state. js/nav.js adds the "js" class on <html>; without it the grouped list is always visible. */
:root {
  --nav-navy: #253c57;
  --nav-muted: #456974;
  --nav-green: #13fb0c;
  --nav-gray: #f2f2f2;
  --nav-ice: #d3f1f5;
  --nav-edge: #e8eaec;
  --nav-ink: #18293d;
  --nav-offset: 72px; /* header + top accent bar; larger steps below for a header that wraps to more lines (narrow screens, 200% zoom) */
}
@media (max-width: 340px) { :root { --nav-offset: 112px; } }
@media (max-width: 300px) { :root { --nav-offset: 190px; } }

/* ---------- header (all widths) ---------- */
.accent-bar { display: none; height: 16px; background: var(--nav-green); }
.site-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 68px;
  padding: 10px 24px 10px 32px;
  background: #fff;
  border-bottom: 1px solid var(--nav-edge);
}
.brand {
  position: relative;
  z-index: 3;
  display: block;
  flex: 0 1 auto;
  margin-right: auto; /* the link is only as wide as the site name, not the whole empty header */
  min-width: 0;
  color: var(--nav-navy);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.menu-toggle {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 48px;
  min-height: 48px;
  margin: 0;
  padding: 12px 14px;
  background: transparent;
  color: var(--nav-navy);
  border: 0;
  border-radius: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(37, 60, 87, 0.2);
}
.menu-toggle:hover, .menu-toggle[aria-expanded="true"] { background: var(--nav-gray); }
.menu-toggle:active { background: var(--nav-edge); }
.menu-toggle-icon { display: flex; flex-direction: column; gap: 5px; width: 22px; }
.menu-toggle-icon span {
  display: block;
  height: 2px;
  background: var(--nav-navy);
  transition: transform 180ms ease, opacity 180ms ease;
}
.menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- panel contents (all widths) ---------- */
.nav { background: #fff; color: var(--nav-navy); font-size: 16px; }
.nav-group { margin: 0; padding: 0; }
.nav-group-title {
  margin: 0;
  padding: 12px 16px 4px;
  color: var(--nav-muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}
.nav-group-list { margin: 0; padding: 0; list-style: none; }
.nav-group-list li { margin: 0; padding: 0; }
.nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 0 6px;
  padding: 10px 10px 10px 12px;
  border-left: 4px solid transparent;
  color: var(--nav-navy);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.3;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(37, 60, 87, 0.2);
}
.nav a:hover { background: var(--nav-gray); text-decoration: underline; text-underline-offset: 3px; }
.nav a:active { background: var(--nav-ice); }
.nav a[aria-current="page"] { font-weight: 700; border-left-color: currentColor; }
/* Standalone first item above the groups (v37): the Five steps page. */
.nav-top-list { margin: 0; padding: 4px 0 8px; list-style: none; }
.nav-top-list li { margin: 0; padding: 0; }
.nav-top-list a { font-weight: 700; }
.menu-close, .nav-group-toggle { display: none; }
.nav-backdrop { display: none; }

/* ---------- focus ring: 3px solid #253c57, offset 3px ---------- */
.site-header a:focus-visible,
.menu-toggle:focus-visible,
.menu-close:focus-visible,
.nav-group-toggle:focus-visible,
.nav a:focus-visible {
  outline: 3px solid var(--nav-navy);
  outline-offset: 3px;
}
.site-header a:focus:not(:focus-visible),
.menu-toggle:focus:not(:focus-visible),
.menu-close:focus:not(:focus-visible),
.nav-group-toggle:focus:not(:focus-visible),
.nav a:focus:not(:focus-visible) { outline: none; }

/* ---------- no JavaScript: grouped headings and links, always visible ---------- */
html:not(.js) .menu-toggle,
html:not(.js) .menu-close,
html:not(.js) .nav-backdrop,
html:not(.js) .nav-group-toggle { display: none; }
html:not(.js) .site-header { flex-wrap: wrap; }
html:not(.js) .brand { flex-basis: 100%; }
html:not(.js) .nav {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0 32px;
  padding-bottom: 4px;
}
html:not(.js) .nav-group { flex: 0 1 auto; }

/* ---------- JavaScript on, 721 px and wider: dropdown under the Menu button ---------- */
@media (min-width: 721px) {
  html.js .nav {
    position: absolute;
    top: calc(100% + 8px);
    right: 24px;
    z-index: 40;
    width: min(360px, calc(100vw - 48px));
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 8px 0 12px;
    border: 1px solid var(--nav-edge);
    box-shadow: 0 8px 24px rgba(24, 41, 61, 0.16);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 180ms ease, transform 180ms ease, visibility 0s linear 180ms;
  }
  html.js .nav.is-open {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition-delay: 0s;
  }
  /* groups are not collapsible here, so the group buttons stay hidden and every list stays open */
  html.js .nav-group-toggle { display: none; }
  html.js .nav-group.is-collapsed .nav-group-list { display: block; }
}
@media (min-width: 1280px) {
  .site-header { padding: 10px 24px 10px 40px; }
  html.js .nav { width: min(400px, calc(100vw - 48px)); }
}

/* ---------- 720 px and narrower: phone ---------- */
@media (max-width: 720px) {
  html { scroll-padding-top: 72px; }
  .accent-bar { display: block; }
  .site-header {
    position: sticky;
    top: 0;
    gap: 8px;
    min-height: 56px;
    padding: 4px 16px 4px 18px;
    border-bottom: 0;
  }
  .brand { font-size: 17px; }
  .menu-toggle { margin-left: auto; min-height: 48px; }
  .nav a { min-height: 48px; margin: 0 6px; padding: 10px 10px 10px 18px; font-size: 18px; }
  .nav-group-title { font-size: 16px; padding-top: 12px; }
  html:not(.js) .nav { flex-direction: column; gap: 0; }

  html.js .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 2;
    max-height: calc(100vh - var(--nav-offset));
    max-height: calc(100dvh - var(--nav-offset));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 max(0px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(0px, env(safe-area-inset-left));
    border-top: 1px solid var(--nav-edge);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 180ms ease, transform 180ms ease, visibility 0s linear 180ms;
  }
  html.js .nav.is-open {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition-delay: 0s;
  }
  html.js .nav-group-title { display: none; }
  html.js .menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 4px 12px 0 auto;
    padding: 0;
    background: transparent;
    color: var(--nav-navy);
    border: 0;
    border-radius: 0;
    font: inherit;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(37, 60, 87, 0.2);
  }
  html.js .menu-close:active, html.js .nav-group-toggle:active { background: var(--nav-ice); }
  html.js .nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: calc(100% - 12px);
    min-height: 48px;
    margin: 0 6px;
    padding: 12px 12px 12px 16px;
    background: transparent;
    color: var(--nav-navy);
    border: 0;
    border-radius: 0;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(37, 60, 87, 0.2);
  }
  html.js .nav-group-toggle:hover { background: var(--nav-gray); }
  html.js .nav-group.is-collapsed .nav-group-list { display: none; }
  .nav-chevron {
    flex: 0 0 auto;
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 4px 4px 8px;
    border-right: 2px solid var(--nav-navy);
    border-bottom: 2px solid var(--nav-navy);
    transform: rotate(45deg);
    transition: transform 180ms ease;
  }
  .nav-group-toggle[aria-expanded="true"] .nav-chevron { transform: rotate(225deg); }

  html.js .nav-backdrop {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1;
    height: 100vh;
    height: 100dvh;
    background: rgba(24, 41, 61, 0.4);
    cursor: pointer;
    touch-action: none;
    animation: nav-fade 180ms ease;
  }
  html.js .nav-backdrop[hidden] { display: none; }
  /* Lock the page behind the open sheet: overflow on <html> only (no position:fixed on body, so the scroll position is kept).
     Do not also set overflow on <body>: html already has overflow-x:hidden, so a non-visible body overflow would make <body> a scroll
     container and the sticky header would stop sticking. */
  html.nav-open { overflow: hidden; }
}
@keyframes nav-fade { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 300px) {
  .site-header { flex-wrap: wrap; }
  .brand { flex-basis: 100%; overflow-wrap: anywhere; }
}

/* ---------- reduced motion: no transitions, no sliding, no rotating chevron ---------- */
@media (prefers-reduced-motion: reduce) {
  .nav, .nav-backdrop, .nav-chevron, .menu-toggle-icon span { transition: none !important; animation: none !important; }
  html.js .nav, html.js .nav.is-open { transform: none; }
}

/* ---------- Windows High Contrast / forced colors ---------- */
@media (forced-colors: active) {
  .menu-toggle-icon span { background: CanvasText; }
  .nav-chevron { border-color: CanvasText; }
  .site-header, .nav { border-color: CanvasText; }
  .nav a[aria-current="page"] { border-left-color: Highlight; }
}

/* ---------- print: menu, panel, backdrop and accent bars gone; the page stays plain ---------- */
@media print {
  .menu-toggle, .menu-close, .nav, .nav-backdrop, .accent-bar { display: none !important; }
  .site-header { position: static; min-height: 0; padding: 0 0 12px; background: #fff; border: 0; box-shadow: none; }
  .brand { color: #000; }
  a[href^="/disclaimer"]::after { content: " (primeworldofsports.org/disclaimer/)"; }
}
