/* The two main sections keep ordinary links and their existing page behavior. */
:root[data-section="search"] {
  --section-enter-x: -14px;
  --section-leave-x: 12px;
}
:root[data-section="guides"] {
  --section-enter-x: 14px;
  --section-leave-x: -12px;
}

@keyframes section-enter {
  from { opacity: 0; transform: translateX(var(--section-enter-x)); }
  to { opacity: 1; transform: none; }
}
@keyframes section-leave {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateX(var(--section-leave-x)); }
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  body > header { view-transition-name: section-header; }
  #main { view-transition-name: section-content; }

  /* Keep the shared header steady and avoid stretching pages of different lengths. */
  ::view-transition-group(root),
  ::view-transition-group(section-header),
  ::view-transition-group(section-content) { animation: none; }
  ::view-transition-old(root),
  ::view-transition-new(root),
  ::view-transition-old(section-header),
  ::view-transition-new(section-header) {
    animation: none;
    mix-blend-mode: normal;
  }
  ::view-transition-old(section-content),
  ::view-transition-new(section-content) {
    width: 100%;
    height: auto;
    mix-blend-mode: normal;
  }
  ::view-transition-old(section-content) {
    animation: section-leave 160ms cubic-bezier(.2, .7, .2, 1) both;
  }
  ::view-transition-new(section-content) {
    animation: section-enter 240ms cubic-bezier(.2, .7, .2, 1) both;
  }

  /* Entrance motion for browsers without document-to-document transitions. */
  :root[data-section-enter] #main {
    animation: section-enter 240ms cubic-bezier(.2, .7, .2, 1) both;
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}
