/* ═══════════════════════════════════════════════
   APEX Terminal — landing styles
   Палитра: королевский синий #2563eb на тёмном / светлом фоне.
   Тема переключается атрибутом data-theme на <html> (theme.js).
   ═══════════════════════════════════════════════ */

/* ═══ Тёмная тема (по умолчанию) ═══ */
:root,
[data-theme="dark"] {
  --bg: #0a0e1a;
  --bg-2: #0f1420;
  --card: #141824;
  --border: #1e2533;
  --text: #e6e8eb;
  --muted: #8b95a5;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #3b82f6;
  --accent-glow: rgba(37, 99, 235, 0.4);
  --accent-soft: rgba(37, 99, 235, 0.12);
  --accent-line: rgba(37, 99, 235, 0.5);
  --profit: #26a269;
  --loss: #c01c28;

  /* rgb-триплеты: нужны для rgba(…) внутри градиентов и теней */
  --bg-rgb: 10, 14, 26;
  --bg-2-rgb: 15, 20, 32;
  --card-rgb: 20, 24, 36;
  --border-rgb: 30, 37, 51;
  --accent-rgb: 37, 99, 235;
  --accent-light-rgb: 59, 130, 246;
  --profit-rgb: 38, 162, 105;
  --loss-rgb: 192, 28, 40;
  --shadow-rgb: 0, 0, 0;

  /* поверхности, текст, служебные цвета */
  --header-bg: rgba(10, 14, 26, 0.72);
  --hero-glow: #111a2c;
  --surface-hover: #1a2030;
  --handle-bg: #2b3446;
  --scroll: #232b3d;
  --scroll-hover: #2f3a51;
  --text-2: #c3cad6;
  --muted-2: #5d6675;
  --muted-3: #b6bec9;
  --warn: #d9a94a;
  --on-accent: #f7f8ff;
  --on-profit: #04140d;
  --on-loss: #fff5f5;

  --radius-sm: 12px;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.38);
  --maxw: 1200px;
  --header-h: 72px;

  color-scheme: dark;
}

/* ═══ Светлая тема ═══ */
[data-theme="light"] {
  --bg: #ffffff;
  --bg-2: #f4f6fb;
  --card: #ffffff;
  --border: #d8dde7;
  --text: #0f1420;
  --muted: #5a6477;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #3b82f6;
  --accent-glow: rgba(37, 99, 235, 0.25);
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-line: rgba(37, 99, 235, 0.45);
  --profit: #059669;
  --loss: #dc2626;

  --bg-rgb: 255, 255, 255;
  --bg-2-rgb: 244, 246, 251;
  --card-rgb: 255, 255, 255;
  --border-rgb: 216, 221, 231;
  --accent-rgb: 37, 99, 235;
  --accent-light-rgb: 59, 130, 246;
  --profit-rgb: 5, 150, 105;
  --loss-rgb: 220, 38, 38;
  --shadow-rgb: 15, 23, 42;

  --header-bg: rgba(255, 255, 255, 0.78);
  --hero-glow: #e8eefc;
  --surface-hover: #f1f5f9;
  --handle-bg: #cbd5e1;
  --scroll: #cbd5e1;
  --scroll-hover: #94a3b8;
  --text-2: #4b5563;
  --muted-2: #9ca3af;
  --muted-3: #6b7280;
  --warn: #b45309;
  --on-accent: #ffffff;
  --on-profit: #ffffff;
  --on-loss: #ffffff;

  --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  color-scheme: light;
}

/* ─── Reset / base ─────────────────────────── */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.025em;
}

p { margin: 0; }

::selection { background: rgba(var(--accent-rgb), 0.32); }

/* якоря не уезжают под фиксированный header */
section[id],
footer[id] { scroll-margin-top: calc(var(--header-h) + 16px); }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 32px;
}

/* ─── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease,
              box-shadow 0.3s ease, transform 0.3s ease;
}

.btn-primary {
  background: rgba(15, 23, 42, 0.72);
  color: #e6e8eb;
  border-color: rgba(30, 58, 138, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.btn-primary:hover {
  background: #1e3a8a;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.45);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--accent-line);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn-lg {
  padding: 14px 26px;
  font-size: 16px;
  border-radius: 14px;
}

/* ─── Header (glassmorphism) ───────────────── */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--header-h);
}

.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--accent);
  white-space: nowrap;
}
.logo span { color: var(--text); }

.nav {
  display: flex;
  align-items: center;
  gap: 32px;
  margin: 0 auto;
}
.nav a {
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.3s ease;
}
.nav a:hover { color: var(--text); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ─── Переключатели языка и темы ───────────── */
.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.3s ease, background-color 0.3s ease,
              color 0.3s ease, transform 0.3s ease;
}
.header-btn:hover {
  border-color: var(--accent-line);
  color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.header-btn .icon-sun { display: block; }
.header-btn .icon-moon { display: none; }

/* ─── Светлая тема: локальные подстройки ───── */
[data-theme="light"] #milkyway { opacity: 0.42; }
[data-theme="light"] .map-section {
  /* на светлом фоне — мягкое голубое свечение вместо «космоса» */
  background: radial-gradient(circle at center,
     rgba(37, 99, 235, 0.08) 0%,
     rgba(255, 255, 255, 0) 70%);
}
[data-theme="light"] .site-header { box-shadow: 0 1px 0 rgba(var(--shadow-rgb), 0.05); }

/* ─── Hero ─────────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  padding: 168px 0 112px;
  background:
    radial-gradient(1100px 560px at 68% 8%, var(--hero-glow) 0%, rgba(var(--bg-rgb), 0) 62%),
    var(--bg);
}

#milkyway {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.7;
  z-index: 0;
  pointer-events: none;
}

/* «Digital wave»: слой волн лежит поверх звёзд, но под контентом
   (hero-inner — z-index 2), поэтому тексту ничего не мешает. */
#waves-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1.04fr 0.96fr;
  gap: 64px;
  align-items: center;
}

/* Плашка над заголовком */
.hero-label {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 24px;
}

/* Двухстрочный заголовок: APEX / TERMINAL — компактный и плотный.
   line1 белый как в макете; в светлой теме он берёт --text,
   иначе белый текст исчезает на белом фоне. */
.hero-title {
  font-size: 64px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -2px;
  margin: 0 0 24px 0;
}

.hero-title-line1 {
  display: block;
  color: #ffffff;
}

[data-theme="light"] .hero-title-line1 {
  color: var(--text);
}

.hero-title-line2 {
  display: block;
  color: var(--accent);
  margin-top: -4px;
}

@media (max-width: 768px) {
  .hero-title { font-size: 42px; letter-spacing: -1px; }
}

.hero-description {
  font-size: 17px;
  line-height: 1.7;
  color: var(--muted);
  max-width: 560px;
  margin: 0 0 32px;
}

.hero-copy .lead {
  margin-top: 26px;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 38px;
}

.fineprint {
  margin-top: 20px;
  font-size: 14px;
  color: var(--muted);
  opacity: 0.9;
}

/* ─── Hero chart card ─────────────────────── */
.hero-card {
  padding: 20px;
  border: 1px solid rgba(34, 211, 238, 0.42);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(var(--card-rgb), 0.92) 0%, rgba(var(--bg-2-rgb), 0.92) 100%);
  box-shadow:
    0 0 0 1px rgba(34, 211, 238, 0.28),
    0 0 28px rgba(34, 211, 238, 0.24),
    0 0 72px rgba(45, 212, 191, 0.14),
    var(--shadow);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
[data-theme="light"] .hero-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86) 0%, rgba(241, 245, 249, 0.9) 100%);
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.chart-pair {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.chart-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.chart-price #chart-change { font-size: 14px; font-weight: 600; }

.chart { height: 250px; width: 100%; }
.chart canvas,
.chart > div { border-radius: 10px; }

.chart-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.chart-foot .sep { opacity: 0.5; }

.up { color: var(--profit); }
.down { color: var(--loss); }

.dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--profit);
  animation: live-pulse 2.2s ease-out infinite;
}

@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(var(--profit-rgb), 0.55); }
  70%  { box-shadow: 0 0 0 9px rgba(var(--profit-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--profit-rgb), 0); }
}

/* ─── Stats ────────────────────────────────── */
.stats {
  padding: 100px 0;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  text-align: center;
}

.stat-num {
  font-size: clamp(34px, 4vw, 50px);
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ─── Section head ─────────────────────────── */
.section-head {
  text-align: center;
  margin-bottom: 56px;
}
.section-head h2 { font-size: clamp(30px, 3.6vw, 46px); }
.section-head p {
  margin-top: 16px;
  font-size: 18px;
  color: var(--muted);
}

/* ─── Map ──────────────────────────────────── */
.map-section {
  position: relative;
  padding: 116px 0;
  /* «космос» вокруг карты */
  background: radial-gradient(circle at center,
     rgba(30, 41, 82, 0.4) 0%,
     rgba(10, 14, 26, 0) 70%);
  overflow: hidden;
}

.map-wrap {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(820px 380px at 50% 24%, rgba(var(--accent-rgb), 0.1) 0%, rgba(var(--bg-rgb), 0) 68%),
    var(--card);
  box-shadow: var(--shadow);
}

/* Плоская карта мира: ECharts контейнер на всю ширину, высота 500px */
#world-map {
  display: block;
  width: 100%;
  height: 500px;
  border-radius: 12px;
  background:
    radial-gradient(58% 74% at 50% 46%, rgba(var(--accent-rgb), 0.09) 0%, rgba(var(--bg-rgb), 0) 70%);
}

/* ─── Features ─────────────────────────────── */
.features {
  position: relative;
  overflow: hidden;
  padding: 116px 0 72px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
}

.wave-stage {
  position: relative;
  height: 280px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
#hero-chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 1;
  pointer-events: none;
}

.features-inner {
  position: relative;
  z-index: 1;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.feature {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.feature:hover {
  transform: translateY(-4px);
  border-color: var(--accent-line);
  box-shadow: var(--shadow-lg);
}

.feature .ico { font-size: 26px; line-height: 1; }

.feature h3 {
  margin-top: 16px;
  font-size: 17px;
  font-weight: 700;
}

.feature p {
  margin-top: 10px;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--muted);
}

/* ─── Exchanges ────────────────────────────── */
.exchanges { padding: 116px 0; }

.ex-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
}

.ex {
  padding: 22px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  text-align: center;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.ex:hover {
  transform: translateY(-3px);
  border-color: var(--accent-line);
  box-shadow: var(--shadow);
}

.ex-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.ex-name { font-size: 15px; font-weight: 600; }
.ex-type { margin-top: 6px; font-size: 12.5px; color: var(--muted); }

.ex-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--profit);
}

.ex-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--profit);
}

/* ─── CTA ──────────────────────────────────── */
.cta {
  position: relative;
  overflow: hidden;
  padding: 124px 0;
  text-align: center;
  background:
    radial-gradient(ellipse at center, rgba(var(--accent-rgb), 0.12) 0%, transparent 55%),
    var(--bg);
}
#cta-stars { display: none; }
.cta-box { position: relative; z-index: 1; }

.cta-box h2 {
  max-width: 18ch;
  margin: 0 auto;
  font-size: clamp(30px, 4.2vw, 54px);
}

.cta .btn { margin-top: 40px; }

/* ─── Footer ───────────────────────────────── */
.site-footer {
  padding: 84px 0 32px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 40px;
}

.footer-col h4 {
  margin-bottom: 18px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.footer-col a {
  display: block;
  padding: 6px 0;
  font-size: 14.5px;
  color: var(--text);
  opacity: 0.86;
  transition: color 0.3s ease, opacity 0.3s ease;
}
.footer-col a:hover { color: var(--accent); opacity: 1; }

.footer-bottom {
  margin-top: 60px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--muted);
}

/* ─── Reveal on scroll ─────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.65s ease, transform 0.65s ease;
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ─── Desktop / Tablet / Mobile ────────────── */
@media (max-width: 1279px) {
  .hero { padding: 148px 0 96px; }
  .hero-inner { grid-template-columns: minmax(0, 1fr); gap: 52px; }
  /* minmax(0,1fr) + min-width:0: колонка обязана сжиматься до ширины
     контейнера, иначе min-content карточки графика (~305px) выталкивает
     оба блока за правый край на 320–360px (body{overflow-x:hidden} режет). */
  .hero-inner > * { min-width: 0; }
  .chart-head { flex-wrap: wrap; row-gap: 6px; }
  .features-grid { grid-template-columns: repeat(2, 1fr); }

  .ex-grid { grid-template-columns: repeat(3, 1fr); }
  .map-section,
  .features,
  .exchanges { padding: 96px 0; }
}

@media (max-width: 900px) {
  .nav { display: none; }
  .header-inner { justify-content: space-between; }
}

@media (max-width: 767px) {
  .container { padding: 0 20px; }

  .hero { padding: 128px 0 76px; }
  .hero-actions .btn { flex: 1 1 100%; }

  .stats { padding: 72px 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 36px 20px; }

  .section-head { margin-bottom: 40px; }
  .section-head p { font-size: 16px; }

  .map-section,
  .features,
  .exchanges { padding: 76px 0; }
  .map-wrap { padding: 14px; }

  .features-grid { grid-template-columns: 1fr; gap: 18px; }
  .ex-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }

  .cta { padding: 84px 0; }
  .cta .btn { margin-top: 30px; width: 100%; }

  .site-footer { padding: 60px 0 28px; }
  .footer-grid { grid-template-columns: repeat(2, 1fr); gap: 32px; }
  /* длинные строки (support@apex.terminal) не должны расширять колонку
     и выталкивать страницу за правый край на 320–360px */
  .footer-col { min-width: 0; }
  .footer-col a { overflow-wrap: anywhere; }
  .footer-bottom { margin-top: 42px; }
}

@media (max-width: 480px) {
  .header-actions .btn-ghost { display: none; }
  .ex-grid { grid-template-columns: 1fr; }

  /* Компактный header: логотип + контролы + CTA обязаны помещаться
     в 320–480px, иначе CTA обрезается overflow-x: hidden у body. */
  .header-inner { gap: 12px; }
  .logo { font-size: 15px; letter-spacing: 0; }
  .header-actions { gap: 8px; }
  .header-controls { gap: 6px; }
  .header-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    font-size: 12px;
    letter-spacing: 0.02em;
  }
  .header-actions .btn {
    padding: 9px 13px;
    font-size: 13px;
    gap: 5px;
  }
}

@media (max-width: 360px) {
  .logo { font-size: 14px; }
  .header-btn { min-width: 32px; height: 32px; padding: 0 6px; }
  .header-actions .btn { padding: 8px 10px; font-size: 12px; }
}

@media (max-width: 340px) {
  /* самые узкие экраны (320px): оставляем только знак ⚡ APEX */
  .logo span { display: none; }
}

/* ─── Reduced motion ───────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .dot-live { animation: none; }
  .feature:hover,
  .ex:hover,
  .btn:hover { transform: none; }
}
