/* ═══════════════════════════════════════════════
   PAYWALL — Canopy Pro upgrade modal
   Design language: frosted glass pills throughout.
   Sheets use var(--glass-bg) + backdrop-filter.
   Interactive elements use border-radius: 100px.
   ═══════════════════════════════════════════════ */

.pw-overlay {
  position: absolute;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.pw-overlay.pw-visible {
  opacity: 1;
  pointer-events: all;
}

.pw-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ── Sheet — frosted glass, not a solid card ── */
.pw-sheet {
  position: relative;
  width: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: 32px 32px 0 0;
  padding: 28px 24px 44px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.pw-overlay.pw-visible .pw-sheet {
  transform: translateY(0);
}

/* drag handle */
.pw-sheet::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.15);
  margin: 0 auto 24px;
}

/* ── Close — frosted glass pill (circle is a pill with equal sides) ── */
.pw-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s;
}
.pw-close:active {
  background: rgba(255, 255, 255, 0.14);
}

/* ── PRO badge — frosted glass pill ── */
.pw-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(188, 130, 243, 0.15);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid rgba(188, 130, 243, 0.25);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
  color: var(--ai-purple);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  margin-bottom: 16px;
  text-transform: uppercase;
}

/* ── Header ── */
.pw-title {
  font-family: 'Swansea', var(--font);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
  letter-spacing: -0.5px;
}

.pw-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 24px;
  line-height: 1.4;
}

/* ── Features list ── */
.pw-features {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pw-feature-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Feature icon — frosted glass pill */
.pw-feature-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-pill);
  background: rgba(188, 130, 243, 0.1);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid rgba(188, 130, 243, 0.18);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--ai-purple);
  flex-shrink: 0;
}

.pw-feature-label {
  font-size: 14px;
  color: var(--text);
  line-height: 1.3;
}

/* ── CTA block ── */
.pw-cta-block {
  margin-bottom: 16px;
}

/* Primary CTA — frosted glass pill with gradient overlay */
.pw-btn-primary {
  width: 100%;
  padding: 15px 24px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg,
    rgba(188, 130, 243, 0.9),
    rgba(141, 159, 255, 0.9));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow:
    0 4px 20px rgba(188, 130, 243, 0.3),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.2px;
  transition: opacity 0.15s, transform 0.1s;
  margin-bottom: 10px;
}
.pw-btn-primary:active {
  opacity: 0.85;
  transform: scale(0.985);
}

.pw-price-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0 0 6px;
}

.pw-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
  margin: 0;
  opacity: 0.7;
}

.pw-terms-block {
  font-size: 10px;
  line-height: 1.4;
  color: var(--text-tertiary);
  opacity: 0.65;
  text-align: center;
  margin: 14px 0 8px;
  padding: 0 4px;
}

.pw-terms-links {
  display: block;
  margin-top: 6px;
}

.pw-terms-links a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pw-terms-links span[aria-hidden] {
  margin: 0 6px;
  opacity: 0.4;
}

/* ── Footer — ghost pills ── */
.pw-footer-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 4px;
}

/* Ghost pill buttons */
.pw-btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill);
  color: var(--text-tertiary);
  font-size: 13px;
  cursor: pointer;
  padding: 7px 16px;
  transition: background 0.15s, color 0.15s;
}
.pw-btn-ghost:active {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-secondary);
}

/* ── Toast — frosted glass pill ── */
.pw-toast {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 0.5px 0 rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 9100;
}

.pw-toast.pw-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Premium "Welcome to Pro" toast ────────────────────────────────────────
 * Bigger, glassier, longer-dwelling. Shown at the highest-emotion moment in
 * the monetization flow with a Try-it CTA that drops the user straight into
 * the just-unlocked feature.
 */
.pw-welcome-toast {
  position: absolute;
  bottom: 110px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 14px 14px 18px;
  background: linear-gradient(135deg, rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  backdrop-filter: blur(32px) saturate(200%);
  -webkit-backdrop-filter: blur(32px) saturate(200%);
  border: 0.5px solid rgba(255,255,255,0.18);
  box-shadow:
    0 24px 60px rgba(0,0,0,0.55),
    0 4px 14px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -0.5px 0 rgba(255,255,255,0.04);
  border-radius: var(--radius-24);
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  transition: opacity 0.35s var(--ease, cubic-bezier(0.16, 1, 0.3, 1)),
              transform 0.45s var(--ease, cubic-bezier(0.16, 1, 0.3, 1));
  z-index: 9200;
  overflow: hidden;
}
.pw-welcome-toast.pw-welcome-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.pw-welcome-glow {
  position: absolute;
  top: -40%;
  left: -10%;
  width: 60%;
  height: 180%;
  background: radial-gradient(ellipse at center, rgba(188, 130, 243, 0.18), transparent 70%);
  pointer-events: none;
  filter: blur(20px);
  animation: pwGlowDrift 6s var(--ease, ease) infinite alternate;
}
@keyframes pwGlowDrift {
  0%   { transform: translateX(0) translateY(0); }
  100% { transform: translateX(70%) translateY(10%); }
}
.pw-welcome-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  color: #fff;
  background: linear-gradient(135deg, rgba(188,130,243,0.55), rgba(141,159,255,0.55));
  border: 0.5px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-12);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 4px 14px rgba(141,159,255,0.4);
}
.pw-welcome-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.pw-welcome-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  line-height: 1.25;
  /* Allow up to two lines on narrow viewports — better than ellipsis at the
   * climax of monetization. Falls back to no-clamp on browsers without
   * line-clamp support. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pw-welcome-sub {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: -0.1px;
}
.pw-welcome-cta {
  flex-shrink: 0;
  background: rgba(255,255,255,0.14);
  border: 0.5px solid rgba(255,255,255,0.22);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: inset 0 0.5px 0 rgba(255,255,255,0.18);
  transition: transform 0.15s var(--ease), background 0.15s ease;
}
.pw-welcome-cta:active {
  transform: scale(0.94);
  background: rgba(255,255,255,0.2);
}

/* ── Light mode overrides ── */
[data-theme="light"] .pw-backdrop {
  background: rgba(0,0,0,0.18);
}

[data-theme="light"] .pw-sheet {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 -20px 60px rgba(0,0,0,0.12), inset 0 1px 0 rgba(0,0,0,0.03);
}

[data-theme="light"] .pw-sheet::before {
  background: rgba(0,0,0,0.12);
}

[data-theme="light"] .pw-close {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
  box-shadow: inset 0 0.5px 0 rgba(0,0,0,0.03);
  color: var(--text-secondary);
}

[data-theme="light"] .pw-close:active {
  background: rgba(0,0,0,0.03);
}

[data-theme="light"] .pw-badge,
[data-theme="light"] .pw-feature-icon {
  box-shadow: inset 0 0.5px 0 rgba(0,0,0,0.03);
}

[data-theme="light"] .pw-title,
[data-theme="light"] .pw-feature-label,
[data-theme="light"] .pw-toast,
[data-theme="light"] .pw-welcome-title,
[data-theme="light"] .pw-welcome-cta {
  color: var(--text);
}

[data-theme="light"] .pw-subtitle,
[data-theme="light"] .pw-welcome-sub {
  color: var(--text-secondary);
}

[data-theme="light"] .pw-price-note,
[data-theme="light"] .pw-disclaimer,
[data-theme="light"] .pw-btn-ghost {
  color: var(--text-tertiary);
}

[data-theme="light"] .pw-btn-primary {
  border-color: rgba(0,0,0,0.08);
  box-shadow:
    0 4px 20px rgba(188, 130, 243, 0.24),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

[data-theme="light"] .pw-btn-ghost {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
  box-shadow: inset 0 0.5px 0 rgba(0,0,0,0.03);
}

[data-theme="light"] .pw-btn-ghost:active {
  background: #ffffff;
  color: var(--text-secondary);
}

[data-theme="light"] .pw-toast {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12), inset 0 0.5px 0 rgba(0,0,0,0.03);
}

[data-theme="light"] .pw-welcome-toast {
  background: linear-gradient(135deg, #ffffff, rgba(0,0,0,0.03));
  border-color: rgba(0,0,0,0.08);
  box-shadow:
    0 24px 60px rgba(0,0,0,0.14),
    0 4px 14px rgba(0,0,0,0.10),
    inset 0 1px 0 rgba(0,0,0,0.03),
    inset 0 -0.5px 0 rgba(0,0,0,0.03);
}

[data-theme="light"] .pw-welcome-icon {
  color: #ffffff;
  border-color: rgba(0,0,0,0.08);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.3),
    0 4px 14px rgba(141,159,255,0.25);
}

[data-theme="light"] .pw-welcome-cta {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
  box-shadow: inset 0 0.5px 0 rgba(0,0,0,0.03);
}

[data-theme="light"] .pw-welcome-cta:active {
  background: rgba(0,0,0,0.03);
}

/* ── Plan selector ──
   Hidden until purchases-bridge confirms the current RevenueCat offering
   actually contains an annual package, so the sheet never shows a plan the
   user cannot buy. Prices are injected from the storefront, never hardcoded. */
.pw-plans {
  display: flex;
  gap: 10px;
  margin: 4px 0 16px;
}
.pw-plan {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 13px 14px 12px;
  border-radius: var(--radius-14);
  border: 1.5px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--motion-normal, 0.26s) var(--ease),
              background var(--motion-normal, 0.26s) var(--ease),
              transform var(--motion-fast, 0.18s) var(--ease);
}
.pw-plan:active { transform: scale(0.98); }
.pw-plan.selected {
  border-color: rgba(188, 130, 243, 0.75);
  background: rgba(188, 130, 243, 0.11);
}
.pw-plan:focus-visible {
  outline: 2px solid var(--ai-blue, #8d9fff);
  outline-offset: 2px;
}
.pw-plan-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.pw-plan.selected .pw-plan-name { color: var(--text); }
.pw-plan-price {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum" on, "lnum" on;
}
.pw-plan-sub {
  font-size: 11.5px;
  color: var(--text-tertiary);
}
.pw-plan-save {
  position: absolute;
  top: -9px;
  right: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, rgba(188, 130, 243, 0.95), rgba(141, 159, 255, 0.95));
  color: #0a0c14;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

[data-theme="light"] .pw-plan {
  border-color: rgba(0, 0, 0, 0.10);
  background: rgba(0, 0, 0, 0.025);
}
[data-theme="light"] .pw-plan.selected {
  border-color: rgba(141, 110, 220, 0.75);
  background: rgba(188, 130, 243, 0.10);
}
