/* ===================================
   Onboarding Styles
   Стили для экранов регистрации
   =================================== */

/* Пока онбординг активен — блокируем клики по фоновым экранам и навигации.
   ВАЖНО: блокировка применяется ТОЛЬКО когда экран онбординга реально виден
   (inline display:flex). Если класс body.onboarding-active случайно «залип»
   после завершения онбординга (экран уже display:none), весь интерфейс
   оставался видимым, но полностью некликабельным. Гейт через :has() это чинит. */
body.onboarding-active:has(#screen-onboarding[style*="flex"]) .screen:not(#screen-onboarding),
body.onboarding-active:has(#screen-onboarding[style*="flex"]) .bottom-nav,
body.onboarding-active:has(#screen-onboarding[style*="flex"]) nav:not(#screen-onboarding nav),
body.onboarding-active:has(#screen-onboarding[style*="flex"]) header:not(#screen-onboarding header) {
  pointer-events: none !important;
}
/* Явно разрешаем всё внутри онбординга */
body.onboarding-active #screen-onboarding,
body.onboarding-active #screen-onboarding * {
  pointer-events: auto !important;
}

.onboarding-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Premium dark background */
  background:
    radial-gradient(ellipse 80% 55% at 50% 0%,    rgba(99, 102, 241, 0.20) 0%, transparent 60%),
    radial-gradient(ellipse 70% 45% at 50% 100%,  rgba(139, 92, 246, 0.16) 0%, transparent 55%),
    linear-gradient(180deg, #0a0e1f 0%, #0f172a 50%, #06091a 100%);
  background-attachment: fixed;
  color: #fff;
}

#screen-onboarding,
#screen-onboarding.screen,
#screen-onboarding.screen.active,
#screen-onboarding.screen-enter,
#screen-onboarding.screen-exit {
  transform: none !important;
  transition: none !important;
  animation: none !important;
  will-change: auto !important;
}

/* Centred column.
   padding-bottom ≥ button_height (56) + bottom_offset (96) + gap (40) = 192 px. */
.onboarding-container {
  width: 100%;
  max-width: 430px;
  flex: 1;
  min-height: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Progress bar — sticky at the very top; scrolls out only on long steps */
.onboarding-progress {
  position: sticky;
  top: 0;
  z-index: 20;
  width: calc(100% - 32px);
  height: 4px;
  margin: 18px 16px 0;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  /* Faint gradient so scrolling content fades under the bar */
  box-shadow: 0 8px 16px rgba(10, 14, 31, 0.50);
}

.onboarding-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  width: 20%;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.5);
}

.onboarding-step {
  display: none;
  flex-direction: column;
  width: 100%;
  animation: none !important;
  transform: none !important;
}

.onboarding-step.active {
  display: flex;
  flex: 1;
  min-height: 0;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.onboarding-content {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #fff;
  padding: 20px 16px 24px;
  box-sizing: border-box;
}

.onboarding-icon {
  font-size: 72px;
  margin-bottom: 20px;
  filter: drop-shadow(0 6px 24px rgba(139, 92, 246, 0.45));
  animation: bounce 1.4s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.onboarding-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  color: #fff;
}

.onboarding-description {
  font-size: 15px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.65);
  margin: 0 0 28px;
  max-width: 320px;
}

/* Legacy feature grid (steps 2+ may still use it). Kept for back-compat. */
.onboarding-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 100%;
  margin-top: 20px;
  box-sizing: border-box;
}

.feature-icon {
  font-size: 32px;
}

.feature-text {
  font-size: 14px;
  font-weight: 600;
}

/* ───────── Welcome (step 1) — premium mobile redesign ───────── */

.welcome-content {
  padding: 28px 16px 24px;
  align-items: stretch;
}

.welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  margin-bottom: 28px;
}

.welcome-icon-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.welcome-icon-glow {
  position: absolute;
  inset: -32%;
  background: radial-gradient(circle,
    rgba(99, 102, 241, 0.42) 0%,
    rgba(139, 92, 246, 0.18) 40%,
    transparent 70%);
  filter: blur(22px);
  z-index: 0;
  pointer-events: none;
  animation: welcomeGlowPulse 3.5s ease-in-out infinite;
}

@keyframes welcomeGlowPulse {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.08); }
}

.welcome-icon {
  position: relative;
  z-index: 1;
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 4px 18px rgba(139, 92, 246, 0.50));
}

.welcome-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: #fff;
  text-align: center;
  text-wrap: balance;
  max-width: 320px;
}

.welcome-subtitle {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.62);
  margin: 0;
  text-align: center;
  text-wrap: balance;
  max-width: 300px;
}

.welcome-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* .welcome-cta was the old in-content CTA — now the button lives in the
   fixed action bar alongside skip. Rule kept empty for DOM compat. */

.welcome-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 24px;
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.055) 0%,
    rgba(255, 255, 255, 0.025) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  box-sizing: border-box;
  transition: transform 0.18s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  /* fade-in stagger by --card-index */
  opacity: 0;
  transform: translateY(10px);
  animation: welcomeCardFadeIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(0.08s + var(--card-index, 0) * 0.07s);
}

@keyframes welcomeCardFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

.welcome-card:hover {
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.08) 0%,
    rgba(255, 255, 255, 0.04) 100%);
  border-color: rgba(255, 255, 255, 0.14);
}

.welcome-card:active {
  transform: scale(0.985);
  background: rgba(255, 255, 255, 0.06);
}

.welcome-card-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22) 0%, rgba(139, 92, 246, 0.18) 100%);
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 14px;
  box-shadow:
    0 0 18px rgba(99, 102, 241, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.welcome-card-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.welcome-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

.welcome-card-subtitle {
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.58);
  line-height: 1.35;
}

/* Options */
.onboarding-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  margin-top: 20px;
  box-sizing: border-box;
}

.onboarding-option {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.025) 100%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 18px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: left;
  color: #fff;
  font-family: inherit;
  width: 100%;
}

.onboarding-option:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.onboarding-option:active {
  transform: scale(0.985);
}

.onboarding-option.selected {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22) 0%, rgba(139, 92, 246, 0.18) 100%);
  border-color: rgba(139, 92, 246, 0.55);
  box-shadow:
    0 0 0 1px rgba(139, 92, 246, 0.30),
    0 10px 30px rgba(99, 102, 241, 0.28);
}

.option-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.option-label {
  font-size: 18px;
  font-weight: 600;
  display: block;
}

.option-description {
  font-size: 13px;
  opacity: 0.8;
  display: block;
  margin-top: 4px;
}

/* Form */
.onboarding-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  margin-top: 12px;
  box-sizing: border-box;
}

/* Body params step: compact to fit 3 fields without scroll */
#onboarding-step-2 .onboarding-icon,
#onboarding-step-3 .onboarding-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

#onboarding-step-2 .onboarding-content,
#onboarding-step-3 .onboarding-content {
  padding-top: 12px;
  padding-bottom: 12px;
}

.form-group {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}

.form-input {
  padding: 16px;
  padding-right: 60px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  font-family: inherit;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.form-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(139, 92, 246, 0.55);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.form-unit {
  position: absolute;
  right: 16px;
  bottom: 16px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0.7;
}

.onboarding-actions {
  position: relative;
  flex-shrink: 0;
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 1001;
  box-sizing: border-box;
  pointer-events: auto;
  transform: none !important;
  transition: none !important;
  animation: none !important;
  will-change: auto !important;
}

/* Step 1: a single CTA → fill the full action-bar width. */
.onboarding-actions--single {
  justify-content: stretch;
}

.onboarding-actions--single .btn {
  flex: 1 1 auto;
  width: 100%;
}

/* Disable hover/active TRANSFORM on buttons so the bar doesn't visually
   shift when the user taps. (Background-only feedback is preserved.) */
.onboarding-actions .btn,
.onboarding-actions .btn:hover,
.onboarding-actions .btn:hover:not(:disabled),
.onboarding-actions .btn:active:not(:disabled),
.onboarding-actions .btn-primary:hover:not(:disabled),
.btn-cta-glow,
.btn-cta-glow:hover:not(:disabled),
.btn-cta-glow:active:not(:disabled) {
  transform: none !important;
  transition: none !important;
  animation: none !important;
  will-change: auto !important;
}

/* Legacy alias from the previous "buttons at top" iteration. */
.onboarding-nav-top { /* no-op alias */ }

/* ── Button base — premium dark glassmorphism ── */
.onboarding-actions .btn {
  flex: 1;
  height: 56px;
  min-height: 56px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 18px;
  cursor: pointer;
  transition: none !important;
  animation: none !important;
  transform: none !important;
  will-change: auto !important;
  font-family: inherit;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.onboarding-actions .btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.13);
  transform: none !important;
}

.onboarding-actions .btn:active:not(:disabled) {
  transform: none !important;
}

.onboarding-actions .btn-primary {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.26);
  font-weight: 700;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.32),
    0 0 16px rgba(99, 102, 241, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
  transition: none !important;
  animation: none !important;
  transform: none !important;
  will-change: auto !important;
}

.onboarding-actions .btn-primary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.36),
    0 0 22px rgba(99, 102, 241, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transform: none !important;
}

.onboarding-actions .btn-primary:disabled,
.onboarding-actions .btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.onboarding-actions .btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.80);
}

.onboarding-actions .btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}

/* (skip button removed from welcome — no per-element override needed) */

/* Primary CTA «Начать →» (step 1 single button, step 5 finish) —
   neon gradient + glow, lives in the sticky-bottom action bar. */
.btn-cta-glow {
  flex: 1 1 auto;
  height: 56px;
  min-height: 56px;
  padding: 0 22px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #ec4899 100%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    0 12px 36px rgba(99, 102, 241, 0.42),
    0 6px 18px rgba(139, 92, 246, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  position: relative;
  overflow: hidden;
  transition: none !important;
  animation: none !important;
  transform: none !important;
  will-change: auto !important;
}

.btn-cta-glow::after {
  /* Subtle sheen */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg,
    rgba(255, 255, 255, 0) 30%,
    rgba(255, 255, 255, 0.18) 50%,
    rgba(255, 255, 255, 0) 70%);
  transform: translateX(-100%);
  transition: none !important;
  pointer-events: none;
}

.btn-cta-glow:hover:not(:disabled) {
  background: linear-gradient(135deg, #7375f3 0%, #9b6efa 55%, #f254a4 100%);
  box-shadow:
    0 16px 44px rgba(99, 102, 241, 0.55),
    0 8px 24px rgba(139, 92, 246, 0.40),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transform: none !important;
}

.btn-cta-glow:hover::after {
  transform: translateX(-100%);
}

.btn-cta-glow:active:not(:disabled) {
  transform: none !important;
}

.btn-loader {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Small phones (360–430px) — keep text + cards readable */
@media (max-width: 480px) {
  .onboarding-title       { font-size: 22px; }
  .onboarding-description { font-size: 14px; }
  .onboarding-icon        { font-size: 60px; }

  .onboarding-features    { grid-template-columns: 1fr; }

  .option-icon  { font-size: 28px; }
  .option-label { font-size: 16px; }

  /* Welcome step compresses slightly */
  .welcome-title     { font-size: 24px; }
  .welcome-subtitle  { font-size: 14px; }
  .welcome-icon-wrap { width: 88px; height: 88px; }
  .welcome-icon      { font-size: 58px; }
  .welcome-card           { padding: 13px 14px; gap: 12px; }
  .welcome-card-icon      { width: 40px; height: 40px; font-size: 20px; }
  .welcome-card-title     { font-size: 14px; }
  .welcome-card-subtitle  { font-size: 12.5px; }
}

/* Very small (≤360px) phones — tighten further */
@media (max-width: 360px) {
  .welcome-title   { font-size: 22px; }
  .welcome-card    { padding: 12px; gap: 10px; }
  .welcome-card-icon { width: 38px; height: 38px; }
  .btn-cta-glow    { font-size: 15px; }
}

/* Global scroll fix (applies when onboarding overlay is NOT visible).
   The onboarding screen itself is position:fixed, so these rules don't
   affect it — they prevent horizontal scroll on the main app pages. */
html,
body {
  overflow-x: hidden;
  overflow-y: auto;
}

/* Main app pages: enough bottom padding so fixed bottom-nav doesn't overlap. */
.screen {
  min-height: 100vh;
  box-sizing: border-box;
}

.screen-content,
.page-content {
  padding-bottom: calc(120px + env(safe-area-inset-bottom));
}

/* Dark theme variant (даже глубже) */
:root[data-theme='dark'] .onboarding-screen,
body.dark-theme .onboarding-screen {
  background:
    radial-gradient(ellipse 80% 55% at 50% 0%,   rgba(99, 102, 241, 0.16) 0%, transparent 60%),
    radial-gradient(ellipse 70% 45% at 50% 100%, rgba(139, 92, 246, 0.12) 0%, transparent 55%),
    linear-gradient(180deg, #07091a 0%, #0a0d24 50%, #040515 100%);
}

/* Reduce motion — respect user accessibility preferences */
@media (prefers-reduced-motion: reduce) {
  .onboarding-step,
  .welcome-card,
  .welcome-icon-glow,
  .onboarding-icon {
    animation: none !important;
    transition: none !important;
  }
  .welcome-card { opacity: 1; transform: none; }
}

/* Кнопка "Далее" на шаге пола скрыта — выбор карточки автоматически переходит дальше */
#btn-gender-next {
  display: none;
}

/* Step 5: лёгкое свечение primary-кнопки «Начать» (финальный CTA) */
#onboarding-step-5 .onboarding-actions .btn-primary {
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.25),
    0 0 12px rgba(255, 255, 255, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

#onboarding-step-5 .onboarding-actions .btn-primary:hover:not(:disabled) {
  box-shadow:
    0 6px 28px rgba(0, 0, 0, 0.30),
    0 0 18px rgba(255, 255, 255, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* Required medical disclaimer before the first onboarding action. */
.onboarding-medical-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 20px 4px 4px;
  color: rgba(232, 241, 236, 0.78);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}

.onboarding-medical-consent input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.onboarding-medical-consent__check {
  display: grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  place-items: center;
  border: 1px solid rgba(153, 181, 165, 0.5);
  border-radius: 6px;
  background: #121b18;
}

.onboarding-medical-consent input:checked + .onboarding-medical-consent__check {
  border-color: #00e686;
  background: #00d978;
  box-shadow: 0 0 14px rgba(0, 230, 134, 0.28);
}

.onboarding-medical-consent input:checked + .onboarding-medical-consent__check::after {
  content: "✓";
  color: #07110d;
  font-size: 14px;
  font-weight: 900;
}
