/* ==========================================================
   MONOLITH: ARSENAL — chrome.css
   Общее для всех страниц: токены, иконки, шапка, нижняя навигация.
   Подключай ДО страничных стилей.
   ========================================================== */

:root {
  --bg: #0a0a0a; --bg-2: #111114; --bg-3: #16161a;
  --border: #232328; --text: #e8e8ea; --dim: #8a8a94;
  --accent: #e30613; --accent-2: #ff1f2e; --glow: rgba(227, 6, 19, 0.35);
  --gold: #d4af37; --green: #4ade80; --blue: #3b82f6; --purple: #a855f7;
  --nav-h: 58px;
}
[data-theme="light"] {
  --bg: #f4f4f6; --bg-2: #ffffff; --bg-3: #eaeaef;
  --border: #d4d4da; --text: #111114; --dim: #5a5a64;
  --glow: rgba(227, 6, 19, 0.2);
}

html { scroll-padding-top: calc(var(--nav-h) + 8px); overflow-x: clip; }
/* Заголовок hero шире экрана телефона: из-за него вся страница уезжала вбок */
@media (max-width: 480px) {
  .hero h1 { font-size: 7.4vw; letter-spacing: 1px; }
  .hero .slogan { letter-spacing: 2px; }
}
body.menu-locked { overflow: hidden; }

/* ---------- Иконки ---------- */
.i {
  width: 1em; height: 1em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.14em; margin-right: 0.42em;
}
.i.solo { margin-right: 0; }
.i.solo + .i.solo { margin-left: 0.35em; }
.i-gold { color: #d4af37; } .i-silver { color: #b8bcc6; } .i-bronze { color: #cd7f32; }
.i-accent { color: var(--accent); }
.dot { display: inline-block; width: 0.7em; height: 0.7em; border-radius: 50%; background: var(--c, var(--dim)); margin-right: 0.5em; vertical-align: 0.02em; box-shadow: 0 0 0 2px color-mix(in srgb, var(--c, var(--dim)) 25%, transparent); }
.mode-icon, .race-icon, .ach-icon, .sponsor-logo, .merch-icon, .partner-icon { color: var(--accent); }

/* ---------- Фокус ---------- */
:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-2); outline-offset: 2px;
}

/* ---------- Шапка ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 300; height: var(--nav-h);
  border-bottom: 1px solid var(--border);
}
/* Фон и размытие вынесены в ::before: backdrop-filter на самой шапке сделал бы её
   контейнером для position:fixed, и выезжающее меню схлопнулось бы до её высоты. */
.topbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: background 0.2s;
}
.topbar.scrolled::before { background: color-mix(in srgb, var(--bg) 96%, transparent); }
/* Красная линия внизу шапки показывает, сколько страницы прочитано */
.topbar::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%;
  background: var(--accent); box-shadow: 0 0 12px var(--glow);
  transform: scaleX(var(--p, 0)); transform-origin: 0 50%;
}
.topbar-inner {
  max-width: 1360px; height: 100%; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 10px;
}

.brand {
  display: flex; align-items: center; gap: 10px; flex: none;
  color: var(--text); text-decoration: none; font-weight: 900; font-size: 14px; letter-spacing: 1.5px;
}
.brand-mark {
  width: 32px; height: 32px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 900; font-size: 15px;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.brand-name span { color: var(--accent); }

.primary {
  position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0;
  background: var(--bg-2); overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 0 calc(24px + env(safe-area-inset-bottom));
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s, visibility 0s 0.18s;
}
.primary.open { opacity: 1; visibility: visible; transform: none; transition: opacity 0.18s, transform 0.18s; }

.menu-group { border-bottom: 1px solid var(--border); }
.menu-group-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 17px 20px; background: none; border: 0; cursor: pointer;
  color: var(--text); font: inherit; font-size: 15px; font-weight: 700; text-align: left;
}
.menu-group-head .chev { margin: 0; color: var(--dim); transition: transform 0.2s; transform: rotate(90deg); }
.menu-group.open .menu-group-head .chev { transform: rotate(-90deg); }
.menu-group-body { display: none; padding: 0 0 10px; }
.menu-group.open .menu-group-body { display: block; }
.menu-group-body a {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px 12px 28px;
  color: var(--text); text-decoration: none; font-size: 14px;
}
.menu-group-body a .i { margin: 0; color: var(--dim); font-size: 18px; }
.menu-group-body a:hover, .menu-group-body a:active { background: var(--bg-3); }
.menu-group-body a:hover .i { color: var(--accent); }

.menu-account {
  display: flex; align-items: center; gap: 12px; padding: 17px 20px;
  color: var(--text); text-decoration: none; font-size: 15px; font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.menu-account .i { margin: 0; color: var(--dim); font-size: 18px; }
button.menu-account { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border); font-family: inherit; text-align: left; cursor: pointer; }
.menu-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 18px 16px 0; padding: 15px; background: var(--accent); color: #fff;
  text-decoration: none; font-size: 15px; font-weight: 700;
}
.menu-cta:active { background: var(--accent-2); }

.tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-clock {
  display: none; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  color: var(--dim); padding: 0 10px; white-space: nowrap;
}
.nav-clock b { color: var(--text); font-weight: 600; }
.icon-btn {
  position: relative; width: 40px; height: 40px; display: grid; place-items: center;
  background: none; border: 1px solid transparent; color: var(--text);
  font-size: 19px; cursor: pointer; text-decoration: none; transition: background 0.15s, border-color 0.15s;
}
.icon-btn .i { margin: 0; }
.icon-btn:hover { background: var(--bg-3); border-color: var(--border); }
.badge {
  position: absolute; top: 2px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
}
.badge:empty { display: none; }
.avatar {
  width: 26px; height: 26px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 800;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
/* Тема: в тёмной показываем солнце, в светлой луну */
.ic-moon { display: none; }
[data-theme="light"] .ic-sun { display: none; }
[data-theme="light"] .ic-moon { display: block; }

.nav-cta {
  display: none; align-items: center; height: 38px; padding: 0 18px; margin-left: 8px;
  background: var(--accent); color: #fff; text-decoration: none; font-size: 13px; font-weight: 700;
  transition: background 0.15s;
}
.nav-cta:hover { background: var(--accent-2); }

.burger {
  width: 40px; height: 40px; display: grid; place-content: center; gap: 5px;
  background: none; border: 0; cursor: pointer; margin-right: -6px;
}
.burger span { display: block; width: 22px; height: 2px; background: var(--text); transition: transform 0.2s, opacity 0.2s; }
.burger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.active span:nth-child(2) { opacity: 0; }
.burger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Узкий экран: в шапке остаются корзина и бургер, остальное живёт в меню */
@media (max-width: 559px) {
  #searchBtn, #themeBtn, #authBtn { display: none; }
}
@media (min-width: 560px) { .menu-tool { display: none; } }

@media (min-width: 1100px) {
  .burger, .menu-account, .menu-cta, .menu-tool { display: none; }
  .primary {
    position: static; inset: auto; background: none; overflow: visible; padding: 0;
    opacity: 1; visibility: visible; transform: none; transition: none;
    display: flex; align-items: stretch; gap: 2px; margin-left: 14px; height: 100%;
  }
  .menu-group { position: relative; border: 0; }
  .menu-group-head {
    height: var(--nav-h); width: auto; padding: 0 12px; font-size: 13px; font-weight: 600;
    justify-content: center; color: var(--dim); transition: color 0.15s;
  }
  .menu-group-head .chev { transform: rotate(90deg) scale(0.8); }
  .menu-group:hover .menu-group-head, .menu-group.open .menu-group-head, .menu-group:focus-within .menu-group-head { color: var(--text); }
  .menu-group:hover .menu-group-head .chev, .menu-group.open .menu-group-head .chev { transform: rotate(-90deg) scale(0.8); }
  .menu-group-body {
    position: absolute; top: 100%; left: 0; min-width: 240px; padding: 6px 0;
    background: var(--bg-2); border: 1px solid var(--border); border-top: 2px solid var(--accent);
    box-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
  }
  .menu-group:hover .menu-group-body, .menu-group:focus-within .menu-group-body, .menu-group.open .menu-group-body { display: block; }
  .menu-group-body.wide { display: none; min-width: 470px; grid-template-columns: 1fr 1fr; }
  .menu-group:hover .menu-group-body.wide, .menu-group:focus-within .menu-group-body.wide, .menu-group.open .menu-group-body.wide { display: grid; }
  .menu-group-body a { padding: 10px 18px; font-size: 13px; }
  .nav-cta { display: inline-flex; }
}
@media (min-width: 1280px) { .nav-clock { display: block; } }

/* ---------- Нижняя навигация (телефон) ---------- */
.floating-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 250; display: flex;
  background: color-mix(in srgb, var(--bg-2) 94%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.floating-nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px 8px; color: var(--dim); text-decoration: none; font-size: 11px;
  transition: color 0.15s;
}
.floating-nav-btn .icon { font-size: 22px; line-height: 1; display: block; }
.floating-nav-btn .icon .i { margin: 0; display: block; }
.floating-nav-btn.active, .floating-nav-btn.highlight { color: var(--accent); }
body.has-floating-nav { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
@media (min-width: 769px) {
  .floating-nav { display: none; }
  body.has-floating-nav { padding-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* «Наверх» не должна лежать под кнопкой чата */
@media (max-width: 768px) {
  .back-top { bottom: calc(140px + env(safe-area-inset-bottom)); }
}

/* Cookie-баннер всегда поверх нижней навигации, иначе не нажать «Принять» */
body .cookie-banner { z-index: 320; }
