/**
 * Kwit Onboarding — Screen-Specific Styles
 *
 * Styles unique to each screen type. Base layout is in components.css.
 *
 * Screen types:
 *   .screen--welcome     — transparent bg, Lottie overlay, logo + card
 *   .screen--info        — transparent bg, Lottie overlay, badges + bubbles
 *   .screen--transition  — full green bg, Lottie animation, animated text
 *   .screen--form        — white bg, character bubble + input/select content
 *   .loading-screen      — centered Lottie spinner + rotating messages
 *
 * Overlay pattern: welcome + info screens use transparent backgrounds
 * so the persistent Lottie (#persistent-lottie-bg) shows through.
 * Content is placed in a relative overlay div (z-index: 1).
 */

/* ============================================
   WELCOME / INFO SCREENS
   ============================================ */
.screen--welcome {
  position: relative;
  overflow: hidden;
  padding: 0;
  min-height: 0;
  background: transparent;
}

/* Content overlay on top of persistent Lottie bg */
.screen--welcome .welcome-overlay {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  padding: var(--space-lg) var(--space-lg) 0;
  min-height: 0;
}

.screen--welcome .welcome-logo-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: var(--space-md);
  flex-shrink: 0;
}

.screen--welcome .welcome-logo-row img {
  width: 110px;
  height: 110px;
}

.screen--welcome .welcome-card {
  background: var(--color-card);
  border-radius: var(--radius-xl);
  padding: var(--space-lg) var(--space-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-md);
  max-width: 300px;
  flex-shrink: 0;
}

.screen--welcome .welcome-card__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.screen--welcome .welcome-card__text {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
}

.screen--welcome .welcome-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) 0 calc(var(--space-lg) + var(--safe-bottom));
  width: 100%;
  flex-shrink: 0;
}

.screen--welcome .welcome-footer .btn-primary {
  background: white;
  color: var(--color-text);
  font-weight: var(--font-weight-bold);
}

.screen--welcome .welcome-login {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.screen--welcome .welcome-login a {
  color: var(--color-text);
  font-weight: var(--font-weight-bold);
  text-decoration: none;
}

/* ============================================
   INFO SCREENS (with Lottie bg like welcome)
   ============================================ */
.screen--info {
  position: relative;
  overflow: hidden;
  padding: 0;
  background: transparent;
}

.screen--info .info-overlay {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  padding: var(--space-sm) var(--space-lg) 0;
  min-height: 0;
}

.info-nav {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: var(--space-sm);
}

.info-nav__back,
.info-nav__skip {
  background: none;
  border: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: var(--space-xs) 0;
}

.info-avatar {
  margin-bottom: var(--space-sm);
}

.info-avatar img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

/* Badge + bubble group: badge overlaps the top-left of the bubble */
.info-bubble-group {
  position: relative;
  align-self: flex-start;
  max-width: 320px;
}

/* Waiting for its character's turn to speak (second bubble while the
   first one types) — revealed by removing the class */
.info-bubble-group--pending {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.info-bubble-group:not(.info-bubble-group--pending) {
  transition: opacity 360ms var(--ease-out), transform 420ms var(--ease-out);
}

.info-badge {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: white;
  margin-bottom: -15px;
  margin-left: var(--space-sm);
}

.info-badge--primary {
  background: var(--color-primary);
}

.info-badge--secondary {
  background: #F5A0B1;
  margin-top: var(--space-md);
}

.info-bubble {
  background: var(--color-card);
  border-radius: var(--radius-xl);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  line-height: var(--line-height-relaxed);
  text-align: left;
}

/* Bubble with image left of text (e.g. OMS logo) */
.info-bubble--with-image {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.info-bubble__inline-image {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}

.info-bubble__text {
  flex: 1;
}

.info-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) 0 calc(var(--space-lg) + var(--safe-bottom));
  width: 100%;
  flex-shrink: 0;
}

.info-footer .btn-primary {
  background: white;
  color: var(--color-text);
  font-weight: var(--font-weight-bold);
}

/* ============================================
   TRANSITION SCREENS (animated green bg)
   ============================================ */
.screen--transition {
  position: relative;
  overflow: hidden;
  padding: 0;
  background: #EAF8FB;
}

.transition-lottie-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.transition-lottie-bg svg {
  width: 100% !important;
  height: 100% !important;
}

.screen--transition .info-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm) var(--space-lg) 0;
}

/* Transition screens: badge + bubble group centered horizontally */
.info-bubble-group--centered {
  align-self: center;
}

.transition-bubble {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
  /* text-align inherited from .info-bubble: left, like every speech bubble */
  max-width: 320px;
}

.screen--transition .info-footer {
  width: 100%;
  padding-bottom: var(--space-lg);
}

.screen--transition .info-footer .btn-primary {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.screen--transition .info-footer .btn-primary {
  background: white;
  color: var(--color-text);
  font-weight: var(--font-weight-bold);
}

/* ============================================
   INFO SCREEN (OMS, stats, community, etc.)
   ============================================ */
.screen--info {
  padding-top: var(--space-lg);
  justify-content: flex-start;
}

.screen--info .screen__body {
  justify-content: flex-start;
}

.screen--info .character-bubble {
  margin-bottom: var(--space-md);
}

.info-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.info-content__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.info-content__text {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
}

.info-content__image {
  display: flex;
  justify-content: center;
  padding: var(--space-xl) 0;
}

.info-content__image img {
  max-width: 200px;
  max-height: 200px;
  object-fit: contain;
}

/* ============================================
   FORM SCREENS
   ============================================ */
.screen--form {
  padding-top: var(--space-sm);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Hold-to-sign: the rings scale far beyond the viewport — clip instead of
   scrolling, otherwise Firefox flashes a scrollbar on each hold tick */
.screen--form.screen--clip {
  overflow: hidden;
}

.screen--form .character-bubble {
  margin-bottom: var(--space-md);
}

.screen--form .back-btn {
  margin-bottom: var(--space-xs);
}

/* No-back screens: pad the header down to where it sits when the back
   button (~42px incl. margin) is present, so the character doesn't jump */
.screen--form > .character-bubble:first-child {
  margin-top: 42px;
}

/* ============================================
   PHASE PRESENTATION SCREENS
   ============================================ */
.phase-presentation {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.phase-presentation__image {
  display: flex;
  justify-content: center;
  padding: var(--space-sm) 0;
}

.phase-presentation__image img {
  max-width: 160px;
  max-height: 160px;
  object-fit: contain;
}

.phase-presentation__header {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  text-align: center;
}

.phase-presentation__content {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
}

/* ============================================
   BENEFITS SUMMARY SCREEN
   ============================================ */
.benefits-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* ============================================
   COMMUNITY POST (mocked — try-count-transition)
   ============================================ */
/* Avatars illustration: the SVG is pre-cropped at its bottom edge so the
   card sits flush below it (iOS: VStack spacing 0, no overlap). Width
   mirrors iOS: 64pt side padding + 0.8 scale ≈ 54% of screen width. */
.community-illustration {
  display: block;
  width: 54%;
  max-width: 220px;
  margin: 0 auto;
}

/* Flush contact with the card (iOS: VStack spacing 0) — this -12px margin
   cancels the .form-body flex gap, and overrides the card's own top margin */
.community-illustration + .community-post {
  margin-top: calc(-1 * var(--space-sm));
}

.community-post {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-top: var(--space-sm);
}

.community-post__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.community-post__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  flex-shrink: 0;
}

.community-post__name-col {
  display: flex;
  flex-direction: column;
}

.community-post__name {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.community-post__time {
  font-size: 11px;
  color: var(--color-text-secondary);
}

.community-post__title {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  margin-bottom: 4px;
}

.community-post__content {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
  white-space: pre-line;
  margin-bottom: var(--space-sm);
}

.community-post__tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-yellow);
  color: #6B5200;
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: var(--space-sm);
}

.community-post__tag svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.community-post__reactions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

/* ============================================
   DOWNLOAD CTA SCREEN
   ============================================ */
.screen--download {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-xl);
}

.download-badges {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

.download-badges img {
  height: 48px;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */
.screen--login {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg);
  overflow: hidden;
  background: linear-gradient(180deg, #DCEEFF 0%, #E7F6E1 55%, #B8E0A8 100%);
}

.login-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.login-bg svg {
  width: 100% !important;
  height: 100% !important;
}

.screen--login > .back-btn,
.screen--login > .login-header,
.screen--login > .login-body {
  position: relative;
  z-index: 1;
}

.login-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: var(--space-xl);
  gap: var(--space-md);
}

.login-header__logo {
  width: 96px;
  height: auto;
}

.login-header__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.login-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: var(--space-xl);
}

.login-cta-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Provider buttons (Apple/Google/Email) */
.btn-provider {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.btn-provider--apple {
  background: #000;
  color: #fff;
}

.btn-provider--google {
  background: #fff;
  color: #1f1f1f;
  border: 1px solid var(--color-border);
}

.btn-provider--email {
  background: var(--color-primary);
  color: #fff;
}

.btn-provider__icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-provider__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.btn-secondary,
.btn-outline {
  width: 100%;
  padding: 16px 24px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

/* Provider buttons need a bit more vertical room than the default btn-primary */
.btn-provider {
  padding: 16px 24px;
  line-height: 1.2;
}

/* Email form */
.login-email-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  background: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
}

.login-email-form--bare {
  background: none;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
}

.login-email-form__title {
  text-align: center;
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
}

.btn-link {
  background: none;
  border: 0;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  padding: var(--space-sm);
}

/* Bottom sheet (other methods) — absolute, not fixed: it is appended to the
   login screen and must stay within the app column (Safari sized it to the
   full viewport otherwise) */
.sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 200ms ease;
}

.sheet {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-lg) var(--space-lg) calc(var(--space-2xl) + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  transform: translateY(100%);
  transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1);
}

.sheet__title {
  text-align: center;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Legal consent modal — absolute for the same containment reason as .sheet-overlay */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: var(--space-lg);
  animation: fadeIn 200ms ease;
}

.modal {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
}

.modal__title {
  text-align: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
}

.legal-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  cursor: pointer;
}

.legal-checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--color-primary);
  flex-shrink: 0;
  margin-top: 2px;
}

.legal-row__text a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: var(--font-weight-semibold);
}
