/* =========================================
   DIJEXA - 3D Effects & Advanced Animations v3.0
   Ultra Premium Visual Experience
   ========================================= */

/* ---- 3D Scene Container ---- */
#three-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---- Loading Screen 3D ---- */
#loading-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #07071a 0%, #0d0d24 100%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-logo-3d {
  animation: float-3d 3s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(200, 16, 46, 0.8));
}

.loading-logo-3d img {
  height: 80px;
  width: auto;
}

/* 3D Morphing Geometrik Şekiller - Loading */
.loading-morph {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.loading-morph-shape {
  position: absolute;
  border: 2px solid rgba(200,16,46,0.2);
  animation: morph-float 6s ease-in-out infinite;
}

.loading-morph-shape:nth-child(1) {
  width: 60px; height: 60px;
  top: 15%; left: 20%;
  border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  animation-duration: 5s;
}

.loading-morph-shape:nth-child(2) {
  width: 40px; height: 40px;
  top: 70%; right: 25%;
  border-radius: 70% 30% 30% 70% / 70% 70% 30% 30%;
  animation-duration: 7s;
  animation-delay: -2s;
}

.loading-morph-shape:nth-child(3) {
  width: 50px; height: 50px;
  bottom: 20%; left: 15%;
  border-radius: 50% 50% 30% 70% / 50% 70% 30% 50%;
  animation-duration: 6s;
  animation-delay: -1s;
}

@keyframes morph-float {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  }
  25% {
    transform: translate(20px, -30px) rotate(90deg) scale(1.1);
    border-radius: 70% 30% 30% 70% / 70% 70% 30% 30%;
  }
  50% {
    transform: translate(-10px, 20px) rotate(180deg) scale(0.9);
    border-radius: 50% 50% 50% 50%;
  }
  75% {
    transform: translate(10px, 10px) rotate(270deg) scale(1.05);
    border-radius: 30% 70% 50% 50% / 70% 30% 50% 50%;
  }
}

.loading-spinner {
  width: 80px;
  height: 80px;
  position: relative;
}

.loading-spinner::before,
.loading-spinner::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid transparent;
  border-top-color: #C8102E;
  border-radius: 50%;
  animation: spin 1.5s linear infinite;
}

.loading-spinner::after {
  border-top-color: #FF1744;
  animation-duration: 1s;
}

.loading-progress {
  width: 300px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #C8102E, #FF1744);
  border-radius: 99px;
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 20px rgba(200, 16, 46, 0.8);
}

.loading-percentage {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #C8102E, #FF1744);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@keyframes float-3d {
  0%, 100% { transform: translateY(0) rotateY(0deg); }
  25% { transform: translateY(-15px) rotateY(5deg); }
  50% { transform: translateY(-25px) rotateY(0deg); }
  75% { transform: translateY(-10px) rotateY(-5deg); }
}

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

/* ---- Aurora Background Effect ---- */
.aurora-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.4;
}

.aurora-layer {
  position: absolute;
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
  animation: aurora-flow 20s ease infinite;
}

.aurora-layer:nth-child(1) {
  background: radial-gradient(ellipse at 30% 40%, rgba(200,16,46,0.12) 0%, transparent 50%);
  animation-duration: 18s;
}

.aurora-layer:nth-child(2) {
  background: radial-gradient(ellipse at 70% 60%, rgba(108,99,255,0.08) 0%, transparent 50%);
  animation-duration: 22s;
  animation-delay: -5s;
}

.aurora-layer:nth-child(3) {
  background: radial-gradient(ellipse at 50% 50%, rgba(0,212,255,0.06) 0%, transparent 50%);
  animation-duration: 25s;
  animation-delay: -10s;
}

@keyframes aurora-flow {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(5%, -3%) rotate(5deg); }
  66% { transform: translate(-3%, 5%) rotate(-3deg); }
}

/* ---- Enhanced Magnetic Buttons ---- */
.btn-magnetic {
  position: relative;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.btn-magnetic::after {
  content: '';
  position: absolute;
  inset: -4px;
  background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
    rgba(200, 16, 46, 0.3) 0%, transparent 70%);
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.btn-magnetic:hover::after {
  opacity: 1;
}

/* ---- Ripple Effect ---- */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: scale(0);
  animation: ripple-animation 0.6s ease-out;
  pointer-events: none;
}

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

/* ---- Glitch Text Effect ---- */
.glitch-text {
  position: relative;
}

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

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

.glitch-text::after {
  color: #6C63FF;
  z-index: -2;
}

.glitch-text:hover::before {
  animation: glitch-1 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both infinite;
  opacity: 0.8;
}

.glitch-text:hover::after {
  animation: glitch-2 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) reverse both infinite;
  opacity: 0.8;
}

@keyframes glitch-1 {
  0% { clip-path: inset(40% 0 61% 0); transform: translate(-2px, 2px); }
  20% { clip-path: inset(92% 0 1% 0); transform: translate(2px, -1px); }
  40% { clip-path: inset(43% 0 1% 0); transform: translate(-1px, 2px); }
  60% { clip-path: inset(25% 0 58% 0); transform: translate(2px, -2px); }
  80% { clip-path: inset(54% 0 7% 0); transform: translate(-2px, 1px); }
  100% { clip-path: inset(58% 0 43% 0); transform: translate(1px, -1px); }
}

@keyframes glitch-2 {
  0% { clip-path: inset(65% 0 13% 0); transform: translate(2px, -1px); }
  20% { clip-path: inset(15% 0 62% 0); transform: translate(-1px, 2px); }
  40% { clip-path: inset(79% 0 2% 0); transform: translate(1px, -2px); }
  60% { clip-path: inset(3% 0 83% 0); transform: translate(-2px, 1px); }
  80% { clip-path: inset(45% 0 29% 0); transform: translate(2px, 2px); }
  100% { clip-path: inset(22% 0 58% 0); transform: translate(-1px, -1px); }
}

/* ---- Text Reveal Animation ---- */
.text-reveal {
  overflow: hidden;
  display: inline-block;
}

.text-reveal-inner {
  display: inline-block;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.8s ease;
}

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

/* ---- Portfolio 3D Flip ---- */
.portfolio-item-3d {
  perspective: 1000px;
  cursor: pointer;
}

.portfolio-item-3d .portfolio-flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.portfolio-item-3d:hover .portfolio-flip-inner {
  transform: rotateY(180deg);
}

.portfolio-flip-front,
.portfolio-flip-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.portfolio-flip-front {
  z-index: 2;
}

.portfolio-flip-back {
  transform: rotateY(180deg);
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  text-align: center;
}

.portfolio-flip-back h3 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.portfolio-flip-back p {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: var(--lh-relaxed);
  margin-bottom: var(--space-5);
}

.portfolio-flip-back .portfolio-tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  margin-bottom: var(--space-5);
}

.portfolio-flip-back .tech-tag {
  padding: 4px 12px;
  background: rgba(200,16,46,0.1);
  border: 1px solid rgba(200,16,46,0.2);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  color: var(--color-primary);
  font-weight: var(--fw-semibold);
}

/* ---- Scroll Down Indicator ---- */
.scroll-indicator {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.scroll-indicator-mouse {
  width: 24px;
  height: 38px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  position: relative;
}

.scroll-indicator-mouse::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 2px;
  animation: scroll-wheel 2s ease-in-out infinite;
}

.scroll-indicator-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.scroll-indicator-arrow i {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.3);
  animation: scroll-bounce 2s ease-in-out infinite;
}

.scroll-indicator-arrow i:nth-child(2) {
  animation-delay: 0.15s;
  opacity: 0.5;
}

@keyframes scroll-wheel {
  0%, 100% { transform: translateX(-50%) translateY(0); opacity: 1; }
  50% { transform: translateX(-50%) translateY(12px); opacity: 0; }
}

@keyframes scroll-bounce {
  0%, 100% { transform: translateY(0); opacity: 0.3; }
  50% { transform: translateY(6px); opacity: 0.8; }
}

/* ---- Section Divider Wave ---- */
.section-wave-divider {
  position: relative;
  height: 80px;
  overflow: hidden;
  pointer-events: none;
}

.section-wave-divider svg {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 100%;
}

/* ---- Gradient Mesh Animation ---- */
.gradient-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.4;
  pointer-events: none;
  background: 
    radial-gradient(ellipse at 20% 30%, rgba(200, 16, 46, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(255, 23, 68, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(200, 16, 46, 0.1) 0%, transparent 60%);
  background-size: 200% 200%;
  animation: mesh-flow 20s ease infinite;
}

@keyframes mesh-flow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ---- Mouse Light Effect ---- */
.mouse-light {
  position: fixed;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(200, 16, 46, 0.15) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
  transform: translate(-50%, -50%);
  transition: opacity 0.3s;
  opacity: 0;
  mix-blend-mode: screen;
}

.mouse-light.active {
  opacity: 1;
}

/* ---- Scroll Reveal Animations ---- */
.reveal-fade {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

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

.reveal-scale {
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

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

.reveal-slide-left {
  opacity: 0;
  transform: translateX(-60px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

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

.reveal-slide-right {
  opacity: 0;
  transform: translateX(60px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

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

/* ---- 3D Flip Cards (Social Icons) ---- */
.flip-3d {
  perspective: 1000px;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.flip-3d:hover {
  transform: rotateY(180deg);
}

.flip-3d-front,
.flip-3d-back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip-3d-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
}

/* ---- Wave Animation (Footer) ---- */
.wave-animation {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 120px;
  overflow: hidden;
  pointer-events: none;
}

.wave {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200%;
  height: 100%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120' preserveAspectRatio='none'%3E%3Cpath d='M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z' opacity='.25' fill='rgba(200,16,46,0.1)'/%3E%3Cpath d='M0,0V15.81C13,36.92,27.64,56.86,47.69,72.05,99.41,111.27,165,111,224.58,91.58c31.15-10.15,60.09-26.07,89.67-39.8,40.92-19,84.73-46,130.83-49.67,36.26-2.85,70.9,9.42,98.6,31.56,31.77,25.39,62.32,62,103.63,73,40.44,10.79,81.35-6.69,119.13-24.28s75.16-39,116.92-43.05c59.73-5.85,113.28,22.88,168.9,38.84,30.2,8.66,59,6.17,87.09-7.5,22.43-10.89,48-26.93,60.65-49.24V0Z' opacity='.5' fill='rgba(200,16,46,0.15)'/%3E%3Cpath d='M0,0V5.63C149.93,59,314.09,71.32,475.83,42.57c43-7.64,84.23-20.12,127.61-26.46,59-8.63,112.48,12.24,165.56,35.4C827.93,77.22,886,95.24,951.2,90c86.53-7,172.46-45.71,248.8-84.81V0Z' fill='rgba(200,16,46,0.2)'/%3E%3C/svg%3E") repeat-x;
  animation: wave 25s cubic-bezier(0.36, 0.45, 0.63, 0.53) infinite;
  transform: translate3d(0, 0, 0);
}

.wave:nth-child(2) {
  animation-duration: 15s;
  animation-direction: reverse;
  opacity: 0.5;
}

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

/* ---- Blog Card Enhanced ---- */
.blog-card:hover {
  box-shadow: 0 12px 40px rgba(200,16,46,0.15), var(--shadow-card-hover);
}

.blog-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(200,16,46,0.05) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.blog-card:hover::after {
  opacity: 1;
}

/* ---- Stat Counter 3D Flip ---- */
.stat-number-flip {
  perspective: 400px;
}

.stat-digit {
  display: inline-block;
  transform-style: preserve-3d;
}

/* ---- Testimonial 3D Carousel ---- */
.testimonials-3d {
  perspective: 2000px;
}

/* ---- Enhanced Link Underline ---- */
.link-underline {
  position: relative;
  display: inline-block;
}

.link-underline::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #C8102E, #FF1744);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ---- Performance Optimizations ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .aurora-bg,
  .floating-shapes,
  .gradient-mesh,
  .mouse-light,
  #three-canvas {
    display: none !important;
  }
}

/* ---- Mobile Optimizations ---- */
@media (max-width: 768px) {
  #three-canvas,
  .floating-shapes,
  .gradient-mesh,
  .mouse-light,
  .aurora-bg {
    display: none;
  }
  
  .tilt-3d {
    transform: none !important;
  }
  
  .loading-logo-3d img {
    height: 60px;
  }
  
  .loading-progress {
    width: 240px;
  }

  .portfolio-item-3d:hover .portfolio-flip-inner {
    transform: none;
  }

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

  .scroll-indicator {
    display: none;
  }

  .section-wave-divider {
    height: 40px;
  }
}

/* ---- High Performance Mode ---- */
@media (max-width: 640px) {
  .wave-animation {
    display: none;
  }
  
  .flip-3d {
    perspective: none;
  }
  
  .btn-magnetic {
    transform: none !important;
  }
}

/* ---- 3D Transform Utils ---- */
.transform-3d {
  transform-style: preserve-3d;
}

.backface-hidden {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.perspective-1000 {
  perspective: 1000px;
}

/* ---- Glow Effects ---- */
.glow-pulse {
  animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(200, 16, 46, 0.4);
  }
  50% {
    box-shadow: 0 0 40px rgba(200, 16, 46, 0.8), 0 0 60px rgba(255, 23, 68, 0.4);
  }
}

/* ---- Text Glow ---- */
.text-glow {
  text-shadow: 0 0 20px rgba(200, 16, 46, 0.5);
}

/* ---- Service Card 3D Icon Container ---- */
.service-3d-icon {
  width: 64px;
  height: 64px;
  position: relative;
  margin-bottom: var(--space-6);
  perspective: 500px;
}

.service-3d-icon-inner {
  width: 100%;
  height: 100%;
  background: var(--gradient-bg);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--color-primary);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  animation: icon-float 6s ease-in-out infinite;
}

.service-card:hover .service-3d-icon-inner {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-glow);
  transform: rotateY(360deg) scale(1.1);
  animation: none;
}

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

/* ---- GPU Acceleration ---- */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform;
}

/* ---- Service Card Enhanced Glow ---- */
.service-card-glow {
  position: absolute;
  inset: -2px;
  background: linear-gradient(45deg, #C8102E, #FF1744, #C8102E);
  border-radius: inherit;
  opacity: 0;
  filter: blur(20px);
  z-index: -1;
  transition: opacity 0.5s;
}

.service-card:hover .service-card-glow {
  opacity: 0.6;
}

/* ---- Parallax Layers ---- */
.parallax-layer {
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

/* ---- Floating Elements ---- */
.floating-shapes {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.floating-shape {
  position: absolute;
  opacity: 0.05;
  animation: float-shape 20s infinite ease-in-out;
  will-change: transform;
}

.floating-shape:nth-child(1) {
  top: 10%;
  left: 10%;
  animation-delay: 0s;
  animation-duration: 25s;
}

.floating-shape:nth-child(2) {
  top: 60%;
  right: 10%;
  animation-delay: -5s;
  animation-duration: 30s;
}

.floating-shape:nth-child(3) {
  bottom: 20%;
  left: 20%;
  animation-delay: -10s;
  animation-duration: 35s;
}

@keyframes float-shape {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  33% {
    transform: translate(30px, -30px) rotate(120deg) scale(1.1);
  }
  66% {
    transform: translate(-20px, 20px) rotate(240deg) scale(0.9);
  }
}
