/* ═══════════════════════════════════════════════════════════════════════
   Demo-Modal (Step 2 — HubSpot calendar) — full override (2026-05-24)

   This file completely overrides the base `.demo-modal` styles shipped in
   site.css. Site.css originally laid out a 380px intro panel + calendar
   in a 2-col grid with min-height:660px, which:
     • clipped the iframe on viewports <760px tall (overflow:hidden,
       no scrollable child)
     • repeated step-1 context the user had just answered
     • took ~half the modal real estate away from the calendar itself

   New shape: single-column with sticky head + body (calendar fills) +
   sticky foot (phone fallback). Matches the qqm modal pattern so step 1
   → step 2 feels like one continuous flow.

   SPECIFICITY NOTE: every rule below is prefixed with `#demoModal` (the
   dialog's id) to land at ID-tier specificity. site.css contains
   defensive mobile sweep rules like `[class*="card"]:not(...){padding:20px}`
   that beat plain `.demo-modal-card` even with !important; ID-tier wins
   without needing !important on most rules.
   ═══════════════════════════════════════════════════════════════════════ */

#demoModal.demo-modal {
  /* 860px gives HubSpot's two-column meeting layout (calendar grid +
     duration/location panel) enough room to breathe; below ~780px the
     right column wraps awkwardly and cuts off the email link. */
  width: min(860px, 94vw);
  max-width: 860px;
  /* Must match .demo-modal-card's max-height (97vh). The dialog is what gets
     centered (top:50% + translate(-50%,-50%)); if it caps shorter than the
     card, the card overflows past the centered dialog and the footer drops
     below the viewport fold on short screens. Keep these two in lockstep. */
  max-height: 97vh;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

/* iOS Chrome / WebKit fallback: when modal.showModal() throws, JS sets
   [open] attribute as fallback. UA-default <dialog> positioning is
   absolute; force fixed centering so both code paths look the same. */
#demoModal.demo-modal[open] {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 9999;
}

#demoModal.demo-modal::backdrop {
  background: rgba(7, 25, 46, .68);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* ── Entrance-animation fix (2026-05-24) ──────────────────────────────
   site.css defines `.demo-modal[open] { animation: demoModalCardIn ... }`
   whose keyframes animate `transform: scale(.96) translateY(12px) →
   scale(1) translateY(0)`. While that animation runs (.42s), it
   OVERRIDES the centering `transform: translate(-50%, -50%)` from the
   rule above, so the dialog's top-left corner pins to viewport center
   and the body extends into the bottom-right quadrant. When the animation
   ends, the centering translate snaps back — visible as a "flash in the
   corner, then jump to middle". Fix: cancel the animation on the dialog
   itself and apply it to the inner `.demo-modal-card` instead. */
#demoModal.demo-modal[open] {
  animation: none;
}
#demoModal.demo-modal[open] .demo-modal-card {
  animation: demoModalCardIn .42s cubic-bezier(.34, 1.56, .64, 1);
  transform-origin: center;
}
@media (prefers-reduced-motion: reduce) {
  #demoModal.demo-modal[open] .demo-modal-card {
    animation: none !important;
  }
}

/* ── Card: flex column with sticky head + scrollable body + sticky foot ─ */
#demoModal .demo-modal-card {
  position: relative;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 0 0 1px rgba(13,24,41,.08),
    0 20px 50px -18px rgba(7,25,46,.20),
    0 40px 120px -20px rgba(7,25,46,.38);
  /* Hug the calendar's natural height instead of forcing a fixed height.
     HubSpot's embed (?embed=true) auto-sizes its iframe to content via
     postMessage (measured: 756px for the date-picker step). The old
     `height:100%` forced on the iframe FOUGHT that auto-size — clipping
     HubSpot's content and triggering its cramped internal scrollbar (the
     "I still have to scroll" bug). Now the card grows to fit head + calendar
     + foot, capped at 96vh. min-height gives a stable open size so the modal
     doesn't visibly balloon when the iframe mounts. On viewports too short to
     show the full calendar, .demo-modal-calendar scrolls (one clean scrollbar)
     instead of HubSpot's internal one. */
  min-height: min(720px, 85vh);
  max-height: 97vh;
  display: flex;
  flex-direction: column;
  padding: 0 !important; /* beats site.css sweep rule */
}

/* ── Header (sticky) ──────────────────────────────────────────────────── */
#demoModal .demo-modal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  /* Trimmed from 18/14 → 13/11 so head + 756px calendar + foot clears the
     97vh cap on a ~900px laptop with margin to spare = zero scroll there. */
  padding: 13px 20px 11px;
  border-bottom: 1px solid rgba(13,24,41,.06);
  background: #fff;
  position: relative;
  z-index: 2;
}
#demoModal .demo-modal-head-text { min-width: 0; }
#demoModal .demo-modal-title {
  /* site.css still ships the OLD modal's heading styles
     (.demo-modal-title{font-size:26px;margin:0 0 14px} + a global h2 rule
     forcing font-weight:800). Those were beating this rule's `font` shorthand,
     so the title rendered at 26px/800 — bloating the header to 87px and pushing
     HubSpot's 756px calendar into an 8px scroll. Force the intended compact
     title with !important longhands at ID-tier specificity so it wins over the
     global h2 cascade no matter the load order. */
  font-family: 'Poppins', system-ui, sans-serif;
  font-size: 18px !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  letter-spacing: -.018em;
  color: #07192E;
  margin: 0 !important;
}
#demoModal .demo-modal-sub {
  font: 500 12.5px/1.4 'Inter', system-ui, sans-serif;
  color: #5B6B7E;
  margin: 3px 0 0;
}
#demoModal .demo-modal-sub[hidden] { display: none; }
#demoModal .demo-modal-close {
  flex: 0 0 auto;
  /* Override base styles that anchored close to top:16/right:16 absolute */
  position: static !important;
  top: auto !important;
  right: auto !important;
  width: 36px;
  height: 36px;
  /* Defeat sitewide accessibility rule that sets min-width/min-height to
     var(--touch-min) (48px) on every <button>. A close X doesn't need a
     48px target — clipping the modal is the secondary action, not the
     primary one. */
  min-width: 0;
  min-height: 0;
  /* !important defeats the home-page.css mobile rule
     `.btn, button, … { padding: 12px 18px !important }` (≤767px), which
     otherwise collapses this grid button's content column to ~6px and
     shrinks the X glyph to a sliver (the "microscopic X" bug). */
  padding: 0 !important;
  background: #fff;
  border: 1px solid rgba(13,24,41,.10);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #07192E;
  transition: background .15s, border-color .15s;
  box-shadow: none;
}
#demoModal .demo-modal-close:hover { background: #FAFBFC; border-color: rgba(13,24,41,.20); }
#demoModal .demo-modal-close:focus-visible { outline: 2px solid #F97316; outline-offset: 2px; }
#demoModal .demo-modal-close svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Body (calendar fills) ────────────────────────────────────────────
   min-height:0 is required on the flex child or it won't shrink below
   its content height and overflow control won't engage. */
#demoModal .demo-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#demoModal .demo-modal-calendar {
  flex: 1 1 auto;
  min-height: 460px; /* keeps HubSpot's grid readable on shorter viewports */
  padding: 0;
  background: #fff;
  /* Single clean scrollbar — engages ONLY when the viewport is too short to
     show HubSpot's full calendar. On tall screens the card hugs content and
     this never appears. Replaces HubSpot's cramped iframe-internal scroll. */
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}
#demoModal .demo-modal-calendar .meetings-iframe-container {
  width: 100%;
  /* auto (not 100%) so the container tracks the iframe's HubSpot-driven
     height; the calendar pane above is the single scroller. */
  height: auto;
  min-height: 460px;
  border-radius: 0;
  overflow: visible;
}
#demoModal .demo-modal-calendar .meetings-iframe-container iframe {
  border: 0 !important;
  background: #fff;
  display: block;
  width: 100% !important;
  /* NO height:100%!important — that overrode HubSpot's inline height:<content>px
     (set via its postMessage auto-resize) and clipped the calendar, forcing
     HubSpot's internal scrollbar. Let HubSpot drive height; min-height is just
     a pre-mount floor so the area isn't collapsed before the iframe loads. */
  height: auto;
  min-height: 460px;
  min-width: 100% !important;
  border-radius: 0;
}

/* Loading state covers the whole calendar pane */
#demoModal .demo-modal-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  background: #fff;
  font: 500 13px/1.4 'Inter', system-ui, sans-serif;
  color: #5B6B7E;
  z-index: 2;
  pointer-events: none;
  transition: opacity .3s ease;
}
#demoModal .demo-modal-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(13,24,41,.08);
  border-top-color: #F97316;
  border-radius: 50%;
  animation: demoModalSpin .8s linear infinite;
}
#demoModal.demo-modal.is-loaded .demo-modal-loading {
  opacity: 0;
}

/* The :has() rule below also fades the spinner the moment HubSpot mounts
   the iframe (no JS timeout dependency). Belt + suspenders with the
   .is-loaded class set by the MutationObserver. */
#demoModal .demo-modal-calendar:has(.meetings-iframe-container iframe) .demo-modal-loading {
  opacity: 0 !important;
  pointer-events: none;
}

/* ── Footer (sticky) ──────────────────────────────────────────────────── */
#demoModal .demo-modal-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid rgba(13,24,41,.06);
  background: #fff;
}
#demoModal .demo-modal-foot-phone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 13px/1 'Inter', system-ui, sans-serif;
  color: #5B6B7E;
  text-decoration: none;
  transition: color .15s;
}
#demoModal .demo-modal-foot-phone:hover { color: #F97316; }
#demoModal .demo-modal-foot-phone svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#demoModal .demo-modal-foot-meta {
  font: 500 11.5px/1 'Inter', system-ui, sans-serif;
  color: #94A3B8;
  letter-spacing: .02em;
}

/* ── Mobile (≤640px): full-screen sheet, same flex structure ──────── */
@media (max-width: 640px) {
  #demoModal.demo-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  #demoModal.demo-modal[open] {
    top: 0;
    left: 0;
    transform: none;
  }
  #demoModal .demo-modal-card {
    border-radius: 0 !important;
    height: 100vh;
    max-height: 100vh;
  }
  #demoModal .demo-modal-head { padding: 12px 14px 10px; }
  #demoModal .demo-modal-title { font-size: 16px; }
  #demoModal .demo-modal-sub { font-size: 12px; }
  /* On mobile, embrace the sitewide 48px touch-target. Scale up the
     SVG so the X glyph isn't lost in a big-but-empty circle. */
  #demoModal .demo-modal-close { width: 44px; height: 44px; }
  #demoModal .demo-modal-close svg { width: 18px; height: 18px; stroke-width: 2.2; }
  #demoModal .demo-modal-calendar { min-height: 0; }
  #demoModal .demo-modal-calendar .meetings-iframe-container,
  #demoModal .demo-modal-calendar .meetings-iframe-container iframe {
    min-height: 0 !important;
  }
  #demoModal .demo-modal-foot {
    padding: 10px 14px;
    flex-direction: row-reverse; /* phone on the right is the primary action on mobile */
    justify-content: space-between;
  }
}

/* ── Hide deprecated DOM if any cached page still renders the old structure
   (e.g. stale browser cache of demo-modal.js). Defensive — once cache busts
   these never apply because the DOM no longer contains them. ──────── */
#demoModal .demo-modal-intro,
#demoModal .demo-modal-num,
#demoModal .demo-modal-eyebrow,
#demoModal .demo-modal-lede,
#demoModal .demo-modal-trust,
#demoModal .demo-modal-footer,
#demoModal .demo-modal-accent {
  display: none !important;
}

/* ── Spin keyframe (local, doesn't depend on site.css declaration) ── */
@keyframes demoModalSpin {
  to { transform: rotate(360deg); }
}

/* ── Fallback panel (shown by JS after 6s if iframe never arrives) ─── */
.demo-modal-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: #FFFFFF;
  z-index: 3;
}
.demo-modal-fallback[hidden] { display: none; }
.demo-modal-fallback-title {
  font: 700 16px/1.35 'Poppins', system-ui, sans-serif;
  color: #07192E;
  margin: 0;
  text-align: center;
  letter-spacing: -.01em;
}
.demo-modal-fallback-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #F97316 0%, #EA580C 100%);
  color: #FFFFFF;
  font: 600 14px/1.2 'Inter', system-ui, sans-serif;
  letter-spacing: -.005em;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 4px 12px rgba(249,115,22,.28);
}
.demo-modal-fallback-btn:hover { transform: translateY(-1px); }
.demo-modal-fallback-call {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 13px/1.2 'Inter', system-ui, sans-serif;
  color: #07192E;
  text-decoration: none;
}
.demo-modal-fallback-call:hover { color: #1779B8; }
