/* DedSec Portfolio - Advanced Animations & Effects */

/* Glitch Effect */
.glitch {
  position: relative;
  display: inline-block;
  animation: glitch-skew 2s infinite linear alternate-reverse;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-bg);
}

.glitch::before {
  left: 2px;
  text-shadow: -2px 0 var(--color-red);
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim-1 5s infinite linear alternate-reverse;
}

.glitch::after {
  left: -2px;
  text-shadow: -2px 0 var(--color-cyan), 2px 2px var(--color-red);
  clip: rect(44px, 450px, 56px, 0);
  animation: glitch-anim-2 1s infinite linear alternate-reverse;
}

/* Glitch Animation Keyframes */
@keyframes glitch-anim-1 {
  0% { clip: rect(25px, 9999px, 99px, 0); }
  5% { clip: rect(70px, 9999px, 36px, 0); }
  10% { clip: rect(17px, 9999px, 99px, 0); }
  15% { clip: rect(85px, 9999px, 10px, 0); }
  20% { clip: rect(40px, 9999px, 95px, 0); }
  25% { clip: rect(50px, 9999px, 30px, 0); }
  30% { clip: rect(25px, 9999px, 15px, 0); }
  35% { clip: rect(95px, 9999px, 66px, 0); }
  40% { clip: rect(10px, 9999px, 85px, 0); }
  45% { clip: rect(48px, 9999px, 13px, 0); }
  50% { clip: rect(69px, 9999px, 79px, 0); }
  55% { clip: rect(57px, 9999px, 85px, 0); }
  60% { clip: rect(90px, 9999px, 79px, 0); }
  65% { clip: rect(32px, 9999px, 92px, 0); }
  70% { clip: rect(75px, 9999px, 65px, 0); }
  75% { clip: rect(39px, 9999px, 60px, 0); }
  80% { clip: rect(71px, 9999px, 100px, 0); }
  85% { clip: rect(28px, 9999px, 2px, 0); }
  90% { clip: rect(99px, 9999px, 51px, 0); }
  95% { clip: rect(16px, 9999px, 43px, 0); }
  100% { clip: rect(65px, 9999px, 6px, 0); }
}

@keyframes glitch-anim-2 {
  0% { clip: rect(65px, 9999px, 119px, 0); }
  5% { clip: rect(52px, 9999px, 74px, 0); }
  10% { clip: rect(79px, 9999px, 85px, 0); }
  15% { clip: rect(75px, 9999px, 5px, 0); }
  20% { clip: rect(67px, 9999px, 61px, 0); }
  25% { clip: rect(14px, 9999px, 79px, 0); }
  30% { clip: rect(1px, 9999px, 66px, 0); }
  35% { clip: rect(86px, 9999px, 30px, 0); }
  40% { clip: rect(23px, 9999px, 98px, 0); }
  45% { clip: rect(85px, 9999px, 72px, 0); }
  50% { clip: rect(96px, 9999px, 38px, 0); }
  55% { clip: rect(17px, 9999px, 65px, 0); }
  60% { clip: rect(05px, 9999px, 73px, 0); }
  65% { clip: rect(86px, 9999px, 25px, 0); }
  70% { clip: rect(55px, 9999px, 99px, 0); }
  75% { clip: rect(38px, 9999px, 15px, 0); }
  80% { clip: rect(83px, 9999px, 61px, 0); }
  85% { clip: rect(54px, 9999px, 70px, 0); }
  90% { clip: rect(91px, 9999px, 25px, 0); }
  95% { clip: rect(49px, 9999px, 55px, 0); }
  100% { clip: rect(77px, 9999px, 43px, 0); }
}

@keyframes glitch-skew {
  0% { transform: skew(0deg); }
  10% { transform: skew(-2deg); }
  20% { transform: skew(1deg); }
  30% { transform: skew(-1deg); }
  40% { transform: skew(2deg); }
  50% { transform: skew(-1deg); }
  60% { transform: skew(0deg); }
  70% { transform: skew(1deg); }
  80% { transform: skew(0deg); }
  90% { transform: skew(-1deg); }
  100% { transform: skew(0deg); }
}

/* Typing Animation */
.typed-text {
  overflow: hidden;
  border-right: 2px solid var(--color-cyan);
  white-space: nowrap;
  margin: 0 auto;
  animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: var(--color-cyan); }
}

/* Data Stream Effect */
.data-stream {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.data-stream::before {
  content: '';
  position: absolute;
  top: -100%;
  left: 0;
  width: 100%;
  height: 200%;
  background-image: 
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      rgba(0, 255, 255, 0.03) 1px,
      rgba(0, 255, 255, 0.03) 3px,
      transparent 4px
    );
  animation: data-flow 20s linear infinite;
}

@keyframes data-flow {
  0% { transform: translateY(0); }
  100% { transform: translateY(50%); }
}

/* Hexagon Grid Pattern */
.hex-pattern {
  position: relative;
  background-image: 
    radial-gradient(circle at center, rgba(0, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

/* Circuit Board Lines */
.circuit-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(90deg, rgba(0, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: circuit-pulse 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes circuit-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* Neon Glow Pulse */
.neon-pulse {
  animation: neon-pulse 2s ease-in-out infinite alternate;
}

@keyframes neon-pulse {
  from {
    text-shadow: 
      0 0 5px currentColor,
      0 0 10px currentColor,
      0 0 15px currentColor;
  }
  to {
    text-shadow: 
      0 0 2px currentColor,
      0 0 5px currentColor,
      0 0 8px currentColor,
      0 0 12px currentColor,
      0 0 18px currentColor;
  }
}

/* Matrix Rain Effect */
.matrix-rain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -3;
  overflow: hidden;
}

.matrix-rain::before {
  content: "01 0110 1001 01 1100 0101 10 1001 01 0110 1100 01 1001 10 0110 01 1100 1001 01";
  position: absolute;
  top: -100px;
  left: 0;
  width: 100%;
  height: calc(100% + 100px);
  color: rgba(0, 255, 65, 0.1);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 20px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: matrix-fall 15s linear infinite;
}

@keyframes matrix-fall {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

/* Holographic Shimmer */
.holographic {
  position: relative;
  background: linear-gradient(
    45deg,
    rgba(0, 255, 255, 0.1) 0%,
    rgba(0, 255, 65, 0.1) 25%,
    rgba(255, 102, 0, 0.1) 50%,
    rgba(157, 78, 221, 0.1) 75%,
    rgba(0, 255, 255, 0.1) 100%
  );
  background-size: 400% 400%;
  animation: holographic-shift 8s ease-in-out infinite;
}

@keyframes holographic-shift {
  0%, 100% { background-position: 0% 50%; }
  25% { background-position: 100% 50%; }
  50% { background-position: 100% 100%; }
  75% { background-position: 0% 100%; }
}

/* Terminal Cursor Blink */
.terminal-cursor {
  animation: terminal-blink 1.5s step-end infinite;
}

@keyframes terminal-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Loading Bar Animation */
.loading-bar {
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.loading-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(0, 255, 255, 0.8) 0%,
    rgba(0, 255, 65, 0.8) 50%,
    rgba(255, 102, 0, 0.8) 100%
  );
  animation: loading-progress 3s ease-in-out infinite;
}

@keyframes loading-progress {
  0% { left: -100%; }
  50% { left: 0%; }
  100% { left: 100%; }
}

/* Particle Float Effect */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -4;
}

.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: var(--color-cyan);
  border-radius: 50%;
  animation: particle-float 20s linear infinite;
  box-shadow: 0 0 6px var(--color-cyan);
}

.particle:nth-child(1) {
  left: 10%;
  animation-delay: 0s;
  animation-duration: 15s;
}

.particle:nth-child(2) {
  left: 30%;
  animation-delay: -2s;
  animation-duration: 18s;
  background: var(--color-green);
  box-shadow: 0 0 6px var(--color-green);
}

.particle:nth-child(3) {
  left: 50%;
  animation-delay: -4s;
  animation-duration: 22s;
}

.particle:nth-child(4) {
  left: 70%;
  animation-delay: -6s;
  animation-duration: 20s;
  background: var(--color-orange);
  box-shadow: 0 0 6px var(--color-orange);
}

.particle:nth-child(5) {
  left: 90%;
  animation-delay: -8s;
  animation-duration: 16s;
}

@keyframes particle-float {
  0% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-10vh) rotate(360deg);
    opacity: 0;
  }
}

/* Screen Flicker Effect */
.screen-flicker {
  animation: screen-flicker 0.15s linear infinite;
}

@keyframes screen-flicker {
  0% { opacity: 1; }
  98% { opacity: 1; }
  99% { opacity: 0.98; }
  100% { opacity: 1; }
}

/* Digital Clock Effect */
.digital-clock {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--color-green);
  text-shadow: var(--glow-green);
  letter-spacing: 2px;
}

.digital-clock::before {
  content: '[';
  color: var(--color-orange);
  text-shadow: var(--glow-orange);
}

.digital-clock::after {
  content: ']';
  color: var(--color-orange);
  text-shadow: var(--glow-orange);
}

/* Connection Status Indicator */
.connection-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-green);
  box-shadow: var(--glow-green);
  animation: connection-pulse 2s ease-in-out infinite;
}

@keyframes connection-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.7;
  }
}

/* Code Block Syntax Highlighting */
.syntax-highlight .keyword {
  color: var(--color-purple);
  text-shadow: 0 0 8px var(--color-purple);
}

.syntax-highlight .string {
  color: var(--color-green);
  text-shadow: var(--glow-green);
}

.syntax-highlight .number {
  color: var(--color-orange);
  text-shadow: var(--glow-orange);
}

.syntax-highlight .comment {
  color: var(--color-text-muted);
  font-style: italic;
}

/* Radar Sweep Effect */
.radar-sweep {
  position: relative;
  width: 100px;
  height: 100px;
  border: 2px solid var(--color-cyan);
  border-radius: 50%;
  overflow: hidden;
}

.radar-sweep::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 50%;
  background: linear-gradient(to bottom, var(--color-cyan), transparent);
  transform-origin: top;
  animation: radar-rotate 2s linear infinite;
}

@keyframes radar-rotate {
  0% { transform: translate(-50%, -100%) rotate(0deg); }
  100% { transform: translate(-50%, -100%) rotate(360deg); }
}

/* Binary Stream Background */
.binary-stream {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 12px;
  color: rgba(0, 255, 255, 0.05);
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  animation: binary-flow 30s linear infinite;
}

@keyframes binary-flow {
  0% { transform: translateX(0) translateY(0); }
  50% { transform: translateX(-50px) translateY(-25px); }
  100% { transform: translateX(0) translateY(-50px); }
}

/* Fade In Animations */
.fade-in-up {
  opacity: 0;
  transform: translateY(30px);
  animation: fade-in-up 0.8s ease forwards;
}

.fade-in-left {
  opacity: 0;
  transform: translateX(-30px);
  animation: fade-in-left 0.8s ease forwards;
}

.fade-in-right {
  opacity: 0;
  transform: translateX(30px);
  animation: fade-in-right 0.8s ease forwards;
}

@keyframes fade-in-up {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in-left {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fade-in-right {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Staggered Animation Delays */
.fade-in-up:nth-child(1) { animation-delay: 0.1s; }
.fade-in-up:nth-child(2) { animation-delay: 0.2s; }
.fade-in-up:nth-child(3) { animation-delay: 0.3s; }
.fade-in-up:nth-child(4) { animation-delay: 0.4s; }
.fade-in-up:nth-child(5) { animation-delay: 0.5s; }

/* Hover Effects */
.hover-glow:hover {
  text-shadow: 
    0 0 10px currentColor,
    0 0 20px currentColor,
    0 0 30px currentColor;
  transition: text-shadow 0.3s ease;
}

.hover-glitch:hover {
  animation: glitch-skew 0.3s ease-in-out;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .glitch::before,
  .glitch::after {
    display: none; /* Disable glitch effect on mobile for performance */
  }
  
  .matrix-rain,
  .particles,
  .data-stream {
    display: none; /* Disable heavy animations on mobile */
  }
  
  .terminal-cursor {
    animation-duration: 1s; /* Faster cursor blink on mobile */
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
