/* The site bar on every page stays at hand: it slides away while you scroll down to read and comes back as soon as you
   scroll up (site/js/shared/sitebar.js sets .sb-away and --sb-h, the height of the bar while it shows). */

.sitebar {
  position: sticky;
  top: 0;
  transition: transform 0.25s ease;
}
.sitebar.sb-away {
  transform: translateY(-100%);
}

/* out of sight, the bar is back in its own place at the top of the page (sitebar.js) */
.sitebar.sb-rest {
  position: relative;
  transform: none;
  transition: none;
}

/* a link to a part of the page lands below the bar, not under it */
html {
  scroll-padding-top: var(--sb-h, 0px);
  /* no blue flash on a tapped button on Android; the buttons show their own pressed and chosen states */
  -webkit-tap-highlight-color: transparent;
}

@media (prefers-reduced-motion: reduce) {
  .sitebar {
    transition: none;
  }
}

/* changing page (js/shared/switch.js). Through the stamp (switch animation on), the browser carries it from the page
   you leave onto the new notebook, so it cannot jump. Any other way (html.nb-morph), one page blends into the next:
   the top bar stays where it is and a notebook's title turns into the next one's. */
@view-transition {
  navigation: auto;
}
html.nb-morph .sitebar {
  view-transition-name: nb-bar;
}
html.nb-morph header.top h1 {
  view-transition-name: nb-title;
}
html.nb-morph::view-transition-group(*),
html.nb-morph::view-transition-old(*),
html.nb-morph::view-transition-new(*) {
  animation-duration: 0.5s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
::view-transition-group(nb-stamp) {
  animation-duration: 0.35s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}
