/* ============================================
   WROCŁAW KODUJE 2.0 — ANIMATIONS
   ============================================ */

/* ---------- KEYFRAMES ---------- */

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

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes shine {
    0% { transform: rotate(45deg) translateX(-100%); }
    100% { transform: rotate(45deg) translateX(100%); }
}

@keyframes spin-text {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

@keyframes scanline {
    0% { top: -10%; }
    100% { top: 110%; }
}

@keyframes neon-flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        text-shadow:
            0 0 4px var(--c-neon-green),
            0 0 11px var(--c-neon-green),
            0 0 19px var(--c-neon-green);
    }
    20%, 24%, 55% {
        text-shadow: none;
    }
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-left {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 5px rgba(0, 255, 136, 0.2);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 255, 136, 0.4), 0 0 40px rgba(0, 255, 136, 0.1);
    }
}

@keyframes code-rain-fade {
    0% { opacity: 0; transform: translateY(-20px); }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; transform: translateY(20px); }
}

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

/* ---------- KEN BURNS — demoscene slow-zoom/pan for section photo backgrounds ---------- */

@keyframes kb-slow-zoom-1 {
    from { transform: scale(1.05) translate(0%,    0%);    }
    to   { transform: scale(1.14) translate(-1.4%, -0.7%); }
}

@keyframes kb-slow-zoom-2 {
    from { transform: scale(1.06) translate(-0.8%, 0.5%);  }
    to   { transform: scale(1.13) translate(1.0%,  -0.6%); }
}

@keyframes kb-slow-zoom-3 {
    from { transform: scale(1.07) translate(0.6%,  -0.4%); }
    to   { transform: scale(1.14) translate(-0.8%, 0.8%);  }
}

/* ---------- GLITCH EFFECT ---------- */

.glitch {
    position: relative;
}

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

.glitch:hover::before {
    opacity: 0.8;
    color: var(--c-neon-pink);
    animation: glitch-1 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both infinite;
    clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
}

.glitch:hover::after {
    opacity: 0.8;
    color: var(--c-neon-blue);
    animation: glitch-2 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) reverse both infinite;
    clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
}

@keyframes glitch-1 {
    0% { transform: translate(0); }
    20% { transform: translate(-3px, 3px); }
    40% { transform: translate(-3px, -3px); }
    60% { transform: translate(3px, 3px); }
    80% { transform: translate(3px, -3px); }
    100% { transform: translate(0); }
}

@keyframes glitch-2 {
    0% { transform: translate(0); }
    20% { transform: translate(3px, -3px); }
    40% { transform: translate(3px, 3px); }
    60% { transform: translate(-3px, -3px); }
    80% { transform: translate(-3px, 3px); }
    100% { transform: translate(0); }
}

/* ---------- SCANLINE OVERLAY ---------- */
.hero::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.05) 0px,
        rgba(0, 0, 0, 0.05) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 2;
}

[data-theme="light"] .hero::after {
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.02) 0px,
        rgba(0, 0, 0, 0.02) 1px,
        transparent 1px,
        transparent 3px
    );
}

/* ---------- REVEAL ON SCROLL ---------- */
.section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered children animation */
.section.visible .guest-card,
.section.visible .stat-card,
.section.visible .news-card {
    animation: slide-up 0.6s ease forwards;
    opacity: 0;
}

.section.visible .guest-card:nth-child(1),
.section.visible .stat-card:nth-child(1),
.section.visible .news-card:nth-child(1) { animation-delay: 0.1s; }

.section.visible .guest-card:nth-child(2),
.section.visible .stat-card:nth-child(2),
.section.visible .news-card:nth-child(2) { animation-delay: 0.2s; }

.section.visible .guest-card:nth-child(3),
.section.visible .stat-card:nth-child(3),
.section.visible .news-card:nth-child(3) { animation-delay: 0.3s; }

.section.visible .guest-card:nth-child(4),
.section.visible .stat-card:nth-child(4),
.section.visible .news-card:nth-child(4) { animation-delay: 0.4s; }

/* ---------- NAV LINK ACTIVE GLOW ---------- */
.nav__links a.active {
    text-shadow: 0 0 8px rgba(0, 255, 136, 0.5);
}

/* ---------- INTERACTIVE CODE BLOCKS ---------- */
.markdown-body code {
    cursor: pointer;
    transition: var(--transition);
}

.markdown-body code:hover {
    background: rgba(0, 255, 136, 0.2);
    box-shadow: var(--glow-green);
}

.markdown-body code.clicked {
    animation: glow-pulse 0.5s ease;
}

/* ---------- BUTTON RIPPLE ---------- */
.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

/* ---------- GRADIENT TEXT ANIMATION ---------- */
.gradient-text {
    background: linear-gradient(
        270deg,
        var(--c-neon-green),
        var(--c-neon-blue),
        var(--c-neon-purple),
        var(--c-neon-pink),
        var(--c-neon-green)
    );
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 8s ease infinite;
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .section {
        opacity: 1;
        transform: none;
    }

    .hero::after {
        display: none;
    }

    #matrix-bg {
        display: none;
    }
}
