/* Stroykalk v869: tablet + dynamically growing component containment.
   Dedicated last-in-cascade layer. Does not modify calculation state or DOM. */

/* A mode toggle must never squeeze a heading or extend past its card at
   intermediate tablet widths. Narrow-phone layouts are handled by v865. */
@media (min-width:768px) and (max-width:1120px) {
  :is(.wp-head,.chim-head,.ply-head,.sand-head,.osb-head,.adh-head,
      .siding-head,.timber-shell-head,.foundationmaster-head,.roofmaster-head,
      .loadmaster-head,.formwork-head,.snowload-head,.guttermaster-head,
      .irr-head,.room-work-head-v272,.beam-work-head-v237) {
    flex-direction:column!important;
    align-items:stretch!important;
    justify-content:flex-start!important;
    gap:12px!important;
    min-width:0!important;
    max-width:100%!important;
  }
  :is(.wp-mode,.chim-mode,.ply-mode,.sand-mode,.osb-mode,.adh-mode,
      .siding-mode,.foundationmaster-mode,.roofmaster-mode,.loadmaster-mode,
      .formwork-mode,.snowload-mode,.guttermaster-mode) {
    display:flex!important;
    flex:0 1 auto!important;
    align-self:flex-start!important;
    width:max-content!important;
    min-width:0!important;
    max-width:100%!important;
    box-sizing:border-box!important;
  }
  :is(.wp-mode,.chim-mode,.ply-mode,.sand-mode,.osb-mode,.adh-mode,
      .siding-mode,.foundationmaster-mode,.roofmaster-mode,.loadmaster-mode,
      .formwork-mode,.snowload-mode,.guttermaster-mode) > button {
    flex:1 1 auto!important;
    min-width:0!important;
    max-width:100%!important;
    white-space:normal!important;
  }
}

/* Shared portal tabs use grid auto-flow on desktop. That can create six
   20-30px columns in the engine calculator between 801 and 1200px. */
@media(max-width:1200px) {
  body.engine-power-page .engine-mode-grid {
    display:grid!important;
    grid-auto-flow:row!important;
    grid-auto-columns:auto!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    min-width:0!important;
    width:100%!important;
    gap:10px!important;
  }
  body.engine-power-page .engine-mode-grid > .engine-mode-card {
    min-width:0!important;
    max-width:100%!important;
    width:100%!important;
    box-sizing:border-box!important;
    white-space:normal!important;
    overflow-wrap:break-word!important;
    word-break:normal!important;
  }
}
@media(max-width:680px) {
  body.engine-power-page .engine-mode-grid {grid-template-columns:minmax(0,1fr)!important;}
}

/* Result headers grow with the text, not outside the results card. */
@media(max-width:1120px) {
  :is(.paving-calc,.lumber-calc,.putty-calc,.plaster-calc,.screed-calc)
  .result-head {
    display:flex;
    flex-wrap:wrap!important;
    align-items:flex-start!important;
    min-width:0!important;
    max-width:100%!important;
  }
  :is(.paving-calc,.lumber-calc,.putty-calc,.plaster-calc,.screed-calc)
  .result-head > * {
    flex:0 1 auto!important;
    min-width:0!important;
    max-width:100%!important;
  }
  :is(.paving-calc,.lumber-calc,.putty-calc,.plaster-calc,.screed-calc)
  .result-head p {
    white-space:normal!important;
    overflow-wrap:break-word!important;
  }
  /* Expanding rows, tabs and editorial tables must not enlarge a grid track. */
  .gf852-content__grid > *, .ec850-content__grid > * {
    min-width:0!important;
    max-width:100%!important;
    box-sizing:border-box!important;
  }
  .gf852-table-wrap,.ec850-table-wrap {
    display:block;
    min-width:0!important;
    max-width:100%!important;
    width:100%!important;
    overflow-x:auto!important;
    overscroll-behavior-inline:contain;
  }
}
