/* ==========================================================================
   flowbase — Dedicated PDF / Print stylesheet
   --------------------------------------------------------------------------
   Activated ONLY when the document is rendered for PDF export, either via:
     - html[data-flowbase-pdf="1"]   (set by the edge function on document-start)
     - @media print                  (browser print dialog, kept consistent)
   Goals:
     1. Preserve the live-site layout (no shrinking, no column collapse).
     2. Lock typography to comfortable, fully-rendered sizes.
     3. Hide chrome that doesn't belong in the PDF (cookie banner, tooltips,
        floating chat widgets, "back to top" buttons, scrollbars).
     4. Force lazy / animated content into its final visible state.
   ========================================================================== */

/* ----- Activation scope ------------------------------------------------- */
html[data-flowbase-pdf="1"] {
  /* Prevent horizontal scroll/clipping at 1440px render width */
  overflow-x: hidden !important;
  scroll-behavior: auto !important;
  /* Keep the same desktop font scale even if user-agent overrides it */
  font-size: 16px !important;
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
}
html[data-flowbase-pdf="1"] body {
  overflow-x: hidden !important;
  overflow-y: visible !important;
  min-width: 1440px !important;
  background: inherit;
}

/* ----- 1. Kill all motion ---------------------------------------------- */
html[data-flowbase-pdf="1"] *,
html[data-flowbase-pdf="1"] *::before,
html[data-flowbase-pdf="1"] *::after {
  animation-duration: 0.001ms !important;
  animation-delay: 0ms !important;
  animation-iteration-count: 1 !important;
  animation-play-state: paused !important;
  transition-duration: 0.001ms !important;
  transition-delay: 0ms !important;
}

/* ----- 2. Force lazy / off-screen content visible ---------------------- */
html[data-flowbase-pdf="1"] * {
  content-visibility: visible !important;
  contain-intrinsic-size: auto !important;
}
html[data-flowbase-pdf="1"] [class*="animate-"],
html[data-flowbase-pdf="1"] [data-aos],
html[data-flowbase-pdf="1"] [data-animate] {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
}

/* ----- 3. Typography baseline ------------------------------------------ */
html[data-flowbase-pdf="1"] h1 { font-size: clamp(2.5rem, 4vw, 3.75rem) !important; line-height: 1.1 !important; }
html[data-flowbase-pdf="1"] h2 { font-size: clamp(2rem, 3vw, 3rem) !important; line-height: 1.15 !important; }
html[data-flowbase-pdf="1"] h3 { font-size: clamp(1.5rem, 2.2vw, 2rem) !important; line-height: 1.2 !important; }
html[data-flowbase-pdf="1"] h4 { font-size: clamp(1.25rem, 1.6vw, 1.5rem) !important; line-height: 1.25 !important; }
html[data-flowbase-pdf="1"] p,
html[data-flowbase-pdf="1"] li {
  font-size: 1rem !important;
  line-height: 1.55 !important;
}
/* Prevent paragraph orphans / awkward breaks across PDF pages */
html[data-flowbase-pdf="1"] h1,
html[data-flowbase-pdf="1"] h2,
html[data-flowbase-pdf="1"] h3,
html[data-flowbase-pdf="1"] h4 {
  break-after: avoid-page;
  page-break-after: avoid;
}
html[data-flowbase-pdf="1"] img,
html[data-flowbase-pdf="1"] video,
html[data-flowbase-pdf="1"] svg,
html[data-flowbase-pdf="1"] figure,
html[data-flowbase-pdf="1"] picture {
  break-inside: avoid;
  page-break-inside: avoid;
  max-width: 100% !important;
}

/* Anti-tiny-text safety net: ignore explicit sub-12px overrides */
html[data-flowbase-pdf="1"] :where(p, span, li, a, button, label) {
  min-font-size: 12px;
}

/* ----- 4. Hide non-content chrome -------------------------------------- */
html[data-flowbase-pdf="1"] [id*="cookie" i],
html[data-flowbase-pdf="1"] [class*="cookie" i],
html[data-flowbase-pdf="1"] [id*="consent" i],
html[data-flowbase-pdf="1"] [class*="consent" i],
html[data-flowbase-pdf="1"] [aria-label*="cookie" i],
html[data-flowbase-pdf="1"] [data-testid*="cookie" i],
html[data-flowbase-pdf="1"] [role="dialog"][aria-label*="cookie" i],
html[data-flowbase-pdf="1"] [role="alertdialog"][aria-label*="cookie" i],
/* Common 3rd-party widgets */
html[data-flowbase-pdf="1"] #intercom-container,
html[data-flowbase-pdf="1"] .intercom-lightweight-app,
html[data-flowbase-pdf="1"] iframe[title*="chat" i],
html[data-flowbase-pdf="1"] iframe[title*="cookie" i],
html[data-flowbase-pdf="1"] [class*="back-to-top" i],
html[data-flowbase-pdf="1"] [aria-label*="back to top" i],
/* Tooltips & ephemeral popovers */
html[data-flowbase-pdf="1"] [role="tooltip"],
html[data-flowbase-pdf="1"] [data-state="open"][data-side] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hide scrollbars in captured output */
html[data-flowbase-pdf="1"] ::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }
html[data-flowbase-pdf="1"] * { scrollbar-width: none !important; }

/* ----- 5. Layout safety nets ------------------------------------------ */
/* Sticky elements should render in-place — Browserless captures full height
   so anything sticky causes duplicate visuals. */
html[data-flowbase-pdf="1"] .sticky,
html[data-flowbase-pdf="1"] [class*="sticky"],
html[data-flowbase-pdf="1"] [style*="position: sticky"] {
  position: relative !important;
  top: auto !important;
}
/* Make sure containers don't clip content with hidden overflow on the
   vertical axis (horizontal clipping at the page edge stays). */
html[data-flowbase-pdf="1"] section,
html[data-flowbase-pdf="1"] main,
html[data-flowbase-pdf="1"] article {
  overflow-y: visible !important;
}

/* ----- 6. Component-level adjustments --------------------------------- */
/* Buttons: keep them readable, never tiny */
html[data-flowbase-pdf="1"] button,
html[data-flowbase-pdf="1"] .btn,
html[data-flowbase-pdf="1"] [role="button"] {
  min-height: 36px !important;
  font-size: 0.95rem !important;
}
/* Cards / panels with backdrop-blur: blur is dropped by some PDF engines —
   substitute a solid translucent background for visual parity. */
html[data-flowbase-pdf="1"] [class*="backdrop-blur"] {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background-color: rgba(0, 0, 0, 0.55) !important;
}
/* Marquees / infinite scrollers freeze at frame 0 */
html[data-flowbase-pdf="1"] [class*="marquee"],
html[data-flowbase-pdf="1"] [class*="animate-marquee"] {
  animation: none !important;
  transform: none !important;
}

/* ----- 7. @media print parity ----------------------------------------- */
@media print {
  html, body {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    background: inherit;
  }
  [id*="cookie" i], [class*="cookie" i],
  [id*="consent" i], [class*="consent" i],
  [role="tooltip"], #intercom-container { display: none !important; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}