---
export interface Props {
  title?: string;
  description?: string;
  columns?: number;
  gap?: 'small' | 'medium' | 'large';
}

const { 
  title, 
  description,
  columns = 3,
  gap = 'medium'
} = Astro.props;

const gapClasses = {
  small: 'gap-4',
  medium: 'gap-6',
  large: 'gap-8'
};
---

<section class="navigation-grid-container" data-reveal data-reveal-distance="64px" data-reveal-delay="0s">
  {(title || description) && (
    <div class="grid-header" data-reveal data-reveal-distance="32px" data-reveal-delay="0.08s">
      {title && <h2 class="grid-title">{title}</h2>}
      {description && <p class="grid-description">{description}</p>}
    </div>
  )}
  
  <div class={`navigation-grid ${gapClasses[gap]}`} style={`--columns: ${columns}`}>
    <slot />
  </div>
</section>

<style>
  .navigation-grid-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
  }
  
  .grid-header {
    text-align: center;
    margin-bottom: 3rem;
  }
  
  .grid-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #7A6B5D;
    margin: 0 0 1rem 0;
    background: linear-gradient(135deg, #7A6B5D, #A68B7B);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  
  .grid-description {
    font-size: 1.1rem;
    color: #9B8B7A;
    margin: 0;
    line-height: 1.6;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }
  
  .navigation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    width: 100%;
  }
  
  /* 响应式列数 */
  @media (min-width: 1200px) {
    .navigation-grid {
      grid-template-columns: repeat(var(--columns, 3), 1fr);
    }
  }
  
  @media (max-width: 768px) {
    .navigation-grid-container {
      padding: 1rem;
    }
    
    .navigation-grid {
      grid-template-columns: 1fr;
    }
    
    .grid-title {
      font-size: 2rem;
    }
    
    .grid-description {
      font-size: 1rem;
    }
  }
  
  @media (max-width: 480px) {
    .grid-title {
      font-size: 1.75rem;
    }
    
    .navigation-grid-container {
      padding: 0.5rem;
    }
  }
  
  .navigation-grid > * {
    --card-delay: 0s;
  }
  
  .navigation-grid > *:nth-child(1) { --card-delay: 0s; }
  .navigation-grid > *:nth-child(2) { --card-delay: 0.08s; }
  .navigation-grid > *:nth-child(3) { --card-delay: 0.16s; }
  .navigation-grid > *:nth-child(4) { --card-delay: 0.24s; }
  .navigation-grid > *:nth-child(5) { --card-delay: 0.32s; }
  .navigation-grid > *:nth-child(6) { --card-delay: 0.4s; }
  .navigation-grid > *:nth-child(7) { --card-delay: 0.48s; }
  .navigation-grid > *:nth-child(8) { --card-delay: 0.56s; }
  .navigation-grid > *:nth-child(9) { --card-delay: 0.64s; }
</style>