/** BMCPC Print Framework — reusable offering-list component fidelity. */

@media print {
  /* Some Elementor fake tables put the four-column repeated-cell grid below
     an outer one-track `.grid-table` and `.e-con-inner`. Chromium can finish
     that nested grid fragment before painting its final row, letting the
     following source Footer occupy the same page area. Treat only the two
     wrapper levels as block shells; the inner `.e-grid` keeps its native
     tracks, cells and row order. */
  body.bmcpc-print-active .grid-table.e-grid:has(> .e-con-inner > .e-grid) {
    display: block !important;
    grid-template-columns: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    contain: none !important;
  }

  body.bmcpc-print-active .grid-table.e-grid:has(> .e-con-inner > .e-grid) > .e-con-inner {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    contain: none !important;
  }

  body.bmcpc-print-active .grid-table.e-grid:has(> .e-con-inner > .e-grid)
  > .e-con-inner > .e-grid {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body.bmcpc-print-active :is(
    .bmcpc-print-offering-list,
    .bmcpc-offering-results
  ) {
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    font-family: "PingFang HK", "Noto Sans HK", "Microsoft JhengHei", Arial, sans-serif !important;
  }

  /* The screen widget is a flex column. Chromium may paginate a following
     Footer into spare space before emitting the flex container's final row on
     the next sheet. The adapter-owned root is an ordered print flow, so make
     that one accepted instance a block fragmentation context. */
  body.bmcpc-print-active .bmcpc-print-offering-list[data-bmcpc-print-offering-list-prepared="1"] {
    display: block !important;
    position: static !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    contain: none !important;
  }

  /* Elementor wraps the component in nested flex containers. A flex ancestor
     can report a completed fragment before the component's final row, allowing
     a later Footer sibling to paint into the same page area. Normalize only
     the ancestor chain that owns the accepted offering component; row grids
     and unrelated Elementor layouts remain untouched. */
  body.bmcpc-print-active :is(
    [data-elementor-type="wp-page"],
    .e-con,
    .e-con-inner
  ):has(.bmcpc-print-offering-list[data-bmcpc-print-offering-list-prepared="1"]) {
    display: block !important;
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    transform: none !important;
    contain: none !important;
  }

  /* A return-to-home button is screen navigation, not printable content. On
     offering pages it also forms an otherwise empty final-page pair with the
     shared Footer. Scope the omission to the same Elementor page that owns an
     accepted offering component; action buttons inside result rows keep their
     own component styling. */
  body.bmcpc-print-active [data-elementor-type="wp-page"]:has(
    .bmcpc-print-offering-list[data-bmcpc-print-offering-list-prepared="1"]
  ) .elementor-widget-button:has(a[href="/"]) {
    display: none !important;
  }

  body.bmcpc-print-active [data-elementor-type="wp-page"]:has(
    .bmcpc-print-offering-list[data-bmcpc-print-offering-list-prepared="1"]
  ) .e-con:has(> .e-con-inner > .elementor-widget-button:only-child a[href="/"]) {
    display: none !important;
  }

  /* The widget's screen font contains Latin glyphs only on the current site.
     Chromium therefore emitted numbers/punctuation but dropped Chinese text
     from the PDF. Keep the fallback local to this component. */
  body.bmcpc-print-active :is(
    .bmcpc-print-offering-list,
    .bmcpc-offering-results
  ) * {
    font-family: inherit !important;
  }

  body.bmcpc-print-active .bmcpc-print-offering-group {
    margin: 0 0 3mm !important;
    background: var(--bmcpc-print-offering-group-background, transparent) !important;
    border: var(--bmcpc-print-offering-group-border, 0) !important;
    break-inside: auto;
    page-break-inside: auto;
  }

  /* Rows, rather than their item/card wrapper, are the pagination geometry
     unit. This keeps a fitting row together without stranding a tall item. */
  body.bmcpc-print-active :is(
    .bmcpc-print-offering-row,
    .bmcpc-offering-results__row
  ) {
    display: grid !important;
    grid-template-columns: var(--bmcpc-print-offering-grid-template, repeat(var(--bmcpc-print-offering-columns, 6), minmax(0, 1fr))) !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  body.bmcpc-print-active .bmcpc-print-offering-row {
    border-bottom: var(--bmcpc-print-offering-row-border, 0) !important;
  }

  body.bmcpc-print-active :is(
    .bmcpc-print-offering-row,
    .bmcpc-offering-results__row
  ) > .bmcpc-offering-results__col {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    min-width: 0 !important;
    padding: 1.5mm 1.8mm !important;
    overflow: visible !important;
  }

  body.bmcpc-print-active :is(
    .bmcpc-print-offering-list,
    .bmcpc-offering-results
  ) .bmcpc-offering-results__label {
    display: block !important;
    margin: 0 0 1mm !important;
    color: var(--bmcpc-print-brand) !important;
    font-size: 8pt !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    -webkit-text-fill-color: var(--bmcpc-print-brand) !important;
  }

  body.bmcpc-print-active :is(
    .bmcpc-print-offering-list,
    .bmcpc-offering-results
  ) .bmcpc-offering-results__value {
    display: block !important;
    min-width: 0 !important;
    color: #111 !important;
    font-size: 8.5pt !important;
    line-height: 1.35 !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    -webkit-text-fill-color: #111 !important;
  }

  /* Preserve the source action language as compact pills instead of turning
     every offering action into a plain underlined text link. */
  body.bmcpc-print-active :is(
    .bmcpc-print-offering-list,
    .bmcpc-offering-results
  ) :is(
    .bmcpc-offering-results__btn,
    .bmcpc-offering-results__subbtn
  ) {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: fit-content !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 1mm 0 0 !important;
    padding: 1.1mm 2.2mm !important;
    color: #fff !important;
    background: var(--bmcpc-print-brand, #1f6e51) !important;
    border: 1px solid var(--bmcpc-print-brand, #1f6e51) !important;
    border-radius: 999px !important;
    box-shadow: none !important;
    clip-path: none !important;
    -webkit-mask: none !important;
    mask: none !important;
    font-size: 7.5pt !important;
    line-height: 1.2 !important;
    text-align: center !important;
    text-decoration: none !important;
    -webkit-text-fill-color: #fff !important;
  }

  body.bmcpc-print-active :is(
    .bmcpc-print-offering-list,
    .bmcpc-offering-results
  ) :is(
    .bmcpc-offering-results__btn.disabled,
    .bmcpc-offering-results__subbtn.disabled,
    .bmcpc-offering-results__btn[disabled],
    .bmcpc-offering-results__subbtn[disabled]
  ) {
    color: #555 !important;
    background: #e4e4e4 !important;
    border-color: #c4c4c4 !important;
    -webkit-text-fill-color: #555 !important;
  }

  body.bmcpc-print-active :is(
    .bmcpc-print-offering-list,
    .bmcpc-offering-results
  ) .bmcpc-offering-results__btn-text {
    position: static !important;
    inset: auto !important;
    color: inherit !important;
    font: inherit !important;
    -webkit-text-fill-color: currentColor !important;
  }

  /* The source widget uses both an empty icon span and button/subbutton
     pseudo-elements for the white chevron. They communicate hover/click
     affordance only, so omit both implementations from the static print pill. */
  body.bmcpc-print-active :is(
    .bmcpc-print-offering-list,
    .bmcpc-offering-results
  ) .bmcpc-offering-results__btn-icon {
    display: none !important;
  }

  body.bmcpc-print-active :is(
    .bmcpc-print-offering-list,
    .bmcpc-offering-results
  ) :is(
    .bmcpc-offering-results__btn,
    .bmcpc-offering-results__subbtn
  )::after {
    content: none !important;
    display: none !important;
  }
}
