@use 'ui-design-system/src/styles/semantic' as *;

.ui-bento-grid {
  display: grid;
  position: relative;
  width: 100%;
  
  // Base grid layout with masonry-like behavior
  gap: $semantic-spacing-grid-gap-md;
  grid-auto-rows: minmax(120px, auto);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  
  // Size variants for gap
  &--gap-xs {
    gap: $semantic-spacing-grid-gap-sm;
  }
  
  &--gap-sm {
    gap: $semantic-spacing-grid-gap-sm;
  }
  
  &--gap-md {
    gap: $semantic-spacing-grid-gap-md;
  }
  
  &--gap-lg {
    gap: $semantic-spacing-grid-gap-lg;
  }
  
  // Column variants for different breakpoints
  &--cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  &--cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  &--cols-4 {
    grid-template-columns: repeat(4, 1fr);
  }
  
  &--cols-5 {
    grid-template-columns: repeat(5, 1fr);
  }
  
  &--cols-6 {
    grid-template-columns: repeat(6, 1fr);
  }
  
  // Auto-fit responsive columns with different min widths
  &--auto-fit-sm {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
  
  &--auto-fit-md {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
  
  &--auto-fit-lg {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  }
  
  // Row height variants
  &--rows-sm {
    grid-auto-rows: minmax(80px, auto);
  }
  
  &--rows-md {
    grid-auto-rows: minmax(120px, auto);
  }
  
  &--rows-lg {
    grid-auto-rows: minmax(160px, auto);
  }
  
  // Dense packing for masonry effect
  &--dense {
    grid-auto-flow: row dense;
  }
  
  // Responsive behavior
  @media (max-width: 1024px) {
    &--cols-6,
    &--cols-5 {
      grid-template-columns: repeat(3, 1fr);
    }
    
    &--cols-4 {
      grid-template-columns: repeat(2, 1fr);
    }
    
    &--auto-fit-lg {
      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
  }
  
  @media (max-width: 768px) {
    gap: $semantic-spacing-grid-gap-sm;
    
    &--cols-6,
    &--cols-5,
    &--cols-4,
    &--cols-3 {
      grid-template-columns: repeat(2, 1fr);
    }
    
    &--auto-fit-md,
    &--auto-fit-lg {
      grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
  }
  
  @media (max-width: 480px) {
    gap: $semantic-spacing-grid-gap-sm;
    
    &--cols-6,
    &--cols-5,
    &--cols-4,
    &--cols-3,
    &--cols-2 {
      grid-template-columns: 1fr;
    }
    
    &--auto-fit-sm,
    &--auto-fit-md,
    &--auto-fit-lg {
      grid-template-columns: 1fr;
    }
  }
}

// Bento Grid Item - for individual grid cells with specific spans
.ui-bento-grid-item {
  position: relative;
  overflow: hidden;
  background: $semantic-color-surface-primary;
  border: $semantic-border-width-1 solid $semantic-color-border-subtle;
  border-radius: $semantic-border-card-radius;
  box-shadow: $semantic-shadow-elevation-1;
  padding: $semantic-spacing-component-md;
  
  // Transitions
  transition: all $semantic-motion-duration-fast $semantic-motion-easing-ease;
  
  // Size variants - column spans
  &--span-1 {
    grid-column: span 1;
  }
  
  &--span-2 {
    grid-column: span 2;
  }
  
  &--span-3 {
    grid-column: span 3;
  }
  
  &--span-4 {
    grid-column: span 4;
  }
  
  &--span-full {
    grid-column: 1 / -1;
  }
  
  // Row spans for featured items
  &--row-span-1 {
    grid-row: span 1;
  }
  
  &--row-span-2 {
    grid-row: span 2;
  }
  
  &--row-span-3 {
    grid-row: span 3;
  }
  
  &--row-span-4 {
    grid-row: span 4;
  }
  
  // Combined featured sizes
  &--featured-sm {
    grid-column: span 2;
    grid-row: span 1;
  }
  
  &--featured-md {
    grid-column: span 2;
    grid-row: span 2;
  }
  
  &--featured-lg {
    grid-column: span 3;
    grid-row: span 2;
  }
  
  &--featured-xl {
    grid-column: span 4;
    grid-row: span 3;
  }
  
  // Color variants
  &--primary {
    background: $semantic-color-primary;
    color: $semantic-color-on-primary;
    border-color: $semantic-color-primary;
  }
  
  &--secondary {
    background: $semantic-color-secondary;
    color: $semantic-color-on-secondary;
    border-color: $semantic-color-secondary;
  }
  
  &--elevated {
    background: $semantic-color-surface-elevated;
    box-shadow: $semantic-shadow-elevation-2;
  }
  
  // Interactive states
  &--interactive {
    cursor: pointer;
    
    &:hover {
      box-shadow: $semantic-shadow-elevation-3;
      transform: translateY(-2px);
    }
    
    &:focus-visible {
      outline: 2px solid $semantic-color-focus;
      outline-offset: 2px;
    }
    
    &:active {
      transform: translateY(-1px);
      box-shadow: $semantic-shadow-elevation-2;
    }
  }
  
  // Content styling
  &__header {
    margin-bottom: $semantic-spacing-content-paragraph;
    font-family: map-get($semantic-typography-heading-h5, font-family);
    font-size: map-get($semantic-typography-heading-h5, font-size);
    font-weight: map-get($semantic-typography-heading-h5, font-weight);
    line-height: map-get($semantic-typography-heading-h5, line-height);
    color: $semantic-color-text-primary;
  }
  
  &__content {
    font-family: map-get($semantic-typography-body-medium, font-family);
    font-size: map-get($semantic-typography-body-medium, font-size);
    font-weight: map-get($semantic-typography-body-medium, font-weight);
    line-height: map-get($semantic-typography-body-medium, line-height);
    color: $semantic-color-text-secondary;
  }
  
  // Responsive item behavior
  @media (max-width: 1024px) {
    &--featured-xl,
    &--featured-lg {
      grid-column: span 2;
      grid-row: span 2;
    }
    
    &--span-4 {
      grid-column: span 3;
    }
    
    &--span-3 {
      grid-column: span 2;
    }
  }
  
  @media (max-width: 768px) {
    padding: $semantic-spacing-component-sm;
    
    &--featured-xl,
    &--featured-lg,
    &--featured-md,
    &--featured-sm {
      grid-column: span 2;
      grid-row: span 1;
    }
    
    &--span-4,
    &--span-3,
    &--span-2 {
      grid-column: span 2;
    }
    
    &--row-span-4,
    &--row-span-3,
    &--row-span-2 {
      grid-row: span 2;
    }
  }
  
  @media (max-width: 480px) {
    padding: $semantic-spacing-component-xs;
    
    &--featured-xl,
    &--featured-lg,
    &--featured-md,
    &--featured-sm,
    &--span-4,
    &--span-3,
    &--span-2,
    &--span-full {
      grid-column: span 1;
    }
    
    &--row-span-4,
    &--row-span-3,
    &--row-span-2 {
      grid-row: span 1;
    }
  }
}