/* ============================================================
   SpeedCheck — speed-check.xyz
   Тёмная, спокойная тема. Один аккуратный акцент.
   ============================================================ */

:root {
  --bg: #0b0e14;
  --bg-soft: #10141d;
  --surface: #151a24;
  --surface-2: #1b212d;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text: #e7eaf0;
  --text-muted: #9aa4b6;
  --text-dim: #8b95a9;

  --accent: #3b82f6;
  --accent-2: #22d3ee;
  --accent-soft: rgba(59, 130, 246, 0.14);

  --download: #3b82f6;
  --upload: #34d399;
  --ping: #a78bfa;

  --danger: #f87171;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 20px 50px -24px rgba(0, 0, 0, 0.7);

  --maxw: 1080px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font);
  background-color: var(--bg);
  background-image:
    radial-gradient(60% 60% at 50% -10%, rgba(59, 130, 246, 0.14), transparent 70%),
    radial-gradient(50% 40% at 100% 0%, rgba(34, 211, 238, 0.08), transparent 60%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 10px 0;
}
.skip-link:focus {
  left: 0;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  background: rgba(11, 14, 20, 0.72);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(34, 211, 238, 0.18));
  border: 1px solid var(--border-strong);
  color: var(--accent-2);
}

.brand-name {
  font-size: 1.15rem;
}
.brand-accent {
  color: var(--accent-2);
}

.site-nav {
  display: flex;
  gap: 26px;
  font-size: 0.95rem;
  color: var(--text-muted);
}
.site-nav a {
  transition: color 0.15s ease;
}
.site-nav a:hover {
  color: var(--text);
}

/* ---------- Hero / Tester ---------- */

.hero {
  text-align: center;
  padding-top: clamp(36px, 6vw, 72px);
  padding-bottom: clamp(28px, 4vw, 48px);
}

.hero-kicker {
  display: inline-block;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.hero-title {
  font-size: clamp(1.7rem, 4.4vw, 2.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  max-width: 18ch;
  margin: 0 auto 14px;
}

.hero-sub {
  color: var(--text-muted);
  font-size: clamp(1rem, 1.6vw, 1.12rem);
  max-width: 52ch;
  margin: 0 auto;
}

.tester {
  margin-top: clamp(28px, 5vw, 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- Gauge ---------- */

.gauge {
  position: relative;
  width: min(340px, 82vw);
  aspect-ratio: 1 / 1;
  margin-bottom: 28px;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gauge-track {
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 14;
}

.gauge-progress {
  stroke: url(#gaugeGradient);
  stroke-width: 14;
  opacity: 0; /* скрыто до старта; управляется из script.js */
  transition: stroke 0.4s ease;
  filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.35));
}

.gauge-ticks text {
  fill: var(--text-dim);
  font-size: 11px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.gauge-ticks line {
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 2;
}

.gauge-dot {
  fill: #fff;
  filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.6));
  opacity: 0;
  transition: opacity 0.3s ease;
}
.gauge.is-active .gauge-dot {
  opacity: 1;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.gauge-phase {
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  min-height: 1.2em;
}

.gauge-value {
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.gauge-unit {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ---------- Start button ---------- */

.btn-start {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 15px 44px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2b62d6, #1d4ed8);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease,
    background 0.2s ease;
  box-shadow: 0 12px 30px -12px rgba(59, 130, 246, 0.8);
}
.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px -14px rgba(59, 130, 246, 0.9);
}
.btn-start:active {
  transform: translateY(0);
}
.btn-start:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}
.btn-start.is-running {
  background: var(--surface-2);
  border-color: var(--border-strong);
  box-shadow: none;
  color: var(--text-muted);
}

/* ---------- Server line ---------- */

.server-line {
  margin-top: 18px;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.server-line b {
  color: var(--text-muted);
  font-weight: 600;
}

/* ---------- Results ---------- */

.results {
  margin-top: 34px;
  width: 100%;
  max-width: 720px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease;
}
.result-card.is-active {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-2px);
}

.result-icon {
  color: var(--text-dim);
  transition: color 0.25s ease;
}
.result-card[data-metric="ping"].is-active .result-icon { color: var(--ping); }
.result-card[data-metric="jitter"].is-active .result-icon { color: var(--ping); }
.result-card[data-metric="download"].is-active .result-icon { color: var(--download); }
.result-card[data-metric="upload"].is-active .result-icon { color: var(--upload); }

.result-name {
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.result-value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.result-unit {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-dim);
}

.test-status {
  margin-top: 20px;
  min-height: 1.3em;
  font-size: 0.92rem;
  color: var(--text-muted);
}
.test-status.is-error {
  color: var(--danger);
}

/* ---------- Sections ---------- */

.section {
  padding-top: clamp(48px, 8vw, 88px);
  padding-bottom: clamp(12px, 3vw, 24px);
}

.section-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
}

.section-lead {
  text-align: center;
  color: var(--text-muted);
  max-width: 60ch;
  margin: 14px auto 0;
}

.cards {
  margin-top: 40px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 24px;
}
.info-card h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 10px;
}
.info-card p {
  color: var(--text-muted);
  font-size: 0.96rem;
}

/* ---------- FAQ ---------- */

.faq {
  margin-top: 36px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 22px;
  transition: border-color 0.2s ease;
}
.faq-item[open] {
  border-color: var(--border-strong);
}
.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 0;
  font-weight: 600;
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.faq-item summary::-webkit-details-marker {
  display: none;
}
.faq-item summary::after {
  content: "";
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex: none;
  margin-top: -4px;
}
.faq-item[open] summary::after {
  transform: rotate(-135deg);
  margin-top: 2px;
}
.faq-item p {
  color: var(--text-muted);
  font-size: 0.96rem;
  padding: 0 0 18px;
}
.faq-item b {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: clamp(56px, 9vw, 100px);
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 34px;
  padding-bottom: 34px;
  flex-wrap: wrap;
}
.footer-tagline {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 6px;
}
.footer-copy {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .site-nav {
    display: none;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .results {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 400px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
  .btn-start {
    width: 100%;
  }
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Цель skip-link получает фокус программно — рамка вокруг всей секции не нужна. */
.hero:focus,
.hero:focus-visible {
  outline: none;
}
