/* ============================================
   ANIMATIONS & SCROLL-DRIVEN EFFECTS
   ============================================ */

/* --- Reveal on Scroll --- */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Stagger children */
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-stagger.visible > *:nth-child(1) { transition-delay: 0.05s; }
.reveal-stagger.visible > *:nth-child(2) { transition-delay: 0.1s; }
.reveal-stagger.visible > *:nth-child(3) { transition-delay: 0.15s; }
.reveal-stagger.visible > *:nth-child(4) { transition-delay: 0.2s; }
.reveal-stagger.visible > *:nth-child(5) { transition-delay: 0.25s; }

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

/* --- Hero Title Animation --- */
.hero__title-line {
  display: block;
  overflow: hidden;
}

.hero.loaded .hero__title-line {
  animation: titleReveal 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hero.loaded .hero__title-line:nth-child(1) { animation-delay: 0.2s; }
.hero.loaded .hero__title-line:nth-child(2) { animation-delay: 0.35s; }
.hero.loaded .hero__title-line:nth-child(3) { animation-delay: 0.5s; }

@keyframes titleReveal {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --- Service Card Hover Effects --- */
.service-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(200, 164, 92, 0.03) 0%,
    transparent 50%
  );
  opacity: 0;
  transition: opacity 0.5s ease;
}

.service-card:hover::before {
  opacity: 1;
}

.service-card--highlight::after {
  content: 'POPULAR';
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.25rem 0.5rem;
}

/* --- Placeholder Box Hover --- */
.placeholder-box::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 60%,
    rgba(10, 10, 10, 0.8) 100%
  );
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 1;
}

.placeholder-box:hover::before {
  opacity: 1;
}

.placeholder-box span,
.placeholder-box small {
  position: relative;
  z-index: 2;
}

/* --- Gallery Item Hover --- */
.gallery__item {
  overflow: hidden;
}

.gallery__item .placeholder-box {
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.4s ease;
}

.gallery__item:hover .placeholder-box {
  transform: scale(1.02);
}

/* --- Button Ripple --- */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
  opacity: 0;
  transform: scale(0);
  transition: transform 0.5s ease, opacity 0.5s ease;
}

.btn:active::after {
  opacity: 1;
  transform: scale(2);
  transition: transform 0s, opacity 0s;
}

/* --- Stat Counter Animation --- */
.stat {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat.visible {
  opacity: 1;
  transform: translateY(0);
}

.stat:nth-child(1) { transition-delay: 0s; }
.stat:nth-child(2) { transition-delay: 0.1s; }
.stat:nth-child(3) { transition-delay: 0.2s; }
.stat:nth-child(4) { transition-delay: 0.3s; }

/* --- Accent line animation --- */
.service-card--highlight {
  position: relative;
}

.service-card--highlight::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 0;
  background: var(--accent);
  transition: height 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.service-card--highlight.visible::before {
  height: 100%;
}

/* --- Link underline animation --- */
.contact__detail-value {
  position: relative;
}

a.contact__detail-value::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--text);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

a.contact__detail-value:hover::after {
  width: 100%;
}

/* --- Page Load Animation --- */
@keyframes pageIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

body {
  animation: pageIn 0.6s ease forwards;
}

/* --- Smooth Scroll Indicator --- */
@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

.hero__scroll-indicator {
  animation: scrollBounce 2s ease-in-out infinite;
}

/* --- Focus States (Accessibility) --- */
.btn:focus-visible,
.form-input:focus-visible,
.nav__link:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* --- Potlight Animations --- */

/* LED warm-up flicker on first turn-on */
@keyframes ledFlicker {
  0%   { opacity: 0; }
  10%  { opacity: 0.6; }
  15%  { opacity: 0.3; }
  25%  { opacity: 0.85; }
  30%  { opacity: 0.5; }
  40%  { opacity: 0.95; }
  50%  { opacity: 0.7; }
  65%  { opacity: 1; }
  75%  { opacity: 0.9; }
  100% { opacity: 1; }
}

.potlight.is-flickering .potlight__lens {
  animation: ledFlicker 0.6s ease forwards;
}

.potlight.is-flickering .potlight__cone {
  animation: ledFlicker 0.6s ease forwards;
}

/* Subtle idle glow pulse when on */
@keyframes glowPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}

.potlight.is-on .potlight__lens {
  animation: glowPulse 4s ease-in-out infinite;
}

/* Light cone subtle sway */
@keyframes coneSway {
  0%, 100% { transform: translateX(-50%) scaleX(1); }
  50% { transform: translateX(-50%) scaleX(1.03); }
}

.potlight.is-on .potlight__cone-inner {
  animation: coneSway 6s ease-in-out infinite;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  .marquee__track {
    animation: none;
  }

  .hero__bolt {
    animation: none;
  }

  html {
    scroll-behavior: auto;
  }

  .potlight.is-flickering .potlight__lens,
  .potlight.is-flickering .potlight__cone {
    animation: none;
    opacity: 1;
  }

  .potlight.is-on .potlight__lens {
    animation: none;
  }

  .potlight.is-on .potlight__cone-inner {
    animation: none;
  }

  .potlights__cta-hint svg {
    animation: none;
  }
}
