/* FrogType - tool-specific styles. Header, hero, footer, privacy badge, and
   the :root tokens come from the shared shell (tool-shell.css); this file
   carries the typing surface, controls, live stats, and results. */

.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;
}

/* ─── Panels ──────────────────────────────────────────────────────────── */

.panel__title {
  margin: 0 0 1.25rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.panel--result { border-color: rgba(25, 195, 125, 0.4); }

/* ─── Controls row (duration / best / restart) ────────────────────────── */

.tt-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.seg-group {
  display: inline-flex;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.seg {
  border: none;
  background: var(--bg-deep);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.seg + .seg { border-left: 1px solid var(--border-dark); }
.seg:hover { color: var(--text-light); }
.seg.is-active { background: var(--accent); color: #07140d; }
.seg:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.tt-best {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}
.tt-best strong { color: var(--accent); }

.tt-clear-best {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 120ms ease;
}
.tt-clear-best:hover { color: #ff8a8a; }
.tt-clear-best:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tt-clear-best[hidden] { display: none; }

/* ─── Live stats ──────────────────────────────────────────────────────── */

.tt-stats {
  display: flex;
  gap: 2.5rem;
  padding: 0 0.25rem 1.25rem;
}
.tt-stat { display: flex; flex-direction: column; }
.tt-stat__num {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.tt-stat__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* ─── Typing surface ──────────────────────────────────────────────────── */

.tt-box {
  position: relative;
  padding: 1.4rem 1.5rem;
  background: var(--bg-deep);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  cursor: text;
  overflow: hidden;
  max-height: calc(3 * 2em + 2.8rem);
}
.tt-box:focus, .tt-box.is-focused { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }

.tt-words {
  font-family: var(--mono);
  font-size: 1.3rem;
  line-height: 2;
  color: var(--muted);
  letter-spacing: 0.01em;
  user-select: none;
  transition: transform 120ms ease;
}
.word { display: inline-block; white-space: nowrap; margin-right: 0.6ch; }

.char { position: relative; border-radius: 2px; }
.char.is-correct { color: var(--text-light); }
.char.is-incorrect { color: #ff6b6b; }
.char.is-incorrect.is-extra { color: #ff8a8a; opacity: 0.55; }
.char.is-current { background: var(--accent-soft); box-shadow: inset 2px 0 0 0 var(--accent); }

/* The capture input fills the box but stays invisible; the rendered words
   below it are what the user sees. caret-color transparent so no double cursor. */
.tt-hidden-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 1.4rem 1.5rem;
  border: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font: inherit;
  font-size: 16px;
  opacity: 0;
  cursor: text;
}

.tt-focus-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 9, 11, 0.55);
  color: var(--text-light);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: text;
}
.tt-focus-hint[hidden] { display: none; }

.tt-hint {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ─── Results ─────────────────────────────────────────────────────────── */

.tt-result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 560px) {
  .tt-result-grid { grid-template-columns: repeat(2, 1fr); }
}
.tt-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0.5rem;
  background: var(--bg-deep);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  text-align: center;
}
.tt-result__num {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.05;
}
.tt-result__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: 0.35rem;
}
.tt-result-best {
  margin: 0 0 1.25rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--muted);
}
.tt-result-best.is-new { color: var(--accent); font-weight: 700; }

@media (max-width: 560px) {
  .tt-words { font-size: 1.15rem; }
  .tt-stats { gap: 1.75rem; }
  .tt-stat__num { font-size: 1.4rem; }
  .btn--sm { min-height: 44px; }
}
