/* Nav menu — the page links live in a dropdown behind the menu toggle, at every
   width. Load after blueprint-shared.css on any page whose nav carries
   .nav-links, together with nav-menu.js. This file owns how .nav-links is shown;
   a page's own stylesheet must not hide or lay it out.

   Desktop: a narrow plate hung under the bar's right end, below the toggle.
   Tablet and phone (1180px and below): the plate runs the bar's full width.

   Branch: the dropdown ground defaults to the cold branch. A warm page sets
     --nav-menu-ground: rgba(20, 18, 16, .97);
   on its page class. */

/* ---- the toggle: square, drawn, three rules that become an X ---- */
.nav-toggle {
  position: relative; display: grid; place-items: center; flex: 0 0 auto;
  width: 46px; height: 46px; margin-left: 14px; padding: 0;
  background: transparent; border: 1px solid var(--accent-line); color: var(--ink);
  cursor: pointer; transition: border-color .3s var(--ease), background .3s var(--ease);
}
.nav-toggle span {
  position: absolute; left: 50%; top: 50%; width: 18px; height: 1.5px; margin: -.75px 0 0 -9px;
  background: currentColor;
  transition: transform .45s var(--ease), opacity .25s var(--ease);
}
.nav-toggle span:nth-child(1) { transform: translateY(-6px); }
.nav-toggle span:nth-child(3) { transform: translateY(6px); }
.nav-toggle:hover { border-color: var(--action); }
.nav-toggle:focus-visible { outline: 2px solid var(--action); outline-offset: 3px; }

.nav.menu-open .nav-toggle { border-color: var(--action); color: var(--action); }
.nav.menu-open .nav-toggle span:nth-child(1) { transform: rotate(45deg); }
.nav.menu-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav.menu-open .nav-toggle span:nth-child(3) { transform: rotate(-45deg); }

/* the bar takes its ground while the menu is open, even at the top of the page */
.nav.menu-open {
  background: var(--nav-menu-ground, rgba(8, 20, 22, .97));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}

/* the links no longer sit in the bar, so the plate side takes the free space */
.nav .nav-links + .nav-end { margin-left: auto; }

/* ---- the dropdown: the page links, stacked under the bar ---- */
.nav .nav-links {
  position: absolute; top: calc(100% + 10px); left: -1px; right: -1px;
  display: block; max-height: calc(100vh - 78px - 1.8vh - 30px); overflow-y: auto;
  padding: 6px clamp(20px, 4vw, 34px) 10px;
  background: var(--nav-menu-ground, rgba(8, 20, 22, .97));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--accent-line);
  visibility: hidden; opacity: 0; transform: translateY(-8px);
  transition: opacity .3s var(--ease), transform .45s var(--ease), visibility 0s linear .45s;
}
.nav.menu-open .nav-links {
  visibility: visible; opacity: 1; transform: none;
  transition: opacity .3s var(--ease), transform .45s var(--ease), visibility 0s;
}
/* corner brackets, so the dropdown reads as a plate hung from the bar */
.nav .nav-links::before, .nav .nav-links::after {
  content: ""; position: absolute; width: 12px; height: 12px; border: 1px solid var(--accent); pointer-events: none;
}
.nav .nav-links::before { left: 5px; bottom: 5px; border-top: 0; border-right: 0; }
.nav .nav-links::after { right: 5px; bottom: 5px; border-top: 0; border-left: 0; }

.nav .nav-links li { display: block; }
.nav .nav-links li + li { border-top: 1px solid var(--accent-line); }
.nav .nav-links li + li::before { display: none; }

.nav .nav-links a {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 19px 0; font-size: 14px; letter-spacing: .2em; color: var(--ink);
}
.nav .nav-links a:hover { color: var(--action); }
.nav .nav-links a:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
/* current page: a Tiffany diamond at the line's end, in place of the underline */
.nav .nav-links a[aria-current="page"]::after {
  position: static; flex: 0 0 auto; width: 7px; height: 7px; margin-right: 4px;
  background: var(--action); transform: rotate(45deg);
}

/* desktop: five short links don't need the bar's full ~1,600px; hang a narrow
   plate under the right end, beneath the toggle */
@media (min-width: 1181px) {
  .nav .nav-links { left: auto; width: clamp(300px, 22vw, 400px); padding: 6px 30px 10px; }
}

@media (max-width: 640px) {
  .nav-toggle { width: 40px; height: 40px; margin-left: 10px; }
  .nav .nav-links { top: calc(100% + 8px); max-height: calc(100vh - 64px - 1.8vh - 24px); }
}

/* the narrowest phones (375px): mark, plate and toggle must share ~350px */
/* (html-prefixed so they outrank each page's own 640px nav rules) */
@media (max-width: 420px) {
  html .nav .brand img { height: 20px; margin-left: calc(20px * -0.15); }
  html .nav .nav-end .bp-cta { display: none; }
  html .nav .nav-toggle { width: 36px; height: 36px; margin-left: 6px; }
}

@media (max-width: 360px) {
  html .nav .brand img { height: 18px; margin-left: calc(18px * -0.15); }
  html .nav .nav-toggle { width: 34px; height: 34px; margin-left: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-toggle span, .nav .nav-links { transition-duration: .01s; }
}
