/* ============================================================
   БЕСКОНЕЧНАЯ ИСТОРИЯ — стили
   Палитра: ночь тайги, уголь, золото, северное сияние.
   ============================================================ */

:root {
  --bg-0: #05080f;        /* космос/ночь */
  --bg-1: #0a0f1c;
  --bg-2: #0e1626;
  --ink: #e8eef2;
  --ink-dim: #93a4b5;
  --gold: #d4a24a;
  --gold-soft: #e6c26e;
  --ember: #ff6d3b;
  --aurora: #2dd4bf;
  --aurora-deep: #0e766e;
  --font-body: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: 'Cormorant Garamond', 'PT Serif', Georgia, serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg-0);
  color: var(--ink);
  line-height: 1.6;
  overflow-x: hidden;
}

::selection { background: rgba(212, 162, 74, .35); color: #fff; }

/* ---------- фон: северное сияние + звёзды ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background:
  radial-gradient(1200px 800px at 70% -10%, #16233d 0%, transparent 60%),
  radial-gradient(900px 700px at 15% 110%, #131c2e 0%, transparent 55%),
  var(--bg-0);
}

.aurora {
  position: absolute; inset: -20%;
  background:
    radial-gradient(60% 45% at 30% 0%,   rgba(45, 212, 191, .16), transparent 65%),
    radial-gradient(55% 40% at 75% 8%,    rgba(212, 162, 74, .10), transparent 60%);
  filter: blur(30px);
  animation: auroraDrift 26s ease-in-out infinite alternate;
}
@keyframes auroraDrift {
  0%   { transform: translate3d(-3%, -2%, 0) scale(1); opacity: .9; }
  50%  { transform: translate3d(2%, 2%, 0)  scale(1.04); opacity: 1; }
  100% { transform: translate3d(3%, -1%, 0) scale(1); opacity: .85; }
}

.stars { position: absolute; inset: 0; background-repeat: repeat; }
.stars-1 { background-image: radial-gradient(1.4px 1.4px at 20% 30%, rgba(255,255,255,.8), transparent 60%),
  radial-gradient(1.2px 1.2px at 70% 20%, rgba(255,255,255,.7), transparent 60%),
  radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,.6), transparent 60%),
  radial-gradient(1.6px 1.6px at 85% 60%, rgba(255,255,255,.75), transparent 60%),
  radial-gradient(1px 1px at 10% 80%, rgba(255,255,255,.5), transparent 60%);
  background-size: 520px 520px;
  animation: starTwinkle 6s ease-in-out infinite alternate;
}
.stars-2 { transform: translateY(40px) scale(1.6); background-image:
  radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,.4), transparent 60%),
  radial-gradient(1.3px 1.3px at 60% 40%, rgba(255,255,255,.35), transparent 60%),
  radial-gradient(1px 1px at 80% 80%, rgba(255,255,255,.3), transparent 60%);
  background-size: 340px 340px;
  animation: starTwinkle 9s ease-in-out infinite alternate-reverse;
}
@keyframes starTwinkle { from { opacity: .55; } to { opacity: 1; } }

.vignette { position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(2,4,10,.75) 100%); }

@media (prefers-reduced-motion: reduce) {
  .aurora, .stars { animation: none; }
}

/* ---------- типографика ---------- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; }
em { font-style: italic; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 20px; }
.section { padding: 96px 0; position: relative; }
.section-alt { background: linear-gradient(180deg, transparent, rgba(14, 22, 38, .5) 18%, transparent); }

.kicker {
  color: var(--aurora);
  text-transform: uppercase;
  letter-spacing: .22em;
  font-size: 12px;
  margin: 0 0 10px;
}
.section-title { font-size: clamp(28px, 5vw, 42px); line-height: 1.15; margin-bottom: 18px; }
.section-lead { color: var(--ink-dim); max-width: 640px; margin: 0 0 36px; font-size: 17px; }

/* ---------- hero ---------- */
.hero {
  min-height: 100svh;
  display: flex; align-items: center; justify-content: center;
  text-align: center; position: relative; padding: 96px 20px 120px;
}
.hero-inner { max-width: 760px; }
.hero-eyebrow {
  color: var(--ink-dim); text-transform: uppercase; letter-spacing: .25em;
  font-size: 11px; margin: 26px 0 18px;
}
.hero-title {
  font-size: clamp(44px, 9vw, 84px); line-height: .95; letter-spacing: .02em;
}
.hero-title em { color: var(--gold-soft); }
.hero-sub { color: var(--ink-dim); font-size: clamp(16px, 2.4vw, 20px); margin: 22px 0 34px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 26px; border-radius: 999px; font-weight: 600; font-size: 15px;
  text-decoration: none; cursor: pointer; transition: box-shadow .25s ease, transform .25s ease, background .25s ease;
}
.btn-primary {
  color: #1c1206; background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  box-shadow: 0 0 0 1px rgba(230, 194, 110, .5), 0 8px 30px rgba(212, 162, 74, .25);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(230,194,110,.6), 0 12px 40px rgba(212,162,74,.4); }
.btn-ghost { color: var(--ink); border: 1px solid rgba(147,164,181,.35); }
.btn-ghost:hover { border-color: var(--aurora); color: var(--aurora); }

.hero-scroll { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); width: 22px; height: 36px; }
.hero-scroll span { display: block; width: 2px; height: 100%; margin: 0 auto; background: linear-gradient(var(--aurora), transparent); animation: drip 2.2s ease-in-out infinite; }
@keyframes drip { 0% { transform: scaleY(0); transform-origin: top; } 55% { transform: scaleY(1); } 100% { opacity: 0; transform: scaleY(1); } }

/* ---------- сигиль ---------- */
.sigil { width: min(340px, 60vw); margin: 0 auto; will-change: transform; }
.sigil-svg { width: 100%; height: auto; display: block; }
.ring { fill: none; stroke: var(--aurora); stroke-width: .6; opacity: .4; }
.ring-outer { animation: pulse 7s ease-in-out infinite; }
.ring-middle { animation: pulse 7s ease-in-out .6s infinite; }
.ring-inner { animation: pulse 7s ease-in-out 1.2s infinite; }
.ring-core, .core-dot { stroke: var(--gold); }
.ring-core { animation: pulse 7s ease-in-out 1.8s infinite; }
.core-dot { fill: var(--gold); filter: drop-shadow(0 0 6px var(--gold)); }
.thread { stroke: var(--gold); stroke-width: .5; opacity: .5; }
.orbit { fill: none; stroke: rgba(212,162,74,.35); stroke-dasharray: 3 6; }
.orbit-dot { fill: var(--gold); }
.sigil .orbit { transform-origin: 100px 100px; animation: spin 40s linear infinite; }
.sigil .orbit-dot { transform-origin: 100px 100px; animation: spin 40s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: .9; } }

/* ---------- путь хранителя ---------- */
.keeper-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 48px; align-items: start; }
.keeper-text p { color: var(--ink-dim); margin: 0 0 16px; }
.keeper-quote {
  font-family: var(--font-display); font-size: 22px; color: var(--gold-soft);
  border-left: 2px solid var(--gold); padding-left: 18px; font-style: italic;
}
.keeper-photo { margin: 0; }
.photo-frame {
  aspect-ratio: 4/5; border-radius: 18px;
  background: linear-gradient(160deg, #182236, #0b1220 60%);
  border: 1px solid rgba(45,212,191,.25);
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  position: relative; overflow: hidden; transform-style: preserve-3d;
}
.photo-glare {
  position: absolute; inset: 0;
  background: radial-gradient(60% 40% at 30% 20%, rgba(45,212,191,.18), transparent 70%),
              radial-gradient(50% 40% at 75% 80%, rgba(212,162,74,.12), transparent 70%);
}
figcaption { text-align: center; color: var(--ink-dim); font-size: 13px; margin-top: 12px; letter-spacing: .06em; }

/* ---------- метод ---------- */
.method-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.method-card {
  background: rgba(14, 22, 38, .55); border: 1px solid rgba(147,164,181,.14);
  border-radius: 16px; padding: 22px; backdrop-filter: blur(6px);
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.method-card:hover { transform: translateY(-4px); border-color: rgba(45,212,191,.4); box-shadow: 0 12px 40px rgba(45,212,191,.12); }
.method-icon { width: 40px; height: 40px; color: var(--aurora); margin-bottom: 14px; }
.method-icon svg { width: 100%; height: 100%; }
.method-card h3 { font-family: var(--font-body); font-size: 16px; font-weight: 600; margin-bottom: 8px; color: #fff; }
.method-card p { color: var(--ink-dim); font-size: 14px; margin: 0; }

/* ---------- портал / чат ---------- */
.portal { background: linear-gradient(180deg, transparent, rgba(45,212,191,.05) 50%, transparent); }
.chat {
  max-width: 760px; margin: 0 auto; border-radius: 18px; overflow: hidden;
  border: 1px solid rgba(45,212,191,.3);
  background: rgba(5, 10, 22, .8);
  box-shadow: 0 0 40px rgba(45,212,191,.08), inset 0 0 60px rgba(45,212,191,.04);
  display: flex; flex-direction: column; height: 560px;
}
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid rgba(147,164,181,.15); font-size: 13px; color: var(--ink-dim);
}
.chat-orb { width: 9px; height: 9px; border-radius: 50%; background: var(--aurora); box-shadow: 0 0 10px var(--aurora); animation: pulse 3s ease-in-out infinite; }
.chat-status { margin-left: auto; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }

.msg { max-width: 82%; }
.msg-user { align-self: flex-end; }
.msg-bot { align-self: flex-start; }
.msg-body {
  padding: 10px 14px; border-radius: 14px; font-size: 15px; white-space: pre-wrap;
}
.msg-user .msg-body { background: linear-gradient(135deg, rgba(212,162,74,.2), rgba(212,162,74,.1)); border: 1px solid rgba(212,162,74,.35); border-bottom-right-radius: 4px; }
.msg-bot .msg-body { background: rgba(45,212,191,.07); border: 1px solid rgba(45,212,191,.2); border-bottom-left-radius: 4px; }
.msg-error .msg-body { border-color: rgba(255,109,59,.5); }
.msg-error .retry { margin-top: 8px; }

.typing { display: flex; gap: 4px; padding: 12px 16px; align-items: center; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--aurora); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

.caret::after { content: '▍'; color: var(--aurora); animation: blink 1s steps(2) infinite; }

.retry {
  background: none; border: 1px solid rgba(45,212,191,.4); color: var(--aurora);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.retry:hover { background: rgba(45,212,191,.1); }

.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid rgba(147,164,181,.15); }
#chat-input {
  flex: 1; background: rgba(10, 15, 28, .6); border: 1px solid rgba(147,164,181,.2);
  color: var(--ink); border-radius: 10px; padding: 12px 14px; font: inherit; font-size: 15px;
  transition: border-color .2s ease;
}
#chat-input:focus { outline: none; border-color: var(--aurora); }
#chat-input::placeholder { color: #5b6b7d; }
.chat-send {
  width: 46px; border: none; border-radius: 10px; cursor: pointer;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold)); color: #1c1206;
  display: grid; place-items: center; transition: filter .2s ease;
}
.chat-send:disabled { opacity: .5; cursor: default; }
.chat-send:not(:disabled):hover { filter: brightness(1.1); }

.chat-hints { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 0 12px 14px; }
.chip {
  background: none; border: 1px solid rgba(147,164,181,.25); color: var(--ink-dim);
  border-radius: 999px; padding: 6px 14px; font-size: 12.5px; cursor: pointer; font-family: inherit;
  transition: border-color .2s ease, color .2s ease;
}
.chip:hover { border-color: var(--aurora); color: var(--aurora); }

/* ---------- цитата ---------- */
.quote-band { padding: 40px 0; border-top: 1px solid rgba(147,164,181,.1); border-bottom: 1px solid rgba(147,164,181,.1); background: rgba(5,10,22,.4); }
.quote-band blockquote {
  font-family: var(--font-display); font-style: italic; font-size: clamp(20px, 3.4vw, 30px);
  text-align: center; color: var(--gold-soft); margin: 0; line-height: 1.5;
}

/* ---------- футер ---------- */
.footer { padding: 56px 0 32px; }
.footer-grid { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: center; }
.footer-name { font-weight: 600; margin: 0; }
.footer-geo { color: var(--ink-dim); font-size: 14px; margin: 4px 0 0; }
.footer-links { display: flex; gap: 22px; }
.footer-links a { color: var(--ink-dim); text-decoration: none; font-size: 14px; transition: color .2s; }
.footer-links a:hover { color: var(--aurora); }
.footer-note { margin-top: 28px; color: #5b6b7d; font-size: 12.5px; }

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s ease, transform .8s ease; }
.reveal.is-in { opacity: 1; transform: none; }

/* ---------- адаптив ---------- */
@media (max-width: 900px) {
  .method-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .keeper-grid { grid-template-columns: 1fr; }
  .keeper-photo { max-width: 360px; }
  .chat { height: 480px; }
  .section { padding: 72px 0; }
}
