/* ============================================
   POLPO 8 — Animations
   ============================================ */

/* ---------- Blink ---------- */
@keyframes blink-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

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

/* ---------- Glitch ---------- */
@keyframes glitch-1 {
  0%   { clip-path: inset(40% 0 61% 0); transform: skew(-0.1deg); }
  20%  { clip-path: inset(92% 0 1% 0);  transform: skew(0.2deg); }
  40%  { clip-path: inset(43% 0 1% 0);  transform: skew(0deg); }
  60%  { clip-path: inset(25% 0 58% 0); transform: skew(0.1deg); }
  80%  { clip-path: inset(54% 0 7% 0);  transform: skew(-0.15deg); }
  100% { clip-path: inset(58% 0 43% 0); transform: skew(0.1deg); }
}

@keyframes glitch-2 {
  0%   { clip-path: inset(10% 0 85% 0); transform: skew(0.2deg); }
  20%  { clip-path: inset(71% 0 12% 0); transform: skew(-0.1deg); }
  40%  { clip-path: inset(62% 0 3% 0);  transform: skew(0deg); }
  60%  { clip-path: inset(9% 0 88% 0);  transform: skew(0.15deg); }
  80%  { clip-path: inset(46% 0 39% 0); transform: skew(-0.2deg); }
  100% { clip-path: inset(36% 0 52% 0); transform: skew(0.1deg); }
}

/* Glitch class for elements */
.glitch {
  position: relative;
}

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

.glitch:hover::before {
  opacity: 0.8;
  color: var(--cyan);
  animation: glitch-1 0.3s linear infinite;
  transform: translateX(-2px);
}

.glitch:hover::after {
  opacity: 0.6;
  color: var(--red, #ff0044);
  animation: glitch-2 0.3s linear infinite;
  transform: translateX(2px);
}

/* ---------- Scan line ---------- */
@keyframes scan-v {
  0%   { top: -1%; opacity: 0; }
  5%   { opacity: 1; }
  90%  { opacity: 0.6; }
  100% { top: 101%; opacity: 0; }
}

.scan-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(128, 189, 15, 0.4) 50%, transparent 100%);
  pointer-events: none;
  z-index: 10;
  animation: scan-v 4s linear infinite;
}

/* ---------- Typing cursor ---------- */
.type-cursor::after {
  content: '_';
  color: var(--green);
  animation: blink-cursor 1s step-end infinite;
}

/* ---------- Float (for octopus) ---------- */
@keyframes float-slow {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(1deg); }
}

/* ---------- Pulse ring ---------- */
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0; }
}

.pulse-ring {
  position: relative;
  display: inline-flex;
}

.pulse-ring::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--green);
  animation: pulse-ring 2s ease-out infinite;
}

/* ---------- Boot sequence ---------- */
@keyframes boot-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.boot-line {
  opacity: 0;
  animation: boot-in 0.2s ease forwards;
}

.boot-line:nth-child(1) { animation-delay: 0.1s; }
.boot-line:nth-child(2) { animation-delay: 0.4s; }
.boot-line:nth-child(3) { animation-delay: 0.7s; }
.boot-line:nth-child(4) { animation-delay: 1.0s; }
.boot-line:nth-child(5) { animation-delay: 1.3s; }

/* ---------- Progress bar fill ---------- */
@keyframes fill-bar {
  from { width: 0%; }
  to   { width: var(--target-width, 100%); }
}

.progress-bar {
  height: 2px;
  background: var(--border-dim);
  position: relative;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--green);
  width: 0%;
  animation: fill-bar 1.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  box-shadow: 0 0 8px var(--green);
}

/* ---------- Number scramble ---------- */
@keyframes num-roll {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-100%); }
}

/* ---------- Fade up (generic) ---------- */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-fade-up {
  animation: fade-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.d-1 { animation-delay: 0.1s; }
.d-2 { animation-delay: 0.2s; }
.d-3 { animation-delay: 0.3s; }
.d-4 { animation-delay: 0.4s; }
.d-5 { animation-delay: 0.5s; }
.d-6 { animation-delay: 0.6s; }

/* ---------- Flicker ---------- */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.4; }
  94% { opacity: 1; }
  96% { opacity: 0.6; }
  97% { opacity: 1; }
}

.flicker { animation: flicker 6s ease-in-out infinite; }

/* ---------- Orbit ---------- */
@keyframes orbit {
  from { transform: rotate(0deg) translateX(140px) rotate(0deg); }
  to   { transform: rotate(360deg) translateX(140px) rotate(-360deg); }
}

/* ---------- Arm wave ---------- */
@keyframes arm-1 {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  50% { transform: rotate(2deg) translateY(-4px); }
}

@keyframes arm-2 {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  50% { transform: rotate(-2deg) translateY(-3px); }
}

.octo-arm:nth-child(odd)  { animation: arm-1 3.5s ease-in-out infinite; transform-origin: 50% 100%; }
.octo-arm:nth-child(even) { animation: arm-2 4s ease-in-out infinite; transform-origin: 50% 100%; }

.octo-arm:nth-child(2) { animation-delay: -0.4s; }
.octo-arm:nth-child(3) { animation-delay: -0.8s; }
.octo-arm:nth-child(4) { animation-delay: -1.2s; }
.octo-arm:nth-child(5) { animation-delay: -1.6s; }
.octo-arm:nth-child(6) { animation-delay: -2.0s; }
.octo-arm:nth-child(7) { animation-delay: -2.4s; }
.octo-arm:nth-child(8) { animation-delay: -2.8s; }

/* ---------- Core glow ---------- */
@keyframes core-glow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(128, 189, 15, 0.5)); }
  50% { filter: drop-shadow(0 0 20px rgba(128, 189, 15, 0.8)); }
}

.octo-core { animation: core-glow 3s ease-in-out infinite; }
