/* ==========================================================================
   Typing Games — shared components used across the hub and every game page.
   Built on the sitewide .container / .section / .card / .btn / .kicker
   system (see assets/css/components.css, layout.css). Loaded only on
   /typing-games/* pages.
   ========================================================================== */

/* Defensive: several .tg-* classes below set their own `display` value at
   equal specificity to the browser's built-in `[hidden] { display: none }`
   rule, which lets the later-loaded class win and silently defeats the
   `hidden` attribute (confirmed: an element with both `hidden` and
   .tg-hero__actions rendered as display:flex). This guarantees `hidden`
   always wins, regardless of what other classes an element carries. */
[hidden] {
  display: none !important;
}

.tg-hero {
  text-align: center;
  padding-block: var(--space-8) var(--space-6);
}

.tg-hero .kicker::before {
  content: '';
  display: inline-block;
  width: 1.1em;
  height: 3px;
  background: var(--tg-yellow);
  border-radius: var(--radius-full);
}

.tg-hero h1 {
  margin-top: var(--space-3);
}

.tg-hero__lead {
  max-width: 60ch;
  margin-inline: auto;
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
}

.tg-hero__actions {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-6);
}

/* Game card — extends .card with a status badge and a monospace metric line */
.tg-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  /* Grid items default to min-width: auto, which lets a card's intrinsic
     content (the longer game-description paragraphs here) demand its full
     unwrapped width and force the single mobile column wider than the
     viewport — the same class of bug assets/css/home.css already
     documents and fixes locally for .hero__content. Scoped to .tg-card
     only; not a sitewide change. */
  min-width: 0;
}

.tg-card__badge {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-kicker);
  background: var(--color-kicker-bg);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
}

/* Word Blaster and Typing Race read as the two "energetic/arcade" games —
   a yellow badge instead of the calmer aqua one used by the other two,
   while staying within the same pill shape/type scale. Deep-green text on
   yellow: 5.8:1 contrast, verified in tokens.css. */
.tg-card__badge--energetic {
  color: var(--tg-deep-green);
  background: var(--tg-yellow);
}

.tg-card__best {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.tg-card__best strong {
  color: var(--color-text);
}

/* Generic widget shell for the progress / daily-challenge / hall-of-fame-preview sections */
.tg-widget {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.tg-widget__title {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  margin: 0 0 var(--space-4);
}

.tg-empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--color-text-muted);
}

.tg-empty-state__icon {
  margin-bottom: var(--space-3);
  opacity: 0.6;
}

/* Progress bar used by lesson completion and daily-challenge widgets */
.tg-progress-bar {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  overflow: hidden;
}

.tg-progress-bar__fill {
  height: 100%;
  background: var(--tg-yellow);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-standard);
}

@media (prefers-reduced-motion: reduce) {
  .tg-progress-bar__fill {
    transition: none;
  }
}

/* Shared stat-tile row — timer/WPM/accuracy style readouts, used by every
   game's active-play and results screens (first used by Accuracy
   Champion, now also Touch Typing Challenge). */
.tg-stats-row {
  display: flex;
  gap: var(--space-6);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.tg-stat {
  text-align: center;
  min-width: 90px;
}

.tg-stat__value {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--font-size-2xl);
  font-weight: var(--weight-medium);
  color: var(--tg-deep-green);
  line-height: 1;
}

.tg-stat__label {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

/* Shared passage/char-diff display — the monospace prompt box with
   correct/incorrect/current/pending character highlighting, used by
   every typing-driven game (Accuracy Champion, Touch Typing Challenge,
   and Typing Race in Plan 5). */
.tg-passage {
  font-family: var(--font-mono);
  font-size: var(--font-size-lg);
  line-height: var(--line-height-normal);
  max-width: 70ch;
  margin-inline: auto;
  padding: var(--space-6);
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  letter-spacing: 0.01em;
  /* pre-wrap, not normal: some passages intentionally use two spaces
     after a sentence-ending . : or ? (see passages.js /
     touch-typing-curriculum.js) — "normal" collapses any run of spaces
     to one even across sibling <span> character boxes, which would
     silently erase that second space and let the player skip a
     keystroke. pre-wrap preserves the literal run of spaces while still
     allowing the browser to wrap the passage normally. */
  white-space: pre-wrap;
  /* Defensive, not a mask: wrapping itself is fixed by rendering a real
     space character instead of &nbsp; (see game-accuracy-champion.js /
     game-touch-typing.js renderPassage()) — this only protects against a
     single token with no valid break point at all (e.g. a very long
     unbroken word), letting the browser break it rather than overflow. */
  overflow-wrap: break-word;
}

.tg-char--correct {
  color: var(--tg-char-correct);
  background: var(--tg-char-correct-bg);
}

.tg-char--incorrect {
  color: var(--tg-char-incorrect);
  background: var(--tg-char-incorrect-bg);
  text-decoration: underline;
}

.tg-char--current {
  background: var(--tg-char-current-bg);
  outline: 2px solid var(--tg-yellow);
  border-radius: 2px;
  /* Underline in addition to the yellow box, so the current position is
     still obvious on a punctuation mark or a space — a thin outline box
     around a space is easy to miss, text-decoration draws right under
     it. Paint-only (no layout box change), and never collides with
     .tg-char--incorrect's own underline since a char is exactly one of
     correct/incorrect/current/pending at a time (text-engine.js
     diffChars). */
  text-decoration: underline;
  text-decoration-color: var(--tg-yellow-deep);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.tg-char--pending {
  color: var(--color-text-muted);
}

/* Shared personal-best banner, used by every game's results screen
   (first used by Accuracy Champion, now also Word Blaster / Typing Race). */
.tg-pb-banner {
  text-align: center;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--tg-pale-aqua);
  color: var(--tg-deep-green);
  font-weight: var(--weight-medium);
  margin-block: var(--space-5);
}

.tg-pb-banner--new-record {
  background: var(--tg-yellow);
}

/* Shared Hall of Fame submission panel + status states, used by every
   game's results screen. */
.tg-submit-panel {
  max-width: 48ch;
  margin: var(--space-6) auto 0;
  padding: var(--space-6);
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: left;
}

.tg-submit-panel label {
  display: block;
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-2);
}

.tg-submit-panel input[type='text'] {
  width: 100%;
  padding: var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: var(--font-body);
  margin-bottom: var(--space-3);
}

.tg-submit-panel__privacy {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.tg-submit-status {
  margin-top: var(--space-4);
  font-size: var(--font-size-sm);
  padding: var(--space-3);
  border-radius: var(--radius-md);
}

.tg-submit-status--rejected {
  background: #fde3e0;
  color: #8a241a;
}

.tg-submit-status--accepted {
  background: var(--tg-pale-aqua);
  color: var(--tg-deep-green);
}

.tg-submit-status--unavailable {
  background: var(--mist);
  color: var(--color-text-muted);
}

/* Achievement badge chip — locked vs unlocked. Unlocked reads as a small
   trophy (yellow/gold), matching the Hall of Fame's champion treatment;
   deep-green text on yellow is the same 5.8:1-verified pairing used
   throughout this page. */
.tg-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: var(--weight-medium);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--tg-yellow);
  color: var(--tg-deep-green);
}

.tg-badge--locked {
  background: var(--tg-badge-locked-bg);
  color: var(--tg-badge-locked-text);
}
