/* Sale-page mobile fix 2026-11-25.
   2-col grids on phones (including .bf-grid.g4), equal card heights,
   shared image frames, Buy buttons pinned to the row baseline,
   featured course cover fills the card (no empty column beside it).
   Do not use height/min-height:100% on cards — iOS Safari resolves
   that against the whole grid and stretches every card to section height.
*/
@media (max-width: 860px) {
  html body .bf-grid,
  html body .bf-grid.sm,
  html body .bf-grid.g4 {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px;
    align-items: stretch !important;
  }
  html body .bf-course-card {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 16px !important;
  }
  html body .bf-course-card .cover {
    width: 100% !important;
    max-width: 280px !important;
    margin: 0 auto !important;
    display: block;
  }
  html body .bf-course-card .cover img {
    width: 100%;
    height: auto;
    display: block;
  }
  html body .bf-course-card .copy { width: 100%; min-width: 0; }
  html body .bf-course-card .bf-more {
    margin-left: 0 !important;
    margin-top: 10px;
  }
}
@media (max-width: 640px) {
  html body .bf-grid,
  html body .bf-grid.sm,
  html body .bf-grid.g4 { gap: 10px; }
  html body .bf-card h3 { overflow-wrap: anywhere; }
}

/* Cells: drop subgrid/span-2 so a 2-col grid packs 2-across, not a squeezed row. */
html body .bf-cell {
  display: flex !important;
  flex-direction: column;
  min-width: 0;
  height: auto !important;
  min-height: 0 !important;
  grid-row: auto !important;
  grid-column: auto !important;
  grid-template-rows: none !important;
}
html body .bf-grid,
html body .bf-grid.sm,
html body .bf-grid.g4 {
  align-items: stretch !important;
}
html body .bf-cell > .bf-card,
html body .bf-card {
  display: flex !important;
  flex-direction: column !important;
  height: auto !important;
  min-height: 0 !important;
  flex: 1 1 auto;
}

/* Same aspect-ratio image frame on every sale card; contain, never crop. */
html body .bf-card > a.im,
html body .bf-card a.im {
  position: relative;
  display: flex !important;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  width: 100%;
  margin: 0 0 8px;
  background: #f4f7fa;
  overflow: hidden;
  border-radius: 10px;
  box-sizing: border-box;
  flex: 0 0 auto !important;
}
html body .bf-card a.im > img,
html body .bf-card a.im img.bf-im,
html body .bf-card img.bf-im {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: center;
  aspect-ratio: auto !important;
  margin: 0 auto !important;
}
html body .bf-card a.im:has(.bf-stack) {
  aspect-ratio: 1 / 1 !important;
  display: block !important;
  background: #eefbfe;
  overflow: hidden;
}
html body .bf-card a.im .bf-stack {
  position: absolute;
  inset: 0;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  margin: 0 !important;
}

/* Price sits after the description; leftover height gathers above it so
   Buy / View line up across the row. */
html body .bf-card .bf-price { margin-top: auto !important; }
html body .bf-card .us-buy-actions {
  margin-top: 8px !important;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
html body .bf-card .us-buy-btn,
html body .bf-card .us-buy-view {
  width: 100%;
  box-sizing: border-box;
  justify-content: center;
  text-align: center;
}

/* Bundle cards have sample links under the buttons. Reserve even space
   so a longer "Read free samples" line does not pull Buy/View up. */
html body .bf-card .us-buy-fine {
  min-height: 2.6em;
}
html body .bf-card .bf-read {
  min-height: 4.8em;
}

/* Bundle cards only: explicit rows so title/sample-link wrapping cannot
   shift Buy/View off the shared baseline. */
html body .bf-card:has(> .bf-read) {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto auto minmax(3.4em, auto) minmax(6em, auto);
}
html body .bf-card:has(> .bf-read) > a.im { grid-row: 1; }
html body .bf-card:has(> .bf-read) > h3 { grid-row: 2; }
html body .bf-card:has(> .bf-read) > p:not(.bf-price):not(.us-buy-fine):not(.bf-read) { grid-row: 3; }
html body .bf-card:has(> .bf-read) > .bf-price { grid-row: 4; margin-top: 8px !important; }
html body .bf-card:has(> .bf-read) > .us-buy-actions { grid-row: 5; }
html body .bf-card:has(> .bf-read) > .us-buy-fine { grid-row: 6; min-height: 3.4em; }
html body .bf-card:has(> .bf-read) > .bf-read { grid-row: 7; min-height: 6em; }
