:root {
  color-scheme: light dark;
  --ground: #f6f7f8;
  --ink: #14181c;
  --muted: #566069;
  --rule: #d9dde1;
  --sign: #0f1215;
  --sign-ink: #ffffff;
  --sign-muted: #c0c7ce;
  --c-v4: #c8005f;
  --c-v6: #0a58ca;
  --c-dns: #66751a;
  --c-speed: #c2410c;
  --on-line: #ffffff;
  --off: #8b949c;
  --dot: 20px;
  --track: 6px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: 'Overpass', system-ui, sans-serif;
  --mono: 'Overpass Mono', ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #15191e;
    --ink: #eef1f3;
    --muted: #a3acb4;
    --rule: #2d343b;
    --sign: #0a0c0f;
    --c-v4: #ff5fa2;
    --c-v6: #6aa8ff;
    --c-dns: #b6c84a;
    --c-speed: #ff8a4c;
    --on-line: #0f1215;
    --off: #737d86;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--off) var(--ground); }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 1rem/1.4 var(--sans);
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--c-v6); color: var(--on-line); }
:focus-visible { outline: 3px solid var(--c-v6); outline-offset: 2px; border-radius: 4px; }
.sign :focus-visible { outline-color: var(--sign-ink); }

.sprite { position: absolute; width: 0; height: 0; }

/* Letrero */
.sign { background: var(--sign); color: var(--sign-ink); --c-v4: #ff5fa2; --c-v6: #6aa8ff; --c-dns: #b6c84a; --c-speed: #ff8a4c; --on-line: #0f1215; }

.sign-inner, .lines, .help, .local-note {
  width: min(100%, 1240px);
  margin-inline: auto;
  padding-inline: clamp(16px, 3vw, 32px);
}

.sign-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    'brand actions lang'
    'verdict verdict scores';
  align-items: center;
  column-gap: 16px;
  padding-block: 12px 18px;
}

.brand { grid-area: brand; display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.0625rem; }
.brand-mark { width: 24px; height: 24px; flex: none; }

.lang { grid-area: lang; display: flex; gap: 2px; }
.lang button {
  appearance: none;
  min-width: 40px;
  min-height: 40px;
  padding: 3px 6px 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sign-muted);
  font: 600 0.875rem/1 var(--sans);
  cursor: pointer;
  transition: background-color 160ms, color 160ms;
}
.lang button:hover { background: #262c32; color: var(--sign-ink); }
.lang button[aria-pressed='true'] { color: var(--sign-ink); font-weight: 800; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }

.scores { grid-area: scores; display: flex; gap: 20px; margin-top: 10px; align-self: start; justify-content: flex-end; }
.score { display: flex; align-items: center; gap: 8px; }
.score--v4 { --c: var(--c-v4); }
.score--v6 { --c: var(--c-v6); }
.score .badge { width: 36px; height: 36px; font-size: 1.125rem; }
.score-text { display: grid; line-height: 1.05; }
.score-text strong { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.score-text span { color: var(--sign-muted); font-size: 0.8125rem; font-weight: 600; }

.verdict { grid-area: verdict; margin-top: 10px; min-width: 0; }

.verdict h1 {
  margin: 0;
  font-size: clamp(1.375rem, 2.6vw, 2rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.verdict p { margin: 6px 0 0; max-width: 110ch; color: var(--sign-muted); font-size: 1rem; line-height: 1.35; text-wrap: pretty; }

.actions { grid-area: actions; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.btn {
  appearance: none;
  min-height: 38px;
  padding: 8px 14px 6px;
  border: 1px solid #59626b;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: 600 0.9375rem/1.2 var(--sans);
  cursor: pointer;
  transition: background-color 160ms, border-color 160ms, transform 120ms var(--ease);
}
.btn:hover { background: #262c32; border-color: #89929b; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--sign-ink); border-color: var(--sign-ink); color: var(--sign); font-weight: 800; }
.btn-primary:hover { background: #dfe3e7; border-color: #dfe3e7; }

.local-note {
  margin-block: 10px 0;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Líneas */
.lines {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 48px;
}

.line {
  --c: var(--ink);
  min-width: 0;
  padding-block: 14px 16px;
  border-bottom: 1px solid var(--rule);
}
.line--v4 { --c: var(--c-v4); }
.line--v6 { --c: var(--c-v6); }
.line--dns { --c: var(--c-dns); border-bottom: 0; }
.line--speed { --c: var(--c-speed); }
.line--speed, .line--dns { grid-column: 1 / -1; }
/* Sin prueba en marcha ni resultados, la línea de velocidad no aporta nada. */
.line--speed[data-state='wait'] { display: none; }

.line-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.line-head > div { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; min-width: 0; }
.badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--c);
  color: var(--on-line);
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
  padding-top: 2px;
}
.line-head h2 { margin: 0; font-size: 1.125rem; font-weight: 800; line-height: 1.1; }
.line-status { margin: 0; font-size: 0.875rem; font-weight: 600; color: var(--muted); line-height: 1.2; }
.line[data-state='ok'] .line-status, .line[data-state='no'] .line-status { color: var(--ink); }
.line-score { margin: 0 0 0 auto; font-size: 0.875rem; color: var(--muted); white-space: nowrap; }
.line-score strong { color: var(--ink); font-weight: 800; font-size: 1.0625rem; }

/* Velocidad y DNS: con datos, se reparten a dos columnas */
.line--dns .line-body,
.line--speed .line-body:has(.speed-live:not([hidden]), .speed-table:not([hidden])) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 48px;
  align-items: start;
}
.line--speed .strip, .line--speed .line-note, .line--dns .strip { grid-column: 1; }
.line--speed .speed-live, .line--speed .speed-table { grid-column: 2; grid-row: 1 / span 2; margin-top: 0; }
.line--dns .facts { grid-column: 2; grid-row: 1 / span 2; margin-top: 0; }
.line--dns .line-note { grid-column: 1; }

/* Tira de estaciones */
.strip { display: flex; margin: 0; padding: 0; list-style: none; }

.stop { position: relative; flex: 1 1 0; min-width: 0; padding-right: 10px; }
.stop:last-child { padding-right: 0; }

.stop:not(:last-child)::before,
.stop:not(:last-child)::after {
  content: '';
  position: absolute;
  top: calc((var(--dot) - var(--track)) / 2);
  left: 0;
  right: 0;
  height: var(--track);
}
.stop::before { background: color-mix(in srgb, var(--c) 22%, var(--ground)); }
.stop::after {
  background: var(--c);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 700ms var(--ease);
}
.stop[data-state='ok']::after { transform: scaleX(1); }
.stop[data-state='no']:not(:last-child)::before {
  height: 0;
  background: none;
  border-top: var(--track) dotted var(--off);
}

.dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--dot);
  height: var(--dot);
  border: 4px solid color-mix(in srgb, var(--c) 35%, var(--ground));
  border-radius: 50%;
  background: var(--ground);
  color: var(--c);
  transition: border-color 200ms, background-color 200ms;
}
.dot svg { display: none; width: 12px; height: 12px; }
.stop[data-state='run'] .dot { border-color: var(--c); animation: pulse 1100ms ease-in-out infinite; }
.stop[data-state='ok'] .dot { border: 0; background: var(--c); color: var(--on-line); }
.stop[data-state='ok'] .dot .i-ok { display: block; }
.stop[data-state='no'] .dot { border: 0; background: var(--off); color: var(--ground); }
.stop[data-state='no'] .dot .i-no { display: block; }
.stop[data-state='skip'] .dot { border-color: var(--off); }

@keyframes pulse { 50% { opacity: 0.35; } }

.stop-name { display: block; margin-top: 6px; color: var(--muted); font-size: 0.8125rem; line-height: 1.2; }
.stop-value { display: block; margin-top: 2px; font-weight: 800; font-size: 1rem; line-height: 1.2; overflow-wrap: anywhere; }
.stop[data-state='no'] .stop-value, .stop[data-state='skip'] .stop-value { font-weight: 600; color: var(--muted); }

/* Datos */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 20px;
  margin: 12px 0 0;
}
.facts:empty { display: none; }
.facts dt { color: var(--muted); font-size: 0.8125rem; line-height: 1.2; }
.facts dd { margin: 1px 0 0; font-weight: 600; font-size: 0.9375rem; line-height: 1.25; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
.facts .addr { font-family: var(--mono); font-weight: 500; font-size: 1rem; letter-spacing: -0.01em; }
.line--dns .facts .addr { font-size: 0.875rem; }

.line-note { margin: 8px 0 0; max-width: 72ch; color: var(--muted); font-size: 0.875rem; line-height: 1.3; text-wrap: pretty; }
.line-note:empty { display: none; }

.score-missing { margin: 10px 0 0; max-width: 72ch; font-size: 0.875rem; font-weight: 600; line-height: 1.3; text-wrap: pretty; }
.score-missing:empty { display: none; }

/* Velocidad */
.speed-live { margin-top: 12px; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 20px; align-items: end; }
.speed-live[hidden] { display: none; }
.speed-phase { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 0.875rem; font-weight: 600; }
.speed-number { margin: 0; font-weight: 800; font-size: 2.25rem; line-height: 1.1; letter-spacing: -0.02em; white-space: nowrap; }
.speed-number small { margin-left: 6px; font-size: 0.9375rem; font-weight: 600; letter-spacing: 0; color: var(--muted); }
.speed-chart { display: block; width: 100%; height: 44px; }

.speed-table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.2; }
.speed-table[hidden], .speed-live:not([hidden]) ~ .speed-table { display: none; }
.speed-table th, .speed-table td { padding: 5px 10px 4px 0; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.speed-table thead th { padding-top: 0; color: var(--muted); font-size: 0.8125rem; font-weight: 400; white-space: normal; vertical-align: bottom; }
.speed-table tbody th { font-weight: 800; }
.speed-table td { font-weight: 600; }
.speed-table td:last-child, .speed-table th:last-child { padding-right: 0; }
.speed-table tbody tr:last-child th, .speed-table tbody tr:last-child td { border-bottom: 0; }

/* Preguntas */
.help { padding-block: 28px 56px; }
.help h2 { margin: 0 0 10px; font-size: 1.125rem; font-weight: 800; }
.help details { border-top: 1px solid var(--rule); }
.help details:last-of-type { border-bottom: 1px solid var(--rule); }
.help summary { padding: 10px 0 8px; font-weight: 600; cursor: pointer; }
.help summary:hover { color: var(--c-v6); }
.help details p { margin: 0; padding: 0 0 14px; max-width: 72ch; color: var(--muted); line-height: 1.45; }

@media (max-width: 900px) {
  .lines { grid-template-columns: minmax(0, 1fr); }
  .line--speed, .line--dns { grid-column: auto; }
  .line--dns { border-bottom: 0; }
  .line--v6 { border-bottom: 1px solid var(--rule); }

  .line--dns .line-body,
  .line--speed .line-body:has(.speed-live:not([hidden]), .speed-table:not([hidden])) { display: block; }
  .line--speed .speed-live, .line--speed .speed-table, .line--dns .facts { margin-top: 12px; }
}

@media (max-width: 640px) {
  .sign-inner {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'brand lang'
      'verdict verdict'
      'scores scores'
      'actions actions';
    padding-block: 6px 14px;
  }
  .verdict { margin-top: 4px; }
  .scores { justify-content: flex-start; margin-top: 12px; }
  .facts dd { font-size: 0.875rem; }
  .verdict p { font-size: 0.9375rem; }
  .actions { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn { min-height: 44px; padding-inline: 8px; }
  .btn-primary { grid-column: 1 / -1; }

  .line { padding-block: 12px 14px; }
  .stop { padding-right: 6px; }
  .stop-name { font-size: 0.75rem; }
  .stop-value { font-size: 0.9375rem; }

  .speed-table { font-size: 0.8125rem; }
  .speed-table th, .speed-table td { padding-right: 6px; }
  .speed-table thead th { font-size: 0.75rem; }
  /* La variación es la columna que menos dice a quien solo quiere su resultado. */
  .speed-table [data-col='jitter'], .speed-table td[data-col='jitter'] { display: none; }
  .speed-number { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
