/* =============================================
   DEVLK SPEED TEST — Ookla-style Design
   ============================================= */

:root {
  --bg:           #1a1f35;
  --bg-widget:    #1e2342;
  --bg-card:      #252c4a;
  --border:       rgba(255,255,255,0.07);
  --border-light: rgba(255,255,255,0.12);

  --cyan:   #00d4ff;
  --blue:   #0066ff;
  --teal:   #00c6c8;
  --green:  #00e676;
  --orange: #ff9800;
  --red:    #f44336;
  --purple: #ab47bc;

  --dl-color: #00d4ff;
  --ul-color: #ab47bc;

  --text:     #ffffff;
  --text-sub: #8892b0;
  --text-dim: #4a5578;

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Particle Canvas ── */
#particleCanvas {
  position: fixed; inset: 0;
  z-index: 0; pointer-events: none;
}

/* ── Top Bar ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 200;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(26,31,53,0.92);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.logo {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
  font-weight: 800; font-size: 1rem; letter-spacing: -0.02em;
}
.logo-bolt { font-size: 1.3rem; filter: drop-shadow(0 0 6px var(--cyan)); }
.logo-accent { color: var(--cyan); }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.tb-btn {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  background: transparent;
  color: var(--text-sub);
  font-family: var(--font);
  font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.04em;
  padding: 5px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}
.tb-btn:hover { color: var(--text); border-color: var(--cyan); background: rgba(0,212,255,0.06); }
.tb-divider { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }

/* ── Main ── */
.main {
  position: relative; z-index: 1;
  padding-top: 72px;
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
}

/* ── Widget ── */
.widget {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 32px 24px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* ── Results Header (Download + Upload) ── */
.results-header {
  display: flex;
  justify-content: center;
  gap: 80px;
  width: 100%;
  margin-bottom: 8px;
  min-height: 90px;
}
.metric-col {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
}
.metric-direction {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-sub);
}
.dir-icon.down { color: var(--dl-color); }
.dir-icon.up   { color: var(--ul-color); }
.dir-icon.down-sm { color: var(--dl-color); }
.dir-icon.up-sm   { color: var(--ul-color); }
.metric-unit-label { color: var(--text-dim); font-size: 0.72rem; }
.metric-number {
  display: flex; align-items: baseline; gap: 1px;
  line-height: 1;
}
.num-int {
  font-size: 4rem; font-weight: 300;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: all 0.1s;
}
.num-dec {
  font-size: 2rem; font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--text-sub);
  transition: all 0.1s;
}

/* — Per-column colors — */
#dlCol .num-int  { color: var(--dl-color); }
#ulCol .num-int  { color: var(--ul-color); }

/* ── Ping Row ── */
.ping-row {
  display: flex; align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-sub);
  margin-bottom: 24px;
}
.ping-label { font-weight: 600; color: var(--text-sub); }
.ping-unit { color: var(--text-dim); font-size: 0.78rem; }
.ping-group { display: flex; align-items: center; gap: 6px; }
.ping-chip {
  display: flex; align-items: center; gap: 5px;
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.25);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.9rem; font-weight: 700;
  color: var(--cyan);
  transition: all 0.3s;
}
.ping-chip.secondary {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
  color: var(--text-sub);
  font-weight: 600;
  font-size: 0.82rem;
}
.ping-icon { opacity: 0.8; }

/* ── Center Area ── */
.center-area {
  display: flex; flex-direction: column;
  align-items: center; gap: 18px;
  margin-bottom: 20px;
}

/* ── Gauge / GO Ring ── */
.gauge-wrap {
  position: relative;
  width: 220px; height: 220px;
  display: flex; align-items: center; justify-content: center;
}
.gauge-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
.arc-track {
  fill: none;
  stroke: rgba(255,255,255,0.06);
  stroke-width: 5;
  stroke-linecap: round;
}
.arc-fill {
  fill: none;
  stroke: url(#arcGrad);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.06s linear;
  filter: url(#glow);
}

/* GO Button — Ookla circle style */
.go-btn {
  position: relative;
  width: 140px; height: 140px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font);
  z-index: 2;
  overflow: hidden;
}
.go-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 3px solid var(--cyan);
  box-shadow:
    inset 0 0 30px rgba(0,212,255,0.12),
    0 0 30px rgba(0,212,255,0.15),
    0 0 60px rgba(0,212,255,0.08);
  transition: all 0.3s ease;
}
.go-btn:hover .go-ring {
  box-shadow:
    inset 0 0 40px rgba(0,212,255,0.22),
    0 0 50px rgba(0,212,255,0.3),
    0 0 80px rgba(0,212,255,0.12);
  border-color: #00eeff;
}
.go-btn::before {
  content: '';
  position: absolute; inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%,
    rgba(0,212,255,0.12) 0%,
    rgba(0,100,200,0.08) 50%,
    transparent 100%);
}
.go-text {
  position: relative; z-index: 3;
  font-size: 1.8rem; font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--cyan);
  text-shadow: 0 0 20px rgba(0,212,255,0.5);
  pointer-events: none;
}
.go-btn:active .go-ring { box-shadow: inset 0 0 50px rgba(0,212,255,0.3), 0 0 30px rgba(0,212,255,0.2); }
.go-btn:disabled { cursor: default; }
.go-btn:disabled .go-text { color: var(--text-sub); text-shadow: none; }
.go-btn:disabled .go-ring {
  border-color: rgba(255,255,255,0.2);
  box-shadow: none;
}
.go-ripple {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,212,255,0.25) 0%, transparent 70%);
  transform: scale(0); opacity: 0;
}
.go-btn:not(:disabled):active .go-ripple {
  animation: goRipple 0.5s ease-out forwards;
}
@keyframes goRipple { to { transform: scale(2.2); opacity: 0; } }

/* Live Mbps overlay */
.live-mbps {
  position: absolute;
  bottom: -8px;
  display: flex; flex-direction: column; align-items: center;
  gap: 0;
}
.live-num {
  font-size: 2.4rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  color: var(--cyan);
  line-height: 1;
}
.live-unit {
  font-size: 0.7rem; font-weight: 600;
  color: var(--text-sub);
  letter-spacing: 0.05em;
}
.live-phase {
  font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Pulse animation during test */
@keyframes ringPulse {
  0%, 100% { box-shadow: inset 0 0 30px rgba(0,212,255,0.12), 0 0 30px rgba(0,212,255,0.15), 0 0 60px rgba(0,212,255,0.08); }
  50%       { box-shadow: inset 0 0 50px rgba(0,212,255,0.25), 0 0 60px rgba(0,212,255,0.35), 0 0 100px rgba(0,212,255,0.18); }
}
.testing .go-ring { animation: ringPulse 1.8s ease-in-out infinite; }

/* ── Phase Dots ── */
.phase-dots {
  display: flex; align-items: center; gap: 28px;
}
.phase-dot-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.75rem; font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  transition: color 0.3s;
}
.phase-dot-item.active { color: var(--cyan); }
.phase-dot-item.done   { color: var(--green); }
.pdot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.3s;
}
.phase-dot-item.active .pdot {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: dotPulse 1.2s ease-in-out infinite;
}
.phase-dot-item.done .pdot { background: var(--green); box-shadow: 0 0 6px var(--green); }
@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(1.5); }
}

/* ── Connection Row ── */
.conn-row {
  display: flex; align-items: center;
  gap: 20px; flex-wrap: wrap; justify-content: center;
  margin-top: 4px; margin-bottom: 8px;
}
.conn-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.78rem; color: var(--text-sub);
}
.conn-item svg { color: var(--text-dim); flex-shrink: 0; }

/* ── Action Buttons ── */
.action-row {
  display: flex; gap: 10px; margin-top: 8px;
}
.act-btn {
  display: flex; align-items: center; gap: 7px;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 0.875rem; font-weight: 600;
  padding: 11px 26px;
  cursor: pointer;
  transition: all 0.2s;
}
.act-btn.primary {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border: none; color: #fff;
  box-shadow: 0 4px 20px rgba(0,100,255,0.3);
}
.act-btn.primary:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0,100,255,0.4); }
.act-btn.ghost {
  background: transparent; color: var(--text-sub);
  border: 1px solid var(--border-light);
}
.act-btn.ghost:hover { color: var(--text); border-color: var(--cyan); background: rgba(0,212,255,0.07); }

/* ── Info Section ── */
.info-section {
  width: 100%; max-width: 900px;
  padding: 48px 24px 64px;
  position: relative; z-index: 1;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.info-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 28px 24px;
  transition: all 0.3s;
}
.info-card:hover {
  border-color: rgba(0,212,255,0.25);
  background: rgba(0,212,255,0.04);
  transform: translateY(-3px);
}
.info-icon { font-size: 1.8rem; margin-bottom: 12px; }
.info-title { font-size: 1rem; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.info-text { font-size: 0.875rem; color: var(--text-sub); line-height: 1.7; }
.info-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.info-list li { font-size: 0.85rem; color: var(--text-sub); line-height: 1.5; }
.info-list b { color: var(--text); }

/* ── Footer ── */
.footer {
  width: 100%;
  position: relative; z-index: 1;
  border-top: 1px solid var(--border);
  padding: 24px;
}
.footer-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}
.footer p { font-size: 0.8rem; color: var(--text-sub); }
.footer a { color: var(--text-sub); text-decoration: none; transition: color 0.2s; }
.footer a:hover { color: var(--cyan); }
.footer-links { display: flex; gap: 16px; }
.footer-links a { font-size: 0.8rem; }

/* ── Background gradient ── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 70% 50% at 15% 20%, rgba(0,100,200,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 85% 80%, rgba(0,196,200,0.05) 0%, transparent 60%);
  pointer-events: none;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: rgba(26,31,53,0.97);
  border: 1px solid var(--border-light);
  color: var(--text);
  padding: 11px 22px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 500;
  backdrop-filter: blur(20px);
  z-index: 1000; opacity: 0;
  transition: all 0.4s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ── */
@media (max-width: 600px) {
  .results-header { gap: 36px; }
  .num-int { font-size: 3rem; }
  .num-dec { font-size: 1.6rem; }
  .gauge-wrap { width: 180px; height: 180px; }
  .go-btn { width: 115px; height: 115px; }
  .go-text { font-size: 1.5rem; }
  .topbar { padding: 0 16px; }
  .logo-name { font-size: 0.9rem; }
  .tb-divider + a, .tb-divider + a + a { display: none; }
  .footer-inner { flex-direction: column; }
  .action-row { flex-direction: column; width: 100%; }
  .act-btn { justify-content: center; }
}
