/* Лендинг Magia Imperata. Задача страницы — не пересказать лор, а за 2-3 минуты объяснить формат:
   свободный ввод + настоящие правила. Порядок экранов (что это → как работает → почему такая свобода →
   во что играть → почему не AI-чат → попробовать) закреплён ТЗ и менять его нельзя.
   Регистр «Скрипторий» (docs/design-brief.md): тёплая тьма, пергамент, золото единственным акцентом.
   Стили самодостаточны: страница статическая, в сборку Vite не входит, токены приложения не наследует. */

:root {
  --bg: #15120c;
  --bg-panel: #1c1810;
  --bg-elev: #262015;
  --border: #3a3122;
  --border-soft: #2b2417;
  --text: #ece2cd;
  --text-dim: #b7a98c;
  --text-faint: #7e7358;
  --accent: #c9a227;
  --accent-dim: #8c6f1c;
  --safe: #4f8f79;

  --serif: "EB Garamond", Georgia, serif;
  --sans: "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --wrap: 1200px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.1; margin: 0; }
h2 { font-size: clamp(32px, 4.6vw, 58px); letter-spacing: -0.015em; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
em { font-style: italic; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Примитивы ─────────────────────────────────────────────── */

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 32px; position: relative; z-index: 2; }
.wrap-narrow { max-width: 720px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  padding: 13px 28px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
.btn:hover { border-color: var(--accent-dim); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a1509; font-weight: 600; }
.btn-primary:hover { background: #d8b23a; border-color: #d8b23a; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: rgba(201, 162, 39, 0.07); }
.btn-sm { padding: 8px 18px; font-size: 14px; }
.btn-lg { padding: 16px 38px; font-size: 16px; }


/* Мелкий пояснительный текст под основным: приписка, а не второй абзац. */
.fine {
  margin-top: 22px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-faint);
  max-width: 46em;
}

/* ── Шапка ─────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid transparent;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), padding 0.25s var(--ease);
}
.topbar.stuck {
  background: rgba(21, 18, 12, 0.93);
  backdrop-filter: blur(10px);
  border-bottom-color: var(--border-soft);
  padding-block: 11px;
}
.topbar-brand { font-family: var(--serif); font-size: 20px; text-decoration: none; letter-spacing: 0.02em; }

/* ── 1 · Герой ─────────────────────────────────────────────── */

.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 140px 0 110px;
}
/* Ключевой арт из главного меню. В картинке ВПЕЧАТАН логотип игры (верхняя треть), а над ней стоит свой
   заголовок — два титула в одном экране читались бы как брак. Поэтому масштаб + сдвиг вверх: верх кадра
   с логотипом уходит за край, остаётся композиция (герой между двумя башнями). Сдвиг живёт в keyframes,
   иначе анимация перебила бы transform. */
.hero-bg {
  position: absolute;
  inset: -2%;
  background-size: cover;
  background-position: center;
  /* Логотип занимает 11-29% высоты картинки. Срез сверху = ((масштаб-1)/2 + сдвиг) / масштаб, тут ≈32% —
     с запасом. Проверять и вторую половину: (масштаб-1)/2 - сдвиг обязано остаться > 0, иначе внизу дыра. */
  /* ПОРЯДОК ВАЖЕН: translate идёт ПЕРВЫМ. При `scale() translate()` сдвиг считается уже в увеличенных
     координатах и умножается на масштаб — внизу открывается щель. */
  transform: translateY(-21%) scale(1.6);
  animation: drift 44s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translateY(-21%) scale(1.6); }
  to { transform: translateY(-22%) scale(1.68); }
}
.hero-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg, rgba(21, 18, 12, 0.96) 30%, rgba(21, 18, 12, 0.55) 72%),
    linear-gradient(180deg, rgba(21, 18, 12, 0.78), rgba(21, 18, 12, 0.32) 42%, var(--bg));
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 70px;
  align-items: center;
}
.hero-text h1 {
  font-size: clamp(42px, 6.4vw, 82px);
  letter-spacing: -0.02em;
  margin-bottom: 28px;
  text-wrap: balance;
}
.hero-sub {
  font-family: var(--serif);
  font-size: clamp(19px, 2.1vw, 23px);
  line-height: 1.6;
  color: var(--text-dim);
  max-width: 34em;
  margin-bottom: 38px;
}
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-note { margin-top: 20px; font-size: 13px; color: var(--text-faint); }

/* Пример хода в герое — не скриншот, а набранная выжимка: он обязан читаться мгновенно. */
.hero-demo {
  background: rgba(28, 24, 16, 0.72);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 26px 28px;
  backdrop-filter: blur(3px);
}
.ex-player {
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  color: var(--text);
  border-left: 2px solid var(--accent-dim);
  padding-left: 16px;
  margin-bottom: 20px;
}
.ex-master {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  color: var(--text-dim);
  margin-bottom: 22px;
}
.ex-tag {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-faint);
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}
.ex-tag em { font-family: var(--serif); color: var(--accent-dim); }
.tick { color: var(--safe); }

.scroll-hint {
  position: absolute; bottom: 30px; left: 50%;
  width: 1px; height: 46px; overflow: hidden;
  background: linear-gradient(180deg, transparent, var(--border));
}
.scroll-hint span {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent, var(--accent-dim));
  animation: fall 2.6s var(--ease) infinite;
}
@keyframes fall {
  0% { transform: translateY(-100%); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: translateY(100%); opacity: 0; }
}

/* ── Полосы ────────────────────────────────────────────────── */

.band { position: relative; padding: 150px 0; }
.band-quiet { background: var(--bg-panel); border-block: 1px solid var(--border-soft); }
.band-art { overflow: hidden; }
.band-bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0.42; }
/* Подложка под экраном, где главное — скриншот или текст: арт только чтобы фон не был пустым. */
.band-bg-faint { opacity: 0.18; }
.band-art::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--bg) 0%, rgba(21, 18, 12, 0.86) 20%, rgba(21, 18, 12, 0.92) 80%, var(--bg) 100%);
}

.band-head { max-width: 780px; margin-bottom: 70px; }
.band-head-center { margin-inline: auto; text-align: center; }
.band-head h2 { margin-bottom: 24px; text-wrap: balance; }
.band-sub {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.7;
  color: var(--text-dim);
}

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 64px; align-items: center; }
.split-wide { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); align-items: start; }
.split-text h2 { margin-bottom: 34px; }

/* ── 2 · Схема четырёх шагов ───────────────────────────────── */

.flow { list-style: none; margin: 0 0 38px; padding: 0; counter-reset: none; }
.flow li {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 18px 0;
  border-top: 1px solid var(--border-soft);
}
.flow li:last-child { border-bottom: 1px solid var(--border-soft); }
.flow-n {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent-dim);
  flex: none;
  width: 26px;
}
.flow-t { font-family: var(--serif); font-size: 22px; color: var(--text); }

/* ── Скриншоты в рамке окна ────────────────────────────────── */

.shot { margin: 0; }
.shot-frame {
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: #141318;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
  cursor: zoom-in;
  transition: border-color 0.2s var(--ease);
}
.shot-frame:hover { border-color: var(--accent-dim); }
.shot-bar {
  display: flex;
  gap: 6px;
  padding: 9px 12px;
  background: #1b1a20;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.shot-bar i { width: 8px; height: 8px; border-radius: 50%; background: #3a3846; }

/* Кадры обрезаются CSS'ом, оригиналы на диске целые (их открывает лупа).
   Срез задаётся в ПРОЦЕНТАХ ШИРИНЫ картинки — так работают процентные margin.
   Формула: срез_в_пикселях / ширина_картинки. Промахнулся кадр — правь одно число здесь. */
.shot-crop { overflow: hidden; }
.shot-crop img { width: 100%; }
.shot-crop-rune img { margin-top: -69%; }     /* 789px шириной, снимаем 545px сверху (латинская реплика) */
.shot-crop-aldric img { margin-top: -34%; }   /* 766px шириной, снимаем 260px сверху (поповер перекрыл ход) */
.shot-crop-study img { margin-bottom: -74%; } /* 721px шириной, снимаем 535px снизу (второй ход с водой) */

/* Подписей под скриншотами нет намеренно: кадр должен говорить сам, иначе он слабый. */
.shots-pair { align-items: start; margin-top: 64px; }

/* ── 3 · Фразы и решётка ───────────────────────────────────── */

.phrases { list-style: none; margin: 0; padding: 0; }
.phrases li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-soft);
}
.phrases li:first-child { border-top: 1px solid var(--border-soft); }
.ph-said { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--text); }
.ph-arrow { color: var(--text-faint); }
.ph-spell { font-size: 13.5px; color: var(--accent); white-space: nowrap; }

/* Решётка шире узкого экрана — прокручивается ВНУТРИ себя, страница по горизонтали не едет. */
.grid-wrap { min-width: 0; overflow-x: auto; }
.matrix { border-collapse: collapse; width: 100%; }
.matrix th {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 8px 6px;
  text-align: center;
  vertical-align: bottom;
}
.matrix th.row-head { text-align: right; padding-right: 14px; white-space: nowrap; vertical-align: middle; }
.matrix th .lat {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent-dim);
}
.matrix td { padding: 3px; }

.cell {
  width: 100%;
  aspect-ratio: 1.6;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text-dim);
  background: rgba(236, 226, 205, 0.04);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease);
}
.cell:hover { border-color: var(--accent-dim); color: var(--text); }
.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cell.active { border-color: var(--accent); background: rgba(201, 162, 39, 0.12); color: var(--accent); }

.grid-detail {
  margin-top: 22px;
  background: rgba(28, 24, 16, 0.8);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 22px 24px;
  min-height: 150px;
}
.detail-title { font-family: var(--serif); font-size: 23px; margin-bottom: 10px; }
.detail-title em { font-size: 15px; color: var(--accent-dim); margin-left: 8px; }
.detail-body { font-family: var(--serif); font-size: 17px; line-height: 1.65; color: var(--text-dim); }
.detail-dc { margin-top: 14px; font-size: 12.5px; color: var(--text-faint); }
.detail-dc b { font-family: var(--mono); color: var(--accent); font-size: 15px; }

/* ── 4 · Иллюстрации мира ──────────────────────────────────── */

/* Арт (карта). Приглушён в покое и оживает под курсором — иначе спорит с текстом рядом. */
.art { margin: 0; }
.art img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  filter: brightness(0.72) saturate(0.85);
  cursor: zoom-in;
  transition: filter 0.35s var(--ease), border-color 0.2s var(--ease);
}
.art img:hover { filter: brightness(0.95) saturate(1); border-color: var(--accent-dim); }
.art figcaption {
  margin-top: 14px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-faint);
}
.art figcaption b { font-weight: 500; color: var(--text-dim); }

/* ── 5 · Технический блок ──────────────────────────────────── */

.tech {
  margin-top: 70px;
  border-top: 1px solid var(--border-soft);
  padding-top: 22px;
}
.tech summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--text-faint);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: color 0.16s var(--ease);
}
.tech summary::-webkit-details-marker { display: none; }
.tech summary::before { content: "+"; font-family: var(--mono); color: var(--accent-dim); }
.tech[open] summary::before { content: "–"; }
.tech summary:hover { color: var(--text-dim); }
.tech-body {
  max-width: 62em;
  margin-top: 20px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-dim);
}
.tech-body em { color: var(--text); font-style: italic; }

/* ── 6 · Финал ─────────────────────────────────────────────── */

.cta-band { padding: 150px 0; overflow: hidden; text-align: center; }
.cta-bg { opacity: 0.3; background-position: center 28%; }
.cta-band::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 60% at 50% 50%, rgba(21, 18, 12, 0.7), rgba(21, 18, 12, 0.94) 75%),
    linear-gradient(180deg, var(--bg), transparent 28%, transparent 72%, var(--bg));
}
.cta-inner h2 { margin-bottom: 38px; }
.cta-inner .hero-cta { justify-content: center; }
.perks {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 26px;
  margin: 34px 0 0;
  padding: 0;
  font-size: 13.5px;
  color: var(--text-faint);
}

.footer { border-top: 1px solid var(--border-soft); padding: 28px 0; }
.footer-inner { display: flex; align-items: center; gap: 22px; }
.footer-brand { font-family: var(--serif); font-size: 16px; color: var(--text-dim); }
.footer-nav { display: flex; gap: 20px; margin-left: auto; }
.footer-nav a { font-size: 14px; color: var(--text-faint); text-decoration: none; }
.footer-nav a:hover { color: var(--text-dim); }

/* ── Просмотр кадра целиком ────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 40px;
  background: rgba(10, 8, 5, 0.93);
  cursor: zoom-out;
  overflow: auto;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: min(100%, 1000px);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ── Появление при прокрутке ───────────────────────────────── */

.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.shown { opacity: 1; transform: none; }

/* ── Адаптив ───────────────────────────────────────────────── */

@media (max-width: 1000px) {
  .hero { padding: 120px 0 90px; }
  /* На узком экране текст ложится поверх центра арта — боковой градиент его уже не прикрывает. */
  .hero-veil { background: linear-gradient(180deg, rgba(21, 18, 12, 0.9), rgba(21, 18, 12, 0.78) 45%, var(--bg)); }
  .hero-grid, .split, .split-wide { grid-template-columns: 1fr; gap: 46px; }
  .hero-demo { order: 2; }
  .band { padding: 96px 0; }
  .band-head { margin-bottom: 48px; }
  .shots-pair { margin-top: 46px; }
}

@media (max-width: 700px) {
  .wrap { padding: 0 20px; }
  .topbar { padding: 12px 20px; }
  .band { padding: 76px 0; }
  .phrases li { grid-template-columns: 1fr; gap: 4px; }
  .ph-arrow { display: none; }
  .hero-cta .btn { flex: 1 1 auto; }
  .matrix th { font-size: 10px; }
  .matrix th .lat { display: none; }
  .matrix th.row-head { padding-right: 8px; font-size: 9.5px; }
  .cell { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .reveal { opacity: 1; transform: none; }
}
