/* Navbar ---------------------------------------------------------------------
   One fixed pill at the top of every page. Markup: templates/base.html, filled by
   tools/build-content.mjs (applyNavigation). Behaviour: scripts/site-nav.js.

   Colour: the bar wears the palette of the section in view (the --nav-* roles in tokens.css,
   each read straight from the page's scroll palette). The root tweens that palette once for the
   whole page, and nothing here puts a colour transition of its own on top of it, so the bar's
   fill, outline, wordmark, links and button change as one, in step with the page. The bar stays
   in view at all times; scrolling never moves it. Besides the palette, what moves:
     - the link for the section in view (aria-current, set by site-nav.js) sits at the whole ink,
       and the bar rests pinched off around it (the lava-lamp outline, drawn by site-nav.js);
     - a link brightens under the pointer or keyboard focus, and the pinch moves to it while it
       is there;
     - the pointer or keyboard focus on the wordmark moves the pinch to it;
     - on narrow windows the links fold into a menu the bar opens downward (.is-open).
   Nothing here depends on the script to be usable on a wide window: without it the bar is a
   plain pill. */

/* how far apart the pieces of the lava-lamp outline rest; registered so the script reads a
   resolved length */
@property --nav-blob-gap{syntax:"<length>";inherits:true;initial-value:0px}

.site-nav{
  /* Geometry. The bar is as tall as its controls (the CTA, the menu button) plus even padding
     round them, and its ends are fully round, so a control nested in an end is concentric
     with it. */
  --nav-top:calc(34*var(--dp));
  --nav-control:calc(40*var(--dp));
  --nav-pad:calc(8*var(--dp));
  --nav-inset:calc(20*var(--dp));
  --nav-height:calc(var(--nav-control) + 2*var(--nav-pad));
  --nav-radius:calc(var(--nav-height)/2);
  --nav-link-gap:calc(44*var(--dp));
  --nav-blob-gap:calc(9*var(--dp));
  /* the shared CTA pill's fill overhangs its box to the right by this much (base.css, Plain CTA) */
  --nav-cta-tail:calc(12*var(--dp));
  --nav-menu-duration:.45s;

  background-color:var(--nav-surface);
  border-radius:var(--nav-radius);
  box-shadow:inset 0 0 0 1px var(--nav-hairline);
  color:var(--nav-ink);
  inset-inline:0;
  margin-inline:auto;
  position:fixed;
  top:var(--nav-top);
  width:var(--nav-width);
  z-index:5;
}

/* The bar: wordmark | links | CTA. Equal side tracks keep the links on the bar's true centre
   whatever the wordmark and the CTA measure. */
.site-nav__bar{
  align-items:center;
  display:grid;
  grid-template-columns:1fr auto 1fr;
  min-height:var(--nav-height);
  padding:var(--nav-pad) var(--nav-pad) var(--nav-pad) var(--nav-inset);
}
.site-nav__logo{
  color:var(--nav-logo);
  font-size:var(--text-md);
  font-weight:700;
  justify-self:start;
  letter-spacing:-.01em;
  line-height:1;
  text-decoration:none;
  text-transform:lowercase;
  white-space:nowrap;
}
/* The words, outlined from Gotham Bold: a unit of their drawing is a thousandth of an em, and the
   box reaches .17em under the baseline for the g. */
.site-nav__word{
  display:inline-block;
  vertical-align:-.17em;
}
/* The slash meets the letters at their baseline. On hover it passes through along its own slant,
   as the CTA arrows do (motion.css, Buttons): out past the top right, in from the bottom left.
   The clip reaches just past the box for the round caps (half the stroke, 7.5 of its 100-unit em);
   the pass moves the path 92 units up and 40 across, which takes the whole stroke past the clip. */
.site-nav__slash{
  --arrow-pass-x:40px;
  --arrow-pass-y:92px;
  clip-path:inset(-.08em);
  display:inline-block;
  fill:none;
  height:.76em;
  margin:0 .02em;
  overflow:visible;
  stroke:currentColor;
  stroke-linecap:round;
  stroke-linejoin:round;
  stroke-width:15px;
  vertical-align:baseline;
  width:.4em;
}
.site-nav__links ul,
.site-nav__menu ul{
  list-style:none;
  margin:0;
  padding:0;
}
.site-nav__links ul{
  display:flex;
  gap:var(--nav-link-gap);
}
/* Links: quiet at rest (--nav-ink-rest, a solid mix of ink and surface), the whole ink under
   the pointer or keyboard focus, in every palette. The mix is made on :root (tokens.css, Quiet
   inks), never in a link's own `color`: Chrome works out the colour of a link you have visited
   separately, and with the ink mixed in there, visited links lit up to the whole ink for as long
   as the palette was fading. The hover fade is off during a palette shift, so a link never
   trails behind the bar.
   Only pointers that can hover get the hover: a tap would leave a link lit until the next tap
   somewhere else. */
.site-nav__links a{
  align-items:center;
  color:var(--nav-ink-rest);
  display:inline-flex;
  font-size:var(--text-xs);
  font-weight:500;
  letter-spacing:0;
  line-height:1.2;
  min-height:calc(32*var(--dp));
  text-decoration:none;
  text-transform:uppercase;
  transition:color var(--hover-transition);
  white-space:nowrap;
}
:root.is-palette-shifting .site-nav__links a{transition:none}
/* the link for the section in view: lit like a hovered link, for as long as it is in view */
.site-nav__links a[aria-current],
.site-nav__links a:focus-visible{
  color:var(--nav-ink);
}
@media (hover:hover){
  .site-nav__links a:hover{
    color:var(--nav-ink);
  }
}
/* The CTA: the site's pill (base.css, Plain CTA), nested in the bar's right end. Its fill
   overhangs its box, so the box keeps that much clear of the bar's padding, and the pill ends
   one padding from the bar's edge all the way round. */
.site-nav__cta{
  justify-self:end;
  margin-right:var(--nav-cta-tail);
}
.site-nav .cta-button:not(.is-square):not(.is-hexagon){
  --cta-tail:var(--nav-cta-tail);
  cursor:pointer;
}
.site-nav .cta-button:not(.is-square):not(.is-hexagon) .cta-button__background{
  border-radius:999px;
}

/* Lava-lamp outline (wide windows): site-nav.js draws the bar's fill and hairline as one SVG
   outline, so the piece round a hovered link can pinch off like a blob. Once it has drawn
   (.has-blob) it stands in for the bar's own fill and hairline, in the same inks. */
.site-nav__blob{
  display:none;
}
@media (min-width:769px){
  .site-nav.has-blob{
    background-color:transparent;
    box-shadow:none;
  }
  .site-nav.has-blob .site-nav__blob{
    display:block;
    height:100%;
    inset:0;
    overflow:visible;
    pointer-events:none;
    position:absolute;
    width:100%;
    z-index:-1;
  }
  .site-nav__blob path{
    fill:var(--nav-surface);
    stroke:var(--nav-hairline);
    stroke-width:1px;
  }
}

/* The menu button and the menu belong to narrow windows only. */
.site-nav__toggle,
.site-nav__menu{
  display:none;
}

@media (max-width:768px){
  .site-nav{
    --nav-top:calc(10*var(--dp));
    --nav-pad:calc(10*var(--dp));
    --nav-inset:calc(18*var(--dp));
  }
  .site-nav__bar{
    grid-template-columns:1fr auto;
  }
  .site-nav__links,
  .site-nav__cta{
    display:none;
  }
  /* Menu button: a circle in the bar's right end holding three bars. Open, the outer bars meet
     on the middle one's line and cross into an X while the middle bar fades. --burger-shift is
     one bar plus one gap, the distance from an outer bar to the middle. Its press is in
     motion.css (Buttons). */
  .site-nav__toggle{
    align-items:center;
    background-color:var(--nav-ink);
    border:0;
    border-radius:50%;
    cursor:pointer;
    display:flex;
    height:var(--nav-control);
    justify-content:center;
    padding:0;
    position:relative;
    width:var(--nav-control);
  }
  /* the circle is a little under the least size for a tap (--tap-min); its target is not */
  .site-nav__toggle::before{
    content:"";
    inset:min(0px,calc((var(--nav-control) - var(--tap-min))/2));
    position:absolute;
  }
  .site-nav.is-open .site-nav__toggle{
    background-color:var(--nav-accent);
  }
  .site-nav__burger{
    /* whole px, not --dp: in fractions of a pixel each bar is rounded to the screen's on its own, and
       the bars and the gaps between them came out uneven */
    --burger-bar:2px;
    --burger-gap:4px;
    --burger-shift:calc(var(--burger-bar) + var(--burger-gap));
    display:grid;
    gap:var(--burger-gap);
    width:calc(16*var(--dp));
  }
  .site-nav__burger span{
    background-color:var(--current-color-100);
    border-radius:999px;
    height:var(--burger-bar);
    transition:
      transform var(--hover-transition),
      opacity var(--hover-transition);
  }
  .site-nav.is-open .site-nav__burger span:first-child{
    transform:translateY(var(--burger-shift)) rotate(45deg);
  }
  .site-nav.is-open .site-nav__burger span:nth-child(2){
    opacity:0;
  }
  .site-nav.is-open .site-nav__burger span:last-child{
    transform:translateY(calc(-1*var(--burger-shift))) rotate(-45deg);
  }

  /* The menu: the bar grows downward to hold it. Its row runs from no height to its content's
     (0fr to 1fr), so nothing is measured by script; closed, it is also out of the tab order.
     A window too short for it caps it and the menu scrolls inside. */
  .site-nav__menu{
    display:grid;
    grid-template-rows:0fr;
    transition:
      grid-template-rows var(--nav-menu-duration) var(--ease-out-strong),
      visibility 0s linear var(--nav-menu-duration);
    visibility:hidden;
  }
  .site-nav.is-open .site-nav__menu{
    grid-template-rows:1fr;
    transition-delay:0s;
    visibility:visible;
  }
  .site-nav__menu-clip{
    max-height:calc(100svh - var(--nav-height) - 2*var(--nav-top));
    min-height:0;
    overflow:hidden;
    overscroll-behavior:contain;
  }
  .site-nav.is-open .site-nav__menu-clip{
    overflow-y:auto;
  }
  .site-nav__menu-panel{
    padding:var(--nav-pad) var(--nav-inset) var(--nav-inset);
  }
  /* Menu links: there is no hover on a touch screen, so they sit at the whole ink, each row a
     full tap target, and give a little under the finger. */
  .site-nav__menu a:not(.cta-button){
    align-items:center;
    color:var(--nav-ink);
    display:flex;
    font-size:var(--text-xl);
    font-weight:700;
    letter-spacing:-.04em;
    line-height:.95;
    min-height:var(--tap-min);
    text-decoration:none;
  }
  /* the link for the section in view takes the accent, a plain colour like the ink (Links) */
  .site-nav__menu a[aria-current]:not(.cta-button){
    color:var(--nav-accent);
  }
  .site-nav__menu a:not(.cta-button):active{
    color:var(--nav-ink-rest);
  }
  .site-nav__menu .cta-button{
    margin-top:var(--stack-action);
  }
}
