/* =============================================================
   VelocidadYa — test de velocidad de internet
   1. Tokens
   ============================================================= */
:root {
  --bg:        #eef1f7;
  --surface:   #ffffff;
  --ink:       #131a2a;
  --ink-soft:  #4a5570;
  --ink-mute:  #6f7996;
  --line:      #dde2ee;

  --panel:     #0d1425;
  --panel-2:   #161f36;
  --panel-line:#26314e;
  --panel-ink: #eef2fb;
  --panel-mute:#93a0c0;

  --down:      #00d6a3;
  --up:        #7d93ff;
  --warn:      #ffb02e;
  --bad:       #ff6b6b;

  --radius:    18px;
  --radius-sm: 12px;
  --gutter:    clamp(1rem, 4vw, 2rem);
  --maxw:      1080px;

  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --shadow:    0 1px 2px rgba(19,26,42,.06), 0 12px 32px rgba(19,26,42,.07);
  --shadow-lg: 0 24px 60px rgba(9,14,28,.28);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.12; letter-spacing: -0.02em; font-weight: 800; }
::selection { background: var(--down); color: #062018; }
:focus-visible { outline: 2px solid var(--down); outline-offset: 3px; border-radius: 6px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 999;
  padding: .6rem 1rem; background: var(--panel); color: #fff;
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }
[hidden] { display: none !important; }

/* =============================================================
   4. Header
   ============================================================= */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 58px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-mark { width: 26px; height: 26px; color: var(--down); }
.brand-name { font-size: 1.05rem; }
.brand-name strong { color: var(--down); }
.header-nav { display: none; gap: 1.4rem; font-size: .92rem; color: var(--ink-soft); font-weight: 500; }
.header-nav a { transition: color .2s var(--ease-out); }
.header-nav a:hover { color: var(--ink); }

/* =============================================================
   5. Hero + tool card
   ============================================================= */
.hero { padding: clamp(1.2rem, 3vw, 2.2rem) 0 1rem; text-align: center; }
h1 { font-size: clamp(1.55rem, 5.2vw, 2.5rem); }
.hero-sub {
  margin: .5rem auto 1.1rem; max-width: 46ch;
  color: var(--ink-soft); font-size: clamp(.94rem, 2.6vw, 1.05rem);
}
.hero-sub strong { color: var(--ink); font-weight: 700; }

.tool-card {
  position: relative;
  max-width: 620px; margin-inline: auto;
  padding: clamp(1rem, 3.4vw, 1.7rem);
  background: linear-gradient(165deg, var(--panel-2), var(--panel) 62%);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  color: var(--panel-ink);
}

/* Gauge ------------------------------------------------------ */
.gauge-wrap { position: relative; max-width: 340px; margin-inline: auto; }
.gauge { width: 100%; height: auto; overflow: visible; }
.gauge-track { stroke: rgba(255,255,255,.09); stroke-width: 14; stroke-linecap: round; }
.gauge-progress {
  stroke: var(--down); stroke-width: 14; stroke-linecap: round;
  filter: drop-shadow(0 0 10px rgba(0,214,163,.35));
  transition: stroke .35s var(--ease-out);
}
.tool-card[data-phase-kind="up"] .gauge-progress { stroke: var(--up); filter: drop-shadow(0 0 10px rgba(125,147,255,.4)); }
.tool-card[data-phase-kind="ping"] .gauge-progress { stroke: var(--warn); filter: drop-shadow(0 0 10px rgba(255,176,46,.35)); }
.gauge-needle { fill: #fff; opacity: .9; }
.tool-card[data-phase-kind="up"] .gauge-needle { fill: var(--up); }
.tool-card[data-phase-kind="down"] .gauge-needle { fill: var(--down); }
.gauge-hub { fill: var(--panel); stroke: rgba(255,255,255,.35); stroke-width: 2; }
.gauge-ticks text { fill: var(--panel-mute); font-family: var(--mono); font-size: 11px; }
.gauge-ticks line { stroke: rgba(255,255,255,.22); stroke-width: 2; stroke-linecap: round; }

/* La cifra vive en la franja libre bajo el arco: la aguja nunca llega ahí. */
.gauge-value {
  position: absolute; left: 0; right: 0; top: 78%;
  text-align: center; pointer-events: none;
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(2rem, 9vw, 2.9rem); line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.gauge-unit { font-size: .42em; font-weight: 500; color: var(--panel-mute); margin-left: .35em; letter-spacing: 0; }
.gauge-phase {
  margin-top: .1rem; text-align: center;
  font-size: .85rem; color: var(--panel-mute); min-height: 1.2em;
}

/* Actions ---------------------------------------------------- */
.tool-actions { display: flex; gap: .6rem; justify-content: center; margin-top: .4rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .85rem 1.9rem; border-radius: 999px;
  font-weight: 700; font-size: 1rem; letter-spacing: -0.01em;
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), background-color .2s var(--ease-out), opacity .2s;
}
.btn-primary { background: var(--down); color: #04241c; box-shadow: 0 8px 24px rgba(0,214,163,.28); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(0,214,163,.36); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; color: var(--panel-ink); box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.btn-ghost:hover { background: rgba(255,255,255,.07); }
.btn-small { padding: .6rem 1.15rem; font-size: .88rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* Metrics ---------------------------------------------------- */
.metrics {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem;
  margin-top: 1.1rem;
}
.metric {
  padding: .6rem .3rem; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.07);
  text-align: center;
}
.metric-label { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--panel-mute); }
.metric-value { display: block; margin-top: .15rem; font-family: var(--mono); font-weight: 700; font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.metric-value em { font-style: normal; font-size: .62em; font-weight: 500; color: var(--panel-mute); margin-left: .2em; }
.metric.is-down .metric-value { color: var(--down); }
.metric.is-up .metric-value { color: var(--up); }
.metric.is-active { border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.09); }

/* Messages & result ------------------------------------------ */
.tool-message {
  display: none; margin-top: .9rem; padding: .7rem .9rem;
  border-radius: var(--radius-sm); font-size: .9rem;
  background: rgba(255,107,107,.12); border: 1px solid rgba(255,107,107,.34); color: #ffd9d9;
}
.tool-message.is-visible { display: block; }

.result-panel { margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid rgba(255,255,255,.1); }
.result-title { font-size: .95rem; font-weight: 700; color: var(--panel-mute); text-align: left; }
.verdicts { list-style: none; padding: 0; margin: .7rem 0 0; display: grid; grid-template-columns: 1fr; gap: .38rem; text-align: left; }
.verdicts li { display: flex; align-items: center; gap: .55rem; font-size: .92rem; }
.verdicts .vmark {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: .72rem; font-weight: 700;
}
.verdicts .ok  .vmark { background: rgba(0,214,163,.18); color: var(--down); }
.verdicts .mid .vmark { background: rgba(255,176,46,.18); color: var(--warn); }
.verdicts .no  .vmark { background: rgba(255,107,107,.16); color: var(--bad); }
.verdicts .no  { color: var(--panel-mute); }
.verdicts .vnote { color: var(--warn); font-size: .85em; }
.result-conn { margin-top: .9rem; font-size: .82rem; color: var(--panel-mute); text-align: left; }
.result-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

/* Badges under the tool -------------------------------------- */
.privacy-badge {
  max-width: 620px; margin: 1rem auto 0;
  font-size: .88rem; color: var(--ink-soft);
}
.privacy-badge strong { color: var(--ink); }
.honest-limits { max-width: 620px; margin: .35rem auto 0; font-size: .8rem; color: var(--ink-mute); }

/* =============================================================
   6. Ad slots (placeholders — el propietario pega AdSense)
   ============================================================= */
.ad-slot {
  display: grid; place-items: center;
  margin: clamp(1.4rem, 4vw, 2.4rem) auto;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.5);
  max-width: 100%;
}
.ad-label { font-size: .65rem; letter-spacing: .16em; text-transform: uppercase; color: #9aa3bd; }
.ad-leaderboard { min-height: 100px; }
.ad-incontent   { min-height: 250px; }
.ad-footer      { min-height: 100px; }

/* =============================================================
   7. Sections
   ============================================================= */
.section { padding: clamp(1.6rem, 5vw, 3rem) 0; }
.section h2 { font-size: clamp(1.25rem, 3.6vw, 1.7rem); }
.section-sub { margin-top: .35rem; color: var(--ink-soft); font-size: .95rem; }
.section-text { background: var(--surface); border-block: 1px solid var(--line); }

.steps { display: grid; gap: .9rem; margin-top: 1.2rem; }
.step {
  padding: 1.1rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.step-icon { width: 26px; height: 26px; color: var(--down); margin-bottom: .5rem; }
.step h3 { font-size: 1.02rem; }
.step p { margin-top: .35rem; font-size: .92rem; color: var(--ink-soft); }

.prose { max-width: 68ch; }
.prose h3 { margin-top: 1.6rem; font-size: 1.08rem; }
.prose p { margin-top: .55rem; color: var(--ink-soft); }
.prose h2 + p { margin-top: .8rem; }
.prose strong { color: var(--ink); }

.faq { margin-top: 1.1rem; display: grid; gap: .55rem; }
.faq details {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .85rem 1rem;
}
.faq summary {
  cursor: pointer; font-weight: 700; font-size: .96rem;
  list-style: none; display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--ink-mute); font-weight: 500; font-size: 1.2rem; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin-top: .55rem; font-size: .92rem; color: var(--ink-soft); }

.tools-grid { list-style: none; padding: 0; margin: 1.1rem 0 0; display: grid; gap: .7rem; }
.tool-tile {
  position: relative; padding: 1rem 1.1rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.tile-title { display: block; font-weight: 700; }
.tile-desc { display: block; margin-top: .2rem; font-size: .88rem; color: var(--ink-soft); }
.tile-badge {
  display: inline-block; margin-top: .5rem;
  font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-mute); background: var(--bg);
  padding: .2rem .5rem; border-radius: 999px;
}

.table-wrap { overflow-x: auto; margin-top: 1rem; }
.history-table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--surface); border-radius: var(--radius-sm); overflow: hidden; }
.history-table th, .history-table td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.history-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-mute); font-weight: 600; }
.history-table td { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.history-table tr:last-child td { border-bottom: 0; }
#historial .btn { margin-top: .8rem; color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--line); }
#historial .btn:hover { background: var(--surface); }

/* Tabla de velocidades recomendadas --------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.speed-table {
  width: 100%; border-collapse: collapse; font-size: .92rem;
  background: var(--surface); border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--line);
}
.speed-table th, .speed-table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--line); }
.speed-table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-mute); font-weight: 600; background: var(--bg); white-space: nowrap;
}
.speed-table tbody th { font-weight: 600; }
.speed-table tbody td { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-soft); }
.speed-table tbody tr:last-child th, .speed-table tbody tr:last-child td { border-bottom: 0; }
.table-note { margin-top: .8rem; font-size: .88rem; color: var(--ink-soft); max-width: 68ch; }
.table-note a { color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* Compartir resultado ----------------------------------------- */
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .8rem; }
.share-label { font-size: .8rem; color: var(--panel-mute); margin-right: .1rem; }
.share-btn {
  display: inline-flex; align-items: center; padding: .38rem .8rem;
  border-radius: 999px; font-size: .82rem; font-weight: 600;
  color: var(--panel-ink); box-shadow: inset 0 0 0 1px rgba(255,255,255,.2);
  transition: background-color .2s var(--ease-out);
}
.share-btn:hover { background: rgba(255,255,255,.09); }
.share-btn.is-done { background: rgba(0,214,163,.16); color: var(--down); box-shadow: inset 0 0 0 1px rgba(0,214,163,.4); }

/* =============================================================
   8. Footer
   ============================================================= */
.site-footer { background: var(--panel); color: var(--panel-mute); padding: 2rem 0; margin-top: 1rem; }
.footer-inner { display: grid; gap: .6rem; }
.footer-brand { color: var(--panel-ink); font-weight: 600; }
.footer-brand strong { color: var(--down); }
.footer-nav { display: flex; flex-wrap: wrap; gap: 1.1rem; font-size: .9rem; }
.footer-nav a { transition: color .2s var(--ease-out); }
.footer-nav a:hover { color: var(--panel-ink); }
.footer-note { font-size: .78rem; max-width: 60ch; opacity: .8; }

/* Legal pages ------------------------------------------------ */
.legal { padding: clamp(1.5rem, 5vw, 3rem) 0; }
.legal .prose h2 { margin-top: 1.7rem; font-size: 1.15rem; }
.legal .prose ul { margin-top: .55rem; padding-left: 1.1rem; color: var(--ink-soft); font-size: .95rem; }
.legal .prose li { margin-top: .3rem; }
.legal .todo {
  display: inline-block; background: #fff4d6; border: 1px solid #ffd88a;
  color: #7a5300; padding: .1rem .4rem; border-radius: 6px; font-size: .82rem; font-weight: 600;
}
.legal .back { display: inline-block; margin-top: 2rem; font-weight: 700; color: var(--ink); }

/* =============================================================
   9. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .verdicts { grid-template-columns: 1fr 1fr; }
  .result-actions .btn { flex: none; }
}
@media (min-width: 720px) {
  .header-nav { display: flex; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .tools-grid { grid-template-columns: repeat(3, 1fr); }
  .hero { padding-top: 2rem; }
}
@media (min-width: 960px) {
  .footer-inner { grid-template-columns: 1fr auto; align-items: center; }
  .footer-note { grid-column: 1 / -1; }
}

/* =============================================================
   10. Reduced motion — solo lo intrusivo
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn-primary:hover { transform: none; }
}
