/* ===========================
   ANIMATIONS & EFFECTS
   =========================== */

/* ===========================
   GAME OF LIFE BACKGROUND
   =========================== */

.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.15;
}

.game-of-life {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.cell {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 1px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cell.alive {
    opacity: 0.6;
    box-shadow: 0 0 3px var(--accent-color);
}

.cell.spark {
    opacity: 1;
    box-shadow: 0 0 8px var(--accent-color), 0 0 16px var(--accent-color);
    transform: scale(1.2);
    transition: all 0.3s ease;
}

/* ===========================
   CLICK EFFECTS
   =========================== */

.click-ripple {
    position: absolute;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    pointer-events: none;
    animation: ripple 0.6s ease-out;
    transform: translate(-50%, -50%); /* Center the element on the cursor */
}

@keyframes ripple {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 60px;
        height: 60px;
        opacity: 0;
    }
}

/* ===========================
   LOADING ANIMATION
   =========================== */

.simple-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s ease;
}

.glitch-loader {
    font-family: 'Orbitron', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-color);
    position: relative;
    text-transform: uppercase;
    letter-spacing: 3px;
}

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

.glitch-loader::before {
    color: var(--accent-secondary);
    animation: glitch-simple1 0.8s infinite linear;
}

.glitch-loader::after {
    color: var(--accent-tertiary);
    animation: glitch-simple2 0.8s infinite linear;
}

@keyframes glitch-simple1 {
    0%, 100% { transform: translate(0); opacity: 0; }
    10% { transform: translate(-2px, 2px); opacity: 0.8; }
    20% { transform: translate(2px, -2px); opacity: 0; }
    30% { transform: translate(-2px, -2px); opacity: 0.8; }
    40% { transform: translate(2px, 2px); opacity: 0; }
    50% { transform: translate(-2px, 2px); opacity: 0.8; }
    60% { transform: translate(2px, -2px); opacity: 0; }
}

@keyframes glitch-simple2 {
    0%, 100% { transform: translate(0); opacity: 0; }
    15% { transform: translate(3px, -3px); opacity: 0.6; }
    25% { transform: translate(-3px, 3px); opacity: 0; }
    35% { transform: translate(3px, 3px); opacity: 0.6; }
    45% { transform: translate(-3px, -3px); opacity: 0; }
    55% { transform: translate(3px, -3px); opacity: 0.6; }
    65% { transform: translate(-3px, 3px); opacity: 0; }
}

/* ===========================
   TEXT EFFECTS
   =========================== */

.scramble-text {
    font-family: 'Orbitron', monospace;
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 900;
    margin-bottom: 1rem;
    position: relative;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 2px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: normal;
    white-space: normal;
    max-width: 100%;
}

.scramble-char {
    display: inline-block;
    position: relative;
}

.scramble-word {
    display: inline;
    position: relative;
    word-break: keep-all;
}

.scramble-space {
    display: inline;
    white-space: pre;
    word-break: normal;
}

.scramble-char.scrambling,
.scramble-word.scrambling {
    animation: scramble-glow 0.1s ease-in-out;
}

@keyframes scramble-glow {
    0%, 100% { color: var(--text-primary); }
    50% { 
        color: var(--accent-color); 
        text-shadow: 0 0 10px var(--accent-color);
    }
}

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

.glitch-text::before {
    color: var(--accent-secondary);
    animation: glitch1 2s infinite;
}

.glitch-text::after {
    color: var(--accent-color);
    animation: glitch2 2s infinite;
}

@keyframes glitch1 {
    0%, 90%, 100% { opacity: 0; transform: translate(0); }
    5% { opacity: 0.7; transform: translate(-2px, -2px); }
    10% { opacity: 0.7; transform: translate(2px, 2px); }
}

@keyframes glitch2 {
    0%, 90%, 100% { opacity: 0; transform: translate(0); }
    15% { opacity: 0.7; transform: translate(2px, -2px); }
    20% { opacity: 0.7; transform: translate(-2px, 2px); }
}

/* ===========================
   TYPEWRITER EFFECT
   =========================== */

.typewriter {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin: 0 auto 2rem;
    font-family: 'JetBrains Mono', monospace;
    border-right: 2px solid var(--accent-color);
    white-space: nowrap;
    overflow: hidden;
    text-align: center;
    display: block;
    width: fit-content;
    max-width: 100%;
    min-height: 1.8rem; /* Maintain consistent height */
    line-height: 1.8rem;
    animation: blink 1s infinite;
}

.cursor {
    color: var(--accent-color);
    animation: blink 1s infinite;
    font-weight: bold;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    0%, 50% { border-color: var(--accent-color); }
    51%, 100% { border-color: transparent; }
}

/* ===========================
   FADE IN ANIMATIONS
   =========================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}
