/**
 * Friends of Bulgaria - Layout System
 * Grid systems, containers, and responsive layout utilities.
 * Mobile-first: base styles are single-column, media queries add multi-column.
 * Requirements: 10.1, 10.2
 */

/* =========================================
   Containers
   Base: full-width with horizontal padding.
   Max-widths applied per breakpoint.
   ========================================= */

/**
 * The concept uses one fluid measure rather than stepped max-widths: the
 * content simply fills the viewport up to 1140px with a constant 28px gutter.
 */
.container {
  width: 100%;
  max-width: var(--fob-wrap-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--fob-wrap-pad);
  padding-right: var(--fob-wrap-pad);
}

.container-fluid {
  width: 100%;
  padding-left: var(--fob-wrap-pad);
  padding-right: var(--fob-wrap-pad);
}

.container-narrow {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--fob-wrap-pad);
  padding-right: var(--fob-wrap-pad);
  max-width: 768px;
}

@media (max-width: 575px) {
  .container,
  .container-fluid,
  .container-narrow {
    padding-left: var(--fob-space-md);
    padding-right: var(--fob-space-md);
  }
}

/* =========================================
   CSS Grid Layout System
   Mobile-first: single column by default.
   Multi-column layouts at 768px and above.
   ========================================= */

.grid {
  display: grid;
  gap: var(--fob-space-lg);
  grid-template-columns: 1fr;
}

/* Two-column grid at medium breakpoint */
@media (min-width: 768px) {
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Three-column grid at medium breakpoint */
@media (min-width: 768px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Four-column grid at large breakpoint */
@media (min-width: 768px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Auto-fit grid — responsive without explicit breakpoints */
.grid-auto {
  display: grid;
  gap: var(--fob-space-lg);
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}

/* Grid gap modifiers */
.grid-gap-sm {
  gap: var(--fob-space-sm);
}

.grid-gap-md {
  gap: var(--fob-space-md);
}

.grid-gap-lg {
  gap: var(--fob-space-lg);
}

.grid-gap-xl {
  gap: var(--fob-space-xl);
}

/* Grid alignment */
.grid-center {
  align-items: center;
  justify-items: center;
}

.grid-start {
  align-items: start;
}

.grid-stretch {
  align-items: stretch;
}

/* =========================================
   Flexbox Layout Utilities
   ========================================= */

.flex {
  display: flex;
}

.flex-inline {
  display: inline-flex;
}

/* Direction */
.flex-row {
  flex-direction: row;
}

.flex-col {
  flex-direction: column;
}

/* Wrapping */
.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;
}

/* Align items */
.items-start {
  align-items: flex-start;
}

.items-center {
  align-items: center;
}

.items-end {
  align-items: flex-end;
}

.items-stretch {
  align-items: stretch;
}

.items-baseline {
  align-items: baseline;
}

/* Align self */
.self-start {
  align-self: flex-start;
}

.self-center {
  align-self: center;
}

.self-end {
  align-self: flex-end;
}

/* Flex sizing */
.flex-1 {
  flex: 1 1 0%;
}

.flex-auto {
  flex: 1 1 auto;
}

.flex-none {
  flex: none;
}

.flex-grow {
  flex-grow: 1;
}

.flex-shrink-0 {
  flex-shrink: 0;
}

/* Flex gap */
.gap-xs {
  gap: var(--fob-space-xs);
}

.gap-sm {
  gap: var(--fob-space-sm);
}

.gap-md {
  gap: var(--fob-space-md);
}

.gap-lg {
  gap: var(--fob-space-lg);
}

.gap-xl {
  gap: var(--fob-space-xl);
}

/* =========================================
   Section Spacing
   Vertical rhythm for homepage and sub-page sections.
   ========================================= */

.section {
  padding-top: var(--fob-space-xl);
  padding-bottom: var(--fob-space-xl);
}

.section-lg {
  padding-top: var(--fob-space-xxl);
  padding-bottom: var(--fob-space-xxl);
}

.section-sm {
  padding-top: var(--fob-space-lg);
  padding-bottom: var(--fob-space-lg);
}

@media (min-width: 768px) {
  .section {
    padding-top: var(--fob-space-xxl);
    padding-bottom: var(--fob-space-xxl);
  }

  .section-lg {
    padding-top: 6rem;
    padding-bottom: 6rem;
  }

  .section-sm {
    padding-top: var(--fob-space-xl);
    padding-bottom: var(--fob-space-xl);
  }
}

/* Section header spacing (heading + optional subtext).
   Left-aligned: the concept ranges every section heading on the same left
   edge as its body copy. Spacing itself lives in sections.css. */
.section-header {
  text-align: left;
}

/* =========================================
   Full-Width Sections
   Break out of container for full-bleed backgrounds.
   ========================================= */

.full-width {
  width: 100vw;
  margin-left: calc(-50vw + 50%);
}

/* =========================================
   Responsive Stack Utility
   Forces flex/grid children into single column below 768px.
   ========================================= */

.stack-mobile {
  display: flex;
  flex-direction: column;
  gap: var(--fob-space-lg);
}

@media (min-width: 768px) {
  .stack-mobile {
    flex-direction: row;
  }
}

/* =========================================
   Sidebar Layouts
   Content + sidebar pattern (desktop only).
   ========================================= */

.layout-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--fob-space-xl);
}

@media (min-width: 992px) {
  .layout-sidebar {
    grid-template-columns: 1fr 300px;
  }

  .layout-sidebar-left {
    grid-template-columns: 300px 1fr;
  }
}

/* =========================================
   Equal-Height Columns
   Ensures cards/columns stretch to same height.
   ========================================= */

.equal-height {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--fob-space-lg);
}

.equal-height > * {
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .equal-height-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .equal-height-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 992px) {
  .equal-height-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}
