/**
 * CASE CREATIVE — React Bits Components CSS Suite
 * Faithful native vanilla port of DavidHDev/react-bits components:
 * - ClickSpark
 * - DecryptedText
 * - SpotlightCard
 * - TiltedCard & Glare
 * - TrueFocus Frame Reticle
 * - ShinyText
 * - StarBorder
 * - Film Grain Noise
 */

/* =========================================
   1. CLICK SPARK (React Bits: Animations/ClickSpark)
   ========================================= */
#click-spark-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99998; /* Under custom cursor, above all content */
}

/* =========================================
   2. DECRYPTED TEXT (React Bits: TextAnimations/DecryptedText)
   ========================================= */
.decrypted-text {
  display: inline-block;
  font-family: inherit;
  letter-spacing: inherit;
  will-change: contents;
}

.decrypt-char {
  display: inline-block;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.decrypt-char.is-scrambling {
  color: var(--accent-blue);
  opacity: 0.95;
  text-shadow: 0 0 8px rgba(0, 210, 255, 0.55);
  font-family: var(--font-mono);
}

.decrypt-char.is-revealed {
  color: inherit;
  opacity: 1;
}

/* =========================================
   3. SPOTLIGHT CARD (React Bits: Components/SpotlightCard)
   ========================================= */
.card-spotlight {
  position: relative;
  overflow: hidden;
  --mouse-x: 50%;
  --mouse-y: 50%;
  --spotlight-color: rgba(0, 210, 255, 0.14);
}

.card-spotlight::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    circle 320px at var(--mouse-x) var(--mouse-y),
    var(--spotlight-color),
    transparent 80%
  );
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 2;
}

.card-spotlight:hover::before,
.card-spotlight:focus-within::before {
  opacity: 1;
}

/* =========================================
   4. TILTED CARD & GLARE (React Bits: Components/TiltedCard)
   ========================================= */
.tilted-card-wrap {
  perspective: 1000px;
  transform-style: preserve-3d;
}

.tilted-card-inner {
  transition: transform 0.12s cubic-bezier(0.25, 1, 0.5, 1);
  transform-style: preserve-3d;
  will-change: transform;
  position: relative;
}

.tilted-card-inner.is-reverting {
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Dynamic Glare/Sheen Reflection Layer */
.tilted-card-glare {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle 450px at var(--glare-x, 50%) var(--glare-y, 50%),
    rgba(255, 255, 255, 0.12),
    transparent 70%
  );
  transition: opacity 0.3s ease;
  z-index: 3;
}

.tilted-card-wrap:hover .tilted-card-glare {
  opacity: 1;
}

/* =========================================
   5. TRUE FOCUS FRAME (React Bits: TextAnimations/TrueFocus)
   ========================================= */
.true-focus-frame {
  position: absolute;
  pointer-events: none;
  box-sizing: border-box;
  border: none;
  z-index: 10;
  opacity: 0;
  transform: scale(0.96);
  transition:
    top 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    left 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    width 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    height 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.25s ease,
    transform 0.25s ease;
  --focus-border-color: var(--accent-lime);
}

.true-focus-frame.is-active {
  opacity: 1;
  transform: scale(1);
}

.true-focus-corner {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--focus-border-color);
  filter: drop-shadow(0 0 6px var(--focus-border-color));
  border-radius: 2px;
}

.true-focus-corner.top-left {
  top: -6px;
  left: -6px;
  border-right: none;
  border-bottom: none;
}

.true-focus-corner.top-right {
  top: -6px;
  right: -6px;
  border-left: none;
  border-bottom: none;
}

.true-focus-corner.bottom-left {
  bottom: -6px;
  left: -6px;
  border-right: none;
  border-top: none;
}

.true-focus-corner.bottom-right {
  bottom: -6px;
  right: -6px;
  border-left: none;
  border-top: none;
}

/* Container helper for TrueFocus */
.true-focus-container {
  position: relative;
}

/* =========================================
   6. SHINY TEXT (React Bits: TextAnimations/ShinyText)
   ========================================= */
.shiny-text {
  color: var(--text-cream);
  background: linear-gradient(
    120deg,
    rgba(186, 220, 255, 0.35) 25%,
    var(--accent-blue) 50%,
    rgba(186, 220, 255, 0.35) 75%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  animation: shinySweep 4.5s ease-in-out infinite;
}

.shiny-text-white {
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.35) 20%,
    #ffffff 50%,
    rgba(255, 255, 255, 0.35) 80%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  animation: shinySweep 5s linear infinite;
}

@keyframes shinySweep {
  0% {
    background-position: 150% center;
  }
  100% {
    background-position: -50% center;
  }
}

/* =========================================
   7. STAR BORDER (React Bits: Animations/StarBorder)
   ========================================= */
.star-border-container {
  display: inline-block;
  position: relative;
  border-radius: var(--radius-full);
  overflow: hidden;
  padding: 1.5px; /* Border thickness */
  background: transparent;
}

.star-border-bottom {
  position: absolute;
  width: 300%;
  height: 60%;
  opacity: 0.85;
  bottom: -16px;
  right: -250%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-blue) 0%, transparent 65%);
  animation: starMovementBottom 5s linear infinite alternate;
  z-index: 0;
  pointer-events: none;
}

.star-border-top {
  position: absolute;
  width: 300%;
  height: 60%;
  opacity: 0.85;
  top: -16px;
  left: -250%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-blue) 0%, transparent 65%);
  animation: starMovementTop 5s linear infinite alternate;
  z-index: 0;
  pointer-events: none;
}

@keyframes starMovementBottom {
  0% {
    transform: translate(0%, 0%);
    opacity: 0.9;
  }
  100% {
    transform: translate(-100%, 0%);
    opacity: 0.2;
  }
}

@keyframes starMovementTop {
  0% {
    transform: translate(0%, 0%);
    opacity: 0.2;
  }
  100% {
    transform: translate(100%, 0%);
    opacity: 0.9;
  }
}

/* =========================================
   8. PROCEDURAL FILM GRAIN NOISE (React Bits: Backgrounds/Noise)
   ========================================= */
.react-bits-noise {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1; /* Sits right above canvas-bg, below content */
  opacity: 0.032;
}

/* =========================================
   9. COUNT UP STYLING (React Bits: TextAnimations/CountUp)
   ========================================= */
.count-up-element {
  font-variant-numeric: tabular-nums;
  will-change: contents;
}

/* =========================================
   10. BLUR TEXT REVEAL (React Bits: TextAnimations/BlurText)
   ========================================= */
.blur-text-reveal {
  opacity: 0;
  filter: blur(12px);
  transform: translateY(22px);
  transition: opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1),
              filter 0.85s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.85s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, filter, opacity;
}

.blur-text-reveal.is-in-view {
  opacity: 1;
  filter: blur(0px);
  transform: translateY(0);
}

/* Ensure tilted card hover does not conflict with style.css hover translateY */
.case-card.tilted-card-wrap:hover {
  transform: none; /* Controlled exclusively by TiltedCard 3D physics */
}

/* Button children positioning for StarBorder */
.book-call-trigger-btn > :not(.star-border-top):not(.star-border-bottom),
.submit-inquiry-btn > :not(.star-border-top):not(.star-border-bottom) {
  position: relative;
  z-index: 1;
}

.star-border-top,
.star-border-bottom {
  position: absolute !important;
  pointer-events: none;
}
