/* ============================================================
   Стили сайта. Здесь ничего сложного: переменные, сетка, карточки.
   Отдельно прокомментированы места, связанные с рекламой.
   ============================================================ */

:root {
  --bg:        #0f1115;
  --surface:   #171a21;
  --surface-2: #1e222b;
  --line:      #272c37;
  --text:      #e6e9ef;
  --muted:     #9aa3b2;
  --accent:    #4ade80;
  --accent-dk: #22c55e;
  --radius:    10px;
  --wrap:      1180px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Segoe UI", system-ui, -apple-system, sans-serif;
}

a { color: inherit; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- шапка ---------- */
.site-head {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.head-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; }
.logo-mark {
  width: 22px; height: 22px; border-radius: 5px;
  background: linear-gradient(135deg, var(--accent), #2dd4bf);
}
.logo-text { font-size: 18px; letter-spacing: -.01em; }
.nav { display: flex; gap: 18px; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
.nav a:hover { color: var(--text); }

/* ---------- разметка страницы ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  align-items: start;
  padding-top: 28px;
  padding-bottom: 48px;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  /* В одну колонку sticky теряет смысл: липнуть внутри собственной области
     не к чему, зато появляется лишний контекст наложения. А вместе с блоком,
     прилипшим к низу экрана, получились бы две закреплённые рекламы разом —
     это нарушение правил почти любой сети. */
  .sidebar { position: static; top: auto; }
}

h1 { font-size: 30px; margin: 0 0 6px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 8px; }
.lede { color: var(--muted); margin: 0 0 22px; max-width: 60ch; }

/* ---------- панель фильтров ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.control {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  min-width: 170px;
}
.control:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#search { flex: 1 1 240px; }
.check {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.check input { accent-color: var(--accent); margin: 0; }

.counter { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- карточки игр ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: #3a4252; transform: translateY(-2px); }

/* Настоящая обложка. Соотношение сторон задано в CSS, а не только в атрибутах:
   место под картинку резервируется до её загрузки, поэтому карточки не прыгают.
   Сдвиг вёрстки при подгрузке рекламные сети штрафуют отдельно. */
.cover-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

/* Запасной вариант, если картинки у игры нет: градиент с первой буквой названия */
.cover {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg,
              hsl(var(--hue) 55% 32%),
              hsl(calc(var(--hue) + 35) 60% 18%));
  font-size: 30px;
  font-weight: 800;
  color: rgba(255,255,255,.9);
  letter-spacing: -.03em;
}
.card-body { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card-title { font-weight: 650; font-size: 15px; line-height: 1.3; }
.card-short { color: var(--muted); font-size: 13px; flex: 1; }
.card-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.tag {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}
.rating { color: var(--accent); font-weight: 700; }

.fav {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}
.fav:hover { border-color: var(--accent); color: var(--text); }
.fav[aria-pressed="true"] { border-color: var(--accent-dk); color: var(--accent); }

/* ---------- текстовые страницы ---------- */
.article { max-width: 70ch; }
.article h2 { font-size: 19px; margin: 26px 0 8px; }
.article p { margin: 0 0 14px; color: #c7cdd8; }
.article ul { margin: 0 0 14px; padding-left: 20px; color: #c7cdd8; }
.article li { margin-bottom: 5px; }
.article a { color: var(--accent); }

/* ---------- страница игры ---------- */
.card-link { text-decoration: none; color: inherit; display: block; }
.card-link:hover .card-title, .card-title .card-link:hover { color: var(--accent); }
.game-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.game-cover {
  width: 220px; aspect-ratio: 16/9; border-radius: var(--radius);
  display: grid; place-items: center; font-size: 46px; font-weight: 800;
  background: linear-gradient(140deg, hsl(var(--hue) 55% 32%), hsl(calc(var(--hue) + 35) 60% 18%));
  color: rgba(255,255,255,.9); flex: 0 0 auto;
}
.game-cover-img {
  width: 320px; max-width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  flex: 0 0 auto;
  background: var(--surface-2);
}
.game-info { flex: 1 1 260px; }

/* Галерея скриншотов */
.shots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin: 10px 0 4px;
}
.shot {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: block;
}
.game-info h1 { margin-bottom: 8px; }
.player {
  position: relative; background: #000; border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 16/9; margin: 20px 0;
}
.player video { width: 100%; height: 100%; display: block; }
/* Контейнер рекламы лежит поверх видео — так работает любой VAST-плеер */
#ad-container { position: absolute; inset: 0; }
.player-note { color: var(--muted); font-size: 13px; margin-top: -8px; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--text); }
.crumbs { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

/* Короткая справка о игре: платформы, время, режим, год */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 18px 0 4px;
}
.fact { background: var(--surface); padding: 11px 13px; display: flex; flex-direction: column; gap: 3px; }
.fact-k { color: var(--muted); font-size: 12px; }
.fact-v { font-size: 14px; font-weight: 600; }

/* Вердикты «кому подойдёт» и «кому нет» — цветная полоса вместо иконок */
.verdict { border-left: 3px solid var(--line); padding-left: 12px; }
.verdict.yes { border-left-color: var(--accent); }
.verdict.no  { border-left-color: #b45309; }

/* Похожие игры */
.similar { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.sim {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 13px;
  text-decoration: none; color: inherit;
  transition: border-color .15s;
}
.sim:hover { border-color: #3a4252; }
.sim-cover {
  width: 46px; height: 34px; border-radius: 6px; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 800; font-size: 17px;
  background: linear-gradient(140deg, hsl(var(--hue) 55% 32%), hsl(calc(var(--hue) + 35) 60% 18%));
  color: rgba(255,255,255,.9);
}
.sim-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.sim-title { font-weight: 600; font-size: 14px; }
.sim-short { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Список статей */
.posts { display: flex; flex-direction: column; gap: 10px; }
.post {
  display: flex; flex-direction: column; gap: 5px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 17px;
  text-decoration: none; color: inherit;
  transition: border-color .15s;
}
.post:hover { border-color: #3a4252; }
.post:hover .post-title { color: var(--accent); }
.post-date { color: var(--muted); font-size: 12.5px; }
.post-title { font-family: inherit; font-weight: 650; font-size: 17px; line-height: 1.3; }
.post-lead { color: var(--muted); font-size: 14px; }

.meta-line { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.source-note {
  color: var(--faint, var(--muted)); font-size: 13px;
  border-top: 1px solid var(--line); padding-top: 12px; margin-top: 26px;
}

/* Обложка в списке похожих: картинка вместо буквы, если она есть */
.sim-img {
  width: 46px; height: 34px; flex: 0 0 auto;
  object-fit: cover; border-radius: 6px; display: block;
  background: var(--surface-2);
}

/* Плитка жанров на главной */
.genres { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; }
.genre-chip {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 13px; font-size: 13.5px;
  text-decoration: none; color: var(--muted); transition: .15s;
}
.genre-chip:hover { border-color: var(--accent); color: var(--text); }

/* ---------- сайдбар ---------- */
/* Липкой делаем не всю колонку, а один блок внутри неё.
   Элемент выше экрана прилипать не умеет — он просто прокручивается вместе
   со страницей. Колонка с двумя блоками 300x250 и панелью как раз выше экрана,
   поэтому sticky на ней не работал, хотя и был прописан. */
.sidebar { display: flex; flex-direction: column; gap: 20px; }
.sidebar .is-sticky { position: sticky; top: 84px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
}
.panel p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ---------- рекламные слоты ----------
   Место под блок резервируется заранее и не зависит от того, приехала реклама
   или нет: иначе страница дёрнется в момент вставки креатива. Это метрика CLS,
   за неё снижают оценку и поисковики, и рекламные сети.

   Резервируем через min-height, а не height. Жёсткая высота вместе с
   overflow:hidden обрезала бы креатив: слот на 250 px, получив баннер 300x600,
   показал бы верхнюю половину. Сеть засчитала бы показ, а рекламодатель увидел
   бы обрубок — за такое площадку отключают.                              */
.ad-slot {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  position: relative;
  min-height: 100px;
  max-width: 100%;
}
.ad-slot::after {
  content: "рекламное место " attr(data-ad-size);
  color: #4b5364;
  font-size: 12px;
  letter-spacing: .04em;
}
/* Как только внутрь слота что-то вставили, подпись убирается */
.ad-slot:not(:empty)::after { content: none; }
.ad-slot:not(:empty) { border-style: solid; }

/* Обёртка с подписью. Подпись лежит СНАРУЖИ слота: правило :not(:empty) выше
   считает слот заполненным по любому содержимому, и подпись внутри отключила бы
   заглушку с размером навсегда. А сама подпись обязательна — рекламу нельзя
   выдавать за редакционный материал, это требование и сетей, и закона. */
.ad-unit { margin: 22px 0; }
.ad-label {
  display: block;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .75;
  margin-bottom: 4px;
}

/* Высота под каждый формат. Она обязана совпадать с самым высоким размером
   из sizeMapping для этой ширины экрана — иначе прыжок вёрстки вернётся. */
.ad-leader { min-height: 90px; }
.ad-rect { min-height: 250px; }
.ad-infeed { min-height: 280px; }
.ad-incontent { min-height: 250px; }
/* Видеоблок в тексте: пропорции держим через aspect-ratio, высота считается сама */
.ad-outstream { aspect-ratio: 16 / 9; min-height: 0; width: 100%; background: #000; }

@media (max-width: 900px) {
  .ad-leader { min-height: 100px; }   /* 320x100 */
}

/* Блок в ленте каталога стоит между двумя сетками, а не внутри них,
   поэтому ширину берёт от колонки контента — растягивать его не нужно. */
.ad-unit-feed { margin: 26px 0; }

/* ---------- прилипающий блок внизу (только мобильная ширина) ----------
   Самый доходный мобильный формат и самый опасный: если он перекроет текст
   или не будет закрываться, площадку отключают. Поэтому кнопка закрытия
   обязательна, а место под блок резервируется классом на body. */
.ad-adhesive {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  /* Ниже шапки (z-index: 10): прилипшая внизу реклама не имеет права
     перекрыть навигацию. */
  z-index: 9;
  display: none;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
}
.ad-adhesive .ad-label { margin-bottom: 2px; }
.ad-adhesive-slot { width: 320px; min-height: 100px; }
.ad-adhesive-close {
  position: absolute; top: -14px; right: 10px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--line); cursor: pointer;
  font-size: 16px; line-height: 1;
}
@media (max-width: 900px) {
  .ad-adhesive { display: flex; }
  /* Отступ ставит скрипт, а не медиазапрос: закрыли рекламу — отступ исчез */
  body.has-adhesive { padding-bottom: 150px; }
}

/* ---------- подвал ---------- */
.site-foot {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 20px 0;
  color: var(--muted);
  font-size: 14px;
}
.foot-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
/* Атрибуция RAWG — обязательное условие их API, ссылка должна быть активной */
.attr { font-size: 13px; color: var(--faint, var(--muted)); }
.attr a { color: var(--muted); }
.attr a:hover { color: var(--accent); }
