/* ============================================
   SAM & SONS V3 — Animation System
   "Industrial Brutalist Tech" / Asphalt Tech
   ─────────────────────────────────────────────
   Loader, Cursor, Reveals, Stagger, Text Split,
   Shimmer, Pulse, Glow, Marquee, Ribbon, Grain,
   Tire Motif, Bento Tiles, Card Effects,
   Parallax, Transitions, Utilities
   ============================================ */


/* ─────────────────────────────────────────────
   01 — PAGE LOADER
   ───────────────────────────────────────────── */

.page-loader {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  z-index: var(--z-loader);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity 0.6s var(--ease-out-expo),
              visibility 0.6s;
}

.page-loader.loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-logo {
  width: 120px;
  height: auto;
  margin-bottom: var(--space-xl);
  animation: loaderPulse 1.5s ease-in-out infinite;
}

.loader-bar {
  width: 200px;
  height: 2px;
  background: var(--color-surface);
  border-radius: 1px;
  overflow: hidden;
  position: relative;
}

.loader-bar::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  border-radius: 1px;
  animation: loaderProgress 1.8s var(--ease-out-expo) forwards;
}

@keyframes loaderPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.05); }
}

@keyframes loaderProgress {
  0%   { width: 0%; }
  50%  { width: 70%; }
  100% { width: 100%; }
}

@keyframes loaderGlow {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 0.8; }
}


/* ─────────────────────────────────────────────
   02 — CUSTOM CURSOR
   ───────────────────────────────────────────── */

.cursor-dot {
  position: fixed;
  width: 4px;
  height: 4px;
  background: var(--color-cyan);
  border-radius: var(--radius-full);
  pointer-events: none;
  z-index: var(--z-cursor);
  transform: translate(-50%, -50%);
  transition: width 0.3s var(--ease-spring),
              height 0.3s var(--ease-spring),
              background 0.3s ease;
}

.cursor-circle {
  position: fixed;
  width: 30px;
  height: 30px;
  border: 1px solid var(--color-cyan);
  border-radius: var(--radius-full);
  pointer-events: none;
  z-index: var(--z-cursor);
  transform: translate(-50%, -50%);
  transition: width 0.4s var(--ease-spring),
              height 0.4s var(--ease-spring),
              border-color 0.3s ease,
              opacity 0.3s ease;
  opacity: 0.5;
}

/* Cursor — hover state */
.cursor-hover .cursor-dot {
  width: 16px;
  height: 16px;
  background: var(--color-cyan-light);
}

.cursor-hover .cursor-circle {
  width: 60px;
  height: 60px;
  border-color: var(--color-cyan-light);
  opacity: 0.3;
}

/* Cursor — click state */
.cursor-click .cursor-dot {
  width: 6px;
  height: 6px;
}

.cursor-click .cursor-circle {
  width: 30px;
  height: 30px;
}

/* Hide cursor on touch devices */
@media (max-width: 1024px) {
  .cursor-dot,
  .cursor-circle {
    display: none !important;
  }
}


/* ─────────────────────────────────────────────
   03 — SCROLL REVEAL SYSTEM
   ───────────────────────────────────────────── */

/* Base — translate Y */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s var(--ease-out-expo),
              transform 0.8s var(--ease-out-expo);
  will-change: opacity, transform;
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Reveal from left */
.reveal-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.8s var(--ease-out-expo),
              transform 0.8s var(--ease-out-expo);
  will-change: opacity, transform;
}

.reveal-left.revealed {
  opacity: 1;
  transform: translateX(0);
}

/* Reveal from right */
.reveal-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.8s var(--ease-out-expo),
              transform 0.8s var(--ease-out-expo);
  will-change: opacity, transform;
}

.reveal-right.revealed {
  opacity: 1;
  transform: translateX(0);
}

/* Reveal — scale */
.reveal-scale {
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 0.8s var(--ease-out-expo),
              transform 0.8s var(--ease-out-expo);
  will-change: opacity, transform;
}

.reveal-scale.revealed {
  opacity: 1;
  transform: scale(1);
}

/* Reveal — rotate */
.reveal-rotate {
  opacity: 0;
  transform: translateY(40px) rotate(3deg);
  transition: opacity 0.8s var(--ease-out-expo),
              transform 0.8s var(--ease-out-expo);
  will-change: opacity, transform;
}

.reveal-rotate.revealed {
  opacity: 1;
  transform: translateY(0) rotate(0deg);
}

/* Reveal — clip (bottom to top) */
.reveal-clip {
  clip-path: inset(100% 0 0 0);
  transition: clip-path 1s var(--ease-out-expo);
  will-change: clip-path;
}

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

/* Reveal — clip left */
.reveal-clip-left {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 1s var(--ease-out-expo);
  will-change: clip-path;
}

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

/* Reveal — clip right */
.reveal-clip-right {
  clip-path: inset(0 0 0 100%);
  transition: clip-path 1s var(--ease-out-expo);
  will-change: clip-path;
}

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

/* Reveal — bento tile (scale variant for grid tiles)
   !important needed to override .bento-tile and [data-tilt] transitions */
.reveal-tile {
  opacity: 0 !important;
  transform: scale(0.97) !important;
  transition: opacity 0.8s var(--ease-out-expo),
              transform 0.8s var(--ease-out-expo) !important;
}

.reveal-tile.revealed {
  opacity: 1 !important;
  transform: scale(1) !important;
}


/* ─────────────────────────────────────────────
   04 — STAGGER DELAYS & GROUPS
   ───────────────────────────────────────────── */

.reveal-delay-1  { transition-delay: 0.1s; }
.reveal-delay-2  { transition-delay: 0.2s; }
.reveal-delay-3  { transition-delay: 0.3s; }
.reveal-delay-4  { transition-delay: 0.4s; }
.reveal-delay-5  { transition-delay: 0.5s; }
.reveal-delay-6  { transition-delay: 0.6s; }
.reveal-delay-7  { transition-delay: 0.7s; }
.reveal-delay-8  { transition-delay: 0.8s; }
.reveal-delay-9  { transition-delay: 0.9s; }
.reveal-delay-10 { transition-delay: 1.0s; }

/* Stagger group — children auto-staggered via JS */
.stagger-group > * {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s var(--ease-out-expo),
              transform 0.6s var(--ease-out-expo);
}

.stagger-group.revealed > * {
  opacity: 1;
  transform: translateY(0);
}


/* ─────────────────────────────────────────────
   05 — TEXT SPLIT ANIMATION
   ───────────────────────────────────────────── */

[data-split] .char,
[data-split] .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.5s var(--ease-out-expo),
              transform 0.5s var(--ease-out-expo);
}

[data-split].revealed .char,
[data-split].revealed .word {
  opacity: 1;
  transform: translateY(0);
}

/* Whitespace for words */
[data-split] .word {
  margin-right: 0.3em;
}

[data-split] .word:last-child {
  margin-right: 0;
}

/* Char overflow hidden wrapper */
[data-split] .char-wrap {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
}


/* ─────────────────────────────────────────────
   06 — CYAN SHIMMER EFFECT
   ───────────────────────────────────────────── */

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-cyan-shimmer);
  background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
  pointer-events: none;
}


/* ─────────────────────────────────────────────
   07 — PULSE ANIMATIONS
   ───────────────────────────────────────────── */

/* Primary red pulse */
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 var(--color-primary-glow); }
  70%  { box-shadow: 0 0 0 20px rgba(226, 5, 18, 0); }
  100% { box-shadow: 0 0 0 0 rgba(226, 5, 18, 0); }
}

.pulse {
  animation: pulse 2.5s ease-in-out infinite;
}

/* Cyan pulse (replaces gold pulse) */
@keyframes pulseCyan {
  0%   { box-shadow: 0 0 0 0 var(--color-cyan-glow); }
  70%  { box-shadow: 0 0 0 15px rgba(226, 5, 18, 0); }
  100% { box-shadow: 0 0 0 0 rgba(226, 5, 18, 0); }
}

.pulse-cyan {
  animation: pulseCyan 2.5s ease-in-out infinite;
}

/* Legacy alias — .pulse-gold now maps to cyan */
.pulse-gold {
  animation: pulseCyan 2.5s ease-in-out infinite;
}

/* Green pulse (battery / energy accent) */
@keyframes pulseGreen {
  0%   { box-shadow: 0 0 0 0 var(--color-green-glow); }
  70%  { box-shadow: 0 0 0 12px rgba(0, 230, 118, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0); }
}

.pulse-green {
  animation: pulseGreen 2.5s ease-in-out infinite;
}


/* ─────────────────────────────────────────────
   08 — GLOW ANIMATION
   ───────────────────────────────────────────── */

@keyframes glowCyan {
  0%, 100% { box-shadow: var(--shadow-glow-cyan); }
  50%      { box-shadow: 0 0 50px var(--color-cyan-glow); }
}

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

@keyframes glowGreen {
  0%, 100% { box-shadow: var(--shadow-glow-green); }
  50%      { box-shadow: 0 0 40px var(--color-green-glow); }
}

.glow-green {
  animation: glowGreen 3s ease-in-out infinite;
}


/* ─────────────────────────────────────────────
   09 — MARQUEE (brand logos)
   ───────────────────────────────────────────── */

@keyframes marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.marquee-container {
  overflow: hidden;
  position: relative;
}

.marquee-track {
  display: flex;
  align-items: center;
  gap: var(--space-4xl);
  animation: marquee 60s linear infinite;
  width: max-content;
}

.marquee-track:hover {
  animation-play-state: paused;
}

/* Dark gradient fade on edges */
.marquee-container::before,
.marquee-container::after {
  content: '';
  position: absolute;
  top: 0;
  width: 150px;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.marquee-container::before {
  left: 0;
  background: linear-gradient(to right, var(--color-bg), transparent);
}

.marquee-container::after {
  right: 0;
  background: linear-gradient(to left, var(--color-bg), transparent);
}

/* Alt bg variant */
.section-alt .marquee-container::before {
  background: linear-gradient(to right, var(--color-bg-alt), transparent);
}

.section-alt .marquee-container::after {
  background: linear-gradient(to left, var(--color-bg-alt), transparent);
}


/* ─────────────────────────────────────────────
   10 — MARQUEE TEXT RIBBON
   ───────────────────────────────────────────── */

.ribbon {
  overflow: hidden;
  white-space: nowrap;
  padding: var(--space-lg) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.ribbon-track {
  display: inline-flex;
  animation: ribbonScroll 25s linear infinite;
}

.ribbon-text {
  font-family: var(--font-heading);
  font-size: var(--fs-mega);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  color: transparent;
  -webkit-text-stroke: 1px var(--color-border-hover);
  padding: 0 var(--space-2xl);
  line-height: 1;
}

.ribbon-text .highlight {
  -webkit-text-stroke-color: var(--color-cyan);
}

@keyframes ribbonScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ribbon:hover .ribbon-track {
  animation-play-state: paused;
}


/* ─────────────────────────────────────────────
   11 — GRAIN TEXTURE OVERLAY
   ───────────────────────────────────────────── */

.grain::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px;
}


/* ─────────────────────────────────────────────
   12 — SCROLL-DRIVEN TIRE ROTATION
   ───────────────────────────────────────────── */

.tire-motif {
  position: fixed;
  bottom: var(--space-2xl);
  right: var(--space-2xl);
  width: var(--tire-size);
  height: var(--tire-size);
  opacity: var(--tire-opacity);
  pointer-events: none;
  z-index: 1;
  animation: tireRotate linear;
  animation-timeline: scroll();
}

@keyframes tireRotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(1080deg); }
}

/* Fallback for browsers without scroll-driven animations */
@supports not (animation-timeline: scroll()) {
  .tire-motif {
    animation: tireRotateFallback 10s linear infinite;
  }

  @keyframes tireRotateFallback {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }
}


/* ─────────────────────────────────────────────
   13 — COUNTER ANIMATION
   ───────────────────────────────────────────── */

@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes counterBounce {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.1); }
}

.counter-bounce {
  animation: counterBounce 0.4s var(--ease-spring);
}


/* ─────────────────────────────────────────────
   14 — FLOAT & SPIN
   ───────────────────────────────────────────── */

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-15px); }
}

.float {
  animation: float 4s ease-in-out infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}


/* ─────────────────────────────────────────────
   15 — LOADING SPINNER (cyan)
   ───────────────────────────────────────────── */

.spinner {
  width: 40px;
  height: 40px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-cyan);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}


/* ─────────────────────────────────────────────
   16 — PROGRESS BAR
   ───────────────────────────────────────────── */

.progress-bar {
  height: 6px;
  background-color: var(--color-surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  border-radius: var(--radius-sm);
  width: 0;
  transition: width 1.5s var(--ease-out-expo);
  position: relative;
}

/* Shimmer on progress bar fill */
.progress-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-cyan-shimmer);
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
}


/* ─────────────────────────────────────────────
   17 — SCROLL INDICATOR
   ───────────────────────────────────────────── */

@keyframes scrollDown {
  0%   { opacity: 0; transform: translateY(-8px); }
  50%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(8px); }
}

.scroll-indicator {
  position: absolute;
  bottom: var(--space-2xl);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-cyan);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  font-family: var(--font-body);
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.scroll-indicator:hover {
  opacity: 1;
}

.scroll-indicator-line {
  width: 1px;
  height: 40px;
  background: var(--color-cyan);
  position: relative;
  overflow: hidden;
}

.scroll-indicator-line::after {
  content: '';
  position: absolute;
  top: -100%;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-cyan-light);
  animation: scrollDown 1.5s ease-in-out infinite;
}


/* ─────────────────────────────────────────────
   18 — CARD TILT 3D (applied by JS)
   ───────────────────────────────────────────── */

[data-tilt] {
  transform-style: preserve-3d;
}

[data-tilt].revealed {
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal),
              transform 0.15s ease-out;
}

[data-tilt] .tilt-inner {
  transform: translateZ(30px);
}

/* Card hover highlight — cyan radial */
.card-highlight {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: radial-gradient(
    600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(226, 5, 18, 0.05),
    transparent 40%
  );
}

[data-tilt]:hover .card-highlight {
  opacity: 1;
}


/* ─────────────────────────────────────────────
   19 — MAGNETIC BUTTON (applied by JS)
   ───────────────────────────────────────────── */

[data-magnetic] {
  transition: transform 0.3s var(--ease-spring);
}


/* ─────────────────────────────────────────────
   20 — IMAGE HOVER ZOOM
   ───────────────────────────────────────────── */

.img-zoom {
  overflow: hidden;
}

.img-zoom img {
  transition: transform 0.8s var(--ease-out-expo);
  will-change: transform;
}

.img-zoom:hover img {
  transform: scale(1.08);
}


/* ─────────────────────────────────────────────
   21 — BORDER ANIMATIONS
   ───────────────────────────────────────────── */

@keyframes borderCyan {
  0%   { border-color: var(--color-border); }
  50%  { border-color: var(--color-border-cyan); }
  100% { border-color: var(--color-border); }
}

@keyframes tileBorderGlow {
  0%, 100% { box-shadow: inset 0 0 0 1px var(--color-border); }
  50%      { box-shadow: inset 0 0 0 1px var(--color-border-cyan); }
}


/* ─────────────────────────────────────────────
   22 — PARALLAX LAYERS
   ───────────────────────────────────────────── */

[data-parallax] {
  will-change: transform;
}


/* ─────────────────────────────────────────────
   23 — LINK ARROW SLIDE
   ───────────────────────────────────────────── */

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-cyan);
  font-weight: var(--fw-medium);
  transition: color var(--transition-fast),
              gap var(--transition-fast);
}

.link-arrow:hover {
  color: var(--color-cyan-light);
  gap: var(--space-md);
}

.link-arrow svg,
.link-arrow .arrow {
  transition: transform var(--transition-fast);
}

.link-arrow:hover svg,
.link-arrow:hover .arrow {
  transform: translateX(4px);
}


/* ─────────────────────────────────────────────
   24 — UNDERLINE ANIMATED (nav links)
   ───────────────────────────────────────────── */

.underline-hover {
  position: relative;
}

.underline-hover::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-cyan);
  transition: width 0.4s var(--ease-out-expo);
}

.underline-hover:hover::after,
.underline-hover.active::after {
  width: 100%;
}


/* ─────────────────────────────────────────────
   25 — DOT INDICATOR (active nav)
   ───────────────────────────────────────────── */

.dot-indicator {
  position: relative;
}

.dot-indicator::before {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%) scale(0);
  width: 4px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-cyan);
  transition: transform 0.3s var(--ease-spring);
}

.dot-indicator.active::before {
  transform: translateX(-50%) scale(1);
}


/* ─────────────────────────────────────────────
   26 — GENERAL ANIMATION UTILITIES
   ───────────────────────────────────────────── */

/* Fade in up */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
  animation: fadeInUp 0.8s var(--ease-out-expo) both;
}

/* Fade in */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.6s ease both;
}

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

.scale-in {
  animation: scaleIn 0.6s var(--ease-spring) both;
}

/* Slide in from left (mobile menu) */
@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* Fade in down (dropdown) */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in-down {
  animation: fadeInDown 0.4s var(--ease-out-expo) both;
}

/* Fade out */
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.fade-out {
  animation: fadeOut 0.3s ease both;
}


/* ─────────────────────────────────────────────
   27 — ACCESSIBILITY — prefers-reduced-motion
   ───────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {

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

  .reveal,
  .reveal-left,
  .reveal-right,
  .reveal-scale,
  .reveal-rotate,
  .reveal-clip,
  .reveal-clip-left,
  .reveal-clip-right,
  .reveal-tile {
    opacity: 1;
    transform: none;
    clip-path: none;
    transition: none;
  }

  .stagger-group > * {
    opacity: 1;
    transform: none;
    transition: none;
  }

  [data-split] .char,
  [data-split] .word {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .page-loader {
    display: none;
  }

  .cursor-dot,
  .cursor-circle {
    display: none;
  }

  .marquee-track {
    animation: none;
  }

  .ribbon-track {
    animation: none;
  }

  .scroll-indicator-line::after {
    animation: none;
  }

  .grain::before {
    display: none;
  }

  .tire-motif {
    animation: none;
  }
}
