/* ─────────────────────────────────────────────────────────────────────────
   In-page membership purchase — sign-in + payment sheet.

   The "never leave the membership page" flow (Design Studio): tapping a tier
   CTA raises a bottom sheet that runs email-OTP sign-in and then mounts Stripe
   Embedded Checkout in-place. Motion + tokens mirror the app's Sheet.jsx so the
   marketing page feels like the app. Everything degrades: if JS or Stripe fail,
   the underlying <a href="/app/?intent=subscribe…"> still navigates.
   ───────────────────────────────────────────────────────────────────────── */

.uki-sheet-backdrop {
  position: fixed;
  inset: 0;
  /* Pin the flex-end anchor to the VISUAL viewport bottom. With plain
     `inset:0`, iOS Safari measures `bottom:0` against the taller layout
     viewport (which extends behind the floating toolbar), so a bottom-anchored
     sheet lands partly below the fold and reads as "short sheeted." 100dvh
     tracks the visible area, lifting the whole sheet into view. */
  height: 100vh;
  height: 100dvh;
  z-index: 1000;
  background: rgba(16, 22, 38, 0);
  -webkit-backdrop-filter: blur(0px);
  backdrop-filter: blur(0px);
  opacity: 0;
  transition:
    background 240ms var(--ease-exit, ease),
    backdrop-filter 240ms var(--ease-exit, ease),
    opacity 240ms var(--ease-exit, ease);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
/* Closed state MUST NOT intercept taps. checkout.js toggles the `hidden`
   attribute to open/close, but the `display:flex` above overrides the UA
   `[hidden]{display:none}` rule, leaving an invisible full-screen fixed
   overlay (opacity:0 still receives pointer events) that swallows every click
   on the page — so the tier CTAs read as dead. Restore hidden semantics.
   (Fix on top of the sibling session's original checkout.css.) */
.uki-sheet-backdrop[hidden] {
  display: none;
}
.uki-sheet-backdrop.is-open {
  background: rgba(16, 22, 38, 0.4);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 1;
}

.uki-sheet {
  position: relative;
  width: 100%;
  max-width: 468px;
  max-height: 94vh;
  max-height: 94dvh;
  background: var(--paper, #f9f7f2);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 40px rgba(16, 22, 38, 0.28);
  transform: translateY(100%);
  /* Gentle spring overshoot on the rise — the sheet settles rather than glides,
     matching iOS sheet physics. (Reduced-motion swaps this for a plain ease.) */
  transition: transform 480ms cubic-bezier(0.32, 1.12, 0.5, 1);
  will-change: transform;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.uki-sheet-backdrop.is-open .uki-sheet {
  transform: translateY(0);
}
/* While a finger is dragging the sheet we drive transform inline and want it
   to track the finger 1:1 — kill the spring transition for that window. */
.uki-sheet.is-dragging {
  transition: none;
}
@media (min-width: 520px) {
  .uki-sheet-backdrop {
    align-items: center;
  }
  .uki-sheet {
    border-radius: 22px;
    max-height: 90vh;
  }
}

.uki-grabber {
  flex: 0 0 auto;
  padding: 10px 0 4px;
  display: flex;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}
.uki-grabber::before {
  content: "";
  width: 38px;
  height: 5px;
  border-radius: 3px;
  background: color-mix(in oklab, var(--navy, #1a2b4c) 22%, transparent);
}

.uki-sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: color-mix(in oklab, var(--navy, #1a2b4c) 8%, transparent);
  color: var(--navy, #1a2b4c);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background 160ms ease,
    transform 120ms var(--ease-spring, ease);
}
.uki-sheet-close:hover {
  background: color-mix(in oklab, var(--navy, #1a2b4c) 14%, transparent);
}
.uki-sheet-close:active {
  transform: scale(0.92);
}

/* Scrollable content column. */
.uki-sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 24px 26px;
}

/* Tier header — echoes what they're buying so the thread is never lost. */
.uki-tier-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 40px 16px 2px;
}
.uki-tier-name {
  font-family: var(--serif, Georgia, serif);
  font-size: 27px;
  font-weight: 600;
  color: var(--navy, #1a2b4c);
  line-height: 1;
}
.uki-tier-price {
  font-family: var(--font-num, system-ui);
  font-size: 15px;
  font-weight: 600;
  color: var(--amber-ink, #8c6526);
  letter-spacing: 0.01em;
}

/* Steps cross-fade in place; the sheet frame stays put (Design Studio spec). */
.uki-step {
  display: none;
  animation: ukiStepIn 200ms var(--ease-enter, ease) both;
}
.uki-step.is-active {
  display: block;
}
@keyframes ukiStepIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.uki-step h2 {
  font-family: var(--serif, Georgia, serif);
  font-size: 24px;
  font-weight: 600;
  color: var(--navy, #1a2b4c);
  margin: 0 0 6px;
  line-height: 1.15;
}
.uki-step p.uki-sub {
  font-family: var(--sans, system-ui);
  font-size: 14.5px;
  color: var(--mid, #4a4438);
  margin: 0 0 18px;
  line-height: 1.5;
}

.uki-field {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--sans, system-ui);
  font-size: 16px; /* ≥16px so iOS never zooms the field on focus */
  color: var(--text, #1c1a16);
  background: #fff;
  border: 1.5px solid var(--rule, #e2dcce);
  border-radius: 13px;
  padding: 14px 16px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
  -webkit-appearance: none;
  appearance: none;
}
.uki-field:focus {
  outline: none;
  border-color: var(--amber, #d4a058);
  box-shadow: 0 0 0 4px
    color-mix(in oklab, var(--amber, #d4a058) 22%, transparent);
}
.uki-field::placeholder {
  color: var(--light, #7a7264);
}

/* 6-digit code — native-iOS segmented cells. A single real <input> (best for
   one-time-code autofill + paste) sits transparent over six visual cells that
   render the digits. The input owns focus; the cells own the look. */
.uki-otp {
  position: relative;
  margin-top: 2px;
}
.uki-otp-cells {
  display: flex;
  gap: 8px;
}
.uki-otp-cell {
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 3 / 4;
  max-height: 60px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1.5px solid var(--rule, #e2dcce);
  border-radius: 12px;
  font-family: var(--font-num, system-ui);
  font-size: 26px;
  font-weight: 600;
  color: var(--text, #1c1a16);
  font-variant-numeric: tabular-nums;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms var(--ease-spring, ease);
}
/* Filled cell gets a subtle lift; the active (next-to-fill) cell gets the amber
   focus ring + a blinking caret — only while the hidden input holds focus. */
.uki-otp-cell.is-filled {
  border-color: color-mix(
    in oklab,
    var(--amber, #d4a058) 55%,
    var(--rule, #e2dcce)
  );
}
.uki-otp.is-focused .uki-otp-cell.is-active {
  border-color: var(--amber, #d4a058);
  box-shadow: 0 0 0 4px
    color-mix(in oklab, var(--amber, #d4a058) 22%, transparent);
  transform: translateY(-1px);
}
.uki-otp.is-focused .uki-otp-cell.is-active::after {
  content: "";
  width: 2px;
  height: 26px;
  background: var(--amber, #d4a058);
  border-radius: 1px;
  animation: ukiCaret 1s steps(1) infinite;
}
.uki-otp-cell.is-filled::after {
  display: none;
}
@keyframes ukiCaret {
  50% {
    opacity: 0;
  }
}
/* The real input: transparent, covering all six cells, caret hidden (the cell
   draws its own). */
.uki-otp-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px; /* keep ≥16px so iOS never zooms on focus */
  text-align: center;
  letter-spacing: 2em;
  outline: none;
  cursor: text;
  -webkit-appearance: none;
  appearance: none;
}
.uki-otp-input::selection {
  background: transparent;
}

.uki-btn-full {
  width: 100%;
  margin-top: 14px;
}
.uki-btn-full:active {
  transform: scale(0.985);
}

.uki-inline-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--amber-ink, #8c6526);
  font-family: var(--sans, system-ui);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.uki-inline-btn:disabled {
  color: var(--light, #7a7264);
  cursor: default;
  text-decoration: none;
}

.uki-meta {
  margin-top: 16px;
  font-family: var(--sans, system-ui);
  font-size: 12.5px;
  color: var(--light, #7a7264);
  line-height: 1.5;
  text-align: center;
}
.uki-meta a {
  color: var(--amber-ink, #8c6526);
}

/* "No account needed" reassurance under the sign-in form. A quiet secondary
   line (Design Studio: never a competing button in the sign-in step). */
.uki-newuser {
  margin: 14px 2px 0;
  font-family: var(--sans, system-ui);
  font-size: 13px;
  line-height: 1.5;
  color: rgba(26, 43, 76, 0.6);
  text-align: center;
}
/* Success-step download CTA: the App Store hand-off is the hero of the
   post-purchase moment, so give it room above the fine print. */
.uki-success-cta {
  margin-top: 22px;
}

.uki-error {
  margin-top: 12px;
  font-family: var(--sans, system-ui);
  font-size: 13.5px;
  color: var(--rust, #b46545);
  line-height: 1.45;
  min-height: 0;
}

/* Spinner used on buttons + loading steps. */
.uki-spin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid color-mix(in oklab, currentColor 28%, transparent);
  border-top-color: currentColor;
  animation: ukiSpin 720ms linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes ukiSpin {
  to {
    transform: rotate(360deg);
  }
}

.uki-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 0 34px;
  color: var(--navy, #1a2b4c);
}
.uki-loading .uki-spin {
  width: 26px;
  height: 26px;
}
.uki-loading span {
  font-family: var(--sans, system-ui);
  font-size: 14px;
  color: var(--mid, #4a4438);
}

/* Stripe Embedded Checkout mounts here. */
#uki-embedded {
  min-height: 340px;
  margin-top: 4px;
}

/* Success moment — a self-drawing check + display type, then auto-lower. */
.uki-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 30px 0 26px;
}
.uki-check {
  width: 66px;
  height: 66px;
  margin-bottom: 18px;
}
.uki-check circle {
  fill: none;
  stroke: var(--amber, #d4a058);
  stroke-width: 5;
  opacity: 0.28;
}
.uki-check path {
  fill: none;
  stroke: var(--amber, #d4a058);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: ukiDraw 520ms var(--ease-enter, ease) 120ms forwards;
}
@keyframes ukiDraw {
  to {
    stroke-dashoffset: 0;
  }
}
.uki-success h2 {
  font-family: var(--serif, Georgia, serif);
  font-size: 27px;
  font-weight: 600;
  color: var(--navy, #1a2b4c);
  margin: 0 0 6px;
}
.uki-success p {
  font-family: var(--sans, system-ui);
  font-size: 14.5px;
  color: var(--mid, #4a4438);
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .uki-sheet-backdrop,
  .uki-sheet,
  .uki-step {
    transition-duration: 150ms;
    animation: none;
  }
  .uki-sheet {
    transition: transform 150ms ease; /* no spring overshoot */
  }
  .uki-check path {
    animation: none;
    stroke-dashoffset: 0;
  }
  .uki-spin {
    animation-duration: 1200ms;
  }
  .uki-otp-cell.is-active::after {
    animation: none; /* steady caret, no blink */
  }
}

/* Some users (and OLED/battery modes) ask for less transparency; drop the
   blur and lean on a more opaque scrim so text stays legible without it. */
@media (prefers-reduced-transparency: reduce) {
  .uki-sheet-backdrop.is-open {
    background: rgba(16, 22, 38, 0.62);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
