/**
 * Layout Styles - Container, Grid, and Flexbox Systems
 * C Color Homepage
 */

/* ========================================
   CONTAINER SYSTEM
   ======================================== */

.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

/* Mobile: Full width with padding */
@media (max-width: 767px) { /* mobile breakpoint */
  .container {
    max-width: var(--container-mobile);
    padding-left: var(--space-lg);
    padding-right: var(--space-lg);
    overflow-x: hidden;
  }
}

/* Tablet: Contained width */
@media (min-width: 768px) and (max-width: 1199px) { /* tablet breakpoint */
  .container {
    max-width: var(--container-tablet);
    padding-left: var(--space-2xl);
    padding-right: var(--space-2xl);
  }
}

/* Desktop: Maximum width */
@media (min-width: 1200px) { /* large breakpoint */
  .container {
    max-width: var(--container-max);
    padding-left: var(--space-3xl);
    padding-right: var(--space-3xl);
  }
}

/* Full width container (no max-width) */
.container-fluid {
  width: 100%;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

/* Remove bottom spacing from last paragraph in containers */
.container > p:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Consistent vertical spacing for all sections with containers */
section > .container {
  padding-top: 50px;
  padding-bottom: 50px;
}

/* ========================================
   SECTION LAYOUT
   ======================================== */

section {
  width: 100%;
  position: relative;
}

/* Section padding - mobile first */
.section-padding {
  padding-top: var(--section-padding-mobile);
  padding-bottom: var(--section-padding-mobile);
}

@media (min-width: 768px) {
  .section-padding {
    padding-top: var(--section-padding-tablet);
    padding-bottom: var(--section-padding-tablet);
  }
}

@media (min-width: 1920px) {
  .section-padding {
    padding-top: var(--section-padding-desktop);
    padding-bottom: var(--section-padding-desktop);
  }
}

/* ========================================
   FLEXBOX UTILITIES
   ======================================== */

.flex {
  display: flex;
}

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

.flex-row {
  flex-direction: row;
}

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

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

/* Justify content */
.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;
}

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

/* Align items */
.items-start {
  align-items: flex-start;
}

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

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

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

/* Gap utilities */
.gap-sm {
  gap: var(--grid-gap-sm);
}

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

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

/* ========================================
   GRID UTILITIES
   ======================================== */

.grid {
  display: grid;
}

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

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

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

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

/* Mobile: Single column by default */
@media (max-width: 767px) { /* mobile breakpoint */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }

  /* Override for specific mobile grid */
  .grid-cols-2-mobile {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tablet: Responsive grids */
@media (min-width: 768px) and (max-width: 1199px) { /* tablet breakpoint */
  .grid-cols-3-tablet {
    grid-template-columns: repeat(3, 1fr);
  }

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

/* Desktop: Full grids */
@media (min-width: 1920px) {
  .grid-cols-4-desktop {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ========================================
   TWO-COLUMN LAYOUT (Image + Text)
   ======================================== */

.two-col-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--grid-gap-md);
  align-items: center;
}

@media (min-width: 768px) {
  .two-col-layout {
    grid-template-columns: 1fr 1fr;
    gap: var(--grid-gap-lg);
  }

  .two-col-layout.reverse {
    direction: rtl;
  }

  .two-col-layout.reverse > * {
    direction: ltr;
  }
}

@media (min-width: 1920px) {
  .two-col-layout {
    gap: var(--space-4xl);
  }
}

/* ========================================
   CENTERED CONTENT LAYOUT
   ======================================== */

.centered-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 1920px) {
  .centered-content {
    max-width: 1000px;
  }
}

/* ========================================
   HERO LAYOUT
   ======================================== */

.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

@media (max-width: 767px) { /* mobile breakpoint */
  .hero {
    min-height: 90vh;
    padding-top: var(--space-3xl);
    padding-bottom: var(--space-3xl);
  }
}

/* ========================================
   SPLIT LAYOUT (50/50)
   ======================================== */

.split-layout {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 600px;
}

@media (min-width: 768px) { /* tablet breakpoint - min */
  .split-layout {
    grid-template-columns: 1fr 1fr;
  }
}

.split-layout__left,
.split-layout__right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
}

@media (min-width: 1200px) { /* large breakpoint */
  .split-layout__left,
  .split-layout__right {
    padding: var(--space-4xl);
  }
}

/* ========================================
   CARD GRID LAYOUT
   ======================================== */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--grid-gap-md);
}

/* Mobile: Single column or 2 columns for smaller cards */
@media (max-width: 767px) { /* mobile breakpoint */
  .card-grid--small {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--grid-gap-sm);
  }
}

/* Tablet: 2 columns */
@media (min-width: 768px) and (max-width: 1199px) { /* tablet breakpoint */
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--grid-gap-lg);
  }

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

/* Desktop: 4 columns or as specified */
@media (min-width: 1200px) { /* large breakpoint */
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--grid-gap-lg);
  }

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

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

/* ========================================
   FEATURE GRID LAYOUT
   ======================================== */

.feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2xl);
  max-width: 1200px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3xl);
  }
}

@media (min-width: 1920px) {
  .feature-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========================================
   ASPECT RATIO CONTAINERS
   ======================================== */

.aspect-ratio {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.aspect-ratio::before {
  content: '';
  display: block;
  padding-bottom: 100%; /* Default 1:1 */
}

.aspect-ratio--16-9::before {
  padding-bottom: 56.25%; /* 16:9 */
}

.aspect-ratio--4-3::before {
  padding-bottom: 75%; /* 4:3 */
}

.aspect-ratio--21-9::before {
  padding-bottom: 42.86%; /* 21:9 */
}

.aspect-ratio__content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ========================================
   STACK LAYOUT (Vertical spacing)
   ======================================== */

.stack > * + * {
  margin-top: var(--space-md);
}

.stack--sm > * + * {
  margin-top: var(--space-sm);
}

.stack--lg > * + * {
  margin-top: var(--space-lg);
}

.stack--xl > * + * {
  margin-top: var(--space-xl);
}

/* ========================================
   WRAPPER (Max width content)
   ======================================== */

.wrapper {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

.wrapper--narrow {
  max-width: 800px;
}

.wrapper--wide {
  max-width: 1600px;
}
