/* ==========================================================================
   animations.css — atmosphere motion, reveal system, reduced-motion rules
   Motion is slow, weightless, and physical. Nothing bounces or spins.
   ========================================================================== */

/* ---- Ambient background atmosphere ---- */

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(120% 90% at 15% 0%, var(--bg-3) 0%, var(--bg-1) 45%, var(--bg-0) 100%);
}

.atmosphere__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.6;
  will-change: transform;
}

.atmosphere__orb--cyan {
  top: -10%;
  left: -8%;
  width: min(60vw, 780px);
  height: min(60vw, 780px);
  background: radial-gradient(circle, var(--light-cyan) 0%, rgba(127, 227, 239, 0) 70%);
  animation: drift-a var(--duration-ambient) ease-in-out infinite alternate;
}

.atmosphere__orb--peach {
  bottom: -15%;
  right: -10%;
  width: min(55vw, 700px);
  height: min(55vw, 700px);
  background: radial-gradient(circle, var(--light-peach) 0%, rgba(255, 185, 143, 0) 70%);
  opacity: 0.5;
  animation: drift-b calc(var(--duration-ambient) * 1.3) ease-in-out infinite alternate;
}

.atmosphere__orb--lavender {
  top: 30%;
  right: 15%;
  width: min(40vw, 560px);
  height: min(40vw, 560px);
  background: radial-gradient(circle, var(--light-lavender) 0%, rgba(182, 166, 255, 0) 70%);
  opacity: 0.4;
  animation: drift-c calc(var(--duration-ambient) * 1.6) ease-in-out infinite alternate;
}

/* Dark theme — orb colors stay the same (only their opacity changed
   between the dark and light atmosphere per Decision #0007); back to
   the original pre-#0007 values here. */
[data-theme="dark"] .atmosphere__orb--cyan {
  opacity: 0.55;
}

[data-theme="dark"] .atmosphere__orb--peach {
  opacity: 0.35;
}

[data-theme="dark"] .atmosphere__orb--lavender {
  opacity: 0.3;
}

/* ---- Cursor light (Phase 7 — Advanced Motion) ----
   Created by motion.js only when hover/fine-pointer + motion are both
   available; positioned via translate3d following the cursor. Layered
   inside .atmosphere so it inherits its fixed/clipped stacking context. */

.cursor-light {
  position: absolute;
  top: 0;
  left: 0;
  width: 480px;
  height: 480px;
  margin: -240px 0 0 -240px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--light-cyan) 0%, rgba(127, 227, 239, 0) 70%);
  opacity: 0;
  /* `overlay` is nearly a no-op against this light/near-white atmosphere
     base — overlay's effect is strongest on midtones and weak at the
     extremes. `multiply` reads as a visible soft tint here instead. */
  mix-blend-mode: multiply;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-glass);
  will-change: transform;
}

.cursor-light.is-active {
  opacity: 0.4;
}

/* Dark theme — `multiply` was chosen specifically because it darkens-
   and-tints against a *light* base (Decision #0020); on a dark base it
   would just push toward black and disappear. `screen` is multiply's
   dark-theme counterpart — it adds light instead of removing it, which
   is what reads as a glow against a dark background. */
[data-theme="dark"] .cursor-light {
  mix-blend-mode: screen;
}

.atmosphere__grain {
  position: absolute;
  inset: -10%;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Dark theme — same reasoning as .cursor-light above: `multiply` needs
   a light base to have any visible effect; `overlay` is the version
   that reads correctly against a dark one (this was in fact the
   original pre-#0007 value). */
[data-theme="dark"] .atmosphere__grain {
  mix-blend-mode: overlay;
}

@keyframes drift-a {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(6%, 8%) scale(1.08);
  }
}

@keyframes drift-b {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(-7%, -5%) scale(1.1);
  }
}

@keyframes drift-c {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(-5%, 6%) scale(0.94);
  }
}

/* ---- Navigation entrance ----
   Runs once on page load via CSS animation (no JS/IntersectionObserver
   needed since the nav is always in view). Uses the standalone `translate`
   property, not `transform`, so it composes independently of .nav's
   `transform: translateX(-50%)` centering instead of overwriting it. */

.nav {
  opacity: 0;
  translate: 0 -16px;
  filter: blur(6px);
  animation: nav-in var(--duration-slow) var(--ease-glass) 200ms both;
}

@keyframes nav-in {
  to {
    opacity: 1;
    translate: 0 0;
    filter: blur(0);
  }
}

/* ---- Hero glass orb ----
   Slow float + a drifting specular highlight, suggesting light moving
   across a curved glass surface. Covered by the global reduced-motion
   rule below like everything else in this file. */

.hero-orb {
  animation: orb-float 7s ease-in-out infinite alternate;
}

.hero-orb__highlight {
  animation: highlight-drift 9s ease-in-out infinite alternate;
}

.hero-chip--a {
  animation: chip-float-a 6s ease-in-out infinite alternate;
}

.hero-chip--b {
  animation: chip-float-b 8s ease-in-out infinite alternate;
}

@keyframes orb-float {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-16px);
  }
}

@keyframes highlight-drift {
  from {
    transform: translate(0, 0);
    opacity: 0.5;
  }
  to {
    transform: translate(14px, 10px);
    opacity: 0.75;
  }
}

@keyframes chip-float-a {
  from {
    transform: translateY(0) rotate(0deg);
  }
  to {
    transform: translateY(-12px) rotate(4deg);
  }
}

@keyframes chip-float-b {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(14px);
  }
}

/* ---- Scroll / load reveal system ----
   JS toggles .is-visible on elements with [data-reveal] via
   IntersectionObserver. Starts blurred + offset, resolves to sharp. */

[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  filter: blur(6px);
  transition: opacity var(--duration-slow) var(--ease-glass),
    transform var(--duration-slow) var(--ease-glass),
    filter var(--duration-slow) var(--ease-glass);
}

[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

[data-reveal-group] > * {
  transition-delay: calc(var(--reveal-index, 0) * 90ms);
}

/* ---- Reduced motion: mandatory ---- */

@media (prefers-reduced-motion: reduce) {
  .atmosphere__orb {
    animation: none !important;
  }

  /* motion.js already skips creating this element under reduced motion;
     this is a belt-and-suspenders hide in case it ever runs anyway. */
  .cursor-light {
    display: none !important;
  }

  [data-reveal] {
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
