/* Hand-made utilities on the site shell: /mouse-test/, /keyboard-test/,
   /dead-pixel-test/ (hardware, coral) and /click-counter/, /spacebar/,
   /reaction/ (skill, cyan). Loaded after games.css, which owns the page
   frame (the .xx-play column, h1 and intro subline), the HUD strip, panels,
   the more-games row and the guide/FAQ sections. This layer holds the parts
   the six tools share; each tool's own sheet holds its instrument.
   Tokens only, logical properties, one accent via body[data-accent]. */

/* ── Tool buttons: secondary buttons with an accent icon ─────────────── */
:is(.mt-ctrl-btn, .kb-ctrl-btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-block-size: var(--tap);
  padding-inline: var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
:is(.mt-ctrl-btn, .kb-ctrl-btn) > i { color: var(--accent); font-size: 0.95em; }
:is(.mt-ctrl-btn, .kb-ctrl-btn):hover { border-color: var(--border-control); background: var(--surface-3); }
:is(.mt-ctrl-btn, .kb-ctrl-btn):active { transform: translateY(1px); }

/* Toolbar row: the controls sit centred under the intro. */
:is(.mt-controls, .kb-controls) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

/* ── Readout strip: the HUD look from games.css for the tool counters ── */
:is(.mt-counts, .kb-stats) {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--border);
  box-shadow: var(--shadow-1);
}
:is(.mt-count, .kb-stat) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-inline-size: 0;
  padding: var(--space-2) var(--space-1);
  background: var(--surface-1);
  text-align: center;
}
:is(.mt-count-label, .kb-stat-label) {
  max-inline-size: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-block-start: 0.12em;
  color: var(--text-muted);
}
:is(.mt-count-val, .kb-stat-value) {
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 0.9;
  padding-block-start: 0.1em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
:lang(ar) :is(.mt-count-label, .kb-stat-label) { letter-spacing: 0; }

/* ── Test pad (spacebar, reaction): the Tap Pad surface ──────────────── */
:is(#spacebar-area, #reaction-area).glass-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-block-size: 15rem;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  color: var(--text);
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
:is(#spacebar-area, #reaction-area).glass-panel:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border-strong)); }
@media (min-width: 768px) {
  :is(#spacebar-area, #reaction-area).glass-panel { min-block-size: clamp(16rem, calc(100svh - 420px), 22rem); }
}

/* ── Stop button (spacebar) ──────────────────────────────────────────── */
.stop-btn {
  align-self: center;
  min-block-size: var(--tap);
  padding-inline: var(--space-6);
  border: 1px solid color-mix(in srgb, var(--danger) 60%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--danger) 14%, var(--surface-1));
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.stop-btn:hover { background: color-mix(in srgb, var(--danger) 26%, var(--surface-1)); }

/* ── Recent tests (spacebar, reaction) ───────────────────────────────── */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-block-end: var(--space-3);
}
.history-header .teko-subtitle { margin: 0; }
.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(12rem, 100%), 1fr));
  gap: var(--space-2);
}
.history-list > :is(.muted, p) { grid-column: 1 / -1; margin: 0; padding-block: var(--space-3); text-align: center; color: var(--text-muted); }
.history-item {
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
}
.history-cps {
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1;
  padding-block-start: 0.1em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.history-meta { color: var(--text-muted); font-size: var(--step--1); }
.history-date { color: var(--text-faint); font-size: var(--step--1); }

@media (prefers-reduced-motion: reduce) {
  :is(.mt-ctrl-btn, .kb-ctrl-btn, #spacebar-area, #reaction-area) { transition: none; }
}
