/* =====================================================
   BASE RESET (Scoped – safe for Shopify themes)
===================================================== */
@import url("https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=Red+Hat+Display:wght@400;500;600;700;800&display=swap");

#chqme-modal * {
  box-sizing: border-box;
  font-family: "Red Hat Display", system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#chqme-modal button,
#chqme-modal a,
#chqme-modal input,
#chqme-modal select,
#chqme-modal [role="button"] {
  touch-action: manipulation;
}

/* Utility */
#chqme-modal .hidden {
  display: none !important;
}

/* Modal container - ensures proper stacking context */
#chqme-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483004 !important; /* above page/3rd-party overlays, below max int (2147483647) */
  pointer-events: none;
  isolation: isolate;
}

#chqme-modal > * {
  pointer-events: auto;
}

/* =====================================================
   OVERLAY
===================================================== */
.chqme-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2147483005 !important; /* overlay above modal container, below dialog */
  animation: chqme-fade-in 0.25s ease-out;
  pointer-events: auto;
}

@keyframes chqme-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* =====================================================
   MODAL CONTAINER
===================================================== */
.chqme-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  margin: 0;
  background: #fff;
  width: 560px;
  max-width: 95%;
  height: 520px;
  max-height: 90vh;
  padding: 0 16px 0;
  border-radius: 18px;
  overflow: hidden;
  z-index: 2147483006 !important; /* dialog on top within modal stacking context */
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.14),
    0 8px 24px rgba(0, 0, 0, 0.09);
  display: flex;
  flex-direction: column;
  animation: chqme-modal-slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transition: height 0.25s ease, max-height 0.25s ease, width 0.25s ease;
  isolation: isolate;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@keyframes chqme-modal-slide-up {
  from {
    opacity: 0;
    transform: translate(-50%, -46%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* =====================================================
   IFRAME MODE
===================================================== */
.chqme-modal.chqme-modal--iframe {
  padding: 0 !important;
  height: 72vh;
  max-height: 80vh;
  position: fixed;
}

.chqme-modal--iframe .chqme-modal-topbar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  padding: 8px 8px 8px;
  justify-content: flex-end;
  pointer-events: none;
  z-index: 10;
  background: transparent;
}

.chqme-modal--iframe .chqme-modal-topbar .chqme-close {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.chqme-modal--iframe .chqme-modal-topbar .chqme-close:hover {
  background: rgba(255, 255, 255, 0.95);
}

.chqme-iframe {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 18px;
  display: block;
  background: #fff;
  touch-action: auto;
  -webkit-overflow-scrolling: touch;
}

/* =====================================================
   CLOSE BUTTON
===================================================== */
.chqme-close {
  position: absolute;
  top: 0;
  right: 0;
  margin: 0;
  z-index: 10;
  flex-shrink: 0;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.04);
  border: none;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #333;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chqme-close:hover {
  background: rgba(0, 0, 0, 0.09);
  transform: scale(1.08);
}

/* =====================================================
   MODAL TOPBAR  (logo + nav buttons wrapper)
   Flex row: [Logo(1)] [Title(2,flex:1)] [Experiences(3)] [Close(4)]
===================================================== */
.chqme-modal-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

/* =====================================================
   MODAL HEADER TITLE  ("Book Demo" — step 0 only)
===================================================== */
.chqme-modal-title {
  order: 2;
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: #ff7a00;
  white-space: nowrap;
}

/* =====================================================
   DESKTOP ENHANCEMENTS
===================================================== */
@media (min-width: 768px) {
  .chqme-modal {
    padding: 0 20px 0;
  }
}

/* ===============================
   MOBILE OPTIMIZATION
================================ */
@media (max-width: 640px) {
  /* ── Hitbox-desync fix ──────────────────────────────────
     Replace transform centering with flexbox centering.
     transform: translate(-50%,-50%) + slide-up animation creates a
     compositor layer whose hit-test coordinates desync from the
     visual paint on mobile WebKit/Blink after the animation ends. */
  #chqme-modal {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Modal shell: flexbox-centered, no transform */
  .chqme-modal {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    transform: none;
    width: min(440px, calc(100vw - 20px));
    max-height: 88vh;
    padding: 0 12px 0;
    animation: chqme-modal-fade-in-mobile 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  }

  /* Iframe mode on mobile — also remove fixed/transform */
  .chqme-modal.chqme-modal--iframe {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    height: 80vh;
    max-height: 85vh;
  }

  /* TOPBAR: flex row, tighter gap + padding on mobile */
  .chqme-modal-topbar {
    gap: 4px;
    padding: 8px 2px 6px;
  }

  /* Keep topbar overlay in iframe mode on mobile */
  .chqme-modal--iframe .chqme-modal-topbar {
    padding: 6px 6px 6px;
  }

  /* Title — smaller on mobile */
  .chqme-modal-title {
    font-size: 14px;
  }

  /* Mobile-only keyframes — opacity only, no transform */
  @keyframes chqme-modal-fade-in-mobile {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}

/* ===============================
   VERY NARROW SCREENS (≤400px)
================================ */
@media (max-width: 400px) {
  .chqme-modal { width: calc(100vw - 12px); padding: 0 10px 0; }
  .chqme-modal-topbar { padding: 6px 2px 4px; }
}

/* =====================================================
   TOUCH DEVICE OPTIMIZATIONS
   Disable hover transforms to prevent touch offset bugs
===================================================== */
@media (hover: none) and (pointer: coarse) {
  /* Close button — bigger touch target on mobile */
  .chqme-close {
    min-width: 36px;
    min-height: 36px;
  }
}

/* =====================================================
   STOREFRONT "BOOK DEMO" BUTTON (below Buy it now)
===================================================== */
.chqme-demo-wrapper {
  width: 100%;
  max-width: 44rem;
  margin-left: 0;
  margin-right: auto;
  padding-left: 0;
  padding-right: 0;
}

/* BOOK DEMO Button - Black by default */
.chqme-demo-wrapper .chqme-book-demo {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-top: 12px;
  padding: 14px 20px !important;
  background: #000 !important;
  color: #fff !important;
  border: none !important;
  border-radius: 50px !important;
  text-align: center !important;
  cursor: pointer !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  position: relative !important;
  overflow: hidden !important;
}

/* Button label span — sits above the animated blue layer */
.chqme-demo-wrapper .chqme-book-demo > span {
  position: relative;
  z-index: 2;
  color: #fff;
  -webkit-text-fill-color: #fff;
  pointer-events: none;
}

/* Orange animated fill layer */
.chqme-demo-wrapper .chqme-book-demo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #c9572a;
  transform: translateX(-100%);
  will-change: transform;
  pointer-events: none;
  z-index: 1;
}

/* Hover-in: blue slides from left to right */
.chqme-demo-wrapper .chqme-book-demo.chqme-hover-in::before {
  transform: translateX(0);
  transition: transform 0.25s ease;
}

/* Hover-out: orange exits to left → black appears from right */
.chqme-demo-wrapper .chqme-book-demo.chqme-hover-out::before {
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}
