/* ════════════════════════════════════════════════════════════
   ioFast.net — Embeddable Speed Test Widget
   Self-contained stylesheet (no dependency on the main site's
   styles.css) so the iframe payload stays small and isolated
   from whatever CSS the embedding page already has.
   ════════════════════════════════════════════════════════════ */
:root,
:root[data-theme="dark"] {
  --bg:          #060d1a;
  --panel:       rgba(11, 22, 44, 0.85);
  --border:      rgba(255,255,255,0.08);
  --text:        #e8f0fb;
  --muted:       #6a89b0;
  --accent:      #6c7cff;
  --accent2:     #27d1b2;
  --accent3:     #4fd6ff;
  --accent4:     #ff3fa8;
  --radius-lg:   14px;
  --radius-md:   10px;
  --radius-sm:   8px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg:          #f3f6fb;
  --panel:       #ffffff;
  --border:      rgba(15,23,42,0.09);
  --text:        #0f1b2e;
  --muted:       #64748b;
  color-scheme: light;
}

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

/* Deliberately no height:100% here. This document reports its own natural
   content height to the parent page (see embed.js's reportSize/postMessage),
   which the parent then applies to the iframe. */
html, body {
  background: var(--bg);
  color-scheme: dark;
  overflow: hidden;
}

html[data-theme="light"],
html[data-theme="light"] body {
  background: var(--bg);
  color-scheme: light;
}

body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}

/* The whole widget is one big click target */
.embed-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 10px 7px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
}
.embed-wrap:hover { border-color: rgba(127,127,127,0.22); }
.embed-wrap:focus-visible { outline: 2px solid rgba(108,124,255,0.5); outline-offset: 2px; }
.embed-wrap.running { cursor: progress; }

/* When embedded via <iframe>, drop the inner border so it doesn't double up
   with a border the embedder might put on the <iframe> itself */
html.is-framed,
body.is-framed {
  background: transparent;
}

html.is-framed .embed-wrap,
body.is-framed .embed-wrap {
  border: none;
  box-shadow: none;
}

/* ── Brand row ─────────────────────────────────────────────── */
.embed-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.embed-brand__name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}
.embed-brand__name svg { color: var(--accent2); flex-shrink: 0; }
.embed-status {
  font-size: 9.5px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
  text-align: center;
  display: block;
  margin: 2px auto 0;
}
[data-compact="1"] .embed-brand { display: none; }

/* ── Metrics grid ──────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.metrics-grid[data-cols="1"] {
  grid-template-columns: minmax(0, 220px);
  justify-content: center;
}
/* Vertical layout: stack Download/Upload as rows instead of side-by-side
   columns, for embedding in a narrow, portrait-shaped space (a sidebar,
   for instance). Takes precedence over the single-card sizing above. */
.metrics-grid[data-layout="vertical"] {
  grid-template-columns: minmax(0, 1fr);
}

.metric-card {
  background: rgba(127,127,127,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.metric-label-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.metric-icon { font-size: 10px; font-weight: 700; line-height: 1; }
.metric-card--dl .metric-icon { color: var(--accent3); }
.metric-card--ul .metric-icon { color: var(--accent2); }

.metric-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.gauge {
  position: relative;
  width: 100%;
  max-width: 102px;
  margin: 0 auto;
}
[data-compact="1"] .gauge { max-width: 76px; }
.gauge__svg { display: block; width: 100%; height: auto; overflow: visible; }
.gauge__track {
  fill: none;
  stroke: rgba(127,127,127,0.16);
  stroke-width: 13;
  stroke-linecap: round;
}
.gauge__arc {
  fill: none;
  stroke-width: 13;
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.gauge__sweep {
  fill: none;
  stroke-width: 13;
  stroke-linecap: round;
  stroke-dasharray: 12 100;
  stroke-dashoffset: 0;
  opacity: 0;
}
.gauge--loading .gauge__sweep {
  opacity: 0.85;
  animation: embed-gauge-sweep 1.5s ease-in-out infinite;
}
.gauge--loading .gauge__arc { opacity: 0; }
.metric-card--dl .gauge__arc, .metric-card--dl .gauge__sweep { stroke: url(#e-grad-dl); filter: drop-shadow(0 0 4px rgba(79,214,255,0.55)); }
.metric-card--ul .gauge__arc, .metric-card--ul .gauge__sweep { stroke: url(#e-grad-ul); filter: drop-shadow(0 0 4px rgba(39,209,178,0.55)); }
@keyframes embed-gauge-sweep {
  0%   { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -100; }
}
@media (prefers-reduced-motion: reduce) {
  .gauge--loading .gauge__sweep { animation: none; opacity: 0.5; }
  .gauge__arc { transition: none; }
}

.gauge__readout {
  position: absolute;
  left: 0; right: 0;
  bottom: 6%;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.metric-value {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
[data-compact="1"] .metric-value { font-size: 0.8rem; }
.metric-unit {
  margin-top: 1px;
  font-size: 7.5px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* ── Error ─────────────────────────────────────────────────── */
.embed-error {
  font-size: 10.5px;
  color: #ff9faa;
  text-align: center;
  min-height: 1em;
}
.embed-error:empty {
  display: none;
}

/* ── Footer attribution ───────────────────────────────────────
   Required on every embed — this is the whole point of the widget
   as a referral channel. Kept small, and close below the gauges. */
.embed-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 3px;
  border-top: 1px solid var(--border);
}
.embed-footer a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.embed-footer a:hover { color: var(--accent2); }
.embed-footer svg { color: var(--accent2); flex-shrink: 0; }

/* Narrow embeds: drop to a single column so numbers don't clip */
@media (max-width: 220px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .gauge { max-width: 130px; }
}
