/* Glitchy Stripes Hero Background для Тильды */
.hero-glitch-bg {
  position: relative;
  width: 100%;
  height: 100vh;
  min-height: 600px;
  overflow: hidden;
  background-color: #000000;
}

/* Обертка для полос */
.glitch-stripes-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  z-index: 1;
}

/* Вертикальные полосы */
.glitch-stripe {
  flex: 1;
  height: 100%;
  background-color: #ffffff;
  animation: stripe-pulse 2.5s ease-in-out infinite;
}

/* Чередование черных и белых полос */
.glitch-stripe:nth-child(odd) {
  background-color: #ffffff;
}

.glitch-stripe:nth-child(even) {
  background-color: #000000;
}

/* Разные скорости пульсации для глубины */
.glitch-stripe:nth-child(1) { animation-delay: 0s; animation-duration: 2s; }
.glitch-stripe:nth-child(2) { animation-delay: 0.3s; animation-duration: 2.2s; }
.glitch-stripe:nth-child(3) { animation-delay: 0.6s; animation-duration: 1.8s; }
.glitch-stripe:nth-child(4) { animation-delay: 0.2s; animation-duration: 2.5s; }
.glitch-stripe:nth-child(5) { animation-delay: 0.8s; animation-duration: 2.1s; }
.glitch-stripe:nth-child(6) { animation-delay: 0.4s; animation-duration: 2.3s; }
.glitch-stripe:nth-child(7) { animation-delay: 0.1s; animation-duration: 2.4s; }
.glitch-stripe:nth-child(8) { animation-delay: 0.7s; animation-duration: 1.9s; }
.glitch-stripe:nth-child(9) { animation-delay: 0.5s; animation-duration: 2.6s; }
.glitch-stripe:nth-child(10) { animation-delay: 0.9s; animation-duration: 2.0s; }

/* Пульсация полос */
@keyframes stripe-pulse {
  0%, 100% {
    opacity: 0.7;
    transform: scaleY(0.98);
  }
  50% {
    opacity: 1;
    transform: scaleY(1.02);
  }
}

/* Слой глитчей - задержки анимации */
.glitch-layer-1,
.glitch-layer-2,
.glitch-layer-3,
.glitch-layer-4 {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  mix-blend-mode: screen;
}

/* Глитч 1 - горизонтальные искажения */
.glitch-layer-1 {
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(255, 255, 255, 0.05) 30%,
    transparent 60%,
    rgba(255, 255, 255, 0.03) 80%,
    transparent 100%
  );
  animation: glitch-1 8s infinite;
}

/* Глитч 2 - вертикальные смещения */
.glitch-layer-2 {
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 20px,
    rgba(255, 255, 255, 0.02) 20px,
    rgba(255, 255, 255, 0.02) 40px
  );
  animation: glitch-2 12s infinite;
}

/* Глитч 3 - случайные вспышки */
.glitch-layer-3 {
  background: rgba(255, 255, 255, 0.1);
  animation: glitch-3 15s infinite;
}

/* Глитч 4 - цифровой шум */
.glitch-layer-4 {
  background-image: 
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.2) 0px,
      rgba(0, 0, 0, 0.2) 1px,
      transparent 1px,
      transparent 2px
    );
  animation: glitch-4 20s infinite;
}

/* Анимации глитчей */
@keyframes glitch-1 {
  0%, 96%, 100% {
    opacity: 0;
    transform: translateY(0);
  }
  97% {
    opacity: 0.6;
    transform: translateY(-10px);
    clip-path: inset(20% 0 30% 0);
  }
  98% {
    opacity: 0.3;
    transform: translateY(5px);
    clip-path: inset(40% 0 20% 0);
  }
  99% {
    opacity: 0.8;
    transform: translateY(0);
    clip-path: inset(0 0 0 0);
  }
}

@keyframes glitch-2 {
  0%, 93%, 100% {
    opacity: 0;
    transform: translateX(0);
  }
  94% {
    opacity: 0.4;
    transform: translateX(15px);
  }
  95% {
    opacity: 0.2;
    transform: translateX(-10px);
  }
  96% {
    opacity: 0.5;
    transform: translateX(0);
  }
}

@keyframes glitch-3 {
  0%, 85%, 88%, 91%, 94%, 97%, 100% {
    opacity: 0;
    clip-path: inset(0 0 100% 0);
  }
  86% {
    opacity: 0.3;
    clip-path: inset(10% 20% 50% 20%);
  }
  89% {
    opacity: 0.2;
    clip-path: inset(30% 10% 40% 10%);
  }
  92% {
    opacity: 0.4;
    clip-path: inset(5% 30% 60% 30%);
  }
  95% {
    opacity: 0.25;
    clip-path: inset(25% 15% 45% 15%);
  }
  98% {
    opacity: 0.35;
    clip-path: inset(15% 25% 55% 25%);
  }
}

@keyframes glitch-4 {
  0%, 90%, 100% {
    opacity: 0;
    background-size: 2px 2px;
  }
  91% {
    opacity: 0.15;
    background-size: 5px 5px;
  }
  92% {
    opacity: 0.1;
    background-size: 3px 3px;
  }
  93% {
    opacity: 0.2;
    background-size: 4px 4px;
  }
  94% {
    opacity: 0.05;
    background-size: 6px 6px;
  }
}

/* Контент поверх фона */
.hero-content {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  text-align: center;
}

.hero-title {
  color: #ffffff;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  animation: title-flicker 10s infinite;
}

.hero-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 300;
  max-width: 600px;
  margin-bottom: 2rem;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
}

@keyframes title-flicker {
  0%, 92%, 100% {
    opacity: 1;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  }
  93% {
    opacity: 0.8;
    text-shadow: 0 2px 20px rgba(255, 255, 255, 0.3);
  }
  94% {
    opacity: 1;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  }
  96% {
    opacity: 0.9;
    text-shadow: 0 2px 15px rgba(255, 255, 255, 0.2);
  }
  97% {
    opacity: 1;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  }
}

/* Адаптация под мобильные устройства */
@media (max-width: 768px) {
  .hero-glitch-bg {
    height: 90vh;
    min-height: 500px;
  }
  
  /* Меньше полос на мобильных для лучшей производительности */
  .glitch-stripe:nth-child(n+7) {
    display: none;
  }
  
  .hero-title {
    font-size: clamp(1.8rem, 6vw, 3rem);
  }
  
  .hero-subtitle {
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    padding: 0 15px;
  }
  
  /* Упрощенные анимации для мобильных */
  .glitch-stripe {
    animation-duration: 3s;
  }
  
  .glitch-layer-4 {
    display: none; /* Убираем сложный глитч на мобильных */
  }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
  .hero-glitch-bg {
    height: 85vh;
    min-height: 400px;
  }
  
  .glitch-stripe:nth-child(n+5) {
    display: none; /* Еще меньше полос */
  }
  
  .glitch-layer-2 {
    display: none; /* Убираем еще один слой глитчей */
  }
}

/* Оптимизация производительности */
.hero-glitch-bg {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
  will-change: transform, opacity;
}