/* ============================================
   AN TECHNOLOGY — GLOBAL EFFECTS CSS
   Animation infrastructure — no layout changes
   All colors locked to existing palette only
   ============================================ */

/* Lenis smooth scroll requirements */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }

/* ============================================
   1. CUSTOM CURSOR
   ============================================ */
.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  border-radius: 50%;
  z-index: 9999;
  will-change: transform;
  transition: width 0.3s ease, height 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, border-radius 0.3s ease;
}

.cursor-dot {
  width: 10px;
  height: 10px;
  background: #2563EB;
  transform: translate(-50%, -50%);
  z-index: 9999;
}

.cursor-ring {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(14, 165, 233, 0.5);
  transform: translate(-50%, -50%);
  z-index: 9998;
}

/* Cursor hover states */
.cursor-dot.hover-link,
.cursor-dot.hover-button,
.cursor-dot.hover-card,
.cursor-dot.hover-magnetic {
  width: 18px;
  height: 18px;
  background: #10B981;
}

.cursor-ring.hover-link,
.cursor-ring.hover-button,
.cursor-ring.hover-card,
.cursor-ring.hover-magnetic {
  width: 70px;
  height: 70px;
  border-color: #10B981;
}

/* Cursor image hover — square */
.cursor-ring.hover-image {
  border-radius: 4px;
}

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

/* ============================================
   2. SCROLL REVEAL BASE STATES
   ============================================ */
.rv {
  opacity: 1;
  transform: none;
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.js .rv {
  opacity: 0;
  transform: translateY(50px);
}

.rv.from-left {
  transform: translateX(-60px);
}

.rv.from-right {
  transform: translateX(60px);
}

.rv.scale-up {
  transform: scale(0.85);
}

.js .rv.in {
  opacity: 1;
  transform: none;
}

/* Stagger delays */
.rv.d1  { transition-delay: 0.1s; }
.rv.d2  { transition-delay: 0.2s; }
.rv.d3  { transition-delay: 0.3s; }
.rv.d4  { transition-delay: 0.4s; }
.rv.d5  { transition-delay: 0.5s; }
.rv.d6  { transition-delay: 0.6s; }

/* ============================================
   3. GLITCH TEXT EFFECT
   ============================================ */
.glitch-text {
  position: relative;
  display: inline-block;
}

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

.glitch-text::before {
  color: #2563EB;
  z-index: -1;
}

.glitch-text::after {
  color: #0EA5E9;
  z-index: -2;
}

.glitch-text.glitch-active::before {
  animation: glitch-before 0.4s ease-in-out;
}

.glitch-text.glitch-active::after {
  animation: glitch-after 0.4s ease-in-out;
}

@keyframes glitch-before {
  0%   { opacity: 0; transform: translateX(0); }
  20%  { opacity: 0.8; transform: translateX(-3px); }
  40%  { opacity: 0; transform: translateX(2px); }
  60%  { opacity: 0.6; transform: translateX(-2px); }
  80%  { opacity: 0; transform: translateX(1px); }
  100% { opacity: 0; transform: translateX(0); }
}

@keyframes glitch-after {
  0%   { opacity: 0; transform: translateX(0); }
  20%  { opacity: 0.8; transform: translateX(3px); }
  40%  { opacity: 0; transform: translateX(-2px); }
  60%  { opacity: 0.6; transform: translateX(2px); }
  80%  { opacity: 0; transform: translateX(-1px); }
  100% { opacity: 0; transform: translateX(0); }
}

/* ============================================
   4. HUD CORNER BRACKETS
   ============================================ */
.hud-corners {
  position: relative;
}

.hud-corners::before,
.hud-corners::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-color: #0EA5E9;
  border-style: solid;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hud-corners::before {
  top: -4px;
  left: -4px;
  border-width: 2px 0 0 2px;
  box-shadow: inset 2px 2px 0 #0EA5E9;
}

.hud-corners::after {
  bottom: -4px;
  right: -4px;
  border-width: 0 2px 2px 0;
  box-shadow: inset -2px -2px 0 #0EA5E9;
}

.hud-corners:hover::before,
.hud-corners:hover::after {
  opacity: 1;
  animation: hud-pulse 2s ease-in-out infinite;
}

@keyframes hud-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ============================================
   5. SCAN LINE
   ============================================ */
.scanline {
  position: relative;
  overflow: hidden;
}

.scanline::after {
  content: '';
  position: absolute;
  top: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(37, 99, 235, 0.15);
  animation: scan-sweep 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes scan-sweep {
  0%   { top: -2px; opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* ============================================
   6. ANIMATED BORDER
   ============================================ */
.animated-border {
  position: relative;
  background: var(--color-surface, #fafbff);
  border-radius: 12px;
  overflow: hidden;
}

.animated-border::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(135deg, #2563EB, #0EA5E9, #10B981, #2563EB);
  background-size: 300% 300%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  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 ease;
  animation: border-rotate 3s linear infinite;
}

.animated-border:hover::before {
  opacity: 1;
}

@keyframes border-rotate {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ============================================
   7. PAGE TRANSITION OVERLAY
   ============================================ */
#page-transition {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0B1220;
  z-index: 10000;
  pointer-events: none;
  transform: translateY(100%);
}

#page-transition.active {
  transform: translateY(0);
}

#page-transition.exit {
  transform: translateY(-100%);
}

/* ============================================
   8. TECH DIVIDER
   ============================================ */
.tech-divider {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 8px;
}

.tech-divider .dot {
  width: 4px;
  height: 4px;
  background: #E2E8F0;
  border-radius: 1px;
  opacity: 0.3;
  animation: tech-dot-glow 2s ease-in-out infinite;
}

.tech-divider .dot:nth-child(1) { animation-delay: 0s; }
.tech-divider .dot:nth-child(2) { animation-delay: 0.15s; }
.tech-divider .dot:nth-child(3) { animation-delay: 0.3s; }
.tech-divider .dot:nth-child(4) { animation-delay: 0.45s; }
.tech-divider .dot:nth-child(5) { animation-delay: 0.6s; }
.tech-divider .dot:nth-child(6) { animation-delay: 0.75s; }
.tech-divider .dot:nth-child(7) { animation-delay: 0.9s; }
.tech-divider .dot:nth-child(8) { animation-delay: 1.05s; }
.tech-divider .dot:nth-child(9) { animation-delay: 1.2s; }
.tech-divider .dot:nth-child(10) { animation-delay: 1.35s; }

@keyframes tech-dot-glow {
  0%, 100% { opacity: 0.2; background: #E2E8F0; }
  50% { opacity: 1; background: #2563EB; box-shadow: 0 0 6px rgba(37, 99, 235, 0.5); }
}

/* ============================================
   9. REFINED BACKGROUND LAYERS
   Clean ambient atmosphere — mesh + constellation + flow ribbons
   ============================================ */

#bg-animation-container {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Constellation canvas */
#constellation-canvas,
#flow-ribbons-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

/* Refined gradient mesh */
.gradient-mesh {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.mesh-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  animation: blob-float 24s ease-in-out infinite;
  will-change: transform;
}

.mesh-blob-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.12) 0%, transparent 70%);
  top: -12%;
  right: -8%;
  animation-delay: 0s;
}

.mesh-blob-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.08) 0%, transparent 70%);
  bottom: -12%;
  left: -6%;
  animation-delay: -8s;
}

.mesh-blob-3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.06) 0%, transparent 70%);
  top: 45%;
  left: 50%;
  animation-delay: -16s;
}

@keyframes blob-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(25px, -35px) scale(1.03); }
  50% { transform: translate(-15px, 18px) scale(0.97); }
  75% { transform: translate(35px, 25px) scale(1.01); }
}

/* Scroll Progress */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, #2563EB, #0EA5E9, #10B981);
  background-size: 300% 100%;
  z-index: 9999;
  width: 0%;
  animation: gradient-shift 3s ease-in-out infinite;
  transition: width 0.1s ease-out;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ============================================
   10. FORM ENHANCEMENTS
   ============================================ */
.form-enhanced input:focus,
.form-enhanced textarea:focus,
.form-enhanced select:focus {
  border-color: #2563EB !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12) !important;
  outline: none !important;
}

.form-enhanced .form-label {
  transition: transform 0.3s ease, color 0.3s ease;
}

.form-enhanced .form-label.floated {
  transform: translateY(-24px) scale(0.85);
  color: #2563EB;
}

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

.ripple-effect {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple-anim 0.6s ease-out forwards;
  pointer-events: none;
}

@keyframes ripple-anim {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ============================================
   13. MAGNETIC CLASS
   ============================================ */
.magnetic {
  transition: transform 0.3s ease;
}

/* ============================================
   14. NAVBAR SCROLL STATE
   ============================================ */
.site-header.scrolled-enhanced,
.navbar.scrolled-enhanced {
  background: rgba(245, 247, 251, 0.95) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08) !important;
  padding-block: 0.6rem !important;
}

/* ============================================
   15. FOOTER ENHANCEMENTS
   ============================================ */
.footer-top-border {
  position: relative;
  height: 2px;
  overflow: hidden;
}

.footer-top-border::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 200%;
  height: 100%;
  background: linear-gradient(90deg, #2563EB, #0EA5E9, #10B981, #2563EB, #0EA5E9, #10B981);
  background-size: 50% 100%;
  animation: footer-gradient-shift 4s linear infinite;
}

@keyframes footer-gradient-shift {
  0% { left: -100%; }
  100% { left: 0%; }
}

/* Live clock styling */
.footer-clock {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.875rem;
  color: rgba(226, 232, 240, 0.7);
  letter-spacing: 0.02em;
}

/* Blinking cursor for copyright */
.blink-cursor::after {
  content: '|';
  animation: copyright-blink 1s step-end infinite;
  margin-left: 2px;
  color: rgba(226, 232, 240, 0.6);
}

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

/* Social icon magnetic hover */
.social-icon-magnetic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(226, 232, 240, 0.7);
  transition: transform 0.3s ease, background 0.3s ease, color 0.3s ease;
}

.social-icon-magnetic:hover {
  background: rgba(37, 99, 235, 0.15);
  color: var(--color-surface, #fafbff);
  transform: scale(1.15);
}

/* ============================================
   16. PREFERS REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .cursor-dot,
  .cursor-ring,
  .scanline::after,
  .tech-divider .dot,
  .mesh-blob,
  .animated-border::before,
  .glitch-text::before,
  .glitch-text::after,
  .hud-corners::before,
  .hud-corners::after,
  .footer-top-border::before,
  .ripple-effect,
  .blink-cursor::after {
    animation: none !important;
    transition: opacity 0.1s ease !important;
  }

  .rv,
  .js .rv,
  .js .rv.in {
    opacity: 1;
    transform: none;
  }

  #page-transition {
    display: none !important;
  }

  .cursor-dot,
  .cursor-ring {
    display: none !important;
  }
}

/* ============================================
   17. LAZY LOAD FADE-IN
   ============================================ */
img[data-lazy] {
  opacity: 0;
  transition: opacity 0.5s ease;
}

img[data-lazy].loaded {
  opacity: 1;
}

/* ============================================
   18. 3D CARD SPECULAR HIGHLIGHT
   ============================================ */
.card-specular {
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.07) 0%, transparent 70%);
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 2;
}

.card-tilt-container:hover .card-specular,
.card-tilt-container.tilted .card-specular {
  opacity: 1;
}

/* ============================================
   19. NAV LINK SCRAMBLE
   ============================================ */
.nav-link-scramble {
  display: inline-block;
  min-width: 1ch;
}

/* ============================================
   20. STATS COUNTER ENHANCED
   ============================================ */
.stat-number-enhanced {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* ============================================
   21. IMAGE REVEAL
   ============================================ */
.image-reveal-container {
  position: relative;
  overflow: hidden;
}

.image-reveal-container img {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 1.2s cubic-bezier(0.76, 0, 0.24, 1);
}

.image-reveal-container.revealed img {
  clip-path: inset(0 0% 0 0);
}

.image-reveal-overlay {
  position: absolute;
  inset: 0;
  background: #2563EB;
  transform: translateX(-100%);
  z-index: 2;
  pointer-events: none;
}

.image-reveal-container.revealed .image-reveal-overlay {
  animation: reveal-sweep 1.2s cubic-bezier(0.76, 0, 0.24, 1) forwards;
}

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

/* ============================================
   22. CONTENT ABOVE BACKGROUND
   ============================================ */

/* All main content sections get z-index: 1 */
header,
main,
footer,
nav,
.section,
.hero-section,
.content-wrapper,
.page-content,
.container {
  position: relative;
  z-index: 1;
}

/* ============================================
   23. RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .mesh-blob {
    opacity: 0.3;
    filter: blur(60px);
  }

  .mesh-blob-1 {
    width: 400px;
    height: 400px;
  }

  .mesh-blob-2 {
    width: 300px;
    height: 300px;
  }

  .mesh-blob-3 {
    width: 250px;
    height: 250px;
  }
}
