/* Strategic Labs — V002-M2 grid composition.
   Loaded LAST so it wins over the per-template grid declarations it corrects. */

/* ==========================================================================
   Composed card grids — no stranded tail card.

   `repeat(auto-fit, minmax(...))` picks its own column count, so whenever a
   CMS-driven item count leaves a remainder of one, the final card sits alone
   beside an empty gap (the "unexplained asymmetric gap" the brief prohibits).
   These grids therefore use an explicit column schedule per breakpoint, with
   the tail item spanning the remaining columns. Because the column count is
   known at each tier, the nth-child rules are exact rather than guesswork.
   ========================================================================== */
.m2-corp-spine, .m2-nine-services, .m2-reward-flow, .m2-corp-outcomes,
.m2-startup-stages, .m2-stage-line, .home-gateway__grid, .home-why__traits,
.pm-cap-preview {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.m2-corp-spine > *:last-child:nth-child(4n+1), .m2-nine-services > *:last-child:nth-child(4n+1),
.m2-reward-flow > *:last-child:nth-child(4n+1), .m2-corp-outcomes > *:last-child:nth-child(4n+1),
.m2-startup-stages > *:last-child:nth-child(4n+1), .m2-stage-line > *:last-child:nth-child(4n+1),
.home-gateway__grid > *:last-child:nth-child(4n+1), .home-why__traits > *:last-child:nth-child(4n+1),
.pm-cap-preview > *:last-child:nth-child(4n+1) { grid-column: 1 / -1; }
.m2-corp-spine > *:last-child:nth-child(4n+2), .m2-nine-services > *:last-child:nth-child(4n+2),
.m2-reward-flow > *:last-child:nth-child(4n+2), .m2-corp-outcomes > *:last-child:nth-child(4n+2),
.m2-startup-stages > *:last-child:nth-child(4n+2), .m2-stage-line > *:last-child:nth-child(4n+2),
.home-gateway__grid > *:last-child:nth-child(4n+2), .home-why__traits > *:last-child:nth-child(4n+2),
.pm-cap-preview > *:last-child:nth-child(4n+2) { grid-column: span 3; }
.m2-corp-spine > *:last-child:nth-child(4n+3), .m2-nine-services > *:last-child:nth-child(4n+3),
.m2-reward-flow > *:last-child:nth-child(4n+3), .m2-corp-outcomes > *:last-child:nth-child(4n+3),
.m2-startup-stages > *:last-child:nth-child(4n+3), .m2-stage-line > *:last-child:nth-child(4n+3),
.home-gateway__grid > *:last-child:nth-child(4n+3), .home-why__traits > *:last-child:nth-child(4n+3),
.pm-cap-preview > *:last-child:nth-child(4n+3) { grid-column: span 2; }

@media (max-width: 1199px) {
  .m2-corp-spine, .m2-nine-services, .m2-reward-flow, .m2-corp-outcomes,
  .m2-startup-stages, .m2-stage-line, .home-gateway__grid, .home-why__traits,
  .pm-cap-preview { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .m2-corp-spine > *:last-child, .m2-nine-services > *:last-child, .m2-reward-flow > *:last-child,
  .m2-corp-outcomes > *:last-child, .m2-startup-stages > *:last-child, .m2-stage-line > *:last-child,
  .home-gateway__grid > *:last-child, .home-why__traits > *:last-child, .pm-cap-preview > *:last-child { grid-column: auto; }
  .m2-corp-spine > *:last-child:nth-child(3n+1), .m2-nine-services > *:last-child:nth-child(3n+1),
  .m2-reward-flow > *:last-child:nth-child(3n+1), .m2-corp-outcomes > *:last-child:nth-child(3n+1),
  .m2-startup-stages > *:last-child:nth-child(3n+1), .m2-stage-line > *:last-child:nth-child(3n+1),
  .home-gateway__grid > *:last-child:nth-child(3n+1), .home-why__traits > *:last-child:nth-child(3n+1),
  .pm-cap-preview > *:last-child:nth-child(3n+1) { grid-column: 1 / -1; }
  .m2-corp-spine > *:last-child:nth-child(3n+2), .m2-nine-services > *:last-child:nth-child(3n+2),
  .m2-reward-flow > *:last-child:nth-child(3n+2), .m2-corp-outcomes > *:last-child:nth-child(3n+2),
  .m2-startup-stages > *:last-child:nth-child(3n+2), .m2-stage-line > *:last-child:nth-child(3n+2),
  .home-gateway__grid > *:last-child:nth-child(3n+2), .home-why__traits > *:last-child:nth-child(3n+2),
  .pm-cap-preview > *:last-child:nth-child(3n+2) { grid-column: span 2; }
}
@media (max-width: 833px) {
  .m2-corp-spine, .m2-nine-services, .m2-reward-flow, .m2-corp-outcomes,
  .m2-startup-stages, .m2-stage-line, .home-gateway__grid, .home-why__traits,
  .pm-cap-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .m2-corp-spine > *:last-child, .m2-nine-services > *:last-child, .m2-reward-flow > *:last-child,
  .m2-corp-outcomes > *:last-child, .m2-startup-stages > *:last-child, .m2-stage-line > *:last-child,
  .home-gateway__grid > *:last-child, .home-why__traits > *:last-child, .pm-cap-preview > *:last-child { grid-column: auto; }
  .m2-corp-spine > *:last-child:nth-child(odd), .m2-nine-services > *:last-child:nth-child(odd),
  .m2-reward-flow > *:last-child:nth-child(odd), .m2-corp-outcomes > *:last-child:nth-child(odd),
  .m2-startup-stages > *:last-child:nth-child(odd), .m2-stage-line > *:last-child:nth-child(odd),
  .home-gateway__grid > *:last-child:nth-child(odd), .home-why__traits > *:last-child:nth-child(odd),
  .pm-cap-preview > *:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 599px) {
  /* minmax(0,1fr) — a bare `1fr` is minmax(auto,1fr), which lets a long
     unbreakable Arabic string push the track past the viewport */
  .m2-corp-spine, .m2-nine-services, .m2-reward-flow, .m2-corp-outcomes,
  .m2-startup-stages, .m2-stage-line { grid-template-columns: minmax(0, 1fr); }
  .m2-corp-spine > *, .m2-nine-services > *, .m2-reward-flow > *,
  .m2-corp-outcomes > *, .m2-startup-stages > *, .m2-stage-line > * { min-inline-size: 0; overflow-wrap: anywhere; }
  .m2-corp-spine > *:last-child, .m2-nine-services > *:last-child, .m2-reward-flow > *:last-child,
  .m2-corp-outcomes > *:last-child, .m2-startup-stages > *:last-child, .m2-stage-line > *:last-child { grid-column: auto; }
}
