/* ============================================================
   ДИЗАЙН-СИСТЕМА — приглушённый тёмно-фиолетовый
   ============================================================ */

:root {
  /* Фоны: не чистый чёрный, чтобы не резало глаза */
  --bg: #0d0b14;
  --bg-2: #13101d;
  --surface: #15111f;
  --surface-2: #1b1628;
  --elevated: #181324;
  --input-bg: #100d19;

  /* Акценты: мягкая лаванда вместо кислотного фиолетового */
  --purple: #8b6cf0;
  --purple-bright: #b4a0fa;
  --purple-deep: #4a2f99;
  --grad: linear-gradient(135deg, #7457e0 0%, #9a74ef 100%);
  --accent-soft: rgba(139, 108, 240, 0.12);
  --accent-softer: rgba(139, 108, 240, 0.07);

  /* Текст: без чистого белого */
  --text: #e4dff0;
  --text-strong: #f4f1fa;
  --muted: #9890ad;
  --muted-2: #6f6884;

  --border: rgba(196, 181, 253, 0.09);
  --border-strong: rgba(196, 181, 253, 0.18);

  /* Категории — приглушённые */
  --c-code: #a994f7;
  --c-game: #7fa8f0;
  --c-story: #d99ae8;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Manrope", "Inter", -apple-system, "Segoe UI", sans-serif;

  --nav-h: 88px;
  --max-w: 1180px;
  --radius: 20px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: dark;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

html,
body {
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body {
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  color: var(--text-strong);
  letter-spacing: -0.02em;
}

img,
video {
  max-width: 100%;
  display: block;
}
a {
  color: inherit;
}
button {
  font-family: inherit;
}

::selection {
  background: rgba(139, 108, 240, 0.35);
  color: var(--text-strong);
}

:focus-visible {
  outline: 2px solid var(--purple-bright);
  outline-offset: 3px;
}

/* Тонкий скроллбар */
html {
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 108, 240, 0.25) transparent;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(139, 108, 240, 0.22);
  border-radius: 100px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 108, 240, 0.4);
}

/* ---------- Фон: статичная мягкая аура, без анимации ---------- */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  pointer-events: none;
}
body::before {
  inset: -20vh -10vw auto;
  height: 70vh;
  background: radial-gradient(
    ellipse 60% 60% at 50% 0%,
    rgba(116, 87, 224, 0.16) 0%,
    transparent 70%
  );
}
body::after {
  width: 520px;
  height: 520px;
  right: -200px;
  bottom: -220px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(154, 116, 239, 0.08) 0%,
    transparent 70%
  );
}

/* ---------- Keyframes (используются и в других CSS) ---------- */
@keyframes riseIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
@keyframes shiftGradient {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* Появление при скролле (main.js) */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 0.7s var(--ease),
    transform 0.7s var(--ease);
}
.reveal.visible {
  opacity: 1;
  transform: none;
}

/* ============================================================
   НАВБАР — плавающая «пилюля»
   ============================================================ */
.nav {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(var(--max-w), calc(100% - 28px));
  z-index: 100;
  animation: fadeDown 0.6s var(--ease) both;
}
.nav-inner {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 10px 0 14px;
  border-radius: 100px;
  background: rgba(19, 16, 29, 0.6);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  transition:
    background 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}
.nav.scrolled .nav-inner {
  background: rgba(19, 16, 29, 0.88);
  border-color: var(--border-strong);
  box-shadow: 0 16px 40px -20px rgba(0, 0, 0, 0.7);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  white-space: nowrap;
}
.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #fff;
  font-size: 16px;
  box-shadow: 0 6px 18px -6px rgba(116, 87, 224, 0.6);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links {
  display: flex;
  gap: 2px;
  list-style: none;
}
.nav-links a {
  display: block;
  padding: 8px 14px;
  border-radius: 100px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition:
    color 0.2s ease,
    background 0.2s ease;
}
.nav-links a:hover {
  color: var(--text);
  background: var(--accent-softer);
}
.nav-links a.active {
  color: var(--text-strong);
  background: var(--accent-soft);
}

.nav-burger {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.nav-burger:hover {
  background: var(--accent-softer);
}
.nav-burger .icon-close {
  display: none;
}
.nav.menu-open .nav-burger .icon-open {
  display: none;
}
.nav.menu-open .nav-burger .icon-close {
  display: block;
}

@media (max-width: 860px) {
  .nav-burger {
    display: inline-flex;
  }
  .nav-links {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    border-radius: 20px;
    background: rgba(19, 16, 29, 0.97);
    border: 1px solid var(--border-strong);
    box-shadow: 0 24px 48px -16px rgba(0, 0, 0, 0.7);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition:
      opacity 0.2s ease,
      transform 0.2s ease,
      visibility 0.2s;
  }
  .nav.menu-open .nav-links {
    opacity: 1;
    visibility: visible;
    transform: none;
  }
  .nav-links a {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 15px;
  }
}

/* ============================================================
   КНОПКИ
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  white-space: nowrap;
  transition:
    transform 0.25s var(--ease),
    box-shadow 0.25s ease,
    background 0.25s ease,
    border-color 0.25s ease;
}
.btn-lg {
  padding: 15px 28px;
  font-size: 15px;
}
.btn-primary {
  color: #fff;
  background: var(--grad);
  box-shadow: 0 10px 28px -12px rgba(116, 87, 224, 0.75);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px -12px rgba(116, 87, 224, 0.9);
}
.btn-ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--border-strong);
}
.btn-ghost:hover {
  background: var(--accent-softer);
  border-color: rgba(180, 160, 250, 0.35);
  transform: translateY(-2px);
}
.btn svg {
  transition: transform 0.25s var(--ease);
}
.btn:hover svg {
  transform: translateX(2px);
}

/* ============================================================
   ФУТЕР
   ============================================================ */
.footer {
  position: relative;
  z-index: 1;
  margin-top: 96px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, transparent, rgba(19, 16, 29, 0.6));
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px 24px 28px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
}
.footer-note {
  margin-top: 12px;
  max-width: 360px;
  color: var(--muted);
  font-size: 14px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: flex-end;
  align-content: flex-start;
  list-style: none;
}
.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s ease;
}
.footer-links a:hover {
  color: var(--text-strong);
}
.footer-copy {
  grid-column: 1 / -1;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted-2);
  font-size: 13px;
}

/* ============================================================
   BADGE
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  background: var(--accent-softer);
  font-size: 13px;
  font-weight: 500;
  color: var(--purple-bright);
  opacity: 0;
  animation: riseIn 0.7s var(--ease) 0.05s forwards;
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6fd49a;
  box-shadow: 0 0 0 3px rgba(111, 212, 154, 0.15);
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 56px) 24px 24px;
  text-align: center;
}
.page-header h1 {
  font-size: clamp(36px, 5vw, 60px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin: 20px 0 16px;
  color: var(--text-strong);
  opacity: 0;
  transform: translateY(16px);
  animation: riseIn 0.7s var(--ease) 0.15s forwards;
}
.page-header .lead {
  max-width: 560px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
  opacity: 0;
  transform: translateY(16px);
  animation: riseIn 0.7s var(--ease) 0.25s forwards;
}

/* ============================================================
   ПОИСК
   ============================================================ */
.search-wrap {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 24px auto 0;
  padding: 0 24px;
  text-align: center;
  opacity: 0;
  animation: riseIn 0.7s var(--ease) 0.35s forwards;
}
.search-field {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  padding: 4px 6px 4px 18px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}
.search-field:focus-within {
  border-color: rgba(180, 160, 250, 0.45);
  box-shadow: 0 0 0 4px rgba(139, 108, 240, 0.1);
}
.search-icon {
  color: var(--muted);
  flex-shrink: 0;
  transition: color 0.2s ease;
}
.search-field:focus-within .search-icon {
  color: var(--purple-bright);
}
.search-field input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 12px;
}
.search-field input::placeholder {
  color: var(--muted-2);
}
.search-clear {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: none;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.search-clear:hover {
  background: rgba(139, 108, 240, 0.25);
}
.search-hint {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted-2);
}

/* ============================================================
   ФИЛЬТРЫ И СОРТИРОВКА
   ============================================================ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}
.filter-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.filter-btn.active {
  color: var(--text-strong);
  background: var(--accent-soft);
  border-color: rgba(180, 160, 250, 0.35);
}
.filter-btn .f-icon {
  font-size: 13px;
  opacity: 0.85;
}
.filter-btn .f-count {
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.05);
}
.filter-btn.active .f-count {
  background: rgba(180, 160, 250, 0.18);
}

.sort {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 4px;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 100px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition:
    color 0.2s ease,
    background 0.2s ease;
}
.sort-btn:hover {
  color: var(--text);
}
.sort-btn.active {
  color: var(--text-strong);
  background: var(--accent-soft);
}

/* ============================================================
   МОДАЛКА
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal[hidden] {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 13, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.modal.open .modal-backdrop {
  opacity: 1;
}
.modal-window {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  border-radius: 24px;
  background: var(--elevated);
  border: 1px solid var(--border-strong);
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition:
    opacity 0.25s var(--ease),
    transform 0.25s var(--ease);
}
.modal.open .modal-window {
  opacity: 1;
  transform: none;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-softer);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: background 0.2s ease;
}
.modal-close:hover {
  background: var(--accent-soft);
}
.modal-body {
  padding: 40px 40px 36px;
  overflow-y: auto;
  max-height: 88vh;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.modal-title {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin-bottom: 20px;
  color: var(--text-strong);
}
.modal-image {
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 24px;
  background: var(--input-bg);
}
.modal-image img {
  width: 100%;
  height: auto;
  display: block;
}
.modal-text {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 24px;
}
.modal-text b {
  color: var(--text-strong);
}
.modal-text a {
  color: var(--purple-bright);
  text-decoration: underline;
  text-decoration-color: rgba(180, 160, 250, 0.4);
  text-underline-offset: 3px;
}
.modal-text a:hover {
  text-decoration-color: currentColor;
}

/* ---------- Пустое состояние ---------- */
.empty-state {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 40px auto;
  padding: 72px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state .empty-emoji {
  display: block;
  font-size: 44px;
  margin-bottom: 12px;
  opacity: 0.75;
}

/* ============================================================
   CONTROLS (posts / suggestions)
   ============================================================ */
.controls {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  opacity: 0;
  animation: riseIn 0.7s var(--ease) 0.45s forwards;
}

/* ============================================================
   КНОПКА «НАВЕРХ»
   ============================================================ */
.scroll-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(24, 19, 36, 0.9);
  border: 1px solid var(--border-strong);
  color: var(--purple-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    background 0.25s ease;
}
.scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
}
.scroll-top:hover {
  background: var(--surface-2);
  transform: translateY(-2px);
}

/* ============================================================
   АДАПТИВ
   ============================================================ */
@media (max-width: 900px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
}

@media (max-width: 720px) {
  .page-header {
    padding: calc(var(--nav-h) + 32px) 20px 16px;
  }
  .search-wrap {
    padding: 0 20px;
  }
  .modal {
    padding: 12px;
  }
  .modal-body {
    padding: 32px 22px 26px;
  }
  .modal-close {
    top: 10px;
    right: 10px;
  }
  .footer-inner {
    grid-template-columns: 1fr;
    padding: 40px 20px 24px;
  }
  .footer-links {
    justify-content: flex-start;
  }
  .controls {
    padding: 20px 20px 24px;
  }
  .scroll-top {
    right: 12px;
    bottom: 12px;
  }
}

@media (max-width: 480px) {
  .nav .logo-text {
    display: none;
  }
}

/* ---------- Меньше движения ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
}
