body {
    margin: 0;
}

.image-grid {
    --gap: 16px;
    --num-cols: 4;
    --row-height: 300px;

    box-sizing: border-box;
    padding: var(--gap);

    display: grid;
    grid-template-columns: repeat(var(--num-cols), 1fr);
    grid-auto-rows: var(--row-height);
    gap: var(--gap);
}

.image-grid>img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease-in-out; /* Smooth transition for movement */
}

.image-grid>img.clicked {
    animation: shake 0.4s ease-in-out, glitch 0.3s linear; /* Apply both animations */
}

@keyframes shake {
    0% { transform: translate(0, 0) rotate(0); }
    25% { transform: translate(-5px, 0) rotate(-5deg); }
    50% { transform: translate(0, 0) rotate(0); }
    75% { transform: translate(5px, 0) rotate(5deg); }
    100% { transform: translate(0, 0) rotate(0); }
}

@keyframes glitch {
    0% { clip-path: inset(0 0 0 0); }
    25% { clip-path: inset(3% 0 3% 0); }
    50% { clip-path: inset(0 2% 0 2%); }
    75% { clip-path: inset(0 0 0 0); }
    100% { clip-path: inset(0 0 0 0); }
}

.image-grid-row-2 {
    grid-row: span 2;
}

/* Anything under 1024px */
@media screen and (max-width: 1024px) {
    .image-grid {
        --num-cols: 2;
        --row-height: 200px;
    }
}
