/* ── Typing Speed Test — amber terminal aesthetic ────────────────────── */
/* Palette: #060709 bg · #f59e0b amber · #10d9a0 teal · #f85149 error    */

/* 1. Page atmosphere */
.tst-page {
  background: #060709;
  color: #e2e8f0;
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Cascadia Code", Consolas, "DejaVu Sans Mono", monospace;
}

.tst-page .site-header {
  background: rgba(6, 7, 9, 0.97);
  border-bottom: 1px solid rgba(245, 158, 11, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tst-page .site-brand {
  color: #f0e6c8;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tst-page .site-nav a {
  color: rgba(200, 180, 140, 0.65);
  font-family: inherit;
  font-size: 0.82rem;
}

.tst-page .site-footer {
  background: rgba(4, 5, 7, 0.98);
  border-top: 1px solid rgba(245, 158, 11, 0.08);
  color: rgba(180, 160, 120, 0.55);
  font-family: inherit;
}

.tst-page .footer-title {
  color: #d4b896;
}

.tst-page .footer-copy,
.tst-page .site-nav.site-nav--footer a {
  color: rgba(160, 140, 100, 0.55);
}

/* 2. Tool shell — transparent */
.tst-page .tool-shell {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.tst-page .section-tool-page {
  padding-block: 4px 20px;
}

.tst-page .tool-header-block {
  margin-bottom: 0.35rem;
}

/* 3. Header — compact to maximize engine space */
.tst-page .page-title {
  color: #f5e6c0;
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.1;
  margin-bottom: 0;
}

.tst-page .page-subtitle {
  color: rgba(200, 178, 130, 0.65);
  font-family: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  margin-top: 0.15rem;
  margin-bottom: 0;
}

/* ── Language toggle button — visually distinct from mode/timer ──────── */
.tst-lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  padding: 0.2rem 0.55rem 0.2rem 0.4rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 217, 160, 0.2);
  background: rgba(16, 217, 160, 0.06);
  color: rgba(16, 217, 160, 0.7);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.tst-lang-icon {
  font-size: 0.85em;
  line-height: 1;
}

.tst-lang-toggle:hover,
.tst-lang-toggle:focus-visible {
  color: #10d9a0;
  border-color: rgba(16, 217, 160, 0.45);
  background: rgba(16, 217, 160, 0.1);
  outline: none;
}

/* ── Main UI wrapper ─────────────────────────────────────────────────── */
.tst-ui {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Engine surface ──────────────────────────────────────────────────── */
.tst-engine {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border-radius: 0.75rem;
  border: 1px solid rgba(245, 158, 11, 0.15);
  background: #0a0b0d;
  box-shadow:
    0 32px 64px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(245, 158, 11, 0.06);
}

/* ── Top bar ─────────────────────────────────────────────────────────── */
.tst-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.25rem;
}

.tst-mode-group,
.tst-timer-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.tst-mode-btn,
.tst-timer-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: rgba(180, 160, 120, 0.45);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
  user-select: none;
  -webkit-user-select: none;
}

.tst-mode-btn:hover,
.tst-timer-btn:hover,
.tst-mode-btn:focus-visible,
.tst-timer-btn:focus-visible {
  color: rgba(245, 158, 11, 0.8);
  border-bottom-color: rgba(245, 158, 11, 0.35);
  outline: none;
}

.tst-mode-btn--active,
.tst-timer-btn--active {
  color: #f59e0b;
  border-bottom-color: #f59e0b;
}

.tst-mode-btn:active,
.tst-timer-btn:active {
  transform: scale(0.94);
  color: #fbbf24;
}

/* ── Live stats bar ──────────────────────────────────────────────────── */
.tst-stats-bar {
  display: flex;
  align-items: baseline;
  gap: 2rem;
}

.tst-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}

.tst-stat__value {
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  font-weight: 700;
  color: rgba(230, 210, 170, 0.6);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  transition: color 200ms ease;
}

/* WPM stat gets bigger hero treatment */
.tst-stat:first-child .tst-stat__value {
  font-size: clamp(2.4rem, 6vw, 3.5rem);
  color: #f0e0b0;
}

.tst-stat__label {
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(180, 155, 100, 0.45);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 0.1rem;
}

.tst-stat--timer .tst-stat__value--timer {
  color: rgba(16, 217, 160, 0.8);
}

.tst-stat--timer.tst-stat--urgent .tst-stat__value--timer {
  color: #f85149;
  animation: tst-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes tst-pulse {
  from { opacity: 1; }
  to   { opacity: 0.5; }
}

/* ── Progress bar ────────────────────────────────────────────────────── */
.tst-progress-wrap {
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.tst-progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #f59e0b, #10d9a0);
  border-radius: 1px;
  transition: width 1s linear, background 500ms ease;
  transform-origin: left;
}

.tst-progress-fill--urgent {
  background: linear-gradient(90deg, #f85149, #fbbf24);
  animation: tst-progress-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes tst-progress-pulse {
  from { opacity: 1; }
  to   { opacity: 0.6; }
}

/* ── Word display ────────────────────────────────────────────────────── */
.tst-display {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.7rem;
  min-height: 16rem;
  padding: 1.4rem 1.5rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(245, 158, 11, 0.08);
  background: #060709;
  cursor: text;
  overflow: hidden auto;
  max-height: 22rem;
  line-height: 2;
  scrollbar-width: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Scroll-hint fade at bottom when content overflows */
.tst-display::after {
  content: "";
  position: sticky;
  bottom: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 2.5rem;
  margin-top: -2.5rem;
  background: linear-gradient(to bottom, transparent, #060709 90%);
  pointer-events: none;
  flex-shrink: 0;
  transition: opacity 200ms ease;
}

.tst-display--scrolled-end::after {
  opacity: 0;
}

.tst-display--active {
  border-color: rgba(245, 158, 11, 0.2);
}

/* Words */
.tst-word {
  display: inline-flex;
  gap: 0;
  padding-bottom: 1px;
  border-bottom: 2px solid transparent;
}

.tst-word--current {
  border-bottom-color: rgba(245, 158, 11, 0.25);
}

.tst-word--error {
  border-bottom-color: rgba(248, 81, 73, 0.45);
}

/* Characters */
.tst-char {
  position: relative;
  font-size: 1.35rem;
  font-weight: 500;
  color: rgba(160, 140, 100, 0.35);
  letter-spacing: 0.01em;
  transition: color 50ms ease;
}

.tst-char--pending {
  color: rgba(160, 140, 100, 0.35);
}

.tst-char--correct {
  color: #10d9a0;
}

.tst-char--error {
  color: #f85149;
}

/* Cursor */
.tst-cursor {
  display: inline-block;
  width: 2px;
  height: 1.25em;
  background: #f59e0b;
  border-radius: 1px;
  vertical-align: middle;
  animation: tst-blink 1s step-end infinite;
  position: relative;
  flex-shrink: 0;
}

@keyframes tst-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Cursor temperature (Streak Fire) */
.tst-cursor--warm {
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7), 0 0 20px rgba(245, 158, 11, 0.3);
  animation: tst-blink 1s step-end infinite;
}

.tst-cursor--hot {
  background: #f97316;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.85), 0 0 28px rgba(249, 115, 22, 0.4);
  animation: tst-blink-fast 0.6s step-end infinite;
}

@keyframes tst-blink-fast {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

/* Ghost cursor */
.tst-ghost-cursor {
  display: inline-block;
  width: 2px;
  height: 1.25em;
  background: rgba(160, 140, 100, 0.2);
  border-radius: 1px;
  vertical-align: middle;
  position: absolute;
  pointer-events: none;
  transition: left 80ms linear, top 80ms linear;
}

/* Ghost particle burst */
.tst-ghost-burst {
  position: absolute;
  pointer-events: none;
  width: 12px;
  height: 12px;
}

.tst-ghost-burst__particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.7);
  animation: tst-particle-fly 500ms ease-out forwards;
}

@keyframes tst-particle-fly {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ── Hidden input ────────────────────────────────────────────────────── */
.tst-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  top: 0;
  left: 0;
  border: 0;
  padding: 0;
  /* pointer-events must be auto for IME to work on some mobile browsers */
  pointer-events: none;
}

/* ── Hint / notices ──────────────────────────────────────────────────── */
.tst-hint {
  margin: 0;
  text-align: center;
  color: rgba(160, 140, 100, 0.4);
  font-size: 0.78rem;
  font-family: inherit;
  letter-spacing: 0.04em;
}

.tst-ghost-notice,
.tst-storage-notice {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.75rem;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.14);
  font-size: 0.76rem;
  color: rgba(245, 158, 11, 0.7);
  font-family: inherit;
}

.tst-storage-notice {
  border-color: rgba(248, 81, 73, 0.2);
  color: rgba(248, 81, 73, 0.7);
  background: rgba(30, 10, 10, 0.6);
}

.tst-ghost-notice[hidden],
.tst-storage-notice[hidden],
.tst-restart-hint[hidden] {
  display: none;
}

.tst-restart-hint {
  margin: 0;
  text-align: center;
  color: rgba(160, 140, 100, 0.4);
  font-size: 0.75rem;
  font-family: inherit;
}

.tst-restart-hint kbd {
  display: inline-block;
  padding: 0.06em 0.35em;
  border-radius: 3px;
  border: 1px solid rgba(245, 158, 11, 0.22);
  background: rgba(20, 16, 8, 0.85);
  color: rgba(245, 158, 11, 0.7);
  font-family: inherit;
  font-size: 0.85em;
  line-height: 1.4;
  vertical-align: middle;
}

/* ── Results panel ───────────────────────────────────────────────────── */
.tst-results {
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border-radius: 0.75rem;
  border: 1px solid rgba(245, 158, 11, 0.15);
  background: #0a0b0d;
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.7);
}

.tst-results[hidden] {
  display: none;
}

.tst-results__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.tst-results__eyebrow {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(245, 158, 11, 0.6);
  font-family: inherit;
}

.tst-results__wpm-hero {
  font-size: clamp(4.5rem, 14vw, 8rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #f5e6c0;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  text-shadow: 0 0 60px rgba(245, 158, 11, 0.2);
}

.tst-results__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.tst-result-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.18);
  background: rgba(20, 16, 8, 0.7);
  font-family: inherit;
}

.tst-result-pill--pb {
  border-color: rgba(16, 217, 160, 0.25);
  background: rgba(8, 30, 22, 0.7);
}

.tst-result-pill[hidden] {
  display: none;
}

.tst-result-pill__label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(180, 155, 100, 0.5);
}

.tst-result-pill__value {
  font-size: 0.92rem;
  font-weight: 700;
  color: #e8d8b0;
  font-variant-numeric: tabular-nums;
}

.tst-result-pill--pb .tst-result-pill__value {
  color: #10d9a0;
}

/* ── Rhythm visualizer ───────────────────────────────────────────────── */
.tst-rhythm-wrap {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tst-rhythm-label {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(180, 155, 100, 0.45);
  font-family: inherit;
}

.tst-rhythm-canvas {
  display: block;
  width: 100%;
  height: 60px;
  border-radius: 4px;
  background: #060709;
  border: 1px solid rgba(245, 158, 11, 0.08);
}

/* ── Estimation note ─────────────────────────────────────────────────── */
.tst-est-note {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(245, 158, 11, 0.6);
  font-family: inherit;
  text-align: center;
}

.tst-est-note[hidden] {
  display: none;
}

/* ── PB broken ───────────────────────────────────────────────────────── */
.tst-pb-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.45rem 1.2rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 217, 160, 0.35);
  background: rgba(8, 30, 22, 0.85);
  animation: tst-pb-pop 400ms cubic-bezier(0.22, 1, 0.36, 1);
}

.tst-pb-broken[hidden] {
  display: none;
}

.tst-pb-broken__text {
  font-size: 0.88rem;
  font-weight: 700;
  color: #10d9a0;
  letter-spacing: 0.04em;
  font-family: inherit;
}

@keyframes tst-pb-pop {
  0%   { transform: scale(0.7); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Share card ──────────────────────────────────────────────────────── */
.tst-share-wrap {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.tst-share-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.6rem;
  border: 1px solid rgba(245, 158, 11, 0.12);
}

.tst-share-canvas[hidden] {
  display: none;
}

.tst-share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

/* Override button styles for amber theme */
.tst-page .button-primary {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #f59e0b;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: none;
}

.tst-page .button-primary:hover,
.tst-page .button-primary:focus-visible {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.65);
  color: #fbbf24;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
  transform: none;
}

.tst-page .button-secondary {
  border: 1px solid rgba(245, 158, 11, 0.18);
  background: transparent;
  color: rgba(245, 158, 11, 0.55);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.tst-page .button-secondary:hover,
.tst-page .button-secondary:focus-visible {
  border-color: rgba(245, 158, 11, 0.38);
  color: rgba(245, 158, 11, 0.85);
}

.tst-share-copy-btn[hidden] {
  display: none;
}

/* ── Results actions ─────────────────────────────────────────────────── */
.tst-results__actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Notes / FAQ below tool ──────────────────────────────────────────── */
.tst-notes {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tst-faq {
  border-radius: 0.6rem;
  border: 1px solid rgba(245, 158, 11, 0.1);
  background: rgba(10, 11, 13, 0.95);
  overflow: hidden;
}

.tst-faq__summary {
  display: flex;
  align-items: center;
  padding: 0.7rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(200, 175, 120, 0.65);
  letter-spacing: 0.04em;
  cursor: pointer;
  list-style: none;
  font-family: inherit;
  gap: 0.45rem;
  user-select: none;
  -webkit-user-select: none;
}

.tst-faq__summary::-webkit-details-marker {
  display: none;
}

.tst-faq__summary::before {
  content: "▶";
  font-size: 0.58em;
  transition: transform 150ms ease;
  color: rgba(245, 158, 11, 0.45);
}

.tst-faq[open] .tst-faq__summary::before {
  transform: rotate(90deg);
}

.tst-faq__body {
  padding: 0.1rem 1rem 0.8rem;
}

.tst-faq__list {
  margin: 0;
  padding: 0 0 0 1.1em;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: rgba(180, 158, 110, 0.6);
  font-family: inherit;
  line-height: 1.6;
}

.tst-faq__list li {
  color: rgba(180, 158, 110, 0.6);
}

.tst-faq__list kbd {
  display: inline-block;
  padding: 0.05em 0.32em;
  border-radius: 3px;
  border: 1px solid rgba(245, 158, 11, 0.22);
  background: rgba(20, 16, 8, 0.85);
  color: rgba(245, 158, 11, 0.7);
  font-family: inherit;
  font-size: 0.85em;
  line-height: 1.4;
  vertical-align: middle;
}

.tst-faq__dl {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0;
}

.tst-faq__item dt {
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(220, 195, 140, 0.75);
  margin-bottom: 0.12rem;
  font-family: inherit;
}

.tst-faq__item dd {
  margin: 0;
  font-size: 0.79rem;
  color: rgba(180, 158, 110, 0.58);
  font-family: inherit;
  line-height: 1.6;
}

/* ── Discovery section overrides ─────────────────────────────────────── */
.tst-page .tool-discovery {
  margin-top: 1.5rem;
}

.tst-page .card {
  background: rgba(10, 11, 13, 0.95);
  border-color: rgba(245, 158, 11, 0.1);
  font-family: inherit;
}

.tst-page .card:hover,
.tst-page .card:focus-within {
  border-color: rgba(245, 158, 11, 0.2);
}

.tst-page .card-title {
  color: rgba(220, 195, 140, 0.85);
  font-family: inherit;
}

.tst-page .card-text,
.tst-page .tool-discovery__faq dd,
.tst-page .tool-discovery__list li {
  color: rgba(180, 158, 110, 0.6);
  font-family: inherit;
}

.tst-page .tool-discovery__title {
  color: #e8d8b0;
  font-family: inherit;
}

.tst-page .card-eyebrow {
  color: rgba(245, 158, 11, 0.55);
  font-family: inherit;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .tst-engine {
    padding: 0.85rem;
    border-radius: 0.6rem;
    gap: 0.55rem;
  }

  .tst-stats-bar {
    gap: 1.25rem;
  }

  .tst-stat:first-child .tst-stat__value {
    font-size: 1.8rem;
  }

  .tst-stat__value {
    font-size: 1.2rem;
  }

  .tst-display {
    min-height: 10rem;
    max-height: 15rem;
    padding: 0.85rem 1rem;
    gap: 0.4rem 0.55rem;
  }

  .tst-char {
    font-size: 1.15rem;
  }

  .tst-topbar {
    gap: 0.3rem 0.75rem;
  }

  .tst-results__wpm-hero {
    font-size: clamp(3.5rem, 15vw, 5.5rem);
  }

  .tst-results {
    padding: 1rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tst-cursor,
  .tst-cursor--warm,
  .tst-cursor--hot {
    animation: none;
    opacity: 1;
  }

  .tst-pb-broken {
    animation: none;
  }

  .tst-progress-fill {
    transition: width 1s linear;
  }

  .tst-stat--urgent .tst-stat__value--timer,
  .tst-progress-fill--urgent {
    animation: none;
  }
}
