/* Floating primary nav. Colours come from codex-theme.css, which must load first. */

:root {
  --nav-bg: rgba(20, 20, 23, 0.82);
  --nav-border: rgba(219, 184, 74, 0.28);
  --nav-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  --nav-current-bg: #dbb84a;
  --nav-current-fg: #0a0a0d;
  --nav-fade: linear-gradient(to bottom,
    rgba(10, 10, 13, 0.97) 0%,
    rgba(10, 10, 13, 0.92) 45%,
    rgba(10, 10, 13, 0.62) 68%,
    rgba(10, 10, 13, 0.24) 86%,
    rgba(10, 10, 13, 0) 100%);
}

/* Site-wide 19pt base type scale; primary page titles opt out locally. */
html {
  font-size: 25.333px;
}

/* Sticks to the top of every page: all navigation lives above the content. */
.site-nav {
  position: sticky;
  top: max(12px, env(safe-area-inset-top));
  z-index: 1000;
  display: flex;
  gap: 4px;
  width: max-content;
  max-width: calc(100vw - 24px);
  margin: 12px auto 0;
  overflow-x: auto;
  padding: 5px;
  border: 1px solid var(--nav-border);
  border-radius: 999px;
  background: var(--nav-bg);
  box-shadow: var(--nav-shadow);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  scrollbar-width: none;
}

.site-nav::-webkit-scrollbar { display: none; }

/* Content fades out as it scrolls under the nav. Sits just below .site-nav. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  z-index: 999;
  height: calc(max(12px, env(safe-area-inset-top)) + 100px);
  background: var(--nav-fade);
  pointer-events: none;
}

/* Hidden at the top of the page so the hero isn't dimmed; always on without support. */
@supports (animation-timeline: scroll()) {
  @keyframes nav-fade-in {
    from { opacity: 0; }
  }

  body::before {
    animation: nav-fade-in linear both;
    animation-timeline: scroll(root);
    animation-range: 0 120px;
  }
}

.site-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 17px;
  border-radius: 999px;
  color: var(--text-muted);
  font: 600 17.334px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.site-nav a:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

.site-nav a:active {
  transform: scale(0.97);
}

.site-nav a[aria-current="page"] {
  color: var(--nav-current-fg);
  background: var(--nav-current-bg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
}

.site-nav a:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .site-nav {
    top: max(8px, env(safe-area-inset-top));
    margin-top: 8px;
  }

  body::before {
    height: calc(max(8px, env(safe-area-inset-top)) + 90px);
  }

  .site-nav a {
    min-height: 36px;
    padding: 0 12px;
    font-size: 18.38px;
  }
}

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