/* The bar's five touch targets stay fixed while the selection travels below them. */
@media (max-width: 820px) {
  .redesigned {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  .glass-nav {
    --tab-index: 0;
    --tab-duration: 230ms;
    --tab-ease: cubic-bezier(.22, .7, .22, 1);
    width: min(calc(100% - 32px), 360px);
    height: 50px;
    bottom: max(8px, env(safe-area-inset-bottom, 0px));
    padding: 2px 4px;
    gap: 0;
    border: 1px solid rgb(214 229 250 / 22%);
    border-radius: 26px;
    background: rgb(12 19 31 / 88%);
    box-shadow: 0 3px 14px rgb(0 0 0 / 26%);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    isolation: isolate;
  }

  .glass-nav[data-current-tab="work"] { --tab-index: 1; }
  .glass-nav[data-current-tab="services"] { --tab-index: 2; }
  .glass-nav[data-current-tab="contact"] { --tab-index: 3; }
  .glass-nav[data-current-tab="menu"],
  .menu-open .glass-nav { --tab-index: 4; }

  .glass-nav .nav-pill {
    position: absolute;
    pointer-events: none;
    left: 4px;
    top: 2px;
    bottom: 2px;
    width: calc((100% - 8px) / 5);
    transform: translateX(calc(100% * var(--tab-index)));
    transition: transform var(--tab-duration) var(--tab-ease);
  }

  .glass-nav .nav-pill::before {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: 24px;
    background: rgb(224 235 252 / 15%);
  }

  .glass-nav[data-current-tab] :is(a, button) {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    align-content: center;
    min-height: 44px;
    padding: 0;
    gap: 2px;
    border: 0;
    border-radius: 23px;
    background: transparent;
    box-shadow: none;
    transform: none;
    color: #c2cad6;
    -webkit-tap-highlight-color: transparent;
  }

  .glass-nav[data-current-tab] :is(a, button) > span {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.1;
    white-space: nowrap;
  }

  .glass-nav svg { width: 22px; height: 22px; }
  .glass-nav[data-current-tab] :is(a, button):focus-visible { outline-offset: -3px; }

  body:not(.menu-open) :is(
    .glass-nav[data-current-tab="home"] [data-nav="home"],
    .glass-nav[data-current-tab="work"] [data-nav="work"],
    .glass-nav[data-current-tab="services"] [data-nav="services"],
    .glass-nav[data-current-tab="contact"] [data-nav="contact"],
    .glass-nav[data-current-tab="menu"] .bottom-menu
  ),
  .menu-open .glass-nav .bottom-menu {
    color: #fff;
  }

  body:not(.menu-open) :is(
    .glass-nav[data-current-tab="home"] [data-nav="home"],
    .glass-nav[data-current-tab="work"] [data-nav="work"],
    .glass-nav[data-current-tab="services"] [data-nav="services"],
    .glass-nav[data-current-tab="contact"] [data-nav="contact"]
  ) svg { fill: currentColor; }

  .glass-nav[data-current-tab="menu"] .bottom-menu svg,
  .menu-open .glass-nav .bottom-menu svg { stroke-width: 2.5; }
}

@media (max-width: 820px) and (max-height: 620px) {
  .redesigned .mobile-menu { bottom: calc(58px + max(8px, env(safe-area-inset-bottom, 0px))); }
}

@media (prefers-reduced-transparency: reduce) {
  .glass-nav { background: #0c131f; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Native page navigations share the selection's position. The other layers switch immediately. */
@media (max-width: 820px) and (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .glass-nav .nav-pill { view-transition-name: alvion-selection; }
  .nav-arriving .glass-nav .nav-pill {
    animation: alvion-tab-arrival var(--tab-duration) var(--tab-ease) backwards;
  }
  @keyframes alvion-tab-arrival {
    from { transform: translateX(calc(100% * var(--nav-from-index))); }
    to { transform: translateX(calc(100% * var(--tab-index))); }
  }

  ::view-transition-group(root), ::view-transition-new(root),
  ::view-transition-new(alvion-selection) { animation: none; }
  ::view-transition-old(root), ::view-transition-old(alvion-selection) { display: none; }
  ::view-transition-group(alvion-selection) {
    animation-duration: 230ms;
    animation-timing-function: cubic-bezier(.22, .7, .22, 1);
  }
}

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