/**
 * BMCPC Print Framework — shared print baseline.
 *
 * This is intentionally the only stylesheet that defines paper geometry.
 * All DOM-facing declarations require the controller's print-state class so
 * normal screen rendering remains untouched.
 */

/* The controller creates this fully prepared DOM during page load. It remains
 * in the document (rather than being assembled during beforeprint) so browser
 * menu / right-click print sees exactly the same layout as the Navbar path. */
[data-bmcpc-print-snapshot-root="1"] {
  display: none !important;
}

[data-bmcpc-print-firefox-notice="1"] {
  display: none !important;
}

@page {
  size: A4 portrait;
  margin: 10mm;
}

@media print {
  :root {
    --bmcpc-print-page-margin: 10mm;
    --bmcpc-print-header-gap: 6mm;
    --bmcpc-print-footer-gap: 8mm;
    --bmcpc-print-font-size: 10pt;
    --bmcpc-print-line-height: 1.45;
    --bmcpc-print-brand: #27665d;
    --bmcpc-print-border: #d9e2df;
    --bmcpc-print-muted: #5a6663;
  }

  html:has(> body.bmcpc-print-active),
  body.bmcpc-print-active {
    background: #fff !important; /* Override theme canvases in print. */
    color: #111 !important;
    font-size: var(--bmcpc-print-font-size) !important;
    line-height: var(--bmcpc-print-line-height) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Print only the immutable, page-load snapshot. Every original body child
     is kept for normal screen interaction but cannot participate in print
     layout or reserve paper space while the snapshot is active. */
  body.bmcpc-print-active.bmcpc-print-snapshot-active > :not([data-bmcpc-print-snapshot-root="1"]) {
    display: none !important;
  }

  body.bmcpc-print-active.bmcpc-print-snapshot-active > [data-bmcpc-print-snapshot-root="1"] {
    display: block !important;
  }

  body.bmcpc-print-active.bmcpc-print-snapshot-active
    > [data-bmcpc-print-snapshot-root="1"]
    > [data-bmcpc-print-firefox-notice="1"] {
    display: block !important;
    position: static !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 5mm !important;
    padding: 3mm 4mm !important;
    color: #3f3300 !important;
    border: 1px solid #c79800 !important;
    border-left: 4px solid #c79800 !important;
    background: #fff8d6 !important;
    font-family: "PingFang HK", "Noto Sans HK", "Microsoft JhengHei", Arial, sans-serif !important;
    font-size: 9.5pt !important;
    font-weight: 400 !important;
    line-height: 1.45 !important;
    text-align: left !important;
    break-inside: avoid-page !important;
    page-break-inside: avoid !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.bmcpc-print-active [data-bmcpc-print-firefox-notice="1"]
    .bmcpc-print-firefox-notice__title {
    display: block !important;
    margin: 0 0 1mm !important;
    font-weight: 700 !important;
  }

  body.bmcpc-print-active [data-bmcpc-print-firefox-notice="1"]
    .bmcpc-print-firefox-notice__message {
    display: block !important;
  }

  body.bmcpc-print-active *,
  body.bmcpc-print-active *::before,
  body.bmcpc-print-active *::after {
    box-sizing: border-box;
  }

  body.bmcpc-print-active :is(
    .bmcpc-print-hide,
    [data-bmcpc-print-hide],
    [data-bmcpc-print-duplicate="responsive"],
    [data-bmcpc-print-duplicate="1"],
    [data-bmcpc-print-chrome],
    [data-bmcpc-print-policy="hide"],
    [data-bmcpc-print-trigger],
    .bmcpc-header-print-button,
    .bmcpc-subnav-wrapper,
    #wpadminbar,
    #back-to-top,
    .back-to-top,
    .scroll-to-top,
    .dialog-close-button,
    .dialog-lightbox-close-button,
    .elementor-menu-toggle,
    .elementor-search-form,
    .elementor-widget-search
  ) {
    display: none !important; /* Print-only chrome must not consume paper space. */
  }

  /* The screen tab bars and dropdown labels are interactive navigation. The
     adapter already emits one synchronized active-tab title, so controls must
     be suppressed for every profile (including standard pages with tabs). */
  body.bmcpc-print-active :is(
    .sk-anchor-tabs,
    [role="tablist"],
    [data-bmcpc-print-tab-controls]
  ),
  body.bmcpc-print-active [data-bmcpc-print-tab-state="inactive"] {
    display: none !important;
  }

  body.bmcpc-print-active :is(
    .bmcpc-print-header,
    [data-bmcpc-print-header],
    header[data-elementor-id="10645"],
    header[data-elementor-type="header"]
  ) :is(
    nav,
    search,
    .elementor-nav-menu,
    .elementor-widget-nav-menu,
    .elementor-menu-toggle,
    .elementor-search-form,
    .elementor-widget-search,
    .elementor-widget-icon,
    .elementor-widget-button
  ) {
    display: none !important; /* Keep screen controls out of the source header. */
  }

  body.bmcpc-print-active .bmcpc-print-only {
    display: revert !important;
  }

  /* The tabs adapter generates one selected-tab heading for every profile
     that prints only the active panel. Keep that heading in ordinary flow
     from one shared rule: standard/FGFA pages must not fall back to theme H2
     geometry while tabbed-allocation pages receive a different treatment. */
  body.bmcpc-print-active .bmcpc-print-active-tab-title {
    display: block !important;
    position: static !important;
    inset: auto !important;
    float: none !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 0 5mm !important;
    padding: 0 0 2mm !important;
    color: var(--bmcpc-print-brand, #27665d) !important;
    border: 0 !important;
    border-bottom: 1px solid var(--bmcpc-print-border, #d9e2df) !important;
    background: transparent !important;
    font-family: "PingFang HK", "Noto Sans HK", "Microsoft JhengHei", Arial, sans-serif !important;
    font-size: 14pt !important;
    font-weight: 700 !important;
    line-height: 1.35 !important;
    letter-spacing: normal !important;
    text-align: left !important;
    text-shadow: none !important;
    transform: none !important;
    break-after: avoid-page !important;
    page-break-after: avoid !important;
    -webkit-text-fill-color: var(--bmcpc-print-brand, #27665d) !important;
  }

  body.bmcpc-print-active :is(
    .bmcpc-print-content,
    main,
    [role="main"]
  ) {
    min-width: 0;
    max-width: none;
  }

  /*
   * P0 compatibility bridge for the live Elementor page roots. Reset only the
   * outer source-flow chain; nested grids, accordions and profile components
   * retain their own layout contracts.
   */
  body.bmcpc-print-active:is(
    .bmcpc-print-profile-home,
    .bmcpc-print-profile-fee-table,
    .bmcpc-print-profile-form,
    .bmcpc-print-profile-fgfa,
    .bmcpc-print-profile-tabbed-allocation
  ) :is(
    main.site-main,
    main.site-main > .page-content,
    main.site-main > .page-content > [data-elementor-type="wp-page"],
    main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent
  ) {
    position: static !important;
    inset: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    transform: none !important;
    contain: none !important;
  }

  /* site-screen-compat.css reserves 80px after every page for the desktop
     theme. In paged media that trailing margin can cross the final page
     boundary and create a completely blank sheet after an in-flow Footer. */
  body.bmcpc-print-active:is(
    .bmcpc-print-profile-home,
    .bmcpc-print-profile-fee-table,
    .bmcpc-print-profile-form,
    .bmcpc-print-profile-fgfa,
    .bmcpc-print-profile-tabbed-allocation
  ) main.site-main > .page-content {
    margin-bottom: 0 !important;
  }

  /* A semantic offering/result component can appear on a newly created
     standard page before that page has a manifest override. Once its adapter
     owns the component, normalize only the shared outer Elementor shells.
     This avoids the screen min-height/flex geometry that can place the source
     Footer over the final result row, without widening the reset to every
     standard-profile page. */
  body.bmcpc-print-active:has([data-bmcpc-print-offering-list-prepared="1"]) :is(
    main.site-main,
    main.site-main > .page-content,
    main.site-main > .page-content > [data-elementor-type="wp-page"],
    main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent
  ) {
    position: static !important;
    inset: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    transform: none !important;
    contain: none !important;
  }

  body.bmcpc-print-active:has([data-bmcpc-print-offering-list-prepared="1"])
  main.site-main > .page-content {
    margin-bottom: 0 !important;
  }

  /* Unmapped pages use the standard profile and leave the one source Footer
     after <main>. Collapse only the outer screen-layout reservation so that
     an otherwise short page does not strand that Footer on an empty sheet.
     Do not relocate the Footer or flatten inner components: some standard
     pages reveal different print content than their screen-visible tail. */
  body.bmcpc-print-active.bmcpc-print-profile-standard :is(
    main.site-main,
    main.site-main > .page-content,
    main.site-main > .page-content > [data-elementor-type="wp-page"],
    main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent
  ) {
    position: static !important;
    inset: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    transform: none !important;
    contain: none !important;
  }

  body.bmcpc-print-active.bmcpc-print-profile-standard
  main.site-main > .page-content {
    margin-bottom: 0 !important;
  }

  /* Image-gallery pages own their nested media grids, but their direct
     Elementor sections are screen flex containers. Chromium can end the final
     flex fragment before the in-flow Footer and create a blank Footer sheet.
     Normalize only those direct section shells; generated gallery grids keep
     their columns and item geometry. */
  body.bmcpc-print-active.bmcpc-print-gallery-block-flow :is(
    main.site-main,
    main.site-main > .page-content,
    main.site-main > .page-content > [data-elementor-type="wp-page"],
    main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent
  ) {
    position: static !important;
    inset: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    transform: none !important;
    contain: none !important;
  }

  body.bmcpc-print-active.bmcpc-print-gallery-block-flow
  main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent {
    display: block !important;
  }

  body.bmcpc-print-active.bmcpc-print-gallery-block-flow
  main.site-main > .page-content {
    margin-bottom: 0 !important;
  }

  /* Reviewed short pages can retain the full screen hero: a negative top offset,
     matching padding, large widget margins and a duplicate breadcrumb. That
     reservation can strand the source Footer on a second, otherwise empty
     sheet. Keep the page title and source content, but use a compact print hero
     and smaller in-flow Header/Footer gaps. The controller adds this class only
     for an explicit page policy or stable data hook; it is not profile-wide. */
  body.bmcpc-print-active.bmcpc-print-compact-hero {
    --bmcpc-print-header-gap: 2mm;
    --bmcpc-print-footer-gap: 2mm;
  }

  body.bmcpc-print-active.bmcpc-print-compact-hero
  main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent:first-child {
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
  }

  body.bmcpc-print-active.bmcpc-print-compact-hero
  main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent:first-child::before,
  body.bmcpc-print-active.bmcpc-print-compact-hero
  main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent:first-child::after {
    display: none !important;
    content: none !important;
  }

  body.bmcpc-print-active.bmcpc-print-compact-hero
  main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent:first-child > .elementor-widget {
    margin: 0 !important;
    padding: 0 !important;
  }

  body.bmcpc-print-active.bmcpc-print-compact-hero
  main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent:first-child
  > .elementor-widget-text-editor.elementor-hidden-mobile {
    display: none !important;
  }

  /* Remove only the common screen hero decoration and empty shape spacers. */
  body.bmcpc-print-active:is(
    .bmcpc-print-profile-home,
    .bmcpc-print-profile-fee-table,
    .bmcpc-print-profile-form,
    .bmcpc-print-profile-fgfa,
    .bmcpc-print-profile-tabbed-allocation
  ) main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent:first-child {
    background-color: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
  }

  body.bmcpc-print-active:is(
    .bmcpc-print-profile-home,
    .bmcpc-print-profile-fee-table,
    .bmcpc-print-profile-form,
    .bmcpc-print-profile-fgfa,
    .bmcpc-print-profile-tabbed-allocation
  ) main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent:first-child::before,
  body.bmcpc-print-active:is(
    .bmcpc-print-profile-home,
    .bmcpc-print-profile-fee-table,
    .bmcpc-print-profile-form,
    .bmcpc-print-profile-fgfa,
    .bmcpc-print-profile-tabbed-allocation
  ) main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent:first-child::after,
  body.bmcpc-print-active:is(
    .bmcpc-print-profile-home,
    .bmcpc-print-profile-fee-table,
    .bmcpc-print-profile-form,
    .bmcpc-print-profile-fgfa
  ) main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent:first-child :is(
    .elementor-shape,
    .elementor-background-overlay
  ) {
    display: none !important;
    content: none !important;
  }

  /* Once the outer height reset removes a screen spacer's min-height, its
     negative margin must not remain as an invisible overlap source. */
  body.bmcpc-print-active:is(
    .bmcpc-print-profile-standard,
    .bmcpc-print-profile-home,
    .bmcpc-print-profile-fee-table,
    .bmcpc-print-profile-form,
    .bmcpc-print-profile-fgfa,
    .bmcpc-print-profile-tabbed-allocation
  ) main.site-main > .page-content > [data-elementor-type="wp-page"] > .e-con.e-parent:not(:has(
    > .elementor-element,
    > .e-con-inner > .elementor-element,
    [data-bmcpc-print-footer-flow-container],
    [data-bmcpc-print-footer-flow-anchor],
    [data-bmcpc-print-footer-flow-owned],
    footer[data-elementor-type="footer"],
    footer[data-bmcpc-print-footer]
  )) {
    display: none !important;
  }

  body.bmcpc-print-active :is(p, li, td, th, figcaption) {
    overflow-wrap: anywhere;
  }

  body.bmcpc-print-active a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 1px;
  }

  /* Suppress theme-added URL suffixes; printable link lists own their output. */
  body.bmcpc-print-active a[href]::after {
    content: none !important;
  }
}
