/* ========================================
   GRID & LAYOUT SYSTEM
   Flexible grid utilities
   ======================================== */

/* ======================================== 
   CONTAINER SYSTEM 
   ======================================== */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.container-wide {
  max-width: var(--container-wide);
}

.container-narrow {
  max-width: var(--container-narrow);
}

.container-fluid {
  max-width: 100%;
}

/* ======================================== 
   SECTION SPACING 
   ======================================== */
section {
  padding: var(--space-6xl) 0;
  position: relative;
}

section.spacing-small {
  padding: var(--space-4xl) 0;
}

section.spacing-large {
  padding: var(--space-7xl) 0;
}

section.spacing-xlarge {
  padding: var(--space-8xl) 0;
}

section.no-padding-top {
  padding-top: 0;
}

section.no-padding-bottom {
  padding-bottom: 0;
}

/* ======================================== 
   SECTION HEADERS 
   ======================================== */
.section-header {
  text-align: center;
  margin-bottom: var(--space-4xl);
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(var(--text-3xl), 4vw, var(--text-5xl));
  font-weight: var(--font-black);
  line-height: var(--leading-tight);
  color: var(--color-gray-900);
  margin-bottom: var(--space-lg);
}

.section-subtitle {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--color-gray-600);
}

/* ======================================== 
   GRID SYSTEMS 
   ======================================== */

/* Basic Grid */
.grid {
  display: grid;
  gap: var(--space-xl);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-5 {
  grid-template-columns: repeat(5, 1fr);
}

.grid-6 {
  grid-template-columns: repeat(6, 1fr);
}

/* Auto-fit Grid */
.grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-auto-lg {
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

/* Gap Variations */
.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

.gap-xl {
  gap: var(--space-xl);
}

.gap-2xl {
  gap: var(--space-2xl);
}

/* ======================================== 
   FLEXBOX UTILITIES 
   ======================================== */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-start {
  align-items: flex-start;
}

.items-center {
  align-items: center;
}

.items-end {
  align-items: flex-end;
}

.justify-start {
  justify-content: flex-start;
}

.justify-center {
  justify-content: center;
}

.justify-end {
  justify-content: flex-end;
}

.justify-between {
  justify-content: space-between;
}

.justify-around {
  justify-content: space-around;
}

/* ======================================== 
   COLUMNS LAYOUT 
   ======================================== */
.columns {
  display: flex;
  gap: var(--space-xl);
}

.columns > * {
  flex: 1;
}

.col-1 { flex: 0 0 8.333%; }
.col-2 { flex: 0 0 16.666%; }
.col-3 { flex: 0 0 25%; }
.col-4 { flex: 0 0 33.333%; }
.col-5 { flex: 0 0 41.666%; }
.col-6 { flex: 0 0 50%; }
.col-7 { flex: 0 0 58.333%; }
.col-8 { flex: 0 0 66.666%; }
.col-9 { flex: 0 0 75%; }
.col-10 { flex: 0 0 83.333%; }
.col-11 { flex: 0 0 91.666%; }
.col-12 { flex: 0 0 100%; }

/* ======================================== 
   MASONRY GRID 
   ======================================== */
.masonry {
  column-count: 3;
  column-gap: var(--space-xl);
}

.masonry > * {
  break-inside: avoid;
  margin-bottom: var(--space-xl);
}

.masonry-2 {
  column-count: 2;
}

.masonry-4 {
  column-count: 4;
}

/* ======================================== 
   RESPONSIVE BREAKPOINTS 
   ======================================== */
@media (max-width: 1280px) {
  .grid-4 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .grid-5,
  .grid-6 {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 1024px) {
  section {
    padding: var(--space-5xl) 0;
  }
  
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-5,
  .grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .columns {
    flex-wrap: wrap;
  }
  
  .masonry,
  .masonry-4 {
    column-count: 2;
  }
}

@media (max-width: 768px) {
  section {
    padding: var(--space-4xl) 0;
  }
  
  .section-header {
    margin-bottom: var(--space-3xl);
  }
  
  .grid-2,
  .grid-3,
  .grid-4,
  .grid-5,
  .grid-6 {
    grid-template-columns: 1fr;
  }
  
  .columns {
    flex-direction: column;
  }
  
  .masonry,
  .masonry-2,
  .masonry-4 {
    column-count: 1;
  }
  
  /* Mobile column overrides */
  .col-mobile-12 {
    flex: 0 0 100%;
  }
}

@media (max-width: 640px) {
  section {
    padding: var(--space-3xl) 0;
  }
  
  .container {
    padding: 0 var(--space-md);
  }
  
  .grid {
    gap: var(--space-lg);
  }
}

/* ======================================== 
   UTILITY CLASSES 
   ======================================== */
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

.relative {
  position: relative;
}

.absolute {
  position: absolute;
}

.fixed {
  position: fixed;
}

.sticky {
  position: sticky;
}

.z-10 {
  z-index: var(--z-10);
}

.z-20 {
  z-index: var(--z-20);
}

.z-30 {
  z-index: var(--z-30);
}

.overflow-hidden {
  overflow: hidden;
}

.overflow-auto {
  overflow: auto;
}

/* ======================================== 
   VISIBILITY UTILITIES 
   ======================================== */
.hidden {
  display: none;
}

.block {
  display: block;
}

.inline-block {
  display: inline-block;
}

.inline {
  display: inline;
}

@media (max-width: 768px) {
  .hidden-mobile {
    display: none;
  }
  
  .visible-mobile {
    display: block;
  }
}

@media (min-width: 769px) {
  .hidden-desktop {
    display: none;
  }
  
  .visible-desktop {
    display: block;
  }
}
