/* US A/1–A/6 guided onboarding paywall — design frames 402×822 (ui-us.pen) */

:root {
  --design-w: 402;
  --design-h: 822;
  --color-title: #484c55;
  --color-subtitle: #526786;
  --color-pill: #7c5cba;
  --color-cta-text: #ffffff;
  --color-pro-title: #55405f;
  --color-pro-sub: #756f88;
  --color-perk-title: #4e4562;
  --shadow-cta: 0 10px 24px rgba(184, 107, 154, 0.14);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  /*
   * Safe area: Android WebView usually reports env(safe-area-inset-*) as 0.
   * Flutter injects --native-safe-* from MediaQuery.viewPadding (logical px).
   * Prefer native when present; fall back to CSS env() for desktop/browser.
   */
  --native-safe-top: 0px;
  --native-safe-right: 0px;
  --native-safe-bottom: 0px;
  --native-safe-left: 0px;
  --safe-top: max(var(--native-safe-top), env(safe-area-inset-top, 0px));
  --safe-right: max(var(--native-safe-right), env(safe-area-inset-right, 0px));
  --safe-bottom: max(var(--native-safe-bottom), env(safe-area-inset-bottom, 0px));
  --safe-left: max(var(--native-safe-left), env(safe-area-inset-left, 0px));
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --page-ms: 480ms;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  font-family: var(--font);
  background: #0b0b12;
  color: var(--color-title);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  overflow: hidden;
}

body.is-preview {
  overflow: auto;
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a1b3d 0%, transparent 55%),
    #0b0b12;
}

/* —— Desktop preview chrome —— */
.preview-chrome {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 14px 18px 10px;
  background: rgba(12, 12, 18, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #e8e4f0;
}

.preview-chrome[hidden] {
  display: none !important;
}

.preview-chrome__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-chrome__title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preview-chrome__title strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.preview-chrome__title span {
  font-size: 12px;
  opacity: 0.7;
}

.preview-chrome__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f4f0ff;
  border-radius: 999px;
  padding: 7px 12px;
  font: 600 12px/1 var(--font);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
}

.chip--link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.preview-chrome__hint {
  margin: 10px 0 0;
  font-size: 12px;
  opacity: 0.55;
}

.preview-chrome__hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
}

/* —— Stage / phone shell —— */
.stage {
  min-height: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 0;
}

body.is-preview .stage {
  padding: 28px 16px 48px;
}

.phone {
  width: 100%;
  height: 100%;
  max-width: none;
  position: relative;
}

body.is-preview .phone {
  width: min(402px, 100%);
  height: min(822px, calc(100dvh - 140px));
  max-height: 822px;
  border-radius: 36px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 8px 24px rgba(120, 80, 140, 0.25);
}

/* —— Paywall surface —— */
.paywall {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f6eef9;
  isolation: isolate;
  --u: calc(100% / var(--design-w));
  --v: calc(100% / var(--design-h));
}

.paywall.is-pro {
  background: #f3e8f6;
}

/* Backgrounds */
.paywall__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity var(--page-ms) var(--ease-out);
}

.paywall__bg-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  user-select: none;
  -webkit-user-drag: none;
}

.paywall__bg--pro {
  opacity: 0;
}

.paywall.is-pro .paywall__bg--shared {
  opacity: 0;
}

.paywall.is-pro .paywall__bg--pro {
  opacity: 1;
}

/* —— Feature stack (A/1–A/5) —— */
.feature-stack {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transition: opacity var(--page-ms) var(--ease-out);
}

.paywall.is-pro .feature-stack {
  opacity: 0;
  pointer-events: none;
}

.feature {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateX(18px) scale(0.985);
  transition:
    opacity var(--page-ms) var(--ease-out),
    transform var(--page-ms) var(--ease-out),
    visibility 0s linear var(--page-ms);
  /* Skip paint for offscreen steps */
  content-visibility: hidden;
  contain: layout paint style;
  pointer-events: none;
}

.feature.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0) scale(1);
  transition:
    opacity var(--page-ms) var(--ease-out),
    transform var(--page-ms) var(--ease-out),
    visibility 0s linear 0s;
  content-visibility: visible;
}

/* Promote only while a step transition is in flight (set by JS). */
.paywall.is-animating .feature.is-active,
.paywall.is-animating .feature.is-exit-left {
  will-change: opacity, transform;
}

.feature.is-exit-left {
  opacity: 0;
  visibility: visible;
  transform: translateX(-22px) scale(0.985);
  transition:
    opacity var(--page-ms) var(--ease-out),
    transform var(--page-ms) var(--ease-out);
}

.feature.is-enter-right {
  opacity: 0;
  transform: translateX(28px) scale(0.99);
}

/* Hero collage per step — design coords on 402×822 */
.feature__hero {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

.feature__hero-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
  /* Soften decode cost on large collages */
  image-rendering: auto;
}

/* Animate hero only on the active step; skip re-running after settle. */
.feature.is-active .feature__hero-img {
  animation: heroIn 0.5s var(--ease-out) both;
}

/* A/1: -12,-12 432×572 */
.feature__hero--1 {
  left: calc(-12 * var(--u));
  top: calc(-12 * var(--v));
  width: calc(432 * var(--u));
  height: calc(572 * var(--v));
}

/* A/2: -50,-22 502×651 */
.feature__hero--2 {
  left: calc(-50 * var(--u));
  top: calc(-22 * var(--v));
  width: calc(502 * var(--u));
  height: calc(651 * var(--v));
}

/* A/3: -53,-32 508×613 */
.feature__hero--3 {
  left: calc(-53 * var(--u));
  top: calc(-32 * var(--v));
  width: calc(508 * var(--u));
  height: calc(613 * var(--v));
}

/* A/4: -40,0 481×593 */
.feature__hero--4 {
  left: calc(-40 * var(--u));
  top: 0;
  width: calc(481 * var(--u));
  height: calc(593 * var(--v));
}

/* A/5: -51,0 503×629 */
.feature__hero--5 {
  left: calc(-51 * var(--u));
  top: 0;
  width: calc(503 * var(--u));
  height: calc(629 * var(--v));
}

/* Decorations (pill / stickers) */
.feature__deco {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 4;
  pointer-events: none;
}

.feature__deco--1 {
  /* Full-bleed absolute layer so butterfly can sit at design coords */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: auto;
}

.feature__pill {
  position: absolute;
  /* Design: x106 y452.5 w190 h34 on 402×822 */
  left: 50%;
  top: calc(452.5 * var(--v));
  transform: translateX(-50%);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  min-width: 190px;
  padding: 0 14px;
  border-radius: 17px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  /* Solid-ish fill instead of expensive backdrop-filter on WebView */
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 6px 18px rgba(140, 110, 180, 0.1);
}

.feature__pill-label {
  color: var(--color-pill);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
}

.feature__sticker {
  position: absolute;
  object-fit: contain;
  pointer-events: none;
}

/*
 * A/1 butterfly — design node uEkN0: x90 y425 61×57, rot 27.3° CCW (Pencil top-left).
 * Crystal sticker is near-white on pastel bg; single drop-shadow (cheaper than multi-filter)
 * + baked contrast in the webp for edge definition.
 */
.feature__sticker--butterfly {
  z-index: 3;
  /* Design uEkN0: x90 y425 61×57; nudge +2px size so crystal edge reads on pastel */
  left: calc(88 * var(--u));
  top: calc(422 * var(--v));
  width: calc(66 * var(--u));
  height: calc(62 * var(--v));
  /* Pencil rotates around top-left; match so it sits on the pill corner */
  transform: rotate(-27.3deg);
  transform-origin: 0 0;
  /* Single cheap drop-shadow (no multi-filter / contrast on WebView) */
  filter: drop-shadow(0 1px 2px rgba(60, 40, 100, 0.5));
  animation: butterflyFloat 5s ease-in-out infinite;
}

/* A/2 CD sticker — design x≈226 y≈437, 83×81, rot -15°, opacity 0.5 */
.feature__deco--2 {
  top: 0;
  height: 100%;
}

.feature__sticker--cd {
  left: calc(226 * var(--u));
  top: calc(437 * var(--v));
  width: calc(83 * var(--u));
  height: calc(81 * var(--v));
  opacity: 0.55;
  transform: rotate(-15deg);
  filter: drop-shadow(0 4px 10px rgba(90, 70, 130, 0.2));
}

/* Copy */
.feature__copy {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(520 * var(--v));
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 calc(34 * var(--u));
  text-align: center;
}

.feature__copy--short {
  top: calc(540 * var(--v));
}

.feature.is-active .feature__copy {
  animation: contentIn 0.65s var(--ease-out) 0.06s both;
}

.feature__title {
  margin: 0;
  max-width: 334px;
  width: 100%;
  color: var(--color-title);
  font-size: clamp(28px, 8.5vw, 34px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.feature__subtitle {
  margin: 12px 0 0;
  max-width: 312px;
  color: var(--color-subtitle);
  font-size: clamp(14px, 4vw, 16px);
  font-weight: 400;
  line-height: 1.45;
}

/* —— Continue footer (steps 0–4) —— */
.paywall__footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Keep CTA + legal above gesture / 3-button nav bars */
  padding:
    0 calc(34 * var(--u))
    max(18px, calc(var(--safe-bottom) + 16px));
  text-align: center;
  transition:
    opacity var(--page-ms) var(--ease-out),
    transform var(--page-ms) var(--ease-out);
}

.paywall__footer--continue {
  gap: 10px;
}

.paywall.is-pro .paywall__footer--continue {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

.paywall__dots {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  height: 10px;
  margin-top: 2px;
}

.paywall__dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(82, 103, 134, 0.22);
  transition:
    width 0.28s var(--ease-out),
    background 0.28s ease;
}

.paywall__dot.is-active {
  width: 16px;
  background: linear-gradient(90deg, #f3a2c1, #82ddf8);
}

/* CTA buttons */
.paywall__cta {
  position: relative;
  width: min(334px, 100%);
  height: 56px;
  min-height: 56px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--color-cta-text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  background-image: linear-gradient(
    90deg,
    #ffd8ea 0%,
    #f3a2c1 48%,
    #82ddf8 100%
  );
  box-shadow: var(--shadow-cta);
  transition:
    transform 0.18s var(--ease-out),
    box-shadow 0.18s ease,
    filter 0.18s ease;
}

.paywall__cta--continue {
  /* design gradient left pink→cyan matches screenshots */
  background-image: linear-gradient(
    90deg,
    #ffd8ea 0%,
    #f3a2c1 48%,
    #82ddf8 100%
  );
}

.paywall__cta--trial {
  width: 100%;
  height: 54px;
  min-height: 54px;
  border-width: 0;
  border-radius: 27px;
  font-size: 15px;
  background-image: linear-gradient(90deg, #f39bc5 0%, #8ebceb 100%);
  box-shadow: 0 8px 18px rgba(181, 141, 200, 0.33);
}

.paywall__cta::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(
    105deg,
    transparent 35%,
    rgba(255, 255, 255, 0.45) 50%,
    transparent 65%
  );
  transform: translateX(-120%);
  animation: ctaShimmer 3.6s ease-in-out 1.2s infinite;
  pointer-events: none;
}

.paywall__cta-label,
.paywall__cta-spinner {
  position: relative;
  z-index: 1;
}

.paywall__cta:hover {
  filter: brightness(1.03);
  box-shadow: 0 12px 28px rgba(184, 107, 154, 0.22);
}

.paywall__cta:active {
  transform: scale(0.975);
}

.paywall__cta:focus-visible {
  outline: 3px solid rgba(124, 92, 186, 0.45);
  outline-offset: 3px;
}

.paywall__cta[disabled],
.paywall.is-busy .paywall__cta--trial {
  cursor: progress;
  filter: saturate(0.92);
}

.paywall__cta-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

.paywall.is-busy .paywall__cta-spinner {
  display: inline-block;
}

.paywall.is-busy .paywall__cta-label {
  opacity: 0.92;
}

.paywall__legal {
  margin: 12px 0 0;
  color: #8a96a8;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  opacity: 0.9;
}

/* Close — always below status bar / notch */
.paywall__close {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  right: max(14px, calc(var(--safe-right) + 10px));
  z-index: 20;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #5a4a6a;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 4px 14px rgba(80, 60, 100, 0.12);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.9);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    background 0.15s ease;
}

.paywall__close:not([hidden]) {
  opacity: 1;
  transform: scale(1);
}

.paywall__close:active {
  background: rgba(255, 255, 255, 0.92);
  transform: scale(0.94);
}

/* Error */
.paywall__error {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: max(88px, calc(var(--safe-bottom) + 88px));
  z-index: 15;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(60, 30, 50, 0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  /* No backdrop-filter — expensive / janky in Android WebView */
}

.paywall__error[hidden] {
  display: none;
}

/* —— PRO page (A/6) —— */
.pro {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding:
    max(16px, calc(var(--safe-top) + 10px))
    calc(23 * var(--u))
    max(12px, calc(var(--safe-bottom) + 12px));
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px) scale(0.98);
  pointer-events: none;
  transition:
    opacity var(--page-ms) var(--ease-out),
    transform var(--page-ms) var(--ease-out),
    visibility 0s linear var(--page-ms);
}

.paywall.is-pro .pro {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition:
    opacity var(--page-ms) var(--ease-out),
    transform var(--page-ms) var(--ease-out),
    visibility 0s linear 0s;
}

.pro__card {
  position: relative;
  width: 100%;
  max-width: 356px;
  margin: 0 auto;
  padding: 18px 12px 14px;
  border-radius: 28px;
  /* Avoid backdrop-filter in Android WebView (expensive, often janky) */
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow:
    0 18px 48px rgba(140, 100, 170, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.pro__logo {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ffd6e8 0%, #d9ecff 100%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 16px rgba(201, 142, 184, 0.33);
  color: #6e4b79;
  flex-shrink: 0;
}

.pro__crown {
  display: block;
}

.pro__title {
  margin: 16px 0 0;
  color: var(--color-pro-title);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-align: center;
}

.pro__subtitle {
  margin: 4px 0 0;
  color: var(--color-pro-sub);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
}

.pro__features {
  width: 100%;
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pro__chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.47);
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: var(--color-perk-title);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

.pro__chip svg {
  flex-shrink: 0;
}

.pro__more-label {
  width: 100%;
  margin: 16px 0 8px;
  color: #a64e83;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: left;
  padding-left: 4px;
}

.pro__perks {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
}

.pro__perk {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 51px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.pro__perk-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.pro__perk-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pro__perk-copy strong {
  color: var(--color-perk-title);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.pro__perk-copy em {
  color: var(--color-pro-sub);
  font-size: 10px;
  font-style: normal;
  font-weight: 500;
  line-height: 1.25;
}

/* No price card — CTA sits under perks with breathing room */
.pro__footer {
  width: 100%;
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* —— Motion —— */
@keyframes heroIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(1.03);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes contentIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes butterflyFloat {
  0%,
  100% {
    transform: rotate(-27.3deg) translate(0, 0);
  }
  50% {
    transform: rotate(-22deg) translate(1px, -4px);
  }
}

@keyframes ctaShimmer {
  0%,
  55% {
    transform: translateX(-120%);
  }
  80%,
  100% {
    transform: translateX(120%);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .feature,
  .feature-stack,
  .pro,
  .paywall__bg,
  .paywall__footer--continue,
  .feature__hero-img,
  .feature__sticker--butterfly,
  .feature.is-active .feature__copy,
  .paywall__cta::before {
    animation: none !important;
    transition: none !important;
  }

  .feature {
    transform: none;
  }

  .feature.is-active {
    transform: none;
  }
}

@media (min-aspect-ratio: 9/18) {
  .paywall__footer {
    padding-bottom: max(28px, calc(var(--safe-bottom) + 20px));
  }
}

@media (max-height: 700px) {
  .feature__title {
    font-size: 28px;
  }

  .feature__subtitle {
    margin-top: 8px;
    font-size: 14px;
  }

  .paywall__cta {
    height: 52px;
  }

  .pro__logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
  }

  .pro__title {
    font-size: 22px;
    margin-top: 10px;
  }

  .pro__features {
    margin-top: 12px;
  }

  .pro__more-label {
    margin-top: 12px;
  }

  .pro__perk {
    min-height: 46px;
    padding: 8px 10px;
  }

  .pro__footer {
    padding-top: 12px;
  }

  .paywall__legal {
    margin-top: 8px;
  }
}
