/* ============================================================
   GoLove AI — клон лендинга create-a2 (vanilla HTML/CSS/JS)
   Дизайн-токени витягнуто з оригіналу через getComputedStyle.
   ============================================================ */

:root {
  --bg: rgb(15, 14, 15);
  --fg: #ffffff;
  --accent-from: #d05bf8;   /* градієнт CTA — початок */
  --accent-to: #ff18a0;     /* градієнт CTA — кінець  */
  --btn-back-bg: rgb(28, 25, 28);
  --ring-idle: rgba(255, 255, 255, 0.10);
  --ring-future: rgba(255, 255, 255, 0.05);
  --radius: 16px;
  --footer-h: 94px;
  --font: "Poppins", "Poppins-fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Fallback-шрифт с подогнанными метриками (size-adjust/overrides под Poppins на базе Arial).
   Пока грузится Poppins (display=swap), fallback занимает ту же высоту/ширину строки —
   swap не двигает layout → убирает CLS от веб-шрифта. Значения — как генерирует next/font.
   ВАЖНО: local("Arial") на headless Linux (там гоняют PageSpeed/Lighthouse) чаще всего
   не резолвится — Arial там не установлена. Без альтернативных local() весь @font-face
   считается невалидным и браузер тихо пропускает его в стеке — override не срабатывает
   вообще (именно так и было: CLS не изменился). Перечисляем метрически совместимые с
   Arial шрифты, которые реально стоят на типичных Linux/CI-машинах (Liberation Sans,
   Arimo, DejaVu Sans), плюс Arial/Helvetica для Windows/Mac. */
@font-face {
  font-family: "Poppins-fallback";
  src: local("Arial"), local("Helvetica"), local("Liberation Sans"),
       local("Arimo"), local("Nimbus Sans"), local("DejaVu Sans");
  ascent-override: 93.62%;
  descent-override: 31.21%;
  line-gap-override: 0%;
  size-adjust: 112.15%;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- Фонові декоративні шари ---------- */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Фіолетове сяйво зверху-по центру */
.bg-glow {
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 90vw;
  height: 60vh;
  background: radial-gradient(
    ellipse at center,
    rgba(150, 60, 190, 0.55) 0%,
    rgba(90, 40, 130, 0.25) 35%,
    rgba(15, 14, 15, 0) 70%
  );
  filter: blur(20px);
}

/* М'які силуети по краях (плейсхолдер замість explicit-фото оригіналу) */
.bg-silhouette {
  position: absolute;
  bottom: 0;
  height: 78vh;
  width: 62vw;
  max-width: 900px;
  filter: blur(2px);
  opacity: 0.6;
}
.bg-silhouette--left {
  left: 0;
  background: radial-gradient(
    ellipse at bottom left,
    rgba(230, 190, 210, 0.22) 0%,
    rgba(120, 70, 120, 0.10) 30%,
    rgba(15, 14, 15, 0) 60%
  );
}
.bg-silhouette--right {
  right: 0;
  background: radial-gradient(
    ellipse at bottom right,
    rgba(200, 170, 220, 0.22) 0%,
    rgba(110, 60, 130, 0.10) 30%,
    rgba(15, 14, 15, 0) 60%
  );
}

/* Затемнення знизу, щоб футер читався */
.bg-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(15, 14, 15, 0) 55%,
    rgba(15, 14, 15, 0.85) 100%
  );
}

/* ---------- Каркас сторінки ---------- */
.page {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--footer-h);
}

/* ---------- Хедер (sticky) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  /* Фон-маска: контент чисто уходит под шапку при скролле */
  background: linear-gradient(
    to bottom,
    rgba(15, 14, 15, 0.95) 0%,
    rgba(15, 14, 15, 0.9) 65%,
    rgba(15, 14, 15, 0) 100%
  );
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.topbar__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px 12px;
}
.logo {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 150px;
}
.logo__img {
  width: 100%;
  max-width: 121px;
  height: auto;
}

/* ---------- Степер ---------- */
.stepper {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  padding: 8px 4px;
  scrollbar-width: none;
  /* Резерв высоты: степпер пуст в HTML, app.js вставляет 8 кружков (32px + padding 8px
     = 48px). Без min-height пустой степпер (16px) вырастает при заполнении и толкает
     .content вниз — это и есть настоящий источник CLS 0.207 (не шрифт/карточки).
     box-sizing:border-box → min-height включает padding. Моб. значение — в @media. */
  min-height: 48px;
}
.stepper::-webkit-scrollbar { display: none; }

.step-dot {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  color: #ffffff;
  background: var(--ring-future);
  box-shadow: inset 0 0 0 1px var(--ring-idle);
  transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}
.step-dot svg { width: 16px; height: 16px; }

.step-dot.is-done { background: var(--ring-idle); color: #ffffff; }
.step-dot.is-active {
  background: #ffffff;
  color: #17151a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6),
              0 0 16px rgba(208, 91, 248, 0.45);
}

.step-connector {
  flex-shrink: 0;
  width: 24px;
  height: 1px;
  background: var(--ring-idle);
}

/* ---------- Контент кроку ---------- */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 8px 16px 24px;
  width: 100%;
}

.step-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  color: #ffffff;
  /* До заповнения JS (app.js вставляет текст с задержкой, defer) элемент пуст
     и без min-height занимает 0px — внутри justify-content:center это даёт
     скачок высоты .content и сдвиг заголовка/карточек (настоящая причина CLS
     0.207, а не веб-шрифт — font-display эксперименты это подтвердили,
     результат не менялся). Резервируем 2 строки — с запасом на перенос текста. */
  min-height: calc(1.2em * 2);
}

/* Заголовок кроків із картками трохи менший */
.content.is-cards .step-title { font-size: 20px; }

/* ---------- Сітка карток ---------- */
.cards {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: stretch;
  width: 100%;
  max-width: 1100px;
  scroll-snap-type: x mandatory;
  /* Пуст до рендера JS (renderCards вызывается с задержкой, после defer app.js) —
     без резервации высота 0, а после заполнения карточками (aspect-ratio 1/1.9
     от .card) высота скачет — тот же источник CLS, что и у .step-title выше.
     Формула повторяет width .card (clamp) * 1.9, чтобы совпасть с реальной высотой. */
  min-height: calc(clamp(140px, 14vw, 200px) * 1.9);
}

/* Режим із малою кількістю варіантів (напр. возраст, тип) — ширші картки */
.cards.is-few { max-width: 720px; }

.card {
  position: relative;
  flex: 0 0 auto;
  width: clamp(140px, 14vw, 200px);
  aspect-ratio: 1 / 1.9;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 0;
  padding: 0;
  scroll-snap-align: center;
  background: #17151a;
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  outline: none;
}
.card:hover { transform: translateY(-2px); }
.card:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

/* Видео-превью варианта (градиент виден как фон-заглушка при загрузке) */
.card__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--card-grad, linear-gradient(160deg, #3a2a4a, #1c1620));
}

/* Скрим під підписом */
.card__scrim {
  position: absolute;
  inset: auto 0 0 0;
  height: 45%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}

.card__label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: #ffffff;
}

/* Виділена картка */
.card.is-selected {
  box-shadow: 0 0 0 2px var(--accent-from),
              0 0 24px rgba(208, 91, 248, 0.40);
}

/* ---------- Футер ---------- */
.footerbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 16px 16px 24px;
  background: rgba(0, 0, 0, 0.40);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.footerbar__inner {
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 28rem;
}

.btn {
  flex: 1 1 0;
  max-width: 218px;
  height: 53px;
  border: 0;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.1s ease, filter 0.2s ease;
}
.btn:active { transform: translateY(1px); }
.btn--back { background: var(--btn-back-bg); }
.btn--back:hover { filter: brightness(1.25); }
.btn--next {
  background: linear-gradient(to bottom right, var(--accent-from), var(--accent-to));
}
.btn--next:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--back.is-hidden { display: none; }

/* ---------- Финальный экран (summary/генерация) ---------- */
.summary {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.summary-image {
  position: relative;
  width: min(340px, 100%);
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #17151a;
  aspect-ratio: 96 / 169; /* 768×1352 из API */
}
.summary-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.summary-loading,
.summary-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  color: rgba(255, 255, 255, 0.75);
}
.skeleton-pulse {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, #1a1a1e 30%, #2c2730 50%, #1a1a1e 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.loading-text {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.btn-retry {
  padding: 10px 26px;
  border: 0;
  border-radius: 9999px;
  background: linear-gradient(to bottom right, var(--accent-from), var(--accent-to));
  color: #fff;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.summary-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}
.badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.72rem;
  white-space: nowrap;
}
.badge-label {
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge-value { color: #fff; font-weight: 700; }

.cta-tagline {
  margin: 20px 0 8px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
}
.cta-button {
  display: block;
  width: 100%;
  max-width: 340px;
  margin-top: 6px;
  padding: 16px;
  border-radius: 9999px;
  background: linear-gradient(to bottom right, var(--accent-from), var(--accent-to));
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  box-shadow: 0 6px 28px rgba(255, 24, 160, 0.35);
  transition: transform 0.15s ease, filter 0.2s ease;
}
.cta-button:hover { transform: scale(1.02); filter: brightness(1.05); }
.cta-button.disabled { opacity: 0.4; pointer-events: none; }

/* ---------- Адаптив ---------- */
@media (max-width: 640px) {
  .cards {
    justify-content: flex-start;
    overflow-x: auto;
    /* вертикальний відступ, щоб glow/бордер виділеної картки не обрізався
       (overflow-x:auto клипает и по вертикали) */
    padding: 26px calc(50vw - 105px);
    scrollbar-width: none;
    /* На мобильном .card — фиксированные 210px (не clamp из десктопной формулы
       выше), поэтому пересчитываем min-height под неё + вертикальный padding
       (box-sizing:border-box — min-height включает padding). */
    min-height: calc(210px * 1.9 + 52px);
  }
  .cards::-webkit-scrollbar { display: none; }
  .card { width: 210px; }

  /* Степпер целиком влезает в мобильную ширину (без горизонтального скролла) */
  .stepper {
    gap: 3px;
    overflow-x: visible;
    padding: 8px 0;
    /* Кружки 24px + padding 8px = 40px (моб. переопределение резерва высоты, см. десктоп) */
    min-height: 40px;
  }
  .step-dot { width: 24px; height: 24px; }
  .step-dot svg { width: 12px; height: 12px; }
  .step-connector { width: 6px; }

  .step-title { font-size: 18px; }
  .content.is-cards .step-title { font-size: 18px; }
  .footerbar__inner { max-width: 100%; }
  .btn { max-width: none; }
}
