/**
 * FKLM Africa Foundation — Layout System
 * Elementor-compatible container/section structure
 */

/* ============================================================
   ELEMENTOR-COMPATIBLE CONTAINER SYSTEM
   ============================================================ */

/* Mirrors Elementor section > container > row > column */
.elementor-section {
  position: relative;
  width: 100%;
}

.elementor-section.elementor-section-full_width {
  max-width: 100%;
}

.elementor-container {
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-px);
  padding-right: var(--container-px);
  width: 100%;
}

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

.elementor-row {
  display: flex;
  flex-wrap: wrap;
  margin-left: calc(var(--space-6) * -0.5);
  margin-right: calc(var(--space-6) * -0.5);
}

.elementor-column {
  padding-left: calc(var(--space-6) * 0.5);
  padding-right: calc(var(--space-6) * 0.5);
  flex: 1;
  min-width: 0;
}

/* Column widths — matching Elementor % system */
.elementor-col-100 { flex: 0 0 100%; max-width: 100%; }
.elementor-col-50  { flex: 0 0 50%;  max-width: 50%; }
.elementor-col-33  { flex: 0 0 33.333%; max-width: 33.333%; }
.elementor-col-67  { flex: 0 0 66.666%; max-width: 66.666%; }
.elementor-col-25  { flex: 0 0 25%; max-width: 25%; }
.elementor-col-75  { flex: 0 0 75%; max-width: 75%; }
.elementor-col-40  { flex: 0 0 40%; max-width: 40%; }
.elementor-col-60  { flex: 0 0 60%; max-width: 60%; }

/* ============================================================
   SECTION SPACING
   ============================================================ */

.section-pad {
  padding-top: var(--section-padding-y);
  padding-bottom: var(--section-padding-y);
}

.section-pad-sm {
  padding-top: clamp(2rem, 4vw, 4rem);
  padding-bottom: clamp(2rem, 4vw, 4rem);
}

.section-pad-lg {
  padding-top: clamp(6rem, 10vw, 10rem);
  padding-bottom: clamp(6rem, 10vw, 10rem);
}

/* ============================================================
   GRID SYSTEM
   ============================================================ */

.grid {
  display: grid;
  gap: var(--space-6);
}

.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-auto-fit-sm {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

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

.grid-auto-fill-sm {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.resources-featured-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
}

/* ============================================================
   RESPONSIVE OVERRIDES
   ============================================================ */

@media (max-width: 1024px) {
  .elementor-col-33,
  .elementor-col-25 {
    flex: 0 0 50%;
    max-width: 50%;
  }

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

@media (max-width: 768px) {
  .elementor-col-50,
  .elementor-col-33,
  .elementor-col-25,
  .elementor-col-40,
  .elementor-col-60,
  .elementor-col-67,
  .elementor-col-75 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .elementor-row {
    margin-left: 0;
    margin-right: 0;
  }

  .elementor-column {
    padding-left: 0;
    padding-right: 0;
  }

  .hide-mobile { display: none !important; }

  .resources-featured-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

/* ============================================================
   ASPECT RATIOS
   ============================================================ */

.aspect-video    { aspect-ratio: 16/9; }
.aspect-square   { aspect-ratio: 1/1; }
.aspect-portrait { aspect-ratio: 3/4; }
.aspect-hero     { aspect-ratio: 16/7; }

/* ============================================================
   OBJECT FIT HELPERS
   ============================================================ */

.img-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.img-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================
   DIVIDERS
   ============================================================ */

.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-8) 0;
}

.divider-brand {
  border-top: 2px solid var(--color-primary);
  width: 3rem;
  margin: var(--space-4) 0;
}

/* ============================================================
   STICKY HEADER OFFSET
   ============================================================ */

:root { --nav-height: 80px; }

.page-content {
  padding-top: var(--nav-height);
}

/* Fixed header pages with a hero should start flush at the viewport top.
   Use a general sibling match because an inline script sits between the nav and main. */
body > .site-header + .site-nav ~ main > .section-hero:first-child {
  margin-top: calc(-1 * var(--nav-height));
}

/* ============================================================
   BREADCRUMB LAYOUT
   ============================================================ */

.breadcrumb-bar {
  background-color: var(--color-neutral-50);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) 0;
}

.breadcrumb-bar .elementor-container {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ============================================================
   TWO-COLUMN SPLIT LAYOUT
   ============================================================ */

.split-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
}

.split-layout--60-40 {
  grid-template-columns: 3fr 2fr;
}

.split-layout--40-60 {
  grid-template-columns: 2fr 3fr;
}

.split-layout--top {
  align-items: start;
}

@media (min-width: 769px) {
  .split-layout__sticky {
    position: sticky;
    top: calc(var(--nav-height) + var(--space-6));
    align-self: start;
  }
}

@media (max-width: 768px) {
  .split-layout,
  .split-layout--60-40,
  .split-layout--40-60 {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }

  .split-layout--reverse-mobile > *:first-child {
    order: 2;
  }
}
