/*
 * Mobile hero composition
 *
 * Desktop keeps copy left / phone right. On narrow screens that overlay
 * collapses into illegible white-on-white. Mobile uses a split-altitude
 * stack: editorial copy + CTA in a charcoal ceiling band, phone as the
 * sole product proof in the open lower field. No overlays on the device.
 */

@media (max-width: 820px) {
  .hero-sticky {
    min-height: 100svh;
  }

  /* Vertical atmosphere: dense top band for type, open mid for the phone. */
  .hero-bg-overlay {
    background:
      linear-gradient(
        180deg,
        rgba(5, 5, 5, 0.98) 0%,
        rgba(5, 5, 5, 0.94) 20%,
        rgba(5, 5, 5, 0.5) 36%,
        rgba(5, 5, 5, 0.1) 50%,
        rgba(5, 5, 5, 0.22) 70%,
        rgba(5, 5, 5, 0.94) 100%
      ) !important;
  }

  .hero-sticky::before {
    background:
      radial-gradient(ellipse 70% 28% at 50% 70%, rgba(255, 255, 255, 0.05), transparent 72%);
  }

  .hero-sticky::after {
    height: max(16vh, calc(env(safe-area-inset-bottom) + 88px));
    background: linear-gradient(transparent, rgba(5, 5, 5, 0.94));
  }

  /* Copy lives in the ceiling band — short, centered, never over the screen. */
  .story-copy {
    top: max(88px, calc(env(safe-area-inset-top) + 72px)) !important;
    right: 20px;
    left: 20px !important;
    width: auto !important;
    min-height: 180px !important;
    padding: 0 4px 12px;
    text-align: center;
    transform: none !important;
    background: linear-gradient(
      180deg,
      rgba(5, 5, 5, 0.55) 0%,
      rgba(5, 5, 5, 0.22) 78%,
      rgba(5, 5, 5, 0) 100%
    );
  }

  .story-beat {
    justify-content: flex-start !important;
  }

  .story-beat h1,
  .story-beat h2 {
    max-width: 11.5ch;
    margin-inline: auto;
    font-size: clamp(36px, 7.2vw, 52px) !important;
    letter-spacing: -0.04em;
    line-height: 0.94 !important;
    /* Soft falloff under clipped glyphs — keeps edges readable on the phone. */
    filter: drop-shadow(0 1px 18px rgba(5, 5, 5, 0.55));
  }

  .hero-sticky .story-beat .supporting-copy,
  .story-copy .supporting-copy {
    max-width: 36ch !important;
    margin: 14px auto 0 !important;
    color: rgba(245, 246, 247, 0.8) !important;
    font-size: 15px !important;
    line-height: 1.5 !important;
    text-shadow: 0 1px 18px rgba(5, 5, 5, 0.7);
  }

  /*
   * CTA is portaled onto .hero-sticky by site-polish.js on mobile.
   * Absolute (not fixed) relative to the sticky hero — no containing-block traps.
   */
  .hero-sticky > .hero-actions {
    position: absolute !important;
    top: auto !important;
    right: 20px;
    bottom: max(78px, calc(env(safe-area-inset-bottom) + 68px));
    left: 20px;
    z-index: 28;
    display: flex;
    width: auto;
    max-width: none;
    height: auto !important;
    margin: 0 !important;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transform: none !important;
    filter: none !important;
    transition: opacity 220ms ease-out;
  }

  .hero-sticky:has(.stage-item[data-stage="0"].is-active) > .hero-actions {
    opacity: 1;
    pointer-events: auto;
  }

  .hero-sticky:has(.stage-item[data-stage="0"].is-active) > .hero-actions a {
    pointer-events: auto;
  }

  /* Single primary CTA under the phone on mobile. */
  .hero-sticky > .hero-actions .hero-pricing-cta {
    display: none !important;
  }

  .hero-sticky > .hero-actions .hero-waitlist-cta {
    position: relative;
    z-index: 25;
    width: min(280px, 100%);
    min-height: 48px !important;
    padding-inline: 28px !important;
    flex: 0 1 auto;
    box-shadow:
      0 14px 36px rgba(0, 0, 0, 0.45),
      0 0 0 1px rgba(255, 255, 255, 0.06);
  }

  /* If the portal has not run yet, keep in-beat CTAs out of the copy. */
  .story-beat .hero-actions {
    display: none !important;
  }

  #phone-canvas {
    z-index: 12;
    transform: none !important;
  }

  .final-copy {
    top: max(88px, calc(env(safe-area-inset-top) + 72px)) !important;
    width: calc(100% - 40px) !important;
  }

  .final-copy h2 {
    max-width: 10ch;
    margin-inline: auto;
    font-size: clamp(36px, 7.2vw, 52px) !important;
    line-height: 0.94 !important;
    filter: drop-shadow(0 1px 18px rgba(5, 5, 5, 0.55));
  }

  .stage-index {
    top: auto !important;
    right: 50% !important;
    bottom: max(28px, calc(env(safe-area-inset-bottom) + 20px)) !important;
    left: auto !important;
    width: min(340px, calc(100vw - 40px)) !important;
    transform: translateX(50%) !important;
    z-index: 34;
  }

  .stage-item {
    min-height: 40px;
  }

  .stage-item:hover,
  .stage-item:focus-visible,
  .stage-item.is-active {
    transform: translateY(-2px) !important;
  }

  .measurement-stage {
    top: 58% !important;
    width: min(96vw, 520px) !important;
  }
}

@media (max-width: 560px) {
  .story-copy {
    top: max(84px, calc(env(safe-area-inset-top) + 68px)) !important;
    right: 16px;
    left: 16px !important;
    min-height: 160px !important;
  }

  .story-beat h1,
  .story-beat h2,
  .final-copy h2 {
    max-width: 10.5ch;
    font-size: clamp(32px, 8.6vw, 42px) !important;
  }

  .hero-sticky .story-beat .supporting-copy,
  .story-copy .supporting-copy {
    max-width: 30ch !important;
    margin-top: 12px !important;
    font-size: 13.5px !important;
  }

  .hero-sticky > .hero-actions {
    right: 16px;
    bottom: max(70px, calc(env(safe-area-inset-bottom) + 60px));
    left: 16px;
  }

  .hero-sticky > .hero-actions .hero-waitlist-cta {
    width: 100%;
    max-width: 280px;
    min-height: 46px !important;
    margin-inline: auto;
    font-size: 11px !important;
  }

  .final-copy {
    top: max(80px, calc(env(safe-area-inset-top) + 64px)) !important;
    width: calc(100% - 32px) !important;
  }

  .stage-index {
    bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px)) !important;
    width: calc(100vw - 32px) !important;
  }
}

/* Short landscape phones: keep copy compact so the device still reads. */
@media (max-width: 820px) and (max-height: 700px) {
  .story-copy {
    top: max(72px, calc(env(safe-area-inset-top) + 56px)) !important;
    min-height: 140px !important;
    padding-bottom: 8px;
  }

  .story-beat h1,
  .story-beat h2 {
    font-size: clamp(28px, 7.5vw, 36px) !important;
  }

  .hero-sticky .story-beat .supporting-copy,
  .story-copy .supporting-copy {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin-top: 8px !important;
    font-size: 12.5px !important;
  }

  .hero-sticky > .hero-actions {
    bottom: max(58px, calc(env(safe-area-inset-bottom) + 48px));
  }

  .stage-index {
    bottom: max(12px, calc(env(safe-area-inset-bottom) + 8px)) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-actions .hero-waitlist-cta,
  .hero-actions .hero-pricing-cta,
  .hero-waitlist-cta {
    transition: none;
  }
}

/*
 * Resend-style editorial light on hero headlines.
 * Bright along the crown of each glyph, cooling toward the baseline.
 * Lives in this last stylesheet so cascade always wins.
 */
.hero-sticky .story-beat h1,
.hero-sticky .story-beat h2,
.hero-sticky .final-copy h2 {
  color: transparent;
  background-image: linear-gradient(
    180deg,
    #ffffff 0%,
    #f7f8fa 42%,
    #d0d4dc 72%,
    #a7adb8 100%
  );
  background-repeat: no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
}
