/* Floating navigation; the header remains the primary navigation. */
.floating-nav {
  --glass-depth: 44px;
  --floating-edge: clamp(16px, 3vw, 24px);
  position: fixed;
  right: max(var(--floating-edge), env(safe-area-inset-right));
  bottom: calc(max(var(--floating-edge), env(safe-area-inset-bottom)) + var(--floating-nav-lift, 0px));
  width: 44px;
  height: 44px;
  max-width: calc(100vw - max(var(--floating-edge), env(safe-area-inset-left)) - max(var(--floating-edge), env(safe-area-inset-right)));
  border-radius: 22px;
  overflow: hidden;
  z-index: 30;
  visibility: hidden;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: width 280ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 220ms ease-out,
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s 280ms;
}

.floating-nav[hidden] { display: none; }
.floating-nav[data-visible="true"] {
  visibility: visible;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition-delay: 0s;
}
.floating-nav[data-open="true"] { width: 288px; }

/* Let the page tint the glass; blur keeps underlying text from competing. */
.floating-nav::before {
  background-color: color-mix(in srgb, var(--background-color) 60%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(115%);
  backdrop-filter: blur(16px) saturate(115%);
}

.floating-nav__trigger {
  position: absolute;
  right: 0;
  top: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  touch-action: manipulation;
}

/* Flat actions share the outer glass; only the current page is raised. */
.floating-nav__action {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-color);
  transition: background-color 200ms ease-out, color 200ms ease-out;
}
.floating-nav__action:hover {
  background: color-mix(in srgb, var(--text-color) 6%, transparent);
  color: var(--heading-color);
}

/* Paint hover on the control itself, without an independently composited layer.
   Full-height hit areas retain the previous spacing and icon/text positions. */
.floating-nav__items .floating-nav__action { margin-inline: -4px; }
.floating-nav .site-nav a:not([aria-current]) {
  min-height: 44px;
  min-width: 66px;
  margin-inline: -1px;
  padding-inline: 17px;
  transition: background-color 200ms ease-out, color 200ms ease-out;
}
.floating-nav .site-nav a:first-child:not([aria-current]) {
  min-width: 71px;
  margin-left: -6px;
  padding-left: 22px;
}
.floating-nav::after { z-index: 2; }

/* HTML bars avoid SVG transform-origin differences in released Safari versions. */
.floating-nav__icon {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
}
.floating-nav__line {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 1.5px;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
.floating-nav__line:first-child { transform: translate(-50%, -50%) translateY(-3px) rotate(0deg); }
.floating-nav__line:last-child { transform: translate(-50%, -50%) translateY(3px) rotate(0deg); }
.floating-nav[data-open="true"] .floating-nav__line:first-child { transform: translate(-50%, -50%) translateY(0) rotate(45deg); }
.floating-nav[data-open="true"] .floating-nav__line:last-child { transform: translate(-50%, -50%) translateY(0) rotate(-45deg); }

.floating-nav__items {
  position: absolute;
  left: 6px;
  right: 48px;
  top: 4px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  clip-path: inset(-4px -4px -4px -6px);
  visibility: hidden;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 120ms ease-out, transform 240ms ease-out, visibility 0s 240ms;
}
.floating-nav[data-open="true"] .floating-nav__items {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition-delay: 60ms, 0s, 0s;
}
.floating-nav .site-nav { padding: 0; flex-wrap: nowrap; }
.floating-nav .theme-toggle { width: 44px; height: 44px; }
.floating-nav__theme { flex: 0 0 auto; display: flex; }
.floating-nav__top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  touch-action: manipulation;
}
.floating-nav__top svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.floating-nav .site-nav a { flex: 0 0 auto; }
.floating-nav :is(button, a):focus-visible {
  outline: 2px solid var(--heading-color);
  outline-offset: -4px;
}

/* Leave room to read/use the footer even when the floating control is present. */
html[data-floating-nav-visible] footer {
  padding-bottom: calc(89px + env(safe-area-inset-bottom));
}

@media (max-width: 600px) {
  :root { --floating-nav-lift: 32px; }
  /* The footer now fits below the raised menu instead of above it. */
  html[data-floating-nav-visible] footer { padding-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .floating-nav,
  .floating-nav__action,
  .floating-nav .site-nav a:not([aria-current]),
  .floating-nav__items,
  .floating-nav[data-open="true"] .floating-nav__items,
  .floating-nav__line { transition: none; }
}

@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .floating-nav::before {
    background: var(--glass-solid);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (forced-colors: active) {
  .floating-nav { background: Canvas; }
  .floating-nav__action { color: ButtonText; }
  .floating-nav__line { background: ButtonText; forced-color-adjust: none; }
}
