/* Ryan Arche Server — Animations v2.0 */
/* "Liquid Precision" — purposeful motion, high-impact moments */

/* ===== GSAP ANIMATION STATES ===== */
/* Elements are visible by default — GSAP hides & animates via JS only. */
/* If GSAP fails to load, everything remains visible (progressive enhancement). */

/* will-change applied via JS only during active animation */

/* ===== TYPEWRITER CURSOR ===== */
.typewriter-cursor {
  display: inline-block;
  color: var(--cyan, #00D4FF);
  font-weight: 400;
  animation: blink-cursor 0.7s step-end infinite;
  margin-left: 2px;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
[data-animate="typewriter"] {
  min-height: 1.2em;
  font-family: var(--font-display, inherit);
}

/* ===== REDUCED MOTION OVERRIDE ===== */
@media (prefers-reduced-motion: reduce) {
  [data-animate] {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }

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

/* ===== KEYFRAME DEFINITIONS ===== */

/* Hero entrance — upward fade */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scroll indicator drop */
@keyframes scrollDrop {
  0%   { top: -100%; opacity: 1; }
  80%  { opacity: 1; }
  100% { top: 100%;  opacity: 0; }
}

/* Floating product image */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-12px); }
}

/* Pulse glow — accent elements */
@keyframes pulse-glow {
  0%, 100% { opacity: 0.3; box-shadow: 0 0 20px var(--accent-glow); }
  50%       { opacity: 0.7; box-shadow: 0 0 40px var(--accent-glow), 0 0 80px var(--accent-glow); }
}

/* Pulse glow — cyan */
@keyframes pulse-glow-cyan {
  0%, 100% { opacity: 0.4; filter: drop-shadow(0 0 8px rgba(0,212,255,0.3)); }
  50%       { opacity: 0.9; filter: drop-shadow(0 0 20px rgba(0,212,255,0.7)); }
}

/* Glitch — chromatic aberration */
@keyframes glitch {
  0%  { text-shadow: none; }
  10% { text-shadow: -2px 0 var(--cyan), 2px 0 var(--accent); clip-path: inset(20% 0 60% 0); }
  12% { text-shadow: none; clip-path: none; }
  40% { text-shadow: -1px 0 var(--cyan), 1px 0 var(--accent); clip-path: inset(70% 0 5% 0); }
  42% { text-shadow: none; clip-path: none; }
  100%{ text-shadow: none; }
}

/* Grid background scan */
@keyframes grid-scan {
  0%   { background-position: 0 0; }
  100% { background-position: var(--grid-size) var(--grid-size); }
}

/* Gradient shift */
@keyframes gradient-shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Rotating border glow */
@keyframes border-rotate {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Blink cursor */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Horizontal bar fill (for comparison bars) */
@keyframes barFill {
  from { width: 0; }
  to   { width: var(--bar-target); }
}

/* Slide in from left */
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Scale in */
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

/* ===== CSS-ONLY HERO ENTRANCE ===== */
/* Used as fallback when GSAP is not available */
.hero-fade {
  opacity: 0;
  transform: translateY(30px);
  animation: fadeUp 0.8s var(--ease-out) forwards;
}

.hero-fade--delay-1 { animation-delay: 0.15s; }
.hero-fade--delay-2 { animation-delay: 0.30s; }
.hero-fade--delay-3 { animation-delay: 0.45s; }
.hero-fade--delay-4 { animation-delay: 0.60s; }

/* ===== PERSISTENT ANIMATIONS ===== */
/* These run continuously regardless of scroll position */

.float-anim {
  animation: float 6s var(--ease-in-out) infinite;
}

.pulse-glow-anim {
  animation: pulse-glow 3s ease-in-out infinite;
}

.cursor-blink::after {
  content: '|';
  animation: blink 1s step-end infinite;
  color: var(--cyan);
  margin-left: 2px;
}

/* ===== HERO BACKGROUND ===== */
.hero-grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 70% at center, black 0%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at center, black 0%, transparent 80%);
  pointer-events: none;
  z-index: 1;
}

.hero-radial-glow {
  position: absolute;
  width: 80vw;
  height: 80vw;
  max-width: 900px;
  max-height: 900px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(23,95,163,0.08) 0%, transparent 65%);
  pointer-events: none;
  z-index: 1;
}

/* ===== CARD GLOW BORDER ===== */
.card-glow {
  position: relative;
}

.card-glow::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, transparent 30%, var(--cyan) 50%, transparent 70%);
  background-size: 300% 300%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  padding: 1px;
}

.card-glow:hover::before {
  opacity: 1;
  animation: border-rotate 4s linear infinite;
}

/* ===== TEXT EFFECTS ===== */
.text-gradient {
  background: linear-gradient(135deg, #ffffff 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-gradient--cyan {
  background: linear-gradient(135deg, #ffffff 0%, var(--cyan) 60%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-glitch {
  animation: glitch 8s ease-in-out infinite;
}

/* Text split chars (for GSAP SplitText) */
.split-char {
  display: inline-block;
  opacity: 0;
  transform: translateY(40px);
}

.split-word {
  display: inline-block;
  overflow: hidden;
}

/* Animated gradient text */
.text-gradient-animate {
  background: linear-gradient(
    90deg,
    var(--text-primary) 0%,
    var(--cyan) 30%,
    var(--accent) 60%,
    var(--text-primary) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 6s linear infinite;
}

/* ===== SECTION TRANSITION ===== */
.section-enter {
  opacity: 0;
  transform: translateY(40px);
}

.section-enter--visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

/* ===== CLIP REVEALS ===== */
.clip-reveal {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 0.9s var(--ease-in-out);
}

.clip-reveal--visible {
  clip-path: inset(0 0 0 0);
}

/* ===== STAGGER DELAYS ===== */
[data-delay="1"] { --stagger: 0.1s; }
[data-delay="2"] { --stagger: 0.2s; }
[data-delay="3"] { --stagger: 0.3s; }
[data-delay="4"] { --stagger: 0.4s; }
[data-delay="5"] { --stagger: 0.5s; }
[data-delay="6"] { --stagger: 0.6s; }

/* ===== ACCENT LINES ===== */
.accent-line {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.4;
}

.accent-line--cyan {
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
}

/* ===== SCAN LINES ===== */
.scanlines::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(255,255,255,0.008) 3px,
    rgba(255,255,255,0.008) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* ===== GLASS MORPHISM ===== */
.glass-card {
  background: rgba(17, 17, 24, 0.6);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.06);
}

/* ===== TECH GRID BACKGROUND ===== */
.tech-grid-bg {
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  position: relative;
}

.tech-grid-bg--animated {
  animation: grid-scan 8s linear infinite;
}

/* ===== NOISE TEXTURE ===== */
/* noise-overlay disabled for performance (SVG feTurbulence + mix-blend-mode) */

/* ===== HOVER LIFT ===== */
.hover-lift {
  transition: transform var(--duration-normal) var(--ease-out), box-shadow var(--duration-normal) var(--ease-out);
}

.hover-lift:hover {
  transform: translateY(-6px);
}

/* ===== MAGNETIC BUTTON ===== */
@media (pointer: fine) {
  .btn-magnetic {
    transition: transform 0.2s var(--ease-out);
  }
}

/* ===== HEADING UNDERLINE ===== */
.heading-line {
  position: relative;
  display: inline-block;
}

.heading-line::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 0;
  width: 48px;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), transparent);
}

/* ===== COUNT-UP NUMBER STYLE ===== */
[data-animate="count-up"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* ===== DOT GRID ===== */
.dot-grid {
  background-image: radial-gradient(circle, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ===== GLOW SHADOWS ===== */
.shadow-glow-cyan {
  box-shadow: var(--shadow-glow-cyan);
}

.shadow-glow-accent {
  box-shadow: var(--shadow-glow-accent);
}

/* =====================================================================
   LITE MODE — low-end hardware performance fallbacks
   Applied to <html class="lite-mode"> by js/app.js when any of these hold:
     - prefers-reduced-motion: reduce
     - prefers-reduced-transparency: reduce
     - navigator.hardwareConcurrency < 4
     - navigator.deviceMemory < 4
   Also applied implicitly via @media (prefers-reduced-transparency: reduce).
   ===================================================================== */

/* Disable backdrop-filter (biggest composite cost during scroll) */
.lite-mode .glass-card,
.lite-mode .bottom-bar {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: rgba(17, 17, 24, 0.95) !important;
}

/* Kill infinite decorative animations that composite every frame */
.lite-mode .float-anim,
.lite-mode .pulse-glow-anim,
.lite-mode .tech-grid-bg--animated,
.lite-mode .text-glitch,
.lite-mode .card-glow:hover::before {
  animation: none !important;
}

/* Hide ambient glow overlays (they're decorative) */
.lite-mode .ambient-glow {
  display: none !important;
}

/* Native hint for browsers that support it */
@media (prefers-reduced-transparency: reduce) {
  .glass-card,
  .bottom-bar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(17, 17, 24, 0.95) !important;
  }
}

/* =====================================================================
   NO-REVEAL-ANIM — scoped "fully static" mode for product detail pages.
   JS early-returns from ArAnimations.init(), but that only gates GSAP
   reveal animations. CSS @keyframes (float, pulse-glow, border-rotate,
   grid-scan, etc.) and transitions keep running unless explicitly killed.
   Mirrors prefers-reduced-motion behavior, scoped to opted-out pages.
   ===================================================================== */
.no-reveal-anim [data-animate] {
  opacity: 1 !important;
  transform: none !important;
}

.no-reveal-anim .float-anim,
.no-reveal-anim .pulse-glow-anim,
.no-reveal-anim .tech-grid-bg--animated,
.no-reveal-anim .text-glitch,
.no-reveal-anim .gradient-shift,
.no-reveal-anim .card-glow:hover::before {
  animation: none !important;
}

.no-reveal-anim .ambient-glow {
  display: none !important;
}

/* Nuke all CSS animations and transitions on product detail pages */
.no-reveal-anim *,
.no-reveal-anim *::before,
.no-reveal-anim *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}
