/* Upgrade — the paywall (light cream/purple original styling), shared by the
   #/upgrade screen and the locked-preview sheet (.paywall), plus the
   post-checkout #/paid screen. */

.paywall .upgrade-close-row {
  flex-shrink: 0;
  display: flex;
  padding: 0 var(--s-lg);
}

/* 36px close with a 44px touch target. */
.paywall .hit-44 {
  position: relative;
}
.paywall .hit-44::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
}

.paywall .upgrade-scroll {
  flex: 1;
  min-height: 0;
}

/* Centered column; on tall screens it sits in the middle of the free space. */
.paywall .upgrade-content {
  min-height: 100%;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-xs) var(--s-lg) var(--s-lg);
}

.paywall .upgrade-wordmark {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  color: var(--accent);
}

.paywall .upgrade-headline {
  margin: 2px 0 var(--s-lg);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1.12;
  text-align: center;
  color: var(--text);
}
.paywall .upgrade-headline span {
  color: var(--accent);
}

/* ---------- Template thumbnails + rotating prank idea ---------- */

.paywall .idea-rotator {
  width: 100%;
  min-height: 48px; /* ≥44px touch target even when the thumbnails are hidden */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--s-lg);
  text-align: center;
}

.paywall .idea-thumbs {
  display: flex;
  justify-content: center;
  padding: 4px 0;
  margin-bottom: var(--s-xs);
}

.paywall .idea-thumb {
  position: relative;
  width: 36px;
  height: 36px;
  margin-left: -7px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-muted);
  box-shadow: 0 0 0 2px #fff, var(--sh-soft);
  transition: transform 0.4s var(--spring), box-shadow 0.3s ease;
}
.paywall .idea-thumb:first-child {
  margin-left: 0;
}
.paywall .idea-thumb.active {
  z-index: 1;
  transform: translateY(-2px) scale(1.12);
  box-shadow: 0 0 0 2px var(--accent), 0 4px 10px rgba(98, 66, 217, 0.22);
}
.paywall .idea-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.paywall .idea-lines {
  position: relative;
  display: block;
  width: 100%;
  height: 22px;
}

.paywall .idea-line {
  position: absolute;
  inset: 0;
  display: block;
  font-size: 15px;
  font-weight: 500;
  line-height: 22px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.paywall .idea-line.active {
  opacity: 1;
}

.paywall .idea-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: var(--s-sm);
}

.paywall .idea-dot {
  width: 7px;
  height: 7px;
  border-radius: 4px;
  background: var(--border-strong);
  transition: width 0.35s var(--ease-out), background-color 0.35s ease;
}
.paywall .idea-dot.active {
  width: 18px;
  background: var(--accent);
}

/* ---------- Draft photo notice ---------- */

.paywall .draft-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  margin-bottom: var(--s-md);
  padding: 7px var(--s-md) 7px 7px;
  border-radius: var(--r-md);
  background: var(--accent-tint);
  text-align: left;
  animation: fadeIn 0.3s ease both;
}
.paywall .draft-thumb {
  flex-shrink: 0;
  width: 30px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 0 0 2px #fff;
}
.paywall .draft-text {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--accent-dark);
  text-wrap: pretty;
}

/* ---------- Segmented control ---------- */

/* Buttons fill the whole 48px track (full touch target); the thumb is inset. */
.paywall .segmented {
  position: relative;
  width: 100%;
  height: 48px;
  display: flex;
  padding: 0;
  margin-bottom: var(--s-md);
  border-radius: var(--r-pill);
  background: var(--surface-muted);
}

.paywall .seg-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(26, 28, 34, 0.08), var(--sh-soft);
  transition: transform 0.4s cubic-bezier(0.3, 1.22, 0.5, 1);
}
.paywall .segmented[data-plan='yearly'] .seg-thumb {
  transform: translateX(100%);
}

.paywall .seg-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--r-pill);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  transition: color 0.25s ease;
}
.paywall .seg-btn[aria-selected='true'] {
  color: var(--text);
  font-weight: 700;
}
/* "Save N%" chip next to a plan label (computed in plans.js, rounded down). */
.paywall .seg-save {
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  line-height: 15px;
  white-space: nowrap;
}

/* ---------- Plan card ---------- */

.paywall .plan-slot {
  width: 100%;
}

.paywall .plan-card {
  width: 100%;
  padding: 14px 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-soft);
  overflow: hidden;
}

.paywall .trial-row {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-sm);
  text-align: left;
}
.paywall .trial-row[hidden],
.paywall .plan-divider[hidden] {
  display: none;
}

.paywall .trial-label {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
}

.paywall .ios-switch {
  position: relative;
  flex-shrink: 0;
  width: 51px;
  height: 31px;
  border-radius: 16px;
  background: #e9e5e1;
  transition: background-color 0.25s ease;
}
.paywall .ios-switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.3s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.paywall .trial-row[aria-checked='true'] .ios-switch {
  background: var(--accent);
}
.paywall .trial-row[aria-checked='true'] .knob {
  transform: translateX(20px);
}
.paywall .trial-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 12px;
}

.paywall .plan-divider {
  height: 1px;
  margin: 10px 0 16px;
  background: var(--border);
}

.paywall .plan-card.no-trial {
  padding-top: 18px;
}

/* Timeline: dot — line — dot, one row per billing moment. */
.paywall .timeline {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.paywall .tl-row {
  position: relative;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  column-gap: var(--s-sm);
  align-items: start;
}
/* Line 1: title … pill / accent; line 2: sub … price. Each wraps on its own: when the pill doesn't
   fit next to the title (Swedish at 360px) it moves under it; the title is never cut. */
.paywall .tl-body {
  min-width: 0;
}
.paywall .tl-head,
.paywall .tl-detail {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  column-gap: var(--s-sm);
}
.paywall .tl-head {
  align-items: center;
  row-gap: 2px;
}
.paywall .tl-detail {
  flex-wrap: nowrap;
  align-items: flex-start;
  margin-top: 3px;
}
.paywall .tl-detail .tl-sub {
  flex: 1 1 auto;
  min-width: 0;
}
.paywall .tl-detail .tl-muted {
  flex: none;
  margin-left: auto;
  text-align: right;
}
/* Line from this row's dot (center 12px down) to the next row's dot. */
.paywall .tl-row:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 12px;
  bottom: -30px;
  width: 2px;
  border-radius: 1px;
  background: var(--accent-soft);
}

.paywall .tl-dot {
  position: relative;
  z-index: 1;
  width: 12px;
  height: 12px;
  margin: 6px 0 0 1px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.paywall .tl-title {
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 24px;
  color: var(--text);
  overflow-wrap: anywhere;
}
.paywall .tl-sub {
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  color: var(--text-2);
}

.paywall .tl-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  white-space: nowrap;
}
.paywall .tl-accent {
  font-size: 15px;
  font-weight: 700;
  line-height: 24px;
  color: var(--accent);
  white-space: nowrap;
}
.paywall .tl-muted {
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  color: var(--text-2);
  white-space: nowrap;
}
/* Intro offer: regular price struck through next to today's price. */
.paywall .tl-price {
  font-size: 15px;
  line-height: 22px;
}
.paywall .tl-was {
  color: var(--text-2);
  font-weight: 500;
  text-decoration-thickness: 1.5px;
}
.paywall .tl-now {
  color: var(--text);
  font-weight: 800;
}

/* ---------- Footer: CTA + fine print (always visible) ---------- */

.paywall .upgrade-footer {
  flex-shrink: 0;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: var(--s-sm) var(--s-lg) calc(var(--safe-bottom) + 16px);
}

.paywall .paywall-cta {
  border-radius: var(--r-md);
}

.paywall .fine-print {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  color: var(--text-2);
  text-wrap: balance;
}
/* Intro terms: today's price AND the recurring price, as readable as the rest of the footer. */
.paywall .fine-print.fine-intro {
  color: var(--text);
  font-size: 13px;
  line-height: 17px;
}

/* "Cancel anytime" reassurance above the CTA. */
.paywall .cancel-note {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 17px;
  color: var(--text);
  text-align: center;
  text-wrap: balance;
}
/* Inline, so it stays next to the text even if a long translation wraps. */
.paywall .cancel-note-icon {
  display: inline-flex;
  vertical-align: -3px;
  margin-right: 6px;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 11px;
}
.paywall .cancel-note-icon ion-icon {
  --ionicon-stroke-width: 64px;
}

.paywall .legal-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  margin-top: 6px;
}

/* 11px links (like the app) with a ~44px tall touch target. */
.paywall .legal-link {
  position: relative;
  padding: 15px 2px;
  margin: -15px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-decoration: underline;
  text-underline-offset: 2px;
  -webkit-tap-highlight-color: transparent;
}
.paywall .legal-dot {
  margin: 0 var(--s-xs);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
}

/* ---------- Tall screens: roomier rhythm, column a bit above center ---------- */

@media (min-height: 800px) {
  .paywall .upgrade-content {
    padding-bottom: 52px;
    padding-bottom: calc(var(--s-lg) + 4dvh);
  }
  .paywall .upgrade-headline {
    margin-bottom: 28px;
  }
  .paywall .idea-thumbs {
    margin-bottom: var(--s-sm);
  }
  .paywall .idea-rotator {
    margin-bottom: 32px;
  }
  .paywall .draft-row,
  .paywall .segmented {
    margin-bottom: var(--s-lg);
  }
}

/* ---------- Fit small phones (iPhone SE & co.) ---------- */

@media (max-height: 740px) {
  .paywall .upgrade-wordmark {
    font-size: 34px;
  }
  .paywall .upgrade-headline {
    font-size: 30px;
    margin-bottom: var(--s-md);
  }
  .paywall .idea-rotator {
    margin-bottom: var(--s-md);
  }
  .paywall .idea-thumbs {
    margin-bottom: 6px;
  }
  .paywall .idea-dots {
    margin-top: 10px;
  }
  .paywall .segmented {
    margin-bottom: var(--s-sm);
  }
  .paywall .draft-row {
    margin-bottom: var(--s-sm);
  }
  .paywall .plan-card {
    padding: 10px 16px 14px;
  }
  .paywall .plan-divider {
    margin: 8px 0 12px;
  }
  .paywall .timeline {
    gap: 14px;
  }
  .paywall .tl-row:not(:last-child)::before {
    bottom: -26px;
  }
}

/* With the draft photo notice there's one more row to fit: the photo itself
   stands in for the template thumbnails. */
@media (max-height: 700px) {
  .paywall.has-draft .idea-thumbs {
    display: none;
  }
  .paywall .upgrade-content {
    padding-bottom: var(--s-sm);
  }
}

@media (max-height: 620px) {
  .paywall .upgrade-wordmark {
    font-size: 30px;
  }
  .paywall .upgrade-headline {
    font-size: 26px;
    margin-bottom: var(--s-sm);
  }
  .paywall .idea-thumbs {
    display: none;
  }
}

/* ---------- #/paid (after Stripe Checkout) ---------- */

.screen-paid {
  background: var(--surface-muted);
}

/* Signed-out tip under the fine print. */
.paywall .signin-tip {
  display: block;
  margin: 4px 0 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  color: var(--accent-dark);
  text-decoration: none;
  text-wrap: balance;
}
.paywall .signin-tip[hidden] {
  display: none;
}
.paywall.has-tip .fine-print {
  margin-top: 8px;
}
.paywall.has-tip .cancel-note {
  margin-bottom: 8px;
}
.paywall.has-tip .signin-tip {
  margin-top: 2px;
}
.paywall.has-tip .upgrade-footer {
  padding-top: 8px;
}

/* Progressive tightening applied by fit() when the column would scroll. */
.paywall.fit-1 .idea-thumbs {
  display: none;
}
.paywall.fit-2 .upgrade-wordmark {
  font-size: 28px;
}
.paywall.fit-2 .upgrade-headline {
  font-size: 26px;
  margin-bottom: var(--s-sm);
}
.paywall.fit-2 .idea-rotator,
.paywall.fit-2 .draft-row,
.paywall.fit-2 .segmented {
  margin-bottom: 10px;
}
.paywall.fit-3 .idea-dots {
  display: none;
}
.paywall.fit-3 .upgrade-content {
  padding-top: 0;
  padding-bottom: var(--s-xs);
}
.paywall.fit-3 .plan-divider {
  margin: 6px 0 10px;
}

/* Card variant: one more step — drop the idea rotator. */
.paywall.fit-4 .idea-rotator {
  display: none;
}

/* ---------- "Sign in to continue" sheet (screens/_signin-sheet.js) ----------
   Shown before Stripe Checkout when nobody is signed in: paying needs an account. */

.signin-sheet-backdrop {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  background: var(--scrim);
  animation: fadeIn 0.2s ease both;
}
.signin-sheet-backdrop.is-closing {
  animation: signinFadeOut 0.22s ease both;
}
.signin-sheet {
  width: 100%;
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -10px 30px rgba(26, 28, 34, 0.14);
  padding: 0 var(--s-xl) calc(var(--s-lg) + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  animation: signinSheetIn 0.42s cubic-bezier(0.32, 1.18, 0.5, 1) both;
}
.signin-sheet-backdrop.is-closing .signin-sheet {
  animation: signinSheetOut 0.22s cubic-bezier(0.4, 0, 0.6, 1) both;
}
.signin-sheet .sheet-grabber {
  width: 36px;
  height: 5px;
  margin: 8px auto 14px;
  border-radius: 3px;
  background: var(--border-strong);
}
.signin-sheet-title {
  margin: 4px 0 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text);
}
.signin-sheet-text {
  margin: 0 auto var(--s-lg);
  max-width: 320px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-2);
}
.signin-sheet-buttons {
  min-height: 56px;
}
.signin-sheet-loading {
  height: 56px;
  border-radius: 28px;
  background: var(--surface-muted);
}
.signin-sheet-note {
  margin: 0 0 var(--s-sm);
  padding: var(--s-sm) var(--s-md);
  border-radius: var(--r-md);
  background: var(--surface-muted);
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
}
.signin-sheet-dismiss {
  margin: var(--s-sm) auto 0;
  min-height: 44px;
  padding: 0 var(--s-lg);
  border: 0;
  background: none;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
}
@keyframes signinSheetIn {
  from {
    transform: translateY(105%);
  }
  to {
    transform: none;
  }
}
@keyframes signinSheetOut {
  to {
    transform: translateY(105%);
  }
}
@keyframes signinFadeOut {
  to {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .signin-sheet,
  .signin-sheet-backdrop,
  .signin-sheet-backdrop.is-closing,
  .signin-sheet-backdrop.is-closing .signin-sheet {
    animation-duration: 0.01ms;
  }
}

/* ---------- #/paid/elsewhere (Stripe's return opened outside the installed app) ---------- */

.screen-paid-elsewhere {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-xl) var(--s-md) calc(var(--s-xl) + var(--safe-bottom));
}
.paid-elsewhere-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-card);
  padding: var(--s-xxl) var(--s-xl) var(--s-xl);
  text-align: center;
}
.paid-elsewhere-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--success);
  color: var(--text-on-dark);
  font-size: 30px;
  margin-bottom: var(--s-md);
}
.paid-elsewhere-title {
  margin: 0 0 var(--s-sm);
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
}
.paid-elsewhere-text {
  margin: 0 0 var(--s-sm);
  font-size: 16px;
  line-height: 22px;
  color: var(--text);
}
.paid-elsewhere-hint {
  margin: 0 0 var(--s-xl);
  font-size: 14px;
  line-height: 20px;
  color: var(--text-2);
}
.paid-elsewhere-actions {
  display: grid;
  gap: var(--s-sm);
}
.paid-elsewhere-actions .btn[hidden] {
  display: none;
}
