/* =====================================================================
   Общая шапка tradecalc + бегущая строка цен (только на компьютере).
   Подключается на каждой странице:
     <link rel="stylesheet" href="/site-header.css?v=1" />
     <div id="site-header"></div>
     <script src="/site-header.js?v=1"></script>
   Классы с префиксом sh- — чтобы не пересекаться со стилями страниц.
   ===================================================================== */

.sh {
  --sh-bg: rgba(11, 15, 23, 0.82);
  --sh-line: #222c3d;
  --sh-line-2: #2c384c;
  --sh-card: #131a26;
  --sh-card-2: #182131;
  --sh-text: #e8ecf3;
  --sh-muted: #8a96aa;
  --sh-dim: #5d6a80;
  --sh-accent: #f5a524;
  --sh-up: #22c55e;
  --sh-down: #f43f5e;
  position: sticky;
  top: 0;
  z-index: 500;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--sh-text);
  -webkit-font-smoothing: antialiased;
}
.sh *,
.sh *::before,
.sh *::after { box-sizing: border-box; margin: 0; padding: 0; }

.sh-top {
  background: var(--sh-bg);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--sh-line);
  padding-top: env(safe-area-inset-top);
}
.sh-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.sh-wide .sh-inner { max-width: none; } /* на страницах-приложениях (графики, сигналы) — во всю ширину */

.sh-brand { display: flex; align-items: center; gap: 10px; flex: none; color: var(--sh-text); text-decoration: none; }
.sh-brand img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--sh-line-2), 0 0 18px rgba(245, 165, 36, 0.25);
}
.sh-brand img:hover { animation: sh-spin 0.6s linear infinite; }
@keyframes sh-spin { to { transform: rotate(360deg) scale(1.05); } }
.sh-name {
  font-family: "Oswald", "Inter", sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1;
}
.sh-name span { color: var(--sh-accent); }

.sh-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.sh-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--sh-muted);
  font: 600 14px/1 "Inter", system-ui, sans-serif;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}
.sh-link svg { width: 15px; height: 15px; flex: none; }
.sh-link:hover { color: var(--sh-text); background: var(--sh-card-2); }
.sh-link.is-current { color: var(--sh-text); background: var(--sh-card); box-shadow: inset 0 0 0 1px var(--sh-line-2); }
.sh-link.is-current svg { color: var(--sh-accent); }

/* «Мой счёт» */
.sh-acc {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  margin-left: 4px;
  border-radius: 10px;
  border: 1px solid var(--sh-line-2);
  color: var(--sh-text);
  font: 600 14px/1 "Inter", system-ui, sans-serif;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s, background-color 0.15s;
}
.sh-acc svg { width: 16px; height: 16px; color: var(--sh-accent); }
.sh-acc:hover, .sh-acc.is-current { background: var(--sh-card-2); border-color: var(--sh-accent); }

/* ---------- бегущая строка: топ-20 монет по капитализации ---------- */
.sh-ticker {
  display: none; /* на телефоне и планшете не показываем */
  height: 36px;
  overflow: hidden;
  background: rgba(8, 11, 17, 0.9);
  border-bottom: 1px solid var(--sh-line);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.sh-track {
  display: flex;
  width: max-content;
  height: 100%;
  animation: sh-scroll var(--sh-dur, 80s) linear infinite;
}
.sh-ticker:hover .sh-track { animation-play-state: paused; }
@keyframes sh-scroll { to { transform: translateX(-50%); } }
.sh-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 18px;
  border-right: 1px solid var(--sh-line);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--sh-text);
  text-decoration: none;
  white-space: nowrap;
}
.sh-item:hover { background: rgba(255, 255, 255, 0.04); }
.sh-item img { width: 18px; height: 18px; border-radius: 50%; }
.sh-item b { font-weight: 700; }
.sh-item .p { color: var(--sh-muted); }
.sh-item .c { font-weight: 600; }
.sh-item .c.up { color: var(--sh-up); }
.sh-item .c.down { color: var(--sh-down); }
.sh-item .r { color: var(--sh-dim); font-size: 11px; }

/* компьютер: широкий экран и мышь (планшеты в горизонтальном положении сюда не попадают) */
@media (min-width: 1200px) and (hover: hover) and (pointer: fine) {
  .sh-ticker.is-ready { display: block; }
}

/* планшет */
@media (max-width: 1100px) {
  .sh-acc span { display: none; } /* только значок */
  .sh-acc { padding: 0 11px; }
}
@media (max-width: 960px) {
  .sh-link { padding: 0 11px; }
}

/* телефон: меню строкой под логотипом, листается пальцем */
@media (max-width: 720px) {
  .sh-inner {
    height: auto;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px 8px;
  }
  /* все четыре пункта всегда видны: ровная сетка 4 колонки */
  .sh-nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
  }
  .sh-link { height: 36px; font-size: 13px; padding: 0 6px; justify-content: center; gap: 6px; }
  .sh-brand img { width: 34px; height: 34px; }
  .sh-acc { order: 1; margin-left: auto; height: 34px; } /* в первой строке справа от логотипа */
  .sh-nav { order: 2; }
  .sh-name { font-size: 20px; }
}
@media (max-width: 460px) {
  .sh-link svg { display: none; } /* на узком телефоне — только подписи, чтобы влезли все 4 */
  .sh-link { font-size: 12.5px; padding: 0 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .sh-track { animation: none; }
}
