/* ===========================
   MAP Digital Works Speedtest
   style.css — Full Replace
   =========================== */

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

:root {
  --navy-900: #060C1A;
  --navy-800: #0B1529;
  --navy-700: #0F1E3A;
  --navy-600: #162748;
  --navy-500: #1E3260;

  --accent:   #00D4FF;
  --accent2:  #0099CC;
  --accent-glow: rgba(0, 212, 255, 0.18);
  --green:    #00FFB0;
  --orange:   #FF9500;
  --red:      #FF4060;

  --text-primary:   #E8F4FF;
  --text-secondary: #7FA8CC;
  --text-muted:     #3D5F80;

  --border:   rgba(0, 212, 255, 0.12);
  --card-bg:  rgba(11, 21, 41, 0.85);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font-display: 'Syne', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html, body {
  min-height: 100%;
  background: var(--navy-900);
  color: var(--text-primary);
  font-family: var(--font-display);
  overflow-x: hidden;
}

/* --- Background --- */
.bg-grid {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
}
.bg-glow {
  position: fixed; z-index: 0;
  top: -300px; left: 50%; transform: translateX(-50%);
  width: 1000px; height: 700px;
  background: radial-gradient(ellipse at center, rgba(0,130,180,0.12) 0%, transparent 65%);
  pointer-events: none;
}
/* Vignette for depth */
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(4,8,18,0.55) 100%);
  pointer-events: none;
}

/* --- App Wrap --- */
.app-wrap {
  position: relative; z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(9, 17, 34, 0.92);
  border: 1px solid rgba(0,212,255,0.15);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  box-shadow: 0 1px 0 rgba(0,212,255,0.08) inset, 0 8px 32px rgba(0,0,0,0.4);
}
.brand { display: flex; align-items: center; gap: 16px; }
.brand-logo-img {
  flex-shrink: 0;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
}
.logo-img {
  width: 48px; height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(0,212,255,0.25));
}
.brand-divider {
  width: 1px;
  height: 34px;
  background: linear-gradient(to bottom, transparent, rgba(0,212,255,0.25), transparent);
  flex-shrink: 0;
}
.brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  line-height: 1.2;
}
.brand-sub {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  margin-top: 3px;
  opacity: 0.7;
}
.header-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(0,212,255,0.05);
  border: 1px solid rgba(0,212,255,0.14);
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  transition: color 0.3s, border-color 0.3s;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s, box-shadow 0.3s;
}
.dot.active  { background: var(--green);  box-shadow: 0 0 8px var(--green); }
.dot.testing { background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 1s infinite; }
.dot.done    { background: var(--green); box-shadow: 0 0 8px var(--green); }

@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.8); }
}

/* --- Info Cards --- */
.info-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.info-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(9, 17, 34, 0.88);
  border: 1px solid rgba(0,212,255,0.1);
  border-radius: var(--radius-md);
  backdrop-filter: blur(16px);
  transition: border-color 0.3s;
}
.info-card:hover { border-color: rgba(0,212,255,0.22); }
.info-icon {
  font-size: 16px;
  color: var(--accent);
  opacity: 0.5;
  flex-shrink: 0;
  line-height: 1;
}
.info-body { flex: 1; min-width: 0; }
.info-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.info-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.4s;
}
.info-val.loaded { color: var(--text-primary); }

/* --- Gauge Area --- */
.gauge-area {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
  position: relative;
}
.gauge-radial-glow {
  position: absolute;
  width: 360px; height: 220px;
  background: radial-gradient(ellipse at 50% 90%, rgba(0,180,220,0.1) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.gauge-wrap {
  position: relative;
  width: 360px;
  height: 220px;
  z-index: 1;
}
.gauge-svg {
  width: 100%;
  height: 100%;
}
.gauge-ring {
  stroke: rgba(0,212,255,0.06);
}
.gauge-track {
  stroke: rgba(20,40,70,0.9);
}
.gauge-progress {
  stroke: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent));
  stroke-dasharray: 433;
  stroke-dashoffset: 433;
  transition: stroke-dashoffset 0.35s ease, stroke 0.4s;
}
.gauge-center {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: 200px;
}
.gauge-value {
  font-family: var(--font-mono);
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  letter-spacing: -3px;
  transition: color 0.3s;
}
.gauge-unit {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.12em;
  margin-top: 4px;
  text-transform: uppercase;
}
.gauge-phase {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 8px;
  min-height: 16px;
  transition: color 0.3s;
  opacity: 0.8;
}

/* --- Progress --- */
.progress-track {
  position: relative;
  height: 4px;
  background: var(--navy-600);
  border-radius: 99px;
  overflow: visible;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 99px;
  transition: width 0.25s linear;
  box-shadow: 0 0 10px var(--accent-glow);
}
.progress-label {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  transition: color 0.3s;
}

/* --- Metric Cards --- */
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1.6fr 1.6fr;
  gap: 10px;
  align-items: stretch;
}
.metric-card {
  position: relative;
  background: rgba(9, 17, 34, 0.88);
  border: 1px solid rgba(0,212,255,0.1);
  border-radius: var(--radius-md);
  padding: 18px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  backdrop-filter: blur(16px);
  transition: border-color 0.3s, box-shadow 0.3s;
  overflow: hidden;
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,212,255,0.15), transparent);
  transition: background 0.4s;
}
.metric-card.active::before {
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.metric-card.active {
  border-color: rgba(0,212,255,0.28);
  box-shadow: 0 0 32px rgba(0,212,255,0.07), 0 0 0 1px rgba(0,212,255,0.06) inset;
}
.metric-large .metric-value {
  font-size: 38px !important;
  letter-spacing: -1.5px !important;
}
.metric-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: rgba(0,212,255,0.06);
  border-radius: 6px;
  flex-shrink: 0;
}
.metric-icon {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1;
  transition: color 0.3s;
}
.metric-dl { color: var(--accent) !important; font-size: 18px; font-weight: 700; }
.metric-ul { color: var(--accent2) !important; font-size: 18px; font-weight: 700; }
.metric-card.active .metric-icon { color: var(--accent); }
.metric-body { flex: 1; }
.metric-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text-muted);
  line-height: 1;
  transition: color 0.4s;
}
.metric-card.done .metric-value { color: var(--text-primary); }
.metric-unit {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 3px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.metric-bar-wrap {
  height: 2px;
  background: rgba(255,255,255,0.05);
  border-radius: 99px;
  overflow: hidden;
}
.metric-bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.5s ease;
}
#cardPing .metric-bar    { background: var(--green); }
#cardJitter .metric-bar  { background: var(--orange); }
#cardDownload .metric-bar{ background: linear-gradient(90deg, var(--accent2), var(--accent)); }
#cardUpload .metric-bar  { background: linear-gradient(90deg, var(--accent2), rgba(0,150,210,0.6)); }

/* --- Controls --- */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 0;
}

.btn-start {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 48px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: var(--navy-900);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  border-radius: 99px;
  cursor: pointer;
  box-shadow: 0 4px 32px rgba(0,212,255,0.3), 0 0 0 0 rgba(0,212,255,0.4);
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}
.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 40px rgba(0,212,255,0.45);
}
.btn-start:active { transform: translateY(0); }
.btn-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-icon { font-size: 14px; }

.btn-again {
  padding: 16px 40px;
  background: rgba(0,212,255,0.08);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid rgba(0,212,255,0.3);
  border-radius: 99px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.btn-again:hover {
  color: var(--navy-900);
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 4px 24px rgba(0,212,255,0.3);
}
.hidden { display: none !important; }

/* --- Footer Note --- */
.footer-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 0 4px;
  text-align: center;
  border-top: 1px solid rgba(0,212,255,0.06);
}
.footer-mvp {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgba(255,149,0,0.5);
  text-transform: uppercase;
}
.footer-text {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.6;
}
.footer-copy {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.4;
  margin-top: 2px;
}

/* --- Animations --- */
@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.metric-card { animation: cardFadeIn 0.5s ease both; }
.metric-card:nth-child(1) { animation-delay: 0.05s; }
.metric-card:nth-child(2) { animation-delay: 0.1s; }
.metric-card:nth-child(3) { animation-delay: 0.15s; }
.metric-card:nth-child(4) { animation-delay: 0.2s; }

/* --- Gauge tick marks (JS drawn) --- */
.gauge-tick { stroke: var(--text-muted); stroke-width: 1.5; stroke-linecap: round; }

/* --- Responsive --- */
@media (max-width: 640px) {
  .metrics {
    grid-template-columns: 1fr 1fr;
  }
  .metric-large .metric-value { font-size: 32px !important; }
  .info-bar {
    grid-template-columns: 1fr 1fr;
  }
  .gauge-wrap { width: 300px; height: 185px; }
  .gauge-value { font-size: 52px; }
  .header { padding: 12px 16px; }
  .brand-logo-img { width: 38px; height: 38px; }
  .logo-img { width: 38px; height: 38px; }
  .brand-title { font-size: 13px; }
  .btn-start { padding: 14px 36px; font-size: 14px; }
}
@media (max-width: 420px) {
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .info-bar { grid-template-columns: 1fr 1fr; gap: 8px; }
  .app-wrap { gap: 12px; padding: 16px 14px 32px; }
  .gauge-wrap { width: 260px; height: 162px; }
  .gauge-value { font-size: 44px; }
}
