/**
 * styles.css — стили Telegram Mini App «Диагностика бизнеса»
 *
 * Архитектура:
 * - CSS-переменные устанавливаются из tg.themeParams через JS (app.js → applyTheme)
 * - Фолбэк-значения рассчитаны на светлую тему
 * - Тёмная тема работает автоматически через переменные Telegram
 * - Все экраны абсолютно позиционированы, переходы через translateX
 */

/* ─── Сброс и базовые настройки ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  font-size: 15px;
  line-height: 1.4;

  /* CSS-переменные темы — задаются через JS из tg.themeParams */
  --bg:          #ffffff;
  --text:        #000000;
  --hint:        #8e8e93;
  --accent:      #2AABEE;
  --accent-text: #ffffff;
  --card:        #f2f2f7;

  /* Фиксированные цвета зон результата */
  --red:    #FF3B30;
  --orange: #FF9500;
  --green:  #34C759;

  --transition-speed: 250ms;

  background-color: var(--bg);
  color: var(--text);
}

/* ─── Контейнер приложения ─── */
#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 430px;
  margin: 0 auto;
  overflow: hidden;
}

/* ─── Базовый экран ─── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1),
    opacity   var(--transition-speed) ease;
  will-change: transform, opacity;
}

/* Активный экран */
.screen.active {
  transform: translateX(0);
  opacity: 1;
  pointer-events: all;
}

/* Уходит влево (переход вперёд) */
.screen.exit-left {
  transform: translateX(-30%);
  opacity: 0;
  pointer-events: none;
}

/* Уходит вправо (возврат назад) */
.screen.exit-right {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

/* Приходит слева (при возврате) */
.screen.enter-left {
  transform: translateX(-30%);
  opacity: 0;
}

/* ─── Скроллируемый контент внутри экрана ─── */
.screen-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.screen-content::-webkit-scrollbar { display: none; }


/* ══════════════════════════════
   ЭКРАН 0: ПРИВЕТСТВИЕ
══════════════════════════════ */

#screen-welcome .screen-content {
  justify-content: center;
  text-align: center;
}

.welcome-greeting {
  font-size: 15px;
  color: var(--hint);
  margin-bottom: 8px;
}

.share-btn {
  margin-top: 14px;
  background: none;
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s ease;
}
.share-btn:active { opacity: 0.6; }

.welcome-icon {
  width: 120px;
  height: 120px;
  margin-bottom: 24px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.welcome-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.welcome-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 12px;
  max-width: 280px;
}

.title-underline {
  display: inline;
  border-bottom: 2.5px solid currentColor;
  padding-bottom: 1px;
}

.welcome-subtitle {
  font-size: 15px;
  color: var(--hint);
  margin-bottom: 28px;
  max-width: 270px;
}

.social-proof {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 16px;
  width: 100%;
  max-width: 320px;
}
.social-proof-icon { font-size: 20px; flex-shrink: 0; }

.welcome-time {
  font-size: 13px;
  color: var(--hint);
}


/* ══════════════════════════════
   ЭКРАНЫ 1–6: ВОПРОСЫ
══════════════════════════════ */

.progress-bar-header {
  flex-shrink: 0;
  padding: 10px 16px 0;
  width: 100%;
}

.progress-top-row {
  height: 32px;
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

/* Кнопка «Назад» в браузере (в Telegram — нативная BackButton) */
.back-btn {
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 0;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.back-btn:active { opacity: 0.6; }

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--card);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
  width: 0%;
}

.progress-label {
  font-size: 13px;
  color: var(--hint);
  white-space: nowrap;
  flex-shrink: 0;
}

#screen-question .screen-content {
  align-items: stretch;
  padding-top: 20px;
}

.question-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 24px;
}

.answers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Кнопка-ответ */
.answer-btn {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 12px 16px;
  background: var(--card);
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  width: 100%;
  line-height: 1.35;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
  -webkit-user-select: none;
  user-select: none;
}

.answer-btn:active {
  transform: scale(0.97);
}

.answer-btn.selected {
  background: var(--accent);
  color: var(--accent-text);
}


/* ══════════════════════════════
   ЭКРАН 7: ЗАГРУЗКА
══════════════════════════════ */

#screen-loading .screen-content {
  justify-content: center;
  align-items: center;
  gap: 28px;
}

.loading-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.2;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%   { transform: scale(0.85); opacity: 0.15; }
  50%  { transform: scale(1.1);  opacity: 0.35; }
  100% { transform: scale(0.85); opacity: 0.15; }
}

.loading-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.loading-step {
  font-size: 14px;
  color: var(--hint);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.loading-step.visible {
  opacity: 1;
  transform: translateY(0);
}


/* ══════════════════════════════
   ЭКРАН 8: РЕЗУЛЬТАТ
══════════════════════════════ */

#screen-result .screen-content {
  align-items: stretch;
  padding-bottom: 32px;
}

.result-greeting {
  font-size: 14px;
  color: var(--hint);
  margin-bottom: 16px;
}

.result-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.result-emoji { font-size: 48px; line-height: 1; }

.result-scale-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.result-scale {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--card);
  overflow: hidden;
}

.result-scale-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

.result-score {
  font-size: 15px;
  color: var(--hint);
}

.result-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
}

/* Универсальная карточка */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
}

.result-desc {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 20px;
}

.result-steps-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--hint);
  margin-bottom: 12px;
}

.result-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-steps li {
  font-size: 14px;
  color: var(--text);
  display: flex;
  gap: 10px;
  line-height: 1.4;
}

.result-steps li::before {
  content: '→';
  color: var(--accent);
  flex-shrink: 0;
  font-weight: 600;
}


/* ══════════════════════════════
   ЭКРАН 9: CTA / ЗАПИСЬ
══════════════════════════════ */

#screen-cta .screen-content {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.expert-photo-wrap { margin-bottom: 14px; }

.expert-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  border: 2px solid var(--accent);
  display: block;
}

.expert-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.expert-role {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 20px;
}

.offer-card {
  width: 100%;
  text-align: left;
  margin-bottom: 16px;
}

.offer-question {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  text-align: center;
}

.offer-desc {
  font-size: 14px;
  color: var(--hint);
  line-height: 1.5;
  text-align: center;
}

.scarcity {
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 6px;
}

.offer-conditions {
  font-size: 12px;
  color: var(--hint);
}

/* ══════════════════════════════
   МОДАЛКА-ОФФЕР
══════════════════════════════ */

.offer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.offer-card-modal {
  background: var(--bg);
  border-radius: 20px;
  padding: 28px 20px 20px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: translateY(24px) scale(0.97);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.offer-overlay.visible .offer-card-modal {
  transform: translateY(0) scale(1);
}

.offer-emoji {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a1f3a 0%, #2AABEE 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  line-height: 1;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(42, 171, 238, 0.35);
}

.offer-badge {
  display: inline-block;
  background: var(--card);
  color: var(--hint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 20px;
  padding: 4px 12px;
  margin-bottom: 14px;
}

.offer-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 10px;
}

.offer-subtitle {
  font-size: 14px;
  color: var(--hint);
  line-height: 1.5;
  margin-bottom: 16px;
}

.offer-bullets {
  list-style: none;
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
}

.offer-bullets li {
  font-size: 14px;
  color: var(--text);
  display: flex;
  gap: 8px;
  line-height: 1.4;
}

.offer-bullets li::before {
  content: '✓';
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}

.offer-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
  margin-bottom: 12px;
}

.offer-btn-primary:active { opacity: 0.85; }

.save-results-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  background: none;
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.save-results-btn:active { opacity: 0.6; }

.offer-btn-skip {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--hint);
  cursor: pointer;
  padding: 6px;
  -webkit-tap-highlight-color: transparent;
}

.offer-btn-skip:active { opacity: 0.6; }


/* ─── Фолбэк-кнопка (только в браузере вне Telegram) ─── */
.fallback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin-top: 24px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.fallback-btn:active {
  opacity: 0.85;
  transform: scale(0.98);
}
