/* ============================================================
   Оракул совместимости арканов — «Светлый эдиториал»
   Тёплый крем · графитовый текст · акцент-баклажан
   Шрифты: Fraunces (дисплей) + Inter (текст)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #f5efe6;          /* тёплый крем */
  --bg-warm: #faf6ee;     /* светлее, для верхнего свечения */
  --card: #fffdf8;        /* карточки/пузыри оракула */
  --ink: #2a2722;         /* графитовый текст */
  --ink-soft: #574f45;    /* вторичный текст */
  --muted: #948a7b;       /* подписи, плейсхолдеры */
  --accent: #6b3f5b;      /* баклажан */
  --accent-deep: #58324b; /* нажатие/ховер */
  --accent-tint: rgba(107, 63, 91, 0.07);
  --line: rgba(42, 39, 34, 0.12);
  --line-soft: rgba(42, 39, 34, 0.07);
  --danger: #a8453b;
  --radius: 18px;
  --shadow: 0 24px 50px -28px rgba(42, 39, 34, 0.30);
  --shadow-soft: 0 10px 30px -18px rgba(42, 39, 34, 0.22);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* КРИТИЧНО: display:flex у экранов перебивает браузерный [hidden]{display:none}.
   Возвращаем приоритет атрибуту, иначе скрытый экран остаётся видимым. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1100px 620px at 50% -18%, var(--bg-warm) 0%, transparent 62%),
    radial-gradient(900px 600px at 90% 115%, #efe7da 0%, transparent 55%),
    var(--bg);
}

/* На светлой теме звёздный слой не нужен */
.stars { display: none; }

a { color: var(--accent); text-underline-offset: 2px; }

/* ---------- Онбординг ---------- */
.onb {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px;
}
.onb-card {
  width: 100%; max-width: 480px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  padding: 46px 42px 36px;
  box-shadow: var(--shadow);
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.onb-sigil {
  text-align: center; font-size: 20px; color: var(--accent);
  letter-spacing: 0.3em; opacity: 0.85;
}
.onb-title {
  font-family: var(--serif); font-optical-sizing: auto;
  font-weight: 500; text-align: center;
  margin: 14px 0 12px;
  font-size: 36px; line-height: 1.08; letter-spacing: -0.015em;
  color: var(--ink);
}
.onb-lead {
  text-align: center; color: var(--ink-soft);
  margin: 0 0 28px; line-height: 1.62; font-size: 15.5px;
}

.date-group { border: none; margin: 0 0 18px; padding: 0; }
.date-group legend {
  color: var(--accent); font-size: 11px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  margin-bottom: 9px; padding: 0;
}
.date-row { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }

select, input[type="text"], input[type="email"] {
  width: 100%; padding: 13px 12px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px; font-family: var(--sans);
}
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select:focus, input[type="text"]:focus, input[type="email"]:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.date-error { color: var(--danger); font-size: 12.5px; min-height: 16px; margin-top: 6px; }

.consents { margin: 8px 0 20px; animation: rise 0.4s ease both; }
.consent {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13.5px; color: var(--ink-soft); line-height: 1.5;
  margin-bottom: 11px; cursor: pointer;
}
.consent input { margin-top: 2px; width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.consent a { color: var(--accent); text-decoration: underline; }
.consent em { color: var(--muted); font-style: normal; }

.onb-submit {
  width: 100%; padding: 16px;
  font-family: var(--sans); font-size: 15.5px; font-weight: 600; letter-spacing: 0.01em;
  color: #fff; border: none; border-radius: 13px; cursor: pointer;
  background: var(--accent);
  transition: transform 0.16s ease, background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: var(--shadow-soft);
}
.onb-submit:hover:not(:disabled) { background: var(--accent-deep); transform: translateY(-1px); }
.onb-submit:active:not(:disabled) { transform: translateY(0); }
.onb-submit:disabled { background: #d9d1c4; color: #fbf8f2; cursor: not-allowed; box-shadow: none; }

.onb-hint { text-align: center; color: var(--muted); font-size: 12.5px; margin: 14px 0 0; transition: color 0.2s ease; }
.onb-hint.hint-warn { color: var(--accent); }

.onb-footer { position: relative; z-index: 1; text-align: center; margin-top: 26px; font-size: 12px; color: var(--muted); }
.onb-footer a { color: var(--ink-soft); text-decoration: none; }
.onb-footer a:hover { color: var(--accent); }
.onb-disclaimer { margin-top: 10px; color: var(--muted); }

/* ---------- Чат (app-раскладка: скролл тела, закреплённый ввод) ---------- */
.chat-screen {
  position: relative; z-index: 1;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
}
.chat-header {
  flex: none; z-index: 2;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: rgba(250, 246, 238, 0.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft); color: var(--ink-soft);
  font-family: var(--sans); font-size: 13.5px; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 9px;
}
.chat-sigil { color: var(--accent); letter-spacing: 0.2em; }

.chat-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  width: 100%; max-width: 700px; margin: 0 auto;
  padding: 28px 18px 14px; display: flex; flex-direction: column; gap: 16px;
}

.msg {
  max-width: 84%; padding: 14px 18px; line-height: 1.7; font-size: 15.5px;
  border-radius: 18px; animation: msg-in 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

.msg-oracle {
  align-self: flex-start;
  background: var(--card); border: 1px solid var(--line-soft);
  border-bottom-left-radius: 6px; color: var(--ink);
  box-shadow: var(--shadow-soft);
}
.msg-user {
  align-self: flex-end;
  background: var(--accent-tint); border: 1px solid rgba(107, 63, 91, 0.16);
  border-bottom-right-radius: 6px; color: var(--accent-deep);
  box-shadow: var(--shadow-soft);
}

/* Прелоадер «оракул всматривается» — спокойные точки + мягкий перелив текста */
.msg.thinking { display: flex; align-items: center; gap: 8px; }
.msg.thinking em {
  margin-left: 4px; font-size: 13.5px; font-style: italic;
  background: linear-gradient(100deg, var(--muted) 20%, var(--accent) 50%, var(--muted) 80%);
  background-size: 200% auto; -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
  animation: shimmer 2.8s linear infinite;
}
@keyframes shimmer { to { background-position: -200% center; } }
.msg.thinking .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  display: inline-block; animation: orb 1.4s infinite ease-in-out both;
}
.msg.thinking .dot:nth-child(2) { animation-delay: 0.18s; }
.msg.thinking .dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes orb {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.7); }
  40% { opacity: 1; transform: scale(1.05); }
}

/* Зона действий — закреплена снизу */
.chat-actions {
  flex: none; width: 100%; max-width: 700px; margin: 0 auto;
  /* max(), а НЕ сумма: иначе на телефонах с home-индикатором под полем ввода
     набегает лишнее пространство (паддинг + safe-area). */
  padding: 12px 18px max(12px, env(safe-area-inset-bottom));
  max-height: 56vh; overflow-y: auto;
  border-top: 1px solid var(--line-soft);
  background: rgba(250, 246, 238, 0.9);
  backdrop-filter: blur(10px);
}
.chat-actions:empty { display: none; }

.block-buttons { display: flex; flex-direction: column; gap: 10px; }
.block-btn {
  width: 100%; padding: 15px 18px; text-align: left;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px;
  font-family: var(--sans); font-size: 15px; font-weight: 500; cursor: pointer;
  transition: transform 0.14s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  animation: msg-in 0.45s ease both;
}
.block-btn:hover:not(:disabled) {
  transform: translateY(-1px); border-color: var(--accent);
  background: #fff; box-shadow: var(--shadow-soft);
}
.block-btn:disabled { opacity: 0.5; cursor: default; }
.block-btn.is-loading { opacity: 0.65; }
.block-btn:nth-child(2) { animation-delay: 0.07s; }
.block-btn:nth-child(3) { animation-delay: 0.14s; }

/* Свободный вопрос / режим вопросов */
.free-q, .q-row { display: flex; gap: 8px; }
.free-q { animation: rise 0.4s ease both; }
.free-q-send {
  padding: 0 22px; border: none; border-radius: 13px; cursor: pointer;
  font-family: var(--sans); font-size: 15px; font-weight: 600; color: #fff;
  background: var(--accent); transition: background 0.2s ease;
}
.free-q-send:hover { background: var(--accent-deep); }

.qmode { flex-direction: column; gap: 10px; }
.q-counter {
  color: var(--accent); font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; text-align: center;
}

/* Пейволл */
.paywall { display: flex; flex-direction: column; gap: 13px; animation: rise 0.45s ease both; }
.paywall-title {
  font-family: var(--serif); font-weight: 500; font-size: 22px; line-height: 1.2;
  color: var(--ink); text-align: center; margin-bottom: 4px;
}
.paywall-email input { width: 100%; }
.pay-error { color: var(--danger); font-size: 12.5px; min-height: 14px; }

.offer {
  display: flex; flex-direction: column; gap: 5px; text-align: left;
  padding: 18px 20px; border-radius: 16px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  transition: transform 0.14s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.offer:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-soft); border-color: var(--accent); }
.offer:disabled { opacity: 0.55; cursor: default; }
.offer-primary { background: var(--accent-tint); border-color: var(--accent); }
.offer-title { font-family: var(--serif); font-weight: 500; font-size: 17px; color: var(--accent-deep); }
.offer-price { font-family: var(--serif); font-weight: 600; font-size: 26px; color: var(--ink); }
.offer-sub { font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.paywall-note { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.paywall-note.pending { color: var(--accent); }

/* ---------- Юридические страницы ---------- */
.page-legal { font-family: var(--sans); line-height: 1.7; }
.legal-header { position: relative; z-index: 1; padding: 20px 22px; border-bottom: 1px solid var(--line-soft); }
.legal-logo { color: var(--accent); text-decoration: none; font-family: var(--serif); font-weight: 500; font-size: 19px; letter-spacing: 0.01em; }
.legal-main { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 40px 22px 56px; }
.legal-eyebrow { color: var(--accent); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600; }
.legal-main h1 { font-family: var(--serif); font-weight: 500; color: var(--ink); margin: 10px 0 26px; font-size: 32px; letter-spacing: -0.01em; }
.legal-main h2 { font-family: var(--serif); font-weight: 500; color: var(--ink); font-size: 21px; margin: 30px 0 8px; }
.legal-main a { color: var(--accent); }
.legal-main ul { padding-left: 20px; }
.legal-disclaimer { margin-top: 32px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink-soft); font-size: 14px; }
.legal-operator { margin-top: 18px; color: var(--ink-soft); font-size: 14px; }
.legal-footer { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 22px; display: flex; flex-wrap: wrap; gap: 16px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 13px; }
.legal-footer a { color: var(--ink-soft); text-decoration: none; }
.legal-footer a:hover { color: var(--accent); }

/* ---------- Мобилка ---------- */
@media (max-width: 420px) {
  .onb { padding: 22px 16px; }
  .onb-card { padding: 34px 24px 26px; border-radius: 20px; }
  .onb-title { font-size: 30px; }

  .chat-body { padding: 20px 14px 10px; gap: 13px; }
  .msg { max-width: 90%; font-size: 15px; padding: 13px 15px; }
  .chat-actions { padding: 10px 14px max(10px, env(safe-area-inset-bottom)); }
  .block-btn { padding: 14px 15px; font-size: 14.5px; }
  .offer { padding: 16px 16px; }
  .offer-price { font-size: 23px; }
  .paywall-title { font-size: 20px; }
}

/* ---------- Доступность ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
