/* ════════════════════════════════════════════════════════════
   AI Pirates — FX Layer
   Futuristic animations & interactions for static HTML site
   ════════════════════════════════════════════════════════════ */

/* ── Reset body scroll for Lenis ─────────────────────────── */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }

/* ── Custom cursor (desktop only) ────────────────────────── */
@media (hover: hover) and (pointer: fine) {
  html.fx-ready, html.fx-ready body, html.fx-ready a, html.fx-ready button { cursor: none !important; }

  .fx-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #00f0ff;
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: difference;
    transform: translate3d(-50%, -50%, 0);
    transition: width .25s cubic-bezier(.22,.61,.36,1),
                height .25s cubic-bezier(.22,.61,.36,1),
                background .25s,
                border-radius .25s,
                opacity .25s;
    will-change: transform;
  }
  .fx-cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(0, 240, 255, 0.5);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    transform: translate3d(-50%, -50%, 0);
    transition: width .35s cubic-bezier(.22,.61,.36,1),
                height .35s cubic-bezier(.22,.61,.36,1),
                border-color .3s,
                opacity .25s;
    will-change: transform;
  }
  .fx-cursor.is-hidden, .fx-cursor-ring.is-hidden { opacity: 0; }
  .fx-cursor.is-hover {
    width: 6px;
    height: 6px;
    background: #ff2a2a;
  }
  .fx-cursor-ring.is-hover {
    width: 60px;
    height: 60px;
    border-color: rgba(255, 42, 42, 0.6);
  }
  .fx-cursor.is-text {
    width: 2px;
    height: 22px;
    border-radius: 1px;
    background: #00f0ff;
  }
  .fx-cursor-ring.is-text { opacity: 0; }
}

/* ── Magnetic buttons ─────────────────────────────────────── */
.fx-magnetic {
  display: inline-flex;
  position: relative;
  will-change: transform;
}
.fx-magnetic-inner {
  display: inline-flex;
  will-change: transform;
}

/* ── Scroll reveals (pre-GSAP, graceful fallback) ────────── */
@media (prefers-reduced-motion: no-preference) {
  .fx-reveal {
    opacity: 0;
    transform: translate3d(0, 30px, 0);
    transition: none;
    will-change: opacity, transform;
  }
  .fx-reveal.is-in {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  .fx-reveal-stagger > * {
    opacity: 0;
    transform: translate3d(0, 20px, 0);
    will-change: opacity, transform;
  }
}
@media (prefers-reduced-motion: reduce) {
  .fx-reveal, .fx-reveal-stagger > * { opacity: 1 !important; transform: none !important; }
}

/* ── Glitch text ──────────────────────────────────────────── */
.fx-glitch {
  position: relative;
  display: inline-block;
}
.fx-glitch::before,
.fx-glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  overflow: hidden;
  pointer-events: none;
}
.fx-glitch::before {
  color: #00f0ff;
  animation: fx-glitch-1 3.5s infinite steps(1);
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  transform: translate(-2px, 0);
  mix-blend-mode: screen;
  opacity: .7;
}
.fx-glitch::after {
  color: #ff2a2a;
  animation: fx-glitch-2 3.5s infinite steps(1);
  clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
  transform: translate(2px, 0);
  mix-blend-mode: screen;
  opacity: .7;
}
@keyframes fx-glitch-1 {
  0%, 92%, 100% { transform: translate(0, 0); }
  93% { transform: translate(-3px, 1px); }
  94% { transform: translate(2px, -1px); }
  95% { transform: translate(-2px, 0); }
  96% { transform: translate(0, 2px); }
}
@keyframes fx-glitch-2 {
  0%, 92%, 100% { transform: translate(0, 0); }
  93% { transform: translate(3px, -1px); }
  94% { transform: translate(-2px, 1px); }
  95% { transform: translate(2px, 0); }
  96% { transform: translate(0, -2px); }
}
@media (prefers-reduced-motion: reduce) {
  .fx-glitch::before, .fx-glitch::after { animation: none; }
}

/* ── Split-text char reveal ──────────────────────────────── */
.fx-split-char {
  display: inline-block;
  opacity: 0;
  transform: translate3d(0, 1em, 0) rotateX(-45deg);
  transform-origin: 0 50% -0.5em;
  will-change: opacity, transform;
}
.fx-split-char.is-space { width: 0.3em; }

/* ── Hero WebGL canvas ────────────────────────────────────── */
.fx-hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.fx-hero-canvas.is-ready { opacity: 1; }
.fx-hero-wrapper { position: relative; }
.fx-hero-wrapper > *:not(.fx-hero-canvas) { position: relative; z-index: 1; }

/* ── Terminal boot sequence ──────────────────────────────── */
.fx-boot {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #020617;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Courier New', monospace;
  color: #00f0ff;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.fx-boot.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.fx-boot-inner {
  max-width: 520px;
  width: 100%;
  padding: 32px;
  font-size: 12px;
  line-height: 1.8;
  letter-spacing: .08em;
}
.fx-boot-logo {
  font-size: 10px;
  color: rgba(0, 240, 255, 0.4);
  margin-bottom: 24px;
  letter-spacing: .18em;
}
.fx-boot-line {
  display: flex;
  justify-content: space-between;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .2s, transform .2s;
}
.fx-boot-line.is-in {
  opacity: 1;
  transform: none;
}
.fx-boot-line .ok { color: #22c55e; }
.fx-boot-line .err { color: #ff2a2a; }
.fx-boot-bar {
  margin-top: 18px;
  height: 2px;
  background: rgba(0, 240, 255, 0.15);
  border-radius: 1px;
  overflow: hidden;
  position: relative;
}
.fx-boot-bar::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: #00f0ff;
  box-shadow: 0 0 10px #00f0ff;
  transition: width 1.6s cubic-bezier(.22,.61,.36,1);
}
.fx-boot.is-loading .fx-boot-bar::after { width: 100%; }
.fx-boot-prompt {
  margin-top: 24px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
}
.fx-boot-prompt::before {
  content: '> ';
  color: #00f0ff;
}
.fx-boot-cursor {
  display: inline-block;
  width: 7px;
  height: 12px;
  background: #00f0ff;
  vertical-align: middle;
  margin-left: 2px;
  animation: fx-blink 0.9s steps(1) infinite;
}
@keyframes fx-blink { 50% { opacity: 0; } }

/* ── Scroll progress bar ─────────────────────────────────── */
.fx-scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, #00f0ff, #ff2a2a);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 999;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
}

/* ── Section scroll anchors (prevent content jumping under sticky nav) ── */
.fx-section-anchor { scroll-margin-top: 80px; }

/* ── Page transition overlay ─────────────────────────────── */
.fx-page-overlay {
  position: fixed;
  inset: 0;
  background: #020617;
  z-index: 9990;
  transform: translateY(100%);
  pointer-events: none;
  will-change: transform;
}
.fx-page-overlay.is-exiting {
  transform: translateY(0);
  transition: transform 0.55s cubic-bezier(.65,0,.35,1);
}

/* ── Utility: hover tilt ─────────────────────────────────── */
.fx-tilt {
  transform-style: preserve-3d;
  transition: transform .3s cubic-bezier(.22,.61,.36,1);
  will-change: transform;
}

/* ── Neon glow pulse on CTAs ─────────────────────────────── */
.fx-neon {
  position: relative;
  isolation: isolate;
}
.fx-neon::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: linear-gradient(135deg, #00f0ff, #ff2a2a, #a855f7, #00f0ff);
  background-size: 300% 300%;
  z-index: -1;
  opacity: 0;
  filter: blur(8px);
  transition: opacity .3s;
  animation: fx-neon-shift 4s linear infinite;
}
.fx-neon:hover::after { opacity: 0.55; }
@keyframes fx-neon-shift {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

/* ── Mobile: disable heavy fx ────────────────────────────── */
@media (max-width: 768px), (pointer: coarse) {
  .fx-cursor, .fx-cursor-ring { display: none !important; }
  .fx-hero-canvas { opacity: 0.4 !important; }
}
