/* ==========================================================================
   Zorn Ventures Limited - Custom effects and animations
   --------------------------------------------------------------------------
   Scroll reveals, text/line animations and decorative hero motion.
   Everything here is disabled under prefers-reduced-motion.

   Contents
     1. Scroll reveal
     2. Text reveal
     3. Line draw
     4. Hero motion
     5. Marquee
     6. Reduced motion
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Scroll reveal
   Elements start hidden and are revealed when IntersectionObserver adds
   .is-inview. A no-js fallback below keeps content visible without scripts.
   -------------------------------------------------------------------------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
[data-reveal].is-inview {
  opacity: 1;
  transform: none;
}
/* Release will-change once the animation has completed. */
[data-reveal].is-done { will-change: auto; }

[data-reveal='fade'] { transform: none; }
[data-reveal='left']  { transform: translateX(-22px); }
[data-reveal='right'] { transform: translateX(22px); }
[data-reveal='scale'] { transform: scale(0.97); }

/* Without JavaScript, never hide content. */
.no-js [data-reveal] { opacity: 1; transform: none; }

/* --------------------------------------------------------------------------
   2. Text reveal
   Each line is wrapped in a clipping mask and slides up in sequence.
   -------------------------------------------------------------------------- */
.nx-reveal-line {
  display: block;
  overflow: hidden;
}
.nx-reveal-line > span {
  display: block;
  transform: translateY(105%);
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--line-delay, 0ms);
}
.is-inview > .nx-reveal-line > span,
.nx-reveal-line.is-inview > span {
  transform: translateY(0);
}
.no-js .nx-reveal-line > span { transform: none; }

/* --------------------------------------------------------------------------
   3. Line draw
   Horizontal rules that expand from the left when scrolled into view.
   -------------------------------------------------------------------------- */
.nx-line-draw {
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1s cubic-bezier(0.22, 1, 0.36, 1);
}
.nx-line-draw.is-inview { transform: scaleX(1); }
.no-js .nx-line-draw { transform: none; }

/* --------------------------------------------------------------------------
   4. Hero motion
   Slow, low-amplitude ambient movement. Deliberately restrained.
   -------------------------------------------------------------------------- */

/* Vertical scan line sweeping the hero grid. */
@keyframes nxScan {
  0%   { transform: translateY(-100%); opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { transform: translateY(1000%); opacity: 0; }
}
.nx-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(4, 181, 255, 0.6), transparent);
  animation: nxScan 9s linear infinite;
}

/* Slow pulse for hero node dots. */
@keyframes nxPulse {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50%      { opacity: 0.9;  transform: scale(1.5); }
}
.nx-node { animation: nxPulse 4s ease-in-out infinite; }

/* Blinking caret for the terminal-style hero panel. */
@keyframes nxBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
.nx-caret {
  display: inline-block;
  width: 0.5rem;
  height: 1em;
  background: currentColor;
  vertical-align: text-bottom;
  animation: nxBlink 1.1s step-end infinite;
}

/* Stroke drawing for the hero SVG diagram. */
@keyframes nxDraw { to { stroke-dashoffset: 0; } }
.nx-draw {
  stroke-dasharray: var(--len, 400);
  stroke-dashoffset: var(--len, 400);
  animation: nxDraw 2.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: var(--draw-delay, 0ms);
}

/* --------------------------------------------------------------------------
   5. Marquee
   Capability ticker. Duplicated content in markup makes the loop seamless.
   -------------------------------------------------------------------------- */
.nx-marquee {
  display: flex;
  overflow: hidden;
  user-select: none;
  gap: 0;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.nx-marquee__track {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 3rem;
  padding-right: 3rem;
  min-width: 100%;
  animation: nxMarquee 38s linear infinite;
}
.nx-marquee:hover .nx-marquee__track { animation-play-state: paused; }
@keyframes nxMarquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* --------------------------------------------------------------------------
   6. Reduced motion
   Honour the user preference: show final states, remove all movement.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

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

  [data-reveal],
  .nx-reveal-line > span,
  .nx-line-draw {
    opacity: 1 !important;
    transform: none !important;
  }

  .nx-scan,
  .nx-node,
  .nx-caret { animation: none !important; }
  .nx-scan { opacity: 0; }

  .nx-marquee__track { animation: none !important; }
  .nx-marquee {
    overflow-x: auto;
    mask-image: none;
    -webkit-mask-image: none;
  }

  .nx-draw { stroke-dashoffset: 0 !important; animation: none !important; }

  .nx-media img { transition: none !important; }
  .nx-media:hover img { transform: none !important; }
}
