/* Hardware-Tester.com - Keyboard Tester
   Loaded after /css/styles.css and reuses its colour tokens (--accent, --bg-card, ...). */

.kt-page {
  --kt-tested: #60a5fa;
  --kt-tested-soft: rgba(96, 165, 250, 0.2);
  --kt-held: #fbbf24;
  --kt-ok: #34d399;
}

/* Breadcrumb ------------------------------------------------------- */
.breadcrumb {
  margin: 0 0 1.25rem;
  font-size: 0.92rem;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
}

.breadcrumb li + li::before {
  content: "/";
  margin-right: 0.4rem;
  color: var(--border-strong);
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--accent);
}

/* Intro ------------------------------------------------------------ */
.kt-intro {
  max-width: 46rem;
  margin-bottom: 1.75rem;
}

.kt-intro h1 {
  font-size: clamp(2rem, 4.5vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.kt-intro p {
  margin: 0;
  color: var(--text-muted);
  font-size: 1.12rem;
}

/* Tester panel ----------------------------------------------------- */
.kt {
  --u: clamp(1.7rem, 3.75vw, 2.6rem); /* one standard key, scales with the viewport */
  padding: clamp(0.9rem, 2vw, 1.4rem);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
}

.kt:fullscreen {
  --u: clamp(2rem, 4vw, 3.6rem);
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: var(--bg);
}

.kt-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-bottom: 1rem;
}

.kt-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.kt-status::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--text-muted);
}

.kt-status[data-state="on"]::before {
  background: var(--kt-ok);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.18);
}

.kt-status[data-state="off"]::before {
  background: var(--kt-held);
}

.kt-layout-badge {
  margin: 0;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.kt-layout-badge strong {
  color: var(--accent);
}

/* Stat cards ------------------------------------------------------- */
.kt-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: 0.75rem;
  margin: 0 0 0.9rem;
}

.kt-stat {
  padding: 0.9rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.kt-stat-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kt-stat-value {
  margin: 0.15rem 0 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.kt-stat-sub {
  margin: 0.1rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.kt-progress {
  height: 0.55rem;
  margin-bottom: 1.1rem;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.kt-progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transition: width 0.2s ease;
}

/* Toolbar (search + fullscreen) ------------------------------------ */
.kt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.kt-search-wrap {
  flex: 1 1 15rem;
  max-width: 24rem;
}

.kt-search-wrap label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kt-search-wrap input {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.5rem 0.8rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 0.7rem;
}

.kt-search-wrap input::placeholder {
  color: var(--text-muted);
}

.kt-search-wrap input:focus-visible {
  border-color: var(--focus);
}

.kt-search-count {
  min-height: 1.2rem;
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.kt-fs-hint {
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.6rem;
  background: var(--accent-soft);
}

/* Virtual keyboard -------------------------------------------------- */
.kt-stage {
  padding: clamp(0.6rem, 1.6vw, 1.1rem);
  overflow-x: auto;
  background: #0d141c;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kt.is-capturing .kt-stage {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft), 0 0 28px rgba(79, 209, 197, 0.14);
}

.kt-kb {
  position: relative;
  flex: none;
  width: calc(var(--kb-w) * var(--u));
  height: calc(var(--kb-h) * var(--u));
  margin-inline: auto;
  user-select: none;
  -webkit-user-select: none;
}

.key {
  position: absolute;
  left: calc(var(--x) * var(--u));
  top: calc(var(--y) * var(--u));
  width: calc(var(--w) * var(--u));
  height: calc(var(--h) * var(--u));
  padding: calc(var(--u) * 0.05);
  transition: opacity 0.15s ease;
}

.key-cap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--text-muted);
  background: linear-gradient(180deg, #223143, #19242f);
  border: 1px solid var(--border-strong);
  border-radius: calc(var(--u) * 0.16);
  box-shadow: 0 calc(var(--u) * 0.06) 0 #070b10, inset 0 1px 0 rgba(255, 255, 255, 0.06);
  line-height: 1.1;
  transition: background 0.08s ease, border-color 0.08s ease, box-shadow 0.08s ease, transform 0.08s ease, color 0.08s ease;
}

.cap-main {
  font-size: clamp(0.62rem, calc(var(--u) * 0.36), 1rem);
  font-weight: 600;
  color: var(--text);
}

.cap-word {
  font-size: clamp(0.5rem, calc(var(--u) * 0.26), 0.8rem);
  letter-spacing: -0.01em;
}

.cap-top {
  font-size: clamp(0.5rem, calc(var(--u) * 0.26), 0.78rem);
  color: var(--text-muted);
}

/* Tested: blue tint + corner dot (colour is not the only cue) */
.key.is-tested .key-cap {
  background: linear-gradient(180deg, var(--kt-tested-soft), rgba(96, 165, 250, 0.1));
  border-color: var(--kt-tested);
}

.key.is-tested .key-cap::after {
  content: "";
  position: absolute;
  top: calc(var(--u) * 0.08);
  right: calc(var(--u) * 0.08);
  width: calc(var(--u) * 0.12);
  height: calc(var(--u) * 0.12);
  border-radius: 50%;
  background: var(--kt-tested);
}

/* Currently pressed: bright accent */
.key.is-down .key-cap {
  color: #04221f;
  background: var(--accent);
  border-color: #a5f3ec;
  box-shadow: 0 0 0 1px var(--accent), 0 0 calc(var(--u) * 0.45) rgba(79, 209, 197, 0.7);
  transform: translateY(calc(var(--u) * 0.04)) scale(0.97);
}

.key.is-down .cap-main,
.key.is-down .cap-top {
  color: #04221f;
}

/* Held a long time with no release event */
.key.is-held .key-cap {
  background: var(--kt-held);
  border-color: #fde68a;
  box-shadow: 0 0 0 1px var(--kt-held), 0 0 calc(var(--u) * 0.45) rgba(251, 191, 36, 0.6);
}

/* Search filter */
.kt-kb.is-filtering .key:not(.is-match) {
  opacity: 0.25;
}

.key.is-match .key-cap {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* Lock lights */
.kb-leds {
  position: absolute;
  left: calc(var(--x) * var(--u));
  top: calc(var(--y) * var(--u));
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 0.3);
  height: calc(var(--u) * 0.6);
  padding-left: calc(var(--u) * 0.1);
  font-size: clamp(0.5rem, calc(var(--u) * 0.26), 0.75rem);
  color: var(--text-muted);
}

.kb-led {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}

.kb-led::before {
  content: "";
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: #243242;
  border: 1px solid var(--border-strong);
}

.kb-led.is-on::before {
  background: var(--kt-ok);
  border-color: var(--kt-ok);
  box-shadow: 0 0 6px var(--kt-ok);
}

/* Controls + legend -------------------------------------------------- */
.kt-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn-sm {
  min-height: 2.5rem;
  padding: 0.45rem 0.95rem;
  font-size: 0.97rem;
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  color: #fff;
  background: rgba(248, 113, 113, 0.2);
  border-color: var(--danger);
}

.kt-mode,
.kt-help {
  margin: 0.7rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.kt-message {
  min-height: 1.4rem;
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}

.kt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.kt-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.kt-swatch {
  position: relative;
  width: 1.4rem;
  height: 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.3rem;
  background: linear-gradient(180deg, #223143, #19242f);
}

.kt-swatch.is-tested {
  background: var(--kt-tested-soft);
  border-color: var(--kt-tested);
}

.kt-swatch.is-tested::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 50%;
  background: var(--kt-tested);
}

.kt-swatch.is-down {
  background: var(--accent);
  border-color: #a5f3ec;
  box-shadow: 0 0 8px rgba(79, 209, 197, 0.6);
}

.kt-swatch.is-held {
  background: var(--kt-held);
  border-color: #fde68a;
}

/* Alerts ------------------------------------------------------------- */
.kt-alerts {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.kt-alerts:not(:empty) {
  margin-top: 1rem;
}

.kt-alert {
  padding: 0.75rem 0.95rem;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 0.7rem 0.7rem 0;
}

.kt-alert.is-warn {
  background: rgba(251, 191, 36, 0.12);
  border-left-color: var(--kt-held);
}

.kt-alert.is-ok {
  background: rgba(52, 211, 153, 0.12);
  border-left-color: var(--kt-ok);
}

/* Detail cards ------------------------------------------------------- */
.kt-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.9rem;
  margin-top: 1.1rem;
}

.kt-card {
  min-width: 0;
  padding: 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.kt-card h3,
.kt-card h2 {
  margin: 0 0 0.7rem;
  font-size: 1.05rem;
}

.kt-card h3 + .kt-muted,
.kt-card .kt-subhead {
  margin: 0.9rem 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kt-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.kt-card-head h3 {
  margin: 0;
}

.kt-last {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.8rem;
}

.kt-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 4rem;
  max-width: 8rem;
  height: 4rem;
  padding: 0 0.6rem;
  overflow: hidden;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 0.8rem;
  text-align: center;
  white-space: nowrap;
}

.kt-glyph.is-long {
  font-size: 1.05rem;
}

.kt-last-event {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.kt-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 0.9rem;
  margin: 0;
  font-size: 0.92rem;
}

.kt-dl dt {
  color: var(--text-muted);
}

.kt-dl dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.kt-dl code,
.kt-log code {
  padding: 0.05rem 0.35rem;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.88em;
  color: var(--accent);
  background: var(--bg);
  border-radius: 0.3rem;
}

.kt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.kt-chip {
  padding: 0.2rem 0.6rem;
  font-size: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
}

.kt-chip.is-warn {
  border-color: var(--kt-held);
  color: var(--kt-held);
}

.kt-muted {
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Event log */
.kt-log {
  max-height: 19rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  font-size: 0.88rem;
}

.kt-log-item {
  display: grid;
  grid-template-columns: 5.9rem 4.8rem minmax(0, 1fr);
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

.kt-log-item time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.kt-log-kind {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.kt-log-item.is-down .kt-log-kind {
  color: var(--accent);
}

.kt-log-item.is-up .kt-log-kind {
  color: var(--kt-tested);
}

.kt-log-item.is-repeat .kt-log-kind {
  color: var(--kt-held);
}

.kt-log-key {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.5rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.kt-untested {
  margin-top: 0.9rem;
  padding: 0.2rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
}

.kt-untested summary {
  padding: 0.8rem 0;
  font-weight: 700;
  cursor: pointer;
}

.kt-untested .kt-chips {
  padding-bottom: 1rem;
}

/* Page sections ------------------------------------------------------ */
.kt-section {
  margin-top: 3rem;
}

.kt-section h2 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.03em;
}

.kt-section > p {
  max-width: 46rem;
  color: var(--text-muted);
}

.kt-section .steps {
  margin-top: 1.2rem;
}

.kt-privacy {
  padding: 1.1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}

.kt-privacy h2 {
  font-size: 1.25rem;
}

.kt-privacy p {
  margin: 0;
  max-width: none;
}

.kt-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.75rem;
  margin: 1.2rem 0 0;
  padding: 0;
  list-style: none;
}

.kt-link-grid a {
  display: block;
  height: 100%;
  padding: 0.95rem 1.1rem;
  color: var(--text);
  text-decoration: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.kt-link-grid a:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.kt-link-grid strong {
  display: block;
  color: var(--accent);
}

.kt-link-grid span {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .kt-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .kt-stat {
    padding: 0.7rem 0.8rem;
  }

  .kt-stat-value {
    font-size: 1.55rem;
  }

  .kt-log-item {
    grid-template-columns: 5.4rem 4.4rem minmax(0, 1fr);
  }

  .kt-controls .btn {
    flex: 1 1 8rem;
  }
}
