<div class="grid-demo">
  <div class="grid-container">
    <div class="grid-header">
      <h2>Animated Card Grid</h2>
      <p>Hover over cards to see beautiful animations</p>
    </div>
    
    <div class="card-grid">
      <div class="card-item" data-category="design">
        <div class="card-image">
          <img src="https://images.unsplash.com/photo-1551650975-87deedd944c3?w=400&h=300&fit=crop" alt="Modern Design">
          <div class="card-overlay">
            <span class="card-tag">UI/UX</span>
          </div>
        </div>
        <div class="card-content">
          <h3>Modern Design System</h3>
          <p>Complete design system with components and guidelines</p>
          <div class="card-meta">
            <span class="card-date">Jan 2024</span>
            <span class="card-likes">❤️ 234</span>
          </div>
        </div>
      </div>
      <div class="card-item" data-category="development">
        <div class="card-image">
          <img src="https://images.unsplash.com/photo-1461749280684-dccba630e2f6?w=400&h=300&fit=crop" alt="Code">
          <div class="card-overlay">
            <span class="card-tag">React</span>
          </div>
        </div>
        <div class="card-content">
          <h3>React Components</h3>
          <p>Reusable components built with React and TypeScript</p>
          <div class="card-meta">
            <span class="card-date">Jan 2024</span>
            <span class="card-likes">❤️ 189</span>
          </div>
        </div>
      </div>
      <div class="card-item" data-category="mobile">
        <div class="card-image">
          <img src="https://images.unsplash.com/photo-1512941937669-90a1b58e7e9c?w=400&h=300&fit=crop" alt="Mobile App">
          <div class="card-overlay">
            <span class="card-tag">Mobile</span>
          </div>
        </div>
        <div class="card-content">
          <h3>Mobile App Design</h3>
          <p>Cross-platform mobile application with native feel</p>
          <div class="card-meta">
            <span class="card-date">Jan 2024</span>
            <span class="card-likes">❤️ 167</span>
          </div>
        </div>
      </div>
      <div class="card-item" data-category="ecommerce">
        <div class="card-image">
          <img src="https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?w=400&h=300&fit=crop" alt="E-commerce">
          <div class="card-overlay">
            <span class="card-tag">E-commerce</span>
          </div>
        </div>
        <div class="card-content">
          <h3>E-commerce Platform</h3>
          <p>Modern e-commerce solutions with seamless UX</p>
          <div class="card-meta">
            <span class="card-date">Jan 2024</span>
            <span class="card-likes">❤️ 203</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
     .grid-demo {
  font-family: 'Arial', sans-serif;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  min-height: 100vh;
  padding: 2rem;
}
.grid-container {
  max-width: 1200px;
  margin: 0 auto;
}
.grid-header {
  text-align: center;
  margin-bottom: 3rem;
  color: white;
}
.grid-header h2 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(45deg, #fff, #e0e0e0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.grid-header p {
  font-size: 1.1rem;
  opacity: 0.9;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  padding: 1rem 0;
}
.card-item {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  position: relative;
  animation: fadeInUp 0.6s ease forwards;
  opacity: 0;
  transform: translateY(30px);
}
.card-item:nth-child(1) { animation-delay: 0.1s; }
.card-item:nth-child(2) { animation-delay: 0.2s; }
.card-item:nth-child(3) { animation-delay: 0.3s; }
.card-item:nth-child(4) { animation-delay: 0.4s; }
@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.card-item:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}
.card-image {
  position: relative;
  height: 200px;
  overflow: hidden;
}
.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.card-item:hover .card-image img {
  transform: scale(1.1);
}
.card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, rgba(102, 126, 234, 0.8), rgba(118, 75, 162, 0.8));
  opacity: 0;
  transition: opacity 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-item:hover .card-overlay {
  opacity: 1;
}
.card-tag {
  background: rgba(255, 255, 255, 0.9);
  color: #667eea;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  transform: scale(0.8);
  transition: transform 0.4s ease;
}
.card-item:hover .card-tag {
  transform: scale(1);
}
.card-content {
  padding: 1.5rem;
  color: white;
}
.card-content h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.3rem;
  font-weight: 600;
}
.card-content p {
  margin: 0 0 1rem 0;
  opacity: 0.8;
  line-height: 1.5;
}
.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  opacity: 0.7;
}
.card-date {
  color: #a0a0a0;
}
.card-likes {
  color: #ff6b6b;
}
.card-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}
.card-item:hover::before {
  transform: translateX(100%);
}
@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .grid-demo {
    padding: 1rem;
  }
}
     class AnimatedCardGrid {
  constructor() {
    this.cards = document.querySelectorAll('.card-item');
    this.init();
  }
  init() {
    this.addHoverEffects();
    this.addClickEffects();
    this.addIntersectionObserver();
  }
  addHoverEffects() {
    this.cards.forEach(card => {
      card.addEventListener('mouseenter', (e) => {
        this.createRippleEffect(e);
      });
    });
  }
  addClickEffects() {
    this.cards.forEach(card => {
      card.addEventListener('click', (e) => {
        this.expandCard(card);
      });
    });
  }
  createRippleEffect(e) {
    const card = e.currentTarget;
    const ripple = document.createElement('span');
    const rect = card.getBoundingClientRect();
    const size = Math.max(rect.width, rect.height);
    const x = e.clientX - rect.left - size / 2;
    const y = e.clientY - rect.top - size / 2;
    ripple.style.cssText = `
      position: absolute;
      width: ${size}px;
      height: ${size}px;
      left: ${x}px;
      top: ${y}px;
      background: rgba(255, 255, 255, 0.3);
      border-radius: 50%;
      transform: scale(0);
      animation: ripple 0.6s linear;
      pointer-events: none;
      z-index: 1;
    `;
    card.appendChild(ripple);
    setTimeout(() => {
      ripple.remove();
    }, 600);
  }
  expandCard(card) {
    // Toggle expanded state
    card.classList.toggle('expanded');
    
    // Close other expanded cards
    this.cards.forEach(otherCard => {
      if (otherCard !== card) {
        otherCard.classList.remove('expanded');
      }
    });
  }
  addIntersectionObserver() {
    const observer = new IntersectionObserver((entries) => {
      entries.forEach(entry => {
        if (entry.isIntersecting) {
          entry.target.style.animationPlayState = 'running';
        }
      });
    }, { threshold: 0.1 });
    this.cards.forEach(card => {
      observer.observe(card);
    });
  }
}
// Add CSS for ripple effect
const style = document.createElement('style');
style.textContent = `
  @keyframes ripple {
    to {
      width: 200px;
      height: 200px;
      opacity: 0;
    }
  }
  .card-item.expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.1);
    z-index: 1000;
    max-width: 600px;
    width: 90%;
  }
`;
document.head.appendChild(style);
document.addEventListener('DOMContentLoaded', function() {
  new AnimatedCardGrid();
});