/* ==========================================================================
   LEECOI — Motion
   ==========================================================================

   Two eases only: `--ease-entrance` for things arriving, `--ease-ui` for things
   responding. A third ease would be a fourth opinion about the same question.

   THE NO-JS CONTRACT

   Every entrance below is gated on `.js`, a class set by a tiny inline script
   in the document head. If scripting is unavailable or fails, the gate never
   closes and content renders in its final state. Nothing is ever left stranded
   at `opacity: 0` waiting for an observer that will not run.

   THE REDUCED-MOTION CONTRACT

   globals.css section 7 resolves `[data-reveal]` to its END STATE under
   `prefers-reduced-motion`, rather than playing a faster version. A visitor who
   asked for less motion sees a finished page, not a brisk one.
   ========================================================================== */

/* ==========================================================================
   1. SCROLL ENTRANCES
   --------------------------------------------------------------------------
   Driven by one shared IntersectionObserver in animations.js, which unobserves
   each element after it fires. There is no scroll listener anywhere in the
   codebase, so entrances cost nothing per frame.
   ========================================================================== */

.js [data-reveal] {
  opacity: 0;
  /* Composited properties only: transform and opacity never trigger layout. */
  will-change: opacity, transform;
  transition:
    opacity var(--dur-slow) var(--ease-entrance),
    transform var(--dur-slow) var(--ease-entrance);
  /* Set per element by animations.js for staggered groups. */
  transition-delay: var(--reveal-delay, 0ms);
}

/* Distances are small on purpose. A 14px rise reads as the content settling;
   a 60px rise reads as a slideshow. */
.js [data-reveal='up']    { transform: translate3d(0, 14px, 0); }
.js [data-reveal='down']  { transform: translate3d(0, -14px, 0); }
.js [data-reveal='left']  { transform: translate3d(-18px, 0, 0); }
.js [data-reveal='right'] { transform: translate3d(18px, 0, 0); }
.js [data-reveal='scale'] { transform: scale(0.97); }
.js [data-reveal='fade']  { transform: none; }

.js [data-reveal][data-revealed] {
  opacity: 1;
  transform: none;
  /* Released once the transition has served its purpose, so the compositor
     stops holding a layer for an element that will never animate again. */
  will-change: auto;
}

/* ==========================================================================
   2. HERO ENTRANCE
   --------------------------------------------------------------------------
   The one orchestrated moment on the site. Runs on load rather than on scroll,
   because the hero is already in view, and lands as a single sequence instead
   of several unrelated effects firing at once.

   Delays are declarative on the element (`data-enter-step`) so the order is
   readable in the markup rather than buried in a stylesheet.
   ========================================================================== */

.js [data-enter] {
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  animation: enter-rise var(--dur-slow) var(--ease-entrance) forwards;
  animation-delay: calc(var(--enter-step, 0) * 90ms);
}

@keyframes enter-rise {
  to {
    opacity: 1;
    transform: none;
  }
}

/* ==========================================================================
   3. AMBIENT HERO FIELD
   --------------------------------------------------------------------------
   A very slow drift behind the hero. 34 seconds and low opacity: it should
   register as depth rather than as an animation. If it is noticeable as
   movement, it is turned up too far.
   ========================================================================== */

.hero-glow {
  position: absolute;
  z-index: var(--z-behind);
  pointer-events: none;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  animation: glow-drift 34s var(--ease-ui) infinite alternate;
}

@keyframes glow-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(3%, -4%, 0) scale(1.12); }
}

/* ==========================================================================
   4. GRADIENT SWEEP ON THE PRIMARY CALL TO ACTION
   --------------------------------------------------------------------------
   Fires on hover and focus only, never on a loop. A permanently shimmering
   button is noise; a button that answers when addressed is feedback.
   ========================================================================== */

.btn--sweep {
  position: relative;
  overflow: hidden;
  /* Keeps the sweep inside the rounded corners in Safari. */
  isolation: isolate;
}

.btn--sweep::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgb(255 255 255 / 0.45) 50%,
    transparent 80%
  );
  transform: translateX(-100%);
  transition: transform var(--dur-slow) var(--ease-ui);
}

.btn--sweep:hover::before,
.btn--sweep:focus-visible::before {
  transform: translateX(100%);
}

/* ==========================================================================
   5. FOCUS PULSE
   --------------------------------------------------------------------------
   A single pulse when a skipped-to region receives focus, so a keyboard user
   can see where they landed. One iteration, not a loop.
   ========================================================================== */

@keyframes ring-pulse {
  from { box-shadow: 0 0 0 0 var(--ring); }
  to   { box-shadow: 0 0 0 6px transparent; }
}

.pulse-once {
  animation: ring-pulse 700ms var(--ease-ui) 1;
}

/* ==========================================================================
   6. DRAWN LINES
   --------------------------------------------------------------------------
   For the progress curve and architecture diagrams. The dash offset starts at
   the full path length and animates to zero, so the stroke draws itself.
   `--path-len` is written by JS from `getTotalLength()`, since hard-coding a
   path length breaks the moment the path is edited.
   ========================================================================== */

/* Gated on `.js`, and this gate is load-bearing rather than tidy: `--path-len`
   is written by animations.js from `getTotalLength()`. Without scripting the
   fallback dash offset would hide the stroke completely, so an ungated rule
   would mean no curve at all for a scriptless visitor. */
.js .draw-line {
  stroke-dasharray: var(--path-len, 1000);
  stroke-dashoffset: var(--path-len, 1000);
}

.js .draw-line[data-drawn] {
  animation: draw var(--dur-draw) var(--ease-entrance) forwards;
}

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

/* The converged endpoint arrives after the line reaches it, not alongside it.
   Gated for the same reason as the stroke above. */
.js .draw-dot {
  opacity: 0;
  transform: scale(0.4);
  transform-origin: center;
}

.js .draw-dot[data-drawn] {
  animation: dot-land 420ms var(--ease-entrance) forwards;
  animation-delay: var(--dur-draw);
}

@keyframes dot-land {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ==========================================================================
   7. PARALLAX
   --------------------------------------------------------------------------
   Offset is written to `--parallax` by animations.js inside a
   requestAnimationFrame, and only for elements currently in the viewport.
   Kept to single-digit percentages: parallax that is obvious is parallax that
   makes people motion sick.
   ========================================================================== */

.parallax {
  transform: translate3d(0, var(--parallax, 0), 0);
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .parallax {
    transform: none;
  }
}

/* ==========================================================================
   8. MARQUEE
   --------------------------------------------------------------------------
   Only for the toolbelt strip at narrow widths, where the marks cannot fit.
   The track is duplicated in markup and the copy is aria-hidden, so the list
   is announced once. Paused on hover and on focus-within so a keyboard user
   can reach anything inside it.
   ========================================================================== */

.marquee {
  display: flex;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(
    to right,
    transparent,
    #000 8%,
    #000 92%,
    transparent
  );
  mask-image: linear-gradient(
    to right,
    transparent,
    #000 8%,
    #000 92%,
    transparent
  );
}

.marquee__track {
  display: flex;
  flex: none;
  gap: var(--space-2xl);
  padding-inline-end: var(--space-2xl);
  animation: marquee-slide 32s linear infinite;
}

.marquee:hover .marquee__track,
.marquee:focus-within .marquee__track {
  animation-play-state: paused;
}

@keyframes marquee-slide {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* ==========================================================================
   9. COUNTERS
   --------------------------------------------------------------------------
   The number itself is animated in JS. This only stops the width of the
   element jittering as digits change, which otherwise nudges everything
   beside it on every frame.
   ========================================================================== */

.counter {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* ==========================================================================
   10. SHIMMER PLACEHOLDER
   --------------------------------------------------------------------------
   For content genuinely in flight, such as a form submitting. Never used to
   stand in for content that does not exist: an unwritten syllabus gets an
   honest notice, not a fake loading state.
   ========================================================================== */

.shimmer {
  background-image: linear-gradient(
    90deg,
    var(--line) 0%,
    var(--line-strong) 50%,
    var(--line) 100%
  );
  background-size: 200% 100%;
  animation: shimmer-slide 1.4s linear infinite;
}

@keyframes shimmer-slide {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
