/* NAV */
/* Scroll-progress indicator — fills left-to-right as the user scrolls */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  transform-origin: left;
  transform: scaleX(0);
  background: linear-gradient(
    to right,
    rgba(var(--theme-glow, 130, 200, 255), 0.7),
    rgba(var(--theme-glow, 130, 200, 255), 0.4)
  );
  z-index: var(--z-nav);
  pointer-events: none;
}
@keyframes scroll-progress-fill {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}
@supports (animation-timeline: scroll()) {
  #scroll-progress {
    animation: scroll-progress-fill linear both;
    animation-timeline: scroll(root block);
  }
}
body.upside-down #scroll-progress {
  opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
  #scroll-progress {
    display: none;
  }
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 3rem;
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: rgba(var(--ink-rgb), 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  will-change: translate;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  /* Only box-shadow transitions — the background is rewritten inline per scroll
     frame (light mode) and must track instantly, not lag behind an animation. */
  transition: box-shadow 0.3s ease;
}
/* Elevation once scrolled off the top — a soft drop shadow lifts the sticky
   nav above the content sliding under it. `scrolled` is toggled in nav.js. */
nav.scrolled {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
}
nav.nav-light.scrolled {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

/* Logo hover sparkle particles — actual four-point stars, so the brand moment
   has its own character instead of reusing the generic glowing dot. */
.logo-sparkle {
  position: fixed;
  width: 10px;
  height: 10px;
  background: rgba(var(--cursor-glow, 180, 200, 255), 0.9);
  clip-path: polygon(
    50% 0%,
    58% 42%,
    100% 50%,
    58% 58%,
    50% 100%,
    42% 58%,
    0% 50%,
    42% 42%
  );
  /* drop-shadow (not box-shadow) follows the clipped star so the glow keeps
     the sparkle's shape rather than haloing a square box. */
  filter: drop-shadow(0 0 3px rgba(var(--cursor-glow, 180, 200, 255), 0.6));
  pointer-events: none;
  z-index: var(--z-cursor-ring);
}

/* Spell-to-toggle feedback — a coloured ghost of the tapped letter laid over
   it: green when the tap extends a word, yellow when it diverts to another
   mid-spell, red + shake on a dead tap. The font (family/size/weight/…) is
   copied from the tapped element inline by JS so it overlays exactly;
   self-cleaning via the Web Animations API. */
.spell-pop {
  position: fixed;
  z-index: var(--z-cursor-ring);
  pointer-events: none;
}
.spell-pop--advance {
  color: rgb(120, 224, 156);
  text-shadow: 0 0 8px rgba(120, 224, 156, 0.55);
}
.spell-pop--transition {
  color: rgb(240, 200, 110);
  text-shadow: 0 0 8px rgba(240, 200, 110, 0.5);
}
.spell-pop--broke {
  color: rgb(235, 116, 116);
  text-shadow: 0 0 8px rgba(235, 116, 116, 0.5);
}

/* SVG Cloud Logo */
.cloud-svg {
  width: 44px;
  height: 32px;
  filter: drop-shadow(0 0 12px rgba(var(--theme-glow), 0.6));
}
.cloud-svg.logo-breathing {
  animation: logoBreath 3s ease-in-out infinite;
}
@keyframes logoBreath {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}
/* One-shot click pulse — interrupts breathing for the duration of the
   keyframe, then the click listener strips the class via animationend. */
.cloud-svg.logo-clicked {
  animation: logoClickPulse 0.35s var(--ease-back);
}
@keyframes logoClickPulse {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(0.92);
  }
  70% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--logo-text-color);
}
.logo-text > span:not(.logo-letter) {
  color: var(--logo-accent-color);
}
.logo-letter {
  display: inline-block;
  will-change: translate;
  color: inherit;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  list-style: none;
}

.nav-links a {
  font-family: "DM Mono", monospace;
  font-size: 0.72rem;
  font-weight: 300;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  transition:
    color 0.3s,
    text-shadow 0.3s;
  position: relative;
}
.nav-links a::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--sky-3);
  transition: width 0.3s;
}
.nav-links a:hover,
.nav-links a.active {
  color: #fff;
}
/* The scroll-active "you are here" link glows so it reads distinctly from a
   transient hover — both go white, but only the current section is haloed. */
.nav-links a.active {
  text-shadow: 0 0 12px rgba(var(--theme-glow), 0.5);
}
.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
}
.nav-sparkle {
  position: absolute;
  border-radius: 50%;
  background: rgb(var(--theme-glow));
  pointer-events: none;
}

.nav-links a.nav-cta {
  font-family: "DM Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: rgb(var(--theme-glow));
  border: 1px solid rgba(var(--theme-glow), 0.4);
  padding: 0.55rem 1.2rem;
  border-radius: 100px;
  position: relative;
  transition:
    background 0.3s,
    border-color 0.3s,
    color 0.3s,
    transform 0.18s;
}
.nav-links a.nav-cta:hover,
.nav-links a.nav-cta.active {
  background: rgba(var(--theme-glow), 0.15);
  border-color: rgb(var(--theme-glow));
}
.nav-links a.nav-cta:active {
  transform: scale(0.95);
}
.nav-links a.nav-cta::after {
  display: none;
}

/* Hamburger menu */
.nav-burger {
  display: none;
  background: none;
  border: none;
  padding: 4px;
  color: rgba(255, 255, 255, 0.7);
  transition: color 0.3s;
}
.nav-burger:hover {
  color: #fff;
}
.nav-burger svg {
  width: 20px;
  height: 20px;
}
.nav-burger .burger-close {
  display: none;
}
.nav-burger.active .burger-open {
  display: none;
}
.nav-burger.active .burger-close {
  display: block;
}
