/* ============================================================
   effects.css — Futuristic Visual Effects
   Loaded AFTER style.css to override/extend existing styles.
   ============================================================ */

/* ------------------------------------------------------------
   1. Scroll Progress Bar
   ------------------------------------------------------------ */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--color-primary);
  transform-origin: 0 50%;
  transform: scaleX(0);
  z-index: 10000;
  pointer-events: none;
  box-shadow: 0 0 8px var(--color-primary), 0 0 20px rgba(34, 211, 238, 0.3);
}

/* ------------------------------------------------------------
   2. Particle Canvas
   ------------------------------------------------------------ */
#particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.hero {
  position: relative;
}

.hero-content {
  position: relative;
  z-index: 1;
}

/* ------------------------------------------------------------
   3. Scanline Overlay (CRT effect via body::before)
   ------------------------------------------------------------ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 9998;
}

/* ------------------------------------------------------------
   4. Neon Glow Enhancements
   ------------------------------------------------------------ */

/* Primary buttons */
.btn-primary:hover {
  box-shadow:
    0 0 5px var(--color-primary),
    0 0 15px rgba(34, 211, 238, 0.3),
    0 0 30px rgba(34, 211, 238, 0.15),
    inset 0 0 8px rgba(34, 211, 238, 0.1);
}

/* Outline buttons */
.btn-outline:hover {
  box-shadow:
    0 0 5px var(--color-primary),
    0 0 12px rgba(34, 211, 238, 0.2);
  border-color: var(--color-primary);
}

/* Form inputs on focus */
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  box-shadow:
    0 0 0 3px rgba(34, 211, 238, 0.1),
    0 0 12px rgba(34, 211, 238, 0.15);
  border-color: var(--color-primary);
}

/* Nav links */
.nav-desktop a:not(.btn):hover {
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.4);
}

/* ------------------------------------------------------------
   5. Gradient Mesh Blobs
   ------------------------------------------------------------ */

/* Shared keyframes */
@keyframes blob-drift-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(30px, -20px) scale(1.05); }
  66%      { transform: translate(-20px, 15px) scale(0.95); }
}

@keyframes blob-drift-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(-25px, 20px) scale(0.95); }
  66%      { transform: translate(15px, -30px) scale(1.1); }
}

/* Ensure sections can contain blobs */
.roi-calc-section,
#pricing,
.openclaw-section {
  position: relative;
  overflow: hidden;
}

/* ROI Calculator — cyan blob top-right */
.roi-calc-section::before {
  content: '';
  position: absolute;
  top: -120px;
  right: -100px;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.06), transparent 70%);
  filter: blur(100px);
  pointer-events: none;
  animation: blob-drift-1 20s ease-in-out infinite;
  z-index: 0;
}

/* ROI Calculator — amber blob bottom-left */
.roi-calc-section::after {
  content: '';
  position: absolute;
  bottom: -80px;
  left: -80px;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.04), transparent 70%);
  filter: blur(80px);
  pointer-events: none;
  animation: blob-drift-2 25s ease-in-out infinite;
  z-index: 0;
}

/* Pricing — cyan blob bottom-right */
#pricing::before {
  content: '';
  position: absolute;
  bottom: -100px;
  right: -80px;
  width: 450px;
  height: 450px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.05), transparent 70%);
  filter: blur(100px);
  pointer-events: none;
  animation: blob-drift-2 22s ease-in-out infinite;
  z-index: 0;
}

/* Pricing — amber blob top-left */
#pricing::after {
  content: '';
  position: absolute;
  top: -60px;
  left: -100px;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.035), transparent 70%);
  filter: blur(90px);
  pointer-events: none;
  animation: blob-drift-1 28s ease-in-out infinite;
  z-index: 0;
}

/* OpenClaw — subtle cyan blob center */
.openclaw-section::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.04), transparent 70%);
  filter: blur(120px);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: blob-drift-1 24s ease-in-out infinite;
  z-index: 0;
}

/* ------------------------------------------------------------
   6. Glitch Text Effect (Hover)
   ------------------------------------------------------------ */
.glitch-hover {
  position: relative;
  display: inline-block;
}

.glitch-hover::before,
.glitch-hover::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.glitch-hover:hover::before {
  opacity: 0.8;
  color: var(--color-primary);
  animation: glitch-1 300ms steps(4) forwards;
  clip-path: inset(20% 0 30% 0);
}

.glitch-hover:hover::after {
  opacity: 0.8;
  color: var(--color-accent);
  animation: glitch-2 300ms steps(4) forwards;
  clip-path: inset(60% 0 5% 0);
}

@keyframes glitch-1 {
  0%   { transform: translate(-2px, 1px);  clip-path: inset(20% 0 30% 0); }
  25%  { transform: translate(2px, -1px);  clip-path: inset(50% 0 10% 0); }
  50%  { transform: translate(-1px, 2px);  clip-path: inset(10% 0 60% 0); }
  75%  { transform: translate(1px, -2px);  clip-path: inset(40% 0 20% 0); }
  100% { transform: translate(0);          clip-path: inset(0); opacity: 0; }
}

@keyframes glitch-2 {
  0%   { transform: translate(2px, -1px);  clip-path: inset(60% 0 5% 0); }
  25%  { transform: translate(-2px, 2px);  clip-path: inset(5% 0 60% 0); }
  50%  { transform: translate(1px, -1px);  clip-path: inset(30% 0 30% 0); }
  75%  { transform: translate(-1px, 1px);  clip-path: inset(70% 0 5% 0); }
  100% { transform: translate(0);          clip-path: inset(0); opacity: 0; }
}

/* ------------------------------------------------------------
   7. Floating Orbs
   ------------------------------------------------------------ */
.floating-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  animation: orb-float var(--orb-duration, 20s) ease-in-out infinite alternate;
  animation-delay: var(--orb-delay, 0s);
}

.floating-orb--cyan {
  background: radial-gradient(circle, rgba(34, 211, 238, 0.4), transparent 70%);
  filter: blur(2px);
}

.floating-orb--amber {
  background: radial-gradient(circle, rgba(245, 158, 11, 0.3), transparent 70%);
  filter: blur(2px);
}

@keyframes orb-float {
  0%   { opacity: 0.15; transform: translate(0, 0) scale(1); }
  25%  { opacity: 0.35; }
  50%  { opacity: 0.2;  transform: translate(var(--orb-dx, 30px), var(--orb-dy, -20px)) scale(1.2); }
  75%  { opacity: 0.4; }
  100% { opacity: 0.15; transform: translate(var(--orb-dx2, -20px), var(--orb-dy2, 15px)) scale(0.8); }
}

/* ------------------------------------------------------------
   8. Section Reveal Masks
   ------------------------------------------------------------ */
.reveal-mask {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 0.8s var(--ease-out);
}

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

/* ------------------------------------------------------------
   9. Custom Cursor
   ------------------------------------------------------------ */
.has-custom-cursor,
.has-custom-cursor * {
  cursor: none !important;
}

/* Preserve default cursor on chatbot widget */
.has-custom-cursor .chatbot-widget,
.has-custom-cursor .chatbot-widget * {
  cursor: auto !important;
}

.custom-cursor-dot {
  position: fixed;
  top: 0;
  left: 0;
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
  pointer-events: none;
  z-index: 99999;
  transform: translate(-50%, -50%);
  transition: width 0.2s, height 0.2s, background 0.2s;
  mix-blend-mode: difference;
}

.custom-cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--color-primary);
  border-radius: 50%;
  pointer-events: none;
  z-index: 99998;
  transform: translate(-50%, -50%);
  transition:
    width 0.3s var(--ease-out),
    height 0.3s var(--ease-out),
    border-color 0.3s,
    opacity 0.3s;
  opacity: 0.6;
}

.custom-cursor-ring.hovering {
  width: 54px;
  height: 54px;
  opacity: 0.4;
  border-color: var(--color-accent);
}

.custom-cursor-dot.hovering {
  width: 12px;
  height: 12px;
  background: var(--color-accent);
}

/* Hide custom cursor on touch devices */
@media (hover: none) {
  .custom-cursor-dot,
  .custom-cursor-ring {
    display: none !important;
  }
}

/* ------------------------------------------------------------
   10. Card Tilt Reflection
   ------------------------------------------------------------ */
.service-card,
.pricing-card,
.story-card,
.testimonial-card {
  transform-style: preserve-3d;
  transition: transform 0.4s var(--ease-out);
}

.tilt-active::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    circle at var(--tilt-x, 50%) var(--tilt-y, 50%),
    rgba(255, 255, 255, 0.06),
    transparent 60%
  );
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.tilt-active:hover::after {
  opacity: 1;
}

/* ------------------------------------------------------------
   11. Typing Cursor
   ------------------------------------------------------------ */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--color-primary);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink-cursor 0.7s step-end infinite;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ------------------------------------------------------------
   12. View Transition (Theme Wipe)
   ------------------------------------------------------------ */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.5s;
  animation-timing-function: var(--ease-out);
}

::view-transition-new(root) {
  clip-path: circle(0% at var(--transition-x, 50%) var(--transition-y, 50%));
  animation: wipe-in 0.5s var(--ease-out) forwards;
}

::view-transition-old(root) {
  animation: none;
}

@keyframes wipe-in {
  to {
    clip-path: circle(150% at var(--transition-x, 50%) var(--transition-y, 50%));
  }
}

/* ------------------------------------------------------------
   13. Light Theme Overrides
   ------------------------------------------------------------ */
[data-theme="light"] body::before {
  opacity: 0.01;
}

[data-theme="light"] #scroll-progress {
  box-shadow: 0 0 4px rgba(8, 145, 178, 0.4);
}

[data-theme="light"] .btn-primary:hover {
  box-shadow:
    0 0 3px rgba(8, 145, 178, 0.3),
    0 0 10px rgba(8, 145, 178, 0.15);
}

[data-theme="light"] .btn-outline:hover {
  box-shadow:
    0 0 3px rgba(8, 145, 178, 0.2),
    0 0 8px rgba(8, 145, 178, 0.1);
}

[data-theme="light"] .form-group input:focus,
[data-theme="light"] .form-group textarea:focus,
[data-theme="light"] .form-group select:focus {
  box-shadow:
    0 0 0 3px rgba(8, 145, 178, 0.08),
    0 0 8px rgba(8, 145, 178, 0.1);
}

[data-theme="light"] .nav-desktop a:not(.btn):hover {
  text-shadow: 0 0 8px rgba(8, 145, 178, 0.2);
}

[data-theme="light"] .custom-cursor-dot {
  background: var(--color-primary-hover);
  mix-blend-mode: normal;
}

[data-theme="light"] .custom-cursor-ring {
  border-color: var(--color-primary-hover);
}

[data-theme="light"] .floating-orb {
  opacity: 0.08 !important;
}

/* ------------------------------------------------------------
   14. Reduced Motion
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  #particle-canvas       { display: none; }
  body::before            { display: none; }
  .floating-orb           { display: none; }
  .custom-cursor-dot,
  .custom-cursor-ring     { display: none; }

  .reveal-mask            { clip-path: none !important; }

  #scroll-progress {
    animation: none;
    box-shadow: none;
  }

  .glitch-hover:hover::before,
  .glitch-hover:hover::after {
    display: none;
  }

  .typing-cursor {
    animation: none;
    opacity: 1;
  }

  .roi-calc-section::before,
  .roi-calc-section::after,
  #pricing::before,
  #pricing::after,
  .openclaw-section::before {
    animation: none !important;
  }
}

/* ------------------------------------------------------------
   15. Mobile Adjustments
   ------------------------------------------------------------ */
@media (max-width: 768px) {
  #particle-canvas   { display: none; }
  .floating-orb      { display: none; }
  .custom-cursor-dot,
  .custom-cursor-ring { display: none; }
  body::before        { opacity: 0.01; }

  /* Reduce blob sizes */
  .roi-calc-section::before { width: 300px; height: 300px; }
  .roi-calc-section::after  { width: 250px; height: 250px; }
  #pricing::before           { width: 280px; height: 280px; }
  #pricing::after            { width: 240px; height: 240px; }
}
