/* Speed test widget styles. Self-contained, no external fonts or assets. */

:root {
  --st-primary: #2563eb;
  --st-bg: #ffffff;
  --st-surface: #f5f7fa;
  --st-text: #1a1f29;
  --st-muted: #5b6472;
  --st-track: #e3e8ef;
  --st-border: #e3e8ef;
  --st-radius: 14px;
  --st-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

/* Dark theme is toggled by adding .st-dark to <html> (see speedtest.js). */
.st-dark {
  --st-bg: #11151c;
  --st-surface: #1b212b;
  --st-text: #eef1f6;
  --st-muted: #9aa4b2;
  --st-track: #2a323e;
  --st-border: #2a323e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--st-bg);
  color: var(--st-text);
  font-family: var(--st-font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.st {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 20px;
  text-align: center;
}

.st-head {
  margin-bottom: 8px;
}

.st-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.st-subtitle {
  font-size: 0.95rem;
  color: var(--st-muted);
  margin: 0;
}

/* ----- Gauge ----- */
.st-gauge-wrap {
  margin: 20px auto 8px;
}

.st-gauge {
  position: relative;
  width: 220px;
  height: 220px;
  max-width: 70vw;
  max-height: 70vw;
  margin: 0 auto;
}

.st-gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg); /* start the arc at the top */
}

.st-gauge-track {
  fill: none;
  stroke: var(--st-track);
  stroke-width: 14;
}

.st-gauge-arc {
  fill: none;
  stroke: var(--st-primary);
  stroke-width: 14;
  stroke-linecap: round;
  /* 2 * pi * r, r = 86  ->  540.35 */
  stroke-dasharray: 540.35;
  stroke-dashoffset: 540.35; /* fully empty to start */
  transition: stroke-dashoffset 0.25s ease;
}

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

.st-gauge-value {
  font-size: 2.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.st-gauge-unit {
  font-size: 0.9rem;
  color: var(--st-muted);
}

.st-status {
  min-height: 1.4em;
  margin: 12px 0 0;
  font-size: 0.95rem;
  color: var(--st-muted);
}

/* ----- Button ----- */
.st-actions {
  margin: 8px 0 4px;
}

.st-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  background: var(--st-primary);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: 999px;
  transition: filter 0.15s ease, transform 0.05s ease;
}

.st-btn:hover {
  filter: brightness(1.05);
}

.st-btn:active {
  transform: translateY(1px);
}

.st-btn:focus-visible {
  outline: 3px solid var(--st-primary);
  outline-offset: 2px;
}

.st-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ----- Results ----- */
.st-results {
  margin-top: 20px;
  text-align: left;
}

.st-results-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 12px;
  text-align: center;
}

.st-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.st-metric {
  background: var(--st-surface);
  border: 1px solid var(--st-border);
  border-radius: var(--st-radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.st-metric-label {
  font-size: 0.8rem;
  color: var(--st-muted);
}

.st-metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.st-metric-unit {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--st-muted);
}

.st-meta {
  margin: 14px 0 0;
  font-size: 0.85rem;
}

.st-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px;
  border-top: 1px solid var(--st-border);
}

.st-meta dt {
  color: var(--st-muted);
  margin: 0;
}

.st-meta dd {
  margin: 0;
  font-weight: 600;
  word-break: break-all;
  text-align: right;
}

/* ----- Error & disclaimer ----- */
.st-error {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: var(--st-radius);
  background: #fdecec;
  color: #9b1c1c;
  font-size: 0.9rem;
}

.st-dark .st-error {
  background: #3a1d1d;
  color: #f6b5b5;
}

.st-disclaimer {
  margin: 18px 0 0;
  font-size: 0.75rem;
  color: var(--st-muted);
}

/* ----- Narrow screens ----- */
@media (max-width: 360px) {
  .st-metrics {
    grid-template-columns: 1fr;
  }
}

/* ----- Reduced motion: no arc animation, no transitions ----- */
@media (prefers-reduced-motion: reduce) {
  .st-gauge-arc {
    transition: none;
  }
  .st-btn {
    transition: none;
  }
}
