/* ============================================================
   character.css — страница «Персонаж AI» (/character)
   Работает поверх общего shell-навбара (rail + мобильный бар).
   Палитра берётся из styles.css :root (--lime, --pink, --violet…).
   ============================================================ */

.page-character { overflow-x: hidden; }
/* верхний навбар + обычная прокрутка (снимаем flex/overflow:hidden от styles.css) */
body.page-character { display: block; overflow-x: hidden; overflow-y: auto; height: auto; min-height: 100vh; }
html:has(body.page-character) { height: auto; overflow-y: auto; }
/* прячем общий rail, если вдруг остался */
.page-character .rail { display: none !important; }

/* фоновое видео (приглушённое) */
/* Фон: плавная анимация цвета — медленно переливающиеся акцентные пятна */
.ch-bganim { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background: linear-gradient(120deg, #0a0812, #0d0a18, #0a0d18, #0c0a14);
  background-size: 300% 300%; animation: chBgShift 24s ease-in-out infinite; }
.ch-bganim::before {
  content: ""; position: absolute; inset: -20%;
  background:
    radial-gradient(700px 520px at 20% 25%, rgba(124,92,255,.30), transparent 60%),
    radial-gradient(650px 500px at 80% 70%, rgba(228,244,130,.14), transparent 60%),
    radial-gradient(600px 480px at 60% 20%, rgba(80,160,255,.18), transparent 60%);
  animation: chBgFloat 28s ease-in-out infinite alternate;
}
.ch-bganim::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,7,12,.45), rgba(8,7,12,.82));
}
@keyframes chBgShift { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes chBgFloat {
  0%   { transform: translate3d(0,0,0) scale(1); }
  50%  { transform: translate3d(3%, -2%, 0) scale(1.08); }
  100% { transform: translate3d(-3%, 2%, 0) scale(1.04); }
}
@media (prefers-reduced-motion: reduce) { .ch-bganim, .ch-bganim::before { animation: none; } }

/* сцена (контент центрирован, верхний навбар) */
.ch-stage {
  position: relative; z-index: 2; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 110px 24px 80px;
}
@media (max-width: 820px) { .ch-stage { padding: 90px 5px 110px; } }

/* экраны */
.ch-screen { width: 100%; max-width: 760px; text-align: center; display: none; }
.ch-screen.active { display: block; animation: chFade .5s ease; }
@keyframes chFade { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.ch-h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(30px, 5.5vw, 58px); line-height: 1; letter-spacing: -.02em; text-transform: uppercase; }
.ch-lead { color: var(--text-2); font-size: clamp(15px, 2vw, 18px); max-width: 520px; margin: 20px auto 0; }
@media (max-width: 820px) { .ch-lead { padding: 0 20px; box-sizing: border-box; } }

/* кнопка «клик» */
.ch-click-btn {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 34px;
  padding: 16px 30px; border-radius: 14px; border: none; cursor: pointer;
  background: var(--lime); color: var(--lime-ink);
  font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .01em;
  box-shadow: 0 0 0 4px rgba(228,244,130,.12), 0 18px 50px -16px rgba(228,244,130,.5);
  transition: transform .15s, box-shadow .25s;
}
.ch-click-btn:hover { transform: translateY(-2px); box-shadow: 0 0 0 5px rgba(228,244,130,.16), 0 22px 56px -14px rgba(228,244,130,.6); }
.ch-click-btn:active { transform: translateY(0) scale(.98); }
.ch-click-btn svg { width: 20px; height: 20px; }

/* кнопки после готовности */
.ch-post { margin-top: 28px; display: none; gap: 12px; justify-content: center; flex-wrap: wrap; position: relative; }
.ch-post.show { display: flex; }
.ch-btn-primary { display: inline-flex; align-items: center; gap: 9px; padding: 15px 26px; border-radius: 13px; background: var(--lime); color: var(--lime-ink); font-family: var(--font-display); font-weight: 700; font-size: 15px; border: none; cursor: pointer; }
.ch-btn-ghost { display: inline-flex; align-items: center; gap: 9px; padding: 15px 24px; border-radius: 13px; background: rgba(255,255,255,.06); border: 1px solid var(--line-strong); color: var(--text); font-weight: 700; font-size: 14px; cursor: pointer; }
.ch-btn-ghost .chev { transition: transform .2s; }
.ch-btn-ghost.open .chev { transform: rotate(180deg); }

/* выпадающий список персонажей */
.ch-menu { position: absolute; top: calc(100% + 10px); left: 0; min-width: 270px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; padding: 8px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.7); display: none; z-index: 10; text-align: left; }
.ch-menu.show { display: block; animation: chFade .25s ease; }
.ch-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 11px; cursor: pointer; }
.ch-item:hover { background: var(--surface-2); }
.ch-item .ca { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--violet), var(--pink)); flex-shrink: 0; }
.ch-item .cn { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.ch-type { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 7px; font-family: var(--font-display); letter-spacing: .02em; }
.ch-type.fast { background: rgba(110,231,255,.16); color: #7fe6ff; }
.ch-type.exact { background: rgba(228,244,130,.16); color: var(--lime); }
.ch-type.video { background: rgba(255,80,151,.16); color: var(--pink); }
.ch-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.ch-add { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 11px; cursor: pointer; color: var(--lime); font-weight: 600; font-size: 14px; }
.ch-add:hover { background: var(--surface-2); }
.ch-add svg { width: 18px; height: 18px; }

/* кнопка «Вернуться» */
.ch-back { position: fixed; top: 76px; left: 24px; z-index: 40; display: none; align-items: center; gap: 8px; color: var(--text-2); font-weight: 600; font-size: 14px; cursor: pointer; background: rgba(20,19,28,.7); backdrop-filter: blur(10px); border: 1px solid var(--line); padding: 9px 16px; border-radius: 11px; text-decoration: none; }
.ch-back svg { width: 16px; height: 16px; }
.ch-back:hover { color: var(--text); }
.page-character.in-train .ch-back { display: flex; }
/* «На главную» — по центру сверху, над заголовком */
.ch-back.ch-home { display: inline-flex; left: 50%; transform: translateX(-50%); top: 20px; }
.page-character.in-train .ch-back.ch-home { left: 50%; }
body.home-topnav .ch-back.ch-home { top: 74px; }
@media (max-width: 820px) {
  .ch-back { left: 10px; top: 66px; }
  .page-character.in-train .ch-back.ch-home { left: 50%; }
  body.home-topnav .ch-back.ch-home { top: 64px; }
  /* «На главную» опускаем ниже, чтобы её было видно под хедером */
  .ch-back.ch-home { top: 118px; }
  body.home-topnav .ch-back.ch-home { top: 118px; }
  /* при входе в «Клик» (выбор/обучение) «На главную» не нужна — скрываем */
  .page-character.in-train .ch-back.ch-home { display: none !important; }
}

/* === ЭКРАН ВЫБОРА ПРОФИЛЯ === */
.ch-choose-head h2 { font-family: var(--font-display); font-weight: 700; font-size: clamp(24px, 4vw, 38px); line-height: 1.04; letter-spacing: -.01em; }
.ch-choose-head p { color: var(--text-2); font-size: 15px; margin: 10px auto 0; max-width: 520px; }
.ch-group { margin-top: 26px; text-align: left; }
.ch-group-lbl { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin: 0 0 12px 2px; }
.ch-group-lbl::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.ch-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 640px) { .ch-cards { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  /* +20px воздуха между «Вернуться» и «Выбери тип персонажа» */
  .ch-choose-head { padding-top: 20px; }
  /* на мобилке «Продолжить» не нужна — клик по карточке сразу открывает создание */
  .ch-next-wrap { display: none; }
}
.ch-card { position: relative; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; cursor: pointer; transition: border-color .18s, transform .18s, background .18s; display: flex; flex-direction: column; gap: 10px; font-family: inherit; }
.ch-card:hover { border-color: var(--line-strong); transform: translateY(-2px); background: var(--surface-2); }
.ch-card.sel { border-color: var(--lime); box-shadow: 0 0 0 3px rgba(228,244,130,.18); }
.ch-card-top { display: flex; align-items: center; gap: 11px; }
.ch-card-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--lime); flex-shrink: 0; }
.ch-card.sel .ch-card-ic { background: rgba(228,244,130,.14); }
.ch-card-ic svg { width: 22px; height: 22px; }
.ch-card-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: #fff; }
.ch-card-badge { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .03em; padding: 4px 9px; border-radius: 7px; font-family: var(--font-display); white-space: nowrap; }
.ch-card-badge.best { background: var(--lime); color: var(--lime-ink); }
.ch-card-badge.fast { background: #2b3a40; color: #7fe6ff; }
.ch-card-badge.pro { background: var(--pink); color: #fff; }
.ch-card-desc { font-size: 13px; color: var(--text-2); line-height: 1.45; }
.ch-card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.ch-tag { font-size: 11px; font-weight: 600; color: var(--text-3); background: var(--surface-3); padding: 5px 10px; border-radius: 8px; display: inline-flex; align-items: center; gap: 5px; }
.ch-tag b { color: var(--text-2); font-weight: 700; }
.ch-tag.price b { color: var(--lime); }
.ch-tag .co { width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe7a3, #e8b54b); }
.ch-next-wrap { margin-top: 26px; display: flex; justify-content: center; }
.ch-next { padding: 15px 40px; border-radius: 13px; background: var(--lime); color: var(--lime-ink); font-family: var(--font-display); font-weight: 700; font-size: 15px; border: none; cursor: pointer; opacity: .5; pointer-events: none; transition: opacity .2s; }
.ch-next.ready { opacity: 1; pointer-events: auto; }

/* === ЭКРАН ОБУЧЕНИЯ === */
.ch-train-card { width: 100%; max-width: 680px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 24px; padding: 30px; text-align: left; }
.ch-name-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.ch-name { font-family: var(--font-display); font-weight: 700; font-size: 22px; background: none; border: none; color: var(--text); outline: none; border-bottom: 1.5px dashed transparent; padding: 2px 0; max-width: 340px; }
.ch-name:focus { border-bottom-color: var(--lime); }
.ch-edit { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; flex: 0 0 auto; font-size: 12px; color: var(--lime); background: rgba(228,244,130,.1); padding: 5px 11px; border-radius: 999px; cursor: pointer; }
.ch-edit svg { width: 13px; height: 13px; }
.ch-hint { color: var(--text-3); font-size: 13px; margin-bottom: 20px; }
.ch-upload { border: 1.5px dashed var(--line-strong); border-radius: 18px; min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(255,255,255,.015); margin-bottom: 18px; }
.ch-btn-upload { display: inline-flex; align-items: center; gap: 9px; padding: 13px 24px; border-radius: 12px; background: var(--lime); color: var(--lime-ink); font-weight: 800; border: none; cursor: pointer; font-family: inherit; }
.ch-btn-upload svg { width: 18px; height: 18px; }
.ch-upload-sub { color: var(--text-3); font-size: 13px; }
.ch-rules { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
@media (max-width: 560px) { .ch-rules { grid-template-columns: 1fr; } }
.ch-rule { display: flex; gap: 11px; align-items: flex-start; }
.ch-rule .ri { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.ch-rule.ok .ri { background: #2ecc71; }
.ch-rule.no .ri { background: #ff4757; }
.ch-rule .ri svg { width: 15px; height: 15px; color: #fff; }
.ch-rule p { font-size: 13px; color: var(--text-2); line-height: 1.4; }
.ch-start { width: 100%; padding: 15px; border-radius: 13px; background: var(--lime); color: var(--lime-ink); font-family: var(--font-display); font-weight: 700; font-size: 15px; border: none; cursor: pointer; }

/* прогресс */
.ch-progress { display: none; text-align: center; padding: 20px 0; }
.ch-progress.show { display: block; }
.ch-ring { width: 96px; height: 96px; margin: 0 auto 22px; position: relative; }
.ch-ring svg { transform: rotate(-90deg); }
.ch-ring .pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; font-size: 22px; }
.ch-progress h3 { font-family: var(--font-display); font-weight: 700; font-size: 20px; margin-bottom: 8px; }
.ch-progress p { color: var(--text-2); font-size: 14px; margin-bottom: 24px; }
.ch-done { display: none; padding: 15px 40px; border-radius: 13px; background: var(--lime); color: var(--lime-ink); font-family: var(--font-display); font-weight: 700; font-size: 15px; border: none; cursor: pointer; }
.ch-done.show { display: inline-block; animation: chFade .4s ease; }

/* верхний навбар как на главной: «Вернуться» ниже навбара */
body.home-topnav .ch-back { top: 100px; }

/* ── Этап 13: загруженные фото (превью-сетка) ── */
.ch-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-bottom: 16px; }
.ch-thumb { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--line-strong); }
.ch-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ch-thumb-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.62); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ch-thumb-x:hover { background: rgba(0,0,0,.82); }

/* ── Этап 13: мобильные правки создания персонажа ── */
@media (max-width: 820px) {
  .ch-train-card { padding: 20px 16px; border-radius: 20px; }
  /* карточку отодвигаем вниз, чтобы фикс-кнопка «Вернуться» не лежала на содержимом */
  #ch-screen-train.ch-screen.active { padding-top: 34px; }
  .ch-name-row { flex-wrap: nowrap; gap: 8px; }
  .ch-name { font-size: 18px; min-width: 0; flex: 1 1 auto; }
  .ch-upload { min-height: 150px; }
  /* «Вернуться» — заметная, поверх карточки, но не перекрывает контент */
  .ch-back { z-index: 60; }
  .ch-thumbs { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
}
