/* ===============================
   Magazine Grid (1 | 2 | 2 | 4)
   =============================== */

.bbw-posts.mag-grid {
  --gap: 80px;
}

.mg-title a {
  font-size: 24px !important;
  color: #000;
  font-weight: 500;
}

.mg-title a:hover {
  color: #000;
}

.mg-title {
  margin-top: 10px;
}

.bbw-posts.mag-grid .mg4-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  /* LHS a touch wider like mock */
  gap: var(--gap);
}

/* Columns */
.bbw-posts.mag-grid .mg4-col {
  display: grid;
  gap: var(--gap);
}

/* Column density:
   feature (one card),
   2 small stacked,
   2 small stacked,
   4 list stacked */
.bbw-posts.mag-grid .col-2,
.bbw-posts.mag-grid .col-3 {
  grid-auto-rows: min-content;
}

.bbw-posts.mag-grid .col-4 {
  grid-auto-rows: min-content;
  gap: 18px;
}

/* Images */
.bbw-posts.mag-grid .mg-thumb {
  display: block;
  margin: 0 0 10px;
}

.bbw-posts.mag-grid .mg-thumb img {
  width: 100%;
  height: auto;
  display: block;
}

.bbw-posts.mag-grid .mg-thumb.feature img {
  aspect-ratio: 3/2;
}

/* Badge */
.bbw-posts.mag-grid .bbw-pill {
  display: inline-block;
  padding: 8px 14px;
  font-size: 20px;
  line-height: 1;
  color: #fff;
  background: #C65FA9;
  /* default; customize via nth-child or global tokens */
  height: max-content;
  margin-top: 20px;
}

.mg4-list .bbw-pill {
  margin-top: 0 !important;
}

article.mg4-small {
  min-height: 320px;
}

/* Titles */
.bbw-posts.mag-grid .mg-title {
  margin: 15px 0 8px;
  font-size: clamp(18px, 1.9vw, 22px);
  line-height: 1.25;
}

.bbw-posts.mag-grid .mg-title.feature {
  font-size: clamp(22px, 2.3vw, 28px);
}

/* Excerpt + readmore on feature only */
.bbw-posts.mag-grid .mg-excerpt {
  font-size: 18px;
  line-height: 1.6;
  color: #444;
  margin-top: 29px
}

.mg-readmore {
  display: inline-block;
  margin-top: 30px;
  font-size: 16px !important;
  color: #2F2F2F;
  font-weight: 600;
  font-size: 16px;
  transition: .2s;
  text-decoration: underline !important;
}

/* List (no image) look */
.bbw-posts.mag-grid .mg4-list .mg-title {
  font-size: clamp(16px, 1.6vw, 20px);
  margin: 15px 0 0;
}

/* Responsive */
@media (max-width: 1100px) {
  .bbw-posts.mag-grid .mg4-wrap {
    grid-template-columns: 1fr 1fr;
  }

  .bbw-posts.mag-grid .col-3 {
    order: 3;
  }

  .bbw-posts.mag-grid .col-4 {
    order: 4;
  }
}

/* =========================
   TABLET: 3-column layout
   ========================= */
@media (max-width: 991px) {

  .mg-title a {
    font-size: 18px !important;
  }

  .bbw-posts.mag-grid {
    --gap: 40px; /* tighter like figma */
  }

  .bbw-posts.mag-grid .mg4-wrap {
    display: grid;
    grid-template-columns: repeat(3, 1fr);  /* 3 equal columns */
    column-gap: var(--gap);
    grid-auto-flow: row dense;
  }

  /* flatten inner column wrappers so children can be placed on parent grid */
  .bbw-posts.mag-grid .mg4-col { 
        display: grid;
          grid-auto-rows: min-content;
  }

  /* --- Row 1 --- */
  .bbw-posts.mag-grid .mg4-feature {           /* big card */
          grid-column: 1;
        grid-row: 1;
  }
  .bbw-posts.mag-grid .col-2 .mg4-small:nth-of-type(1) {
        grid-column: 1;
        grid-row: 2;           /* first small to the right */
  }

  /* --- Row 2 (two smalls) --- */
  .bbw-posts.mag-grid .col-2 .mg4-small:nth-of-type(2) {
        grid-column: 1;
        grid-row: 1;
  }
  .bbw-posts.mag-grid .col-3 .mg4-small:nth-of-type(1) {
        grid-column: 1;
        grid-row: 2;
  }
  /* Hide the extra small on tablet so last line is titles only */
  .bbw-posts.mag-grid .col-3 .mg4-small:nth-of-type(2) { 
        grid-column: 1;
        grid-row: 1;
   }

   .bbw-posts.mag-grid .col-4 {
    grid-column: 1 / -1;
   }

   .bbw-posts.mag-grid .mg-excerpt {
    font-size: 14px;
   }

  /* --- Row 3 (titles only, three across) --- */
  .bbw-posts.mag-grid .col-4 .mg4-list:nth-of-type(1) { grid-column: 1; grid-row: 3; }
  .bbw-posts.mag-grid .col-4 .mg4-list:nth-of-type(2) { grid-column: 2; grid-row: 3; }
  .bbw-posts.mag-grid .col-4 .mg4-list:nth-of-type(3) { grid-column: 3; grid-row: 3; }
  .bbw-posts.mag-grid .col-4 .mg4-list:nth-of-type(4) { display: none; } /* hide 4th title on tablet */

  /* Visual tweaks to match figma proportions on tablet */
  .bbw-posts.mag-grid article.mg4-small { min-height: 0; }            /* remove desktop min-height gaps */
  .bbw-posts.mag-grid .mg-thumb.feature img { aspect-ratio: 3 / 2; }  /* keep feature proportion */
  .bbw-posts.mag-grid .mg-title.feature { font-size: clamp(20px, 2.2vw, 26px); }
  .bbw-posts.mag-grid .mg-title { font-size: clamp(16px, 1.7vw, 20px); }
  .bbw-posts.mag-grid .mg-excerpt { font-size: 16px; line-height: 1.55; margin-top: 16px; }
  .bbw-posts.mag-grid .mg4-list .mg-title { font-size: clamp(15px, 1.5vw, 18px); }

  .bbw-posts.mag-grid .bbw-pill {
    font-size: 14px;
    padding: 5px 14px;
        margin-top: 5px;
  }

  .bbw-posts.mag-grid .mg-title {
        margin: 10px 0 0px;
  }

  .mg-readmore {
    margin-top: 15px;
  }
}

/* =========================
   MOBILE: single column
   ========================= */
@media (max-width: 767px) {

  .mg-title a {
    font-size: 14px !important;
  }
  .bbw-posts.mag-grid { --gap: 24px; }

  .bbw-posts.mag-grid .mg4-wrap {
    grid-template-columns: repeat(2, 1fr);
    column-gap: 20;
    row-gap: var(--gap);
  }

   .bbw-posts.mag-grid .col-4 {
    grid-column: auto;
   }

  .bbw-posts.mag-grid .col-2 .mg4-small:nth-of-type(2) {
       grid-column: 1;
      grid-row: 1;
  }

  /* restore normal stacking inside columns */
  .bbw-posts.mag-grid .mg4-col { display: grid; gap: var(--gap); }

  /* show everything on mobile (including the 4th list item and the hidden small) */
  .bbw-posts.mag-grid .col-3 .mg4-small:nth-of-type(2),
  .bbw-posts.mag-grid .col-4 .mg4-list:nth-of-type(4) { display: initial; }

  /* mobile type/spacing */
  .bbw-posts.mag-grid .mg-title.feature { font-size: 20px; }
  .bbw-posts.mag-grid .mg-title { font-size: 18px; }
  .bbw-posts.mag-grid .mg-excerpt { font-size: 15px; line-height: 1.6; margin-top: 12px; }
  .bbw-posts.mag-grid .mg4-list .mg-title { font-size: 16px; }

      .bbw-posts.mag-grid .col-4 .mg4-list:nth-of-type(1) {
        grid-column: 1;
        grid-row: 1;
    }

        .bbw-posts.mag-grid .col-4 .mg4-list:nth-of-type(2) {
        grid-column: 1;
        grid-row: 2;
    }

        .bbw-posts.mag-grid .col-4 .mg4-list:nth-of-type(3) {
        grid-column: 1;
        grid-row: 3;
    }


}
