/* ============================================
   Revia Subscription Modal
   All selectors scoped under #revia-modal
   ============================================ */

/* Backdrop */
#revia-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 200ms ease;
}

#revia-modal-backdrop.is-visible {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

#revia-modal-backdrop.is-active {
  opacity: 1;
}

/* Container — wide for tier selection, narrow for forms */
#revia-modal {
  background: #fff;
  border-radius: 1rem;
  max-width: 84rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(20px);
  opacity: 0;
  transition: transform 200ms ease, opacity 200ms ease, max-width 300ms ease;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: #111827;
}

/* Narrow modal for form steps */
#revia-modal.is-narrow {
  max-width: 36rem;
}

#revia-modal-backdrop.is-active #revia-modal {
  transform: translateY(0);
  opacity: 1;
}

/* Close button */
#revia-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 1.25rem;
  line-height: 1;
  z-index: 1;
  transition: color 150ms ease, background 150ms ease;
}

#revia-modal-close:hover {
  color: #374151;
  background: #f4f4f5;
}

/* Content area */
#revia-modal-content {
  padding: 3.5rem 3rem;
}

#revia-modal.is-narrow #revia-modal-content {
  padding: 2.5rem;
}


/* ---- Progress indicator ---- */
.revia-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.revia-progress-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #e5e7eb;
  transition: background 200ms ease;
}

.revia-progress-dot.is-active {
  background: #111827;
}

.revia-progress-dot.is-done {
  background: #22c55e;
}

/* ---- Typography ---- */
#revia-modal .rm-title {
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  text-align: center;
  margin-bottom: 0.75rem;
}

#revia-modal .rm-subtitle {
  font-size: 1.125rem;
  font-weight: 500;
  color: #6b7280;
  text-align: center;
  margin-bottom: 2rem;
}

/* Smaller titles for form steps */
#revia-modal.is-narrow .rm-title {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

#revia-modal.is-narrow .rm-subtitle {
  font-size: 1rem;
  font-weight: 400;
  margin-bottom: 1.5rem;
}

/* ---- Cadence toggle ---- */
.revia-cadence-toggle {
  display: flex;
  background: #f4f4f5;
  border-radius: 0.5rem;
  padding: 0.25rem;
  margin: 0 auto 2.5rem;
  width: fit-content;
}

.revia-cadence-btn {
  padding: 0.5rem 1.5rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transition: all 150ms ease;
}

.revia-cadence-btn.is-active {
  background: #fff;
  color: #111827;
  border-color: #d1d5db;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.revia-cadence-btn:not(.is-active):hover {
  color: #374151;
}

/* ---- Tier cards (3-column grid matching select-tier page) ---- */
.revia-tiers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  align-items: stretch;
}

.revia-tier-card {
  background: #fff;
  border: 1px solid rgba(17, 24, 39, 0.1);
  border-radius: 1rem;
  padding: 2.5rem 2.5rem;
  display: flex;
  flex-direction: column;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.revia-tier-card:hover {
  border-color: rgba(17, 24, 39, 0.3);
}

.revia-tier-card.is-featured {
  background: #111827;
  color: #fff;
  border-color: transparent;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.revia-tier-label {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ff6600;
}

.revia-tier-card.is-featured .revia-tier-label {
  color: #a5b4fc;
}

.revia-tier-name {
  font-size: 2rem;
  font-weight: 600;
  margin-top: 0.5rem;
  letter-spacing: -0.01em;
}

.revia-tier-desc {
  font-size: 1.0625rem;
  color: #6b7280;
  margin-top: 0.5rem;
  line-height: 1.5;
}

.revia-tier-card.is-featured .revia-tier-desc {
  color: #9ca3af;
}

.revia-tier-price-block {
  margin-top: 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.revia-tier-price-currency {
  font-size: 1.5rem;
  font-weight: 400;
  color: #a1a1aa;
}

.revia-tier-card.is-featured .revia-tier-price-currency {
  color: #6b7280;
}

.revia-tier-price-amount {
  font-size: 3.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1;
}

.revia-tier-price-cadence {
  font-size: 1rem;
  color: #6b7280;
  margin-left: 0.25rem;
}

.revia-tier-card.is-featured .revia-tier-price-cadence {
  color: #9ca3af;
}

.revia-tier-features {
  margin-top: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  flex: 1;
}

.revia-tier-feature {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 1.125rem;
  line-height: 1.5;
  color: #4b5563;
}

.revia-tier-card.is-featured .revia-tier-feature {
  color: #d1d5db;
}

.revia-tier-feature svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.revia-tier-check-accent { color: #ff6600; }
.revia-tier-check-light { color: #a5b4fc; }

.revia-tier-btn {
  display: block;
  width: 100%;
  padding: 1rem 2rem;
  border-radius: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 150ms ease;
  margin-top: 1.25rem;
  border: none;
  font-family: inherit;
}

.revia-tier-btn-primary {
  background: #111827;
  color: #fff;
}

.revia-tier-btn-primary:hover {
  background: #1f2937;
}

.revia-tier-btn-featured {
  background: #fff;
  color: #111827;
}

.revia-tier-btn-featured:hover {
  background: #f4f4f5;
}

.revia-tier-btn-outline {
  background: transparent;
  color: #111827;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.15);
}

.revia-tier-btn-outline:hover {
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.3);
}

/* ---- Form fields ---- */
.revia-form-group {
  margin-bottom: 1rem;
}

.revia-form-group label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: #374151;
}

.revia-form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-family: inherit;
  color: #111827;
  background: #fff;
  outline: none;
  transition: border-color 150ms ease;
}

.revia-form-group input:focus {
  border-color: #111827;
}

.revia-form-group input::placeholder {
  color: #9ca3af;
}

/* ---- Buttons ---- */
.revia-btn {
  display: block;
  width: 100%;
  padding: 0.875rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: all 150ms ease;
}

.revia-btn-primary {
  background: #111827;
  color: #fff;
}

.revia-btn-primary:hover {
  background: #1f2937;
}

.revia-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.revia-btn-secondary {
  background: transparent;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

.revia-btn-secondary:hover {
  color: #374151;
  border-color: #d1d5db;
}

/* ---- Selected tier summary ---- */
.revia-selected-tier {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: #f9fafb;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
}

.revia-selected-tier-name {
  font-size: 1.0625rem;
  font-weight: 600;
}

.revia-selected-tier-price {
  font-size: 1.0625rem;
  font-weight: 600;
}

.revia-selected-tier-price .rm-cadence {
  font-weight: 400;
  color: #6b7280;
}

/* ---- Back link ---- */
.revia-back {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #6b7280;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  margin-bottom: 1.25rem;
}

.revia-back:hover {
  color: #374151;
}

/* ---- Error / status messages ---- */
.revia-error {
  background: #fef2f2;
  color: #b91c1c;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  text-align: center;
}

.revia-info {
  background: #f0fdf4;
  color: #166534;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  text-align: center;
}

/* ---- OTC code input ---- */
.revia-otc-wrap {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 1.5rem 0;
}

.revia-otc-input {
  width: 3rem;
  height: 3.5rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  font-family: inherit;
  border: 2px solid #d1d5db;
  border-radius: 0.5rem;
  outline: none;
  color: #111827;
  transition: border-color 150ms ease;
  -moz-appearance: textfield;
}

.revia-otc-input::-webkit-outer-spin-button,
.revia-otc-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.revia-otc-input:focus {
  border-color: #111827;
}

.revia-otc-input.is-filled {
  border-color: #22c55e;
  background: #f0fdf4;
}

.revia-resend {
  display: block;
  margin: 0.75rem auto 0;
  background: none;
  border: none;
  color: #6b7280;
  font-size: 0.8125rem;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.revia-resend:hover {
  color: #374151;
}

/* ---- Success state ---- */
.revia-success-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1.25rem;
  background: #ecfdf5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #22c55e;
}

/* ---- Payment pending ---- */
.revia-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid #e5e7eb;
  border-top-color: #111827;
  border-radius: 50%;
  animation: revia-spin 0.8s linear infinite;
  margin: 0 auto 1.25rem;
}

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

/* ---- Loading skeleton for tiers ---- */
.revia-skeleton {
  background: linear-gradient(90deg, #f4f4f5 25%, #e5e7eb 50%, #f4f4f5 75%);
  background-size: 200% 100%;
  animation: revia-shimmer 1.5s ease infinite;
  border-radius: 1rem;
  height: 20rem;
}

@keyframes revia-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Powered by ---- */
.revia-powered {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.6875rem;
  color: #d1d5db;
}

.revia-powered a {
  color: #9ca3af;
  text-decoration: none;
}

/* ============================================
   Mobile bottom sheet (< 640px)
   ============================================ */
/* ============================================
   Mobile bottom sheet (< 768px)
   ============================================ */
@media (max-width: 767px) {
  #revia-modal-backdrop.is-visible {
    align-items: flex-end;
    padding: 0;
  }

  #revia-modal {
    max-width: 100% !important;
    max-height: 92vh;
    border-radius: 1rem 1rem 0 0;
    transform: translateY(100%);
  }

  #revia-modal-backdrop.is-active #revia-modal {
    transform: translateY(0);
  }

  /* Drag handle */
  #revia-modal::before {
    content: '';
    display: block;
    width: 2.5rem;
    height: 0.25rem;
    background: #d1d5db;
    border-radius: 0.25rem;
    margin: 0.625rem auto 0;
  }

  #revia-modal-content {
    padding: 1.5rem 1.25rem 2rem;
  }

  /* Stack tier cards vertically on mobile */
  .revia-tiers {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Larger touch targets */
  .revia-tier-card {
    padding: 1.25rem;
  }

  .revia-btn, .revia-tier-btn {
    padding: 0.875rem;
    font-size: 0.9375rem;
  }

  .revia-otc-input {
    width: 2.75rem;
    height: 3.25rem;
    font-size: 1.375rem;
  }
}
