/* ==========================================================
   teste de digitação — complementa o base.css
   ========================================================== */

.durations {
  display: flex;
  gap: 2px;
}

.divider {
  width: 1px;
  height: 18px;
  background: var(--line);
}

.test {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.test[hidden] {
  display: none;
}

.live {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 22px;
  font-family: var(--mono);
  font-size: 17px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.live-time {
  font-size: 34px;
  color: var(--accent);
}

/* palavras */
.typing-box {
  --font-size: 30px;
  --line-h: 54px;
  position: relative;
  cursor: text;
}

#hiddenInput {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  top: 0;
  left: 0;
  border: 0;
  padding: 0;
  pointer-events: none;
}

.words-view {
  height: calc(var(--line-h) * 3);
  overflow: hidden;
}

.words {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  font-family: var(--mono);
  font-size: var(--font-size);
  line-height: var(--line-h);
  transition: transform .18s ease;
  user-select: none;
}

.word {
  margin-right: .6em;
  white-space: nowrap;
  height: var(--line-h);
  background-image: linear-gradient(transparent, transparent);
  background-repeat: no-repeat;
  background-size: 100% 2px;
  background-position: 0 calc(100% - 8px);
}

.word .l {
  color: var(--dim);
}

.word .l.ok {
  color: var(--ink);
}

.word .l.bad {
  color: var(--error);
}

.word .l.extra {
  color: var(--error-dim);
}

.word.error {
  background-image: linear-gradient(var(--error), var(--error));
}

.caret {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: calc(var(--font-size) * 1.13);
  margin-top: calc((var(--line-h) - var(--font-size) * 1.13) / 2);
  margin-left: -0.5px;
  background: var(--accent);
  border-radius: 2px;
  transition: transform .08s linear;
  /* piscar suave, igual ao "editor.cursorBlinking": "smooth" do VS Code */
  animation: caret-smooth .5s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes caret-smooth {
  0%,
  20% {
    opacity: 1;
  }

  60%,
  100% {
    opacity: 0;
  }
}

/* aviso de Caps Lock (na linha do tempo, ppm e precisão) */
.caps-warn {
  margin-left: auto;
  align-self: center;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 800;
}

.caps-warn[hidden] {
  display: none;
}

.focus-overlay {
  position: absolute;
  inset: -6px;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 20px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  background: var(--overlay);
  backdrop-filter: blur(3px);
}

.typing-box.blurred .focus-overlay {
  display: flex;
}

.typing-box.blurred .caret {
  display: none;
}

/* ---------- resultado ---------- */
.results {
  animation: appear .25s ease;
}

.results[hidden] {
  display: none;
}

@keyframes appear {
  from {
    opacity: 0;
  }
}

.res-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-bottom: 14px;
}

.res-big {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.res-big span {
  font-size: 96px;
  font-weight: 900;
  font-stretch: 125%;
  line-height: .85;
  letter-spacing: -0.04em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.res-big small {
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}

.res-badge {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-ink);
  background: var(--accent);
  padding: 5px 11px;
  border-radius: 999px;
}

.res-badge[hidden] {
  display: none;
}

.res-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 36px;
  margin: 0 0 18px;
}

.res-grid dt {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.res-grid dd {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  font-stretch: 115%;
  font-variant-numeric: tabular-nums;
}

.chart {
  width: 100%;
  height: 150px;
  display: block;
}

.chart .grid {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart .axis {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--sans);
}

.chart .line-wpm {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}

.chart .line-raw {
  fill: none;
  stroke: var(--dim);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
}

.chart .area-wpm {
  fill: var(--accent);
  opacity: .1;
}

.chart .err {
  fill: var(--error);
}

.chart-legend {
  display: flex;
  gap: 18px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.lg {
  display: inline-block;
  width: 14px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 2px;
}

.lg-wpm {
  background: var(--accent);
}

.lg-raw {
  background: var(--dim);
}

.lg-err {
  background: var(--error);
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.res-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
  font-size: 14px;
  color: var(--muted);
}

.again {
  border: 1.5px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
  padding: 11px 18px;
  border-radius: 8px;
  cursor: pointer;
}

.again:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ---------- teclado da dica ---------- */
.keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--g);
}

.row {
  display: flex;
  gap: var(--g);
}

/* no resultado o teclado e o lembrete do Tab saem de cena */
body.show-results .keyboard,
body.show-results #telaDigitacao .footnote {
  display: none;
}

@media (max-width: 760px) {
  .typing-box {
    --font-size: 19px;
    --line-h: 36px;
  }

  .live {
    font-size: 15px;
  }

  .live-time {
    font-size: 26px;
  }

  .res-big span {
    font-size: 64px;
  }

  .res-grid dd {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {

  .words,
  .caret {
    transition: none;
  }

  /* o cursor continua piscando (como no VS Code), mesmo com animações reduzidas */

  .results {
    animation: none;
  }
}