/* =====================================================================
   dusktype — typing test: words, caret, live stats, pb panel
   ===================================================================== */
#testView { position: relative; width: 100%; max-width: 62.5rem; margin: 0 auto; }

/* caps lock warning: floats above the words so it never shifts the layout */
.caps-warn {
  position: absolute; left: 50%; bottom: 100%; z-index: 4;
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.75rem; padding: 0.375rem 0.875rem;
  border: 1px solid var(--error); border-radius: 0.5rem;
  background: var(--bg); color: var(--text);
  font-size: .8rem; width: max-content; max-width: calc(100vw - 2rem);
  opacity: 0; transform: translate(-50%, 0.375rem); pointer-events: none;
  transition: opacity 150ms ease-out, transform 150ms ease-out;
}
.caps-warn svg { width: 0.875rem; height: 0.875rem; flex: none; color: var(--error); }
.caps-warn.show { opacity: 1; transform: translate(-50%, 0); }

.live {
  display: flex; gap: 1.1em; align-items: baseline;
  height: 1.5em;
  font-size: calc(var(--fs) * .9);
  color: var(--main);
  padding-left: .33em;
  transition: opacity var(--t);
}
.live.idle { opacity: .55; }
.live span { animation: fadeIn 150ms ease-out; } /* live wpm / acc / race fade in when switched on */

.wrap {
  position: relative;
  overflow: hidden;
  font-size: var(--fs);
  cursor: default;
}
.wrap.fresh { animation: fadeIn 150ms ease-out; }
#words {
  position: relative;            /* offsetParent for letters + caret */
  display: flex; flex-wrap: wrap; align-content: flex-start;
  line-height: 1.25;
  user-select: none;
  transition: transform 150ms ease-out, filter 150ms ease, opacity 150ms ease;
  will-change: transform;
}
.wrap.blurred #words { filter: blur(0.3125rem); opacity: .35; }
.word { margin: .25em .3em; white-space: nowrap; }
/* incorrectly submitted word: error underline (covers its missed letters too) */
.word.error { background: linear-gradient(var(--error), var(--error)) left bottom / 100% 2px no-repeat; }
.letter { position: relative; z-index: 1; color: var(--sub); transition: color 100ms ease; }
.letter.correct { color: var(--text); }
.letter.incorrect { color: var(--error); }
.letter.extra { color: var(--error-extra); }
.letter.missed { color: var(--sub); text-decoration: underline; text-decoration-color: var(--error); text-decoration-thickness: 2px; text-underline-offset: .22em; }

/* caret */
#caret {
  position: absolute; z-index: 0; left: 0; top: 0;
  width: 2px; height: 1em;
  background: var(--main);
  border-radius: 2px;
  pointer-events: none;
}
#caret.smooth { transition: left 100ms ease-out, top 100ms ease-out, width 100ms ease-out; }
#caret.blink { animation: blink 1s ease-in-out infinite; }
#caret.block { background: rgba(142, 96, 106, .55); background: color-mix(in srgb, var(--main) 55%, transparent); border-radius: 0.1875rem; }
#caret.gone, .wrap.blurred #caret { visibility: hidden; }

/* ghost caret: a past run replaying alongside you in a race */
#ghost {
  position: absolute; z-index: 0; left: 0; top: 0;
  width: 2px; height: 1em;
  background: var(--accent2);
  border-radius: 2px;
  opacity: .75;
  pointer-events: none;
  transition: left 90ms linear, top 90ms ease-out;
}
.wrap.blurred #ghost { visibility: hidden; }
#liveRace { color: var(--accent2); }

.focus-warn {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center; gap: .6em;
  color: var(--text); font-size: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t);
}
.focus-warn svg { width: 1rem; height: 1rem; }
.focus-warn.show { opacity: 1; pointer-events: auto; cursor: pointer; }

/* hidden input that captures typing (works with mobile keyboards) */
#hiddenInput {
  position: absolute; left: 0; top: 0;
  width: 1px; height: 1px;
  opacity: 0; border: 0; padding: 0; margin: 0;
  font-size: 16px; /* avoids iOS zoom-on-focus */
  color: transparent; background: transparent; caret-color: transparent;
  pointer-events: none;
}

.under { display: flex; flex-direction: column; align-items: center; margin-top: 1.5rem; }
.under .hint { margin-top: 0.75rem; } /* margin, not gap, so it can collapse smoothly */
.restart-btn {
  width: 3rem; height: 2.375rem;
  display: grid; place-items: center;
  border-radius: 0.5rem;
  color: var(--sub);
  transition: color var(--t), background-color var(--t);
}
.restart-btn:hover { color: var(--text); background: var(--sub-alt); }
.restart-btn svg { width: 1.125rem; height: 1.125rem; }

.pb-panel { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; align-items: center; font-size: .7rem; margin-top: 1.875rem; }
.pb-panel .pbt { margin-right: 0.25rem; }
.pb { display: flex; flex-direction: column; align-items: center; min-width: 3.25rem; padding: 0.3125rem 0.625rem; border-radius: 0.375rem; background: var(--panel); }
.pb .k { color: var(--sub); }
.pb .v { color: var(--text); font-size: .95rem; line-height: 1.3; }
.pb.cur .k { color: var(--main); }
