/* ============================================================
   PLAYDING — main.css
   Базовые стили: CSS-переменные, сброс, типографика, layout
   Методология: BEM
   ============================================================ */

/* ---------- 1. CSS Custom Properties (темизация) ---------- */
:root {
  /* Палитра (тёмная тема по умолчанию) */
  --bg-deep: #0a0e17;
  --bg-base: #101728;
  --bg-elevated: #141b2d;
  --bg-card: rgba(20, 27, 45, 0.72);
  --bg-hover: #1c2541;

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(0, 212, 255, 0.35);

  --text-primary: #e8ecf4;
  --text-secondary: #9aa4b8;
  --text-muted: #5c6780;

  --accent-cyan: #00d4ff;
  --accent-violet: #8b5cf6;
  --accent-orange: #ff6b35;
  --accent-green: #2dd4a7;

  --danger: #ff4d6d;
  --star: #ffc53d;

  /* Градиенты */
  --grad-hero: linear-gradient(135deg, rgba(0, 212, 255, 0.28) 0%, rgba(139, 92, 246, 0.22) 50%, rgba(255, 107, 53, 0.12) 100%);
  --grad-accent: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));

  /* Glassmorphism */
  --glass-bg: rgba(16, 23, 40, 0.55);
  --glass-border: 1px solid rgba(255, 255, 255, 0.08);
  --glass-blur: blur(12px) saturate(120%);

  /* Тени */
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 34px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 24px rgba(0, 212, 255, 0.35);
  --shadow-violet: 0 0 24px rgba(139, 92, 246, 0.35);

  /* Типографика */
  --font-body: "Inter", "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Orbitron", "Inter", system-ui, sans-serif;

  /* Размеры и отступы */
  --container-max: 1440px;
  --header-h: 72px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* Анимации */
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --t-fast: 220ms var(--ease);
  --t-med: 350ms var(--ease);
  --t-slow: 500ms var(--ease);

  /* Z-index шкала */
  --z-header: 100;
  --z-modal: 200;
  --z-toast: 300;

  /* Контент */
  color-scheme: dark;
}

/* Светлая тема (accessible через toggle) */
[data-theme="light"] {
  --bg-deep: #eef2f8;
  --bg-base: #ffffff;
  --bg-elevated: #eef2fa;
  --bg-card: rgba(255, 255, 255, 0.96);
  --bg-hover: #e3e9f5;

  --border-subtle: rgba(10, 14, 23, 0.1);
  --border-strong: rgba(0, 120, 200, 0.4);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #5b6784;

  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-border: 1px solid rgba(10, 14, 23, 0.07);
  --grad-hero: linear-gradient(135deg, rgba(0, 180, 255, 0.18) 0%, rgba(139, 92, 246, 0.14) 50%, rgba(255, 107, 53, 0.1) 100%);

  --shadow-sm: 0 4px 14px rgba(30, 40, 70, 0.12);
  --shadow-md: 0 10px 34px rgba(30, 40, 70, 0.16);

  color-scheme: light;
}

/* ---------- 2. Сброс ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(139, 92, 246, 0.08), transparent 60%),
    radial-gradient(1000px 500px at -10% 20%, rgba(0, 212, 255, 0.06), transparent 60%);
  min-height: 100vh;
  transition: background-color var(--t-med), color var(--t-med);
  overflow-x: hidden;
}

img,
svg,
canvas,
video {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: color var(--t-fast);
}

a:hover {
  color: var(--accent-violet);
}

ul {
  list-style: none;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

/* Фокус-индикаторы (WCAG 2.1 AA) */
:focus-visible {
  outline: 3px solid var(--accent-cyan);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---------- 3. Утилиты ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 48px);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---------- 4. Типографика ---------- */
::selection {
  background: rgba(0, 212, 255, 0.35);
  color: #fff;
}

/* ---------- 4.1. Атрибут hidden всегда скрывает элемент ----------
   Авторские display-правила (.btn и др.) перебивают UA-стиль [hidden],
   из-за чего элементы с hidden остаются видимыми. Лечится !important. */
[hidden] {
  display: none !important;
}

/* ---------- 5. Кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background-color var(--t-med), color var(--t-med), border-color var(--t-med);
  position: relative;
  overflow: hidden;
  min-height: 44px; /* touch-friendly */
  user-select: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn--accent {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.btn--accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 34px rgba(0, 212, 255, 0.55);
}

.btn--ghost {
  /* Без backdrop-filter: экономит GPU на множестве кнопок */
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn--ghost:hover {
  border-color: var(--border-strong);
  background: rgba(0, 212, 255, 0.08);
  transform: translateY(-1px);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn--danger:hover {
  background: #e23852;
  transform: translateY(-2px);
  box-shadow: 0 0 26px rgba(255, 77, 109, 0.5);
}

.btn--block {
  width: 100%;
}

.btn--sm {
  padding: 8px 16px;
  font-size: 13px;
  min-height: 36px;
}

/* Иконки-кнопки */
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: color var(--t-fast), background-color var(--t-fast), transform var(--t-fast);
}

.icon-btn:hover {
  color: var(--accent-cyan);
  background: rgba(0, 212, 255, 0.08);
}

.icon-btn:active {
  transform: scale(0.92);
}

/* ---------- 6. Скроллбар ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-cyan), var(--accent-violet));
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg-deep);
}

/* ---------- 7. High-contrast режим ---------- */
@media (prefers-contrast: more) {
  :root {
    --border-subtle: rgba(255, 255, 255, 0.35);
    --text-secondary: var(--text-primary);
  }
  .btn--ghost,
  .filters,
  .card-game {
    backdrop-filter: none;
  }
}

/* ---------- 8. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 9. Жёсткий контейнер для производительности ---------- */
.hero,
.catalog__main,
.filters {
  contain: layout style paint;
}