/* 
  Monkeytype-like dark theme (approx. "serika dark"/default feel). 
  Goal: indiscernable first-glance: spacing, typography, subtle transitions, minimal chrome.
*/
:root {
  --bg: #1b1d22;
  --panel: #17181c;
  --text: #e3e6ee;
  --muted: #8b909f;
  --muted2: #6f7483;
  --accent: #e2b714; /* Monkeytype yellow-ish */
  --good: #d4d7e0;
  --bad: #ff5a5f;
  --bad2: #b34345;
  --caret: #e2b714;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --sans:
    "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    sans-serif;
  --smooth: cubic-bezier(0.2, 0.7, 0.2, 1);
  /* Monkeytype-ish yellow; remplace par TON jaune si tu as déjà une variable */
  --accent: #e2b714;
}
#testWrap {
  overflow: hidden;
  position: relative;
}

/* Bloc qui va être translaté verticalement */
#text {
  will-change: transform;
  transition: transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Chaque caractère */
.char {
  border-radius: 4px; /* plus doux */
}

/* Le caractère "courant" : repère visuel */
.char.active {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
}

/* Optionnel : rendre le repère plus “Monkeytype” (petit underline) */
.char.active {
  position: relative;
}
.char.active::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: -2px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.55;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  letter-spacing: -0.01em;
  overflow-x: hidden;
  overflow-y: auto; /* ✅ scroll réactivé */
}
.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  opacity: 0.92;
}
.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(226, 183, 20, 0.06);
}
.brand-name {
  font-weight: 600;
  letter-spacing: -0.02em;
  text-transform: lowercase;
  color: var(--text);
}

.controls {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.label {
  font-size: 12px;
  color: var(--muted2);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.select {
  position: relative;
}
select {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 34px 10px 12px;
  font-size: 14px;
  outline: none;
  transition:
    border-color 0.18s var(--smooth),
    background 0.18s var(--smooth);
}
select:hover {
  border-color: rgba(226, 183, 20, 0.18);
}
select:focus {
  border-color: rgba(226, 183, 20, 0.35);
  background: rgba(0, 0, 0, 0.18);
}
.chev {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 12px;
}

.seg {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  overflow: hidden;
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  transition:
    color 0.18s var(--smooth),
    background 0.18s var(--smooth);
}
.seg-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.seg-btn.is-active {
  color: var(--accent);
  background: rgba(226, 183, 20, 0.08);
}

.toggles {
  flex-direction: row;
  align-items: flex-end;
  gap: 14px;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle input {
  display: none;
}
.toggle-ui {
  width: 34px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.12);
  position: relative;
  transition:
    background 0.18s var(--smooth),
    border-color 0.18s var(--smooth);
}
.toggle-ui::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.65);
  transition:
    transform 0.18s var(--smooth),
    background 0.18s var(--smooth);
}
.toggle input:checked + .toggle-ui {
  border-color: rgba(226, 183, 20, 0.25);
  background: rgba(226, 183, 20, 0.1);
}
.toggle input:checked + .toggle-ui::after {
  transform: translate(16px, -50%);
  background: var(--accent);
}
.toggle-text {
  font-size: 13px;
  color: var(--muted);
}
.toggle:hover .toggle-text {
  color: var(--text);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 18px 0;
  gap: 18px;
}

.stats {
  width: min(1040px, 92vw);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 70px;
}
.stat-k {
  font-size: 12px;
  color: var(--muted2);
  text-transform: lowercase;
}
.stat-v {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}
.stat-time .stat-v {
  color: var(--accent);
}

.test {
  width: min(1040px, 92vw);
  position: relative;
}

.test-wrap {
  position: relative;
  border-radius: var(--radius);
  padding: 18px 18px 42px;
  outline: none;
}
.test-wrap:focus .hint {
  opacity: 0;
  transform: translateY(4px);
}
.test-wrap:hover .hint {
  opacity: 0;
  transform: translateY(4px);
}

.section-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 10px;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 0.22s var(--smooth),
    transform 0.22s var(--smooth);
}
.section-banner.show {
  opacity: 0.95;
  transform: translateY(0);
}
.section-pill {
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 0.08em;
  color: rgba(0, 0, 0, 0.9);
  background: var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
}
.section-meta {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.text {
  position: relative;
  font-family: var(--sans);
  font-size: 28px;
  line-height: 1.65;
  letter-spacing: -0.015em;
  color: rgba(227, 230, 238, 0.26); /* pending */
  user-select: none;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 220px;
  transition:
    opacity 0.18s var(--smooth),
    transform 0.18s var(--smooth);
}
.text.is-switching {
  opacity: 0;
  transform: translateY(6px);
}

.char {
  position: relative;
}
.char.correct {
  color: rgba(227, 230, 238, 0.92);
}
.char.incorrect {
  color: var(--bad);
}
.char.extra {
  color: var(--bad2);
  text-decoration: underline;
  text-decoration-color: rgba(255, 90, 95, 0.35);
  text-underline-offset: 6px;
}

.caret {
  position: absolute;
  width: 2px;
  height: 32px;
  background: var(--caret);
  border-radius: 2px;
  transform: translate(0, 0);
  transition:
    transform 70ms linear,
    opacity 0.18s var(--smooth);
  box-shadow: 0 0 0 5px rgba(226, 183, 20, 0.06);
  opacity: 0;
}
.caret.on {
  opacity: 1;
}

.ghost {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  resize: none;
}

.hint {
  position: absolute;
  left: 18px;
  bottom: 16px;
  display: flex;
  gap: 14px;
  color: var(--muted);
  opacity: 0.75;
  transition:
    opacity 0.22s var(--smooth),
    transform 0.22s var(--smooth);
  font-size: 13px;
}
kbd {
  font-family: var(--mono);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(0, 0, 0, 0.16);
  color: var(--text);
}

.footer {
  height: auto;
  display: flex;
  flex-direction: column; /* ✅ empile verticalement */
  align-items: center;
  justify-content: center;
  gap: 6px; /* espace entre les lignes (ajuste) */
  padding: 10px 18px;
  text-align: center;
  color: var(--muted2);
  font-size: 12px;
  opacity: 0.9;
}

.muted {
  color: var(--muted2);
}

.footer .muted {
  display: block; /* chaque span sur sa ligne */
}

.result {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition:
    opacity 0.22s var(--smooth),
    transform 0.22s var(--smooth);
}
.result.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
}
.result-card {
  width: min(520px, 92%);
  background: rgba(23, 24, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.result-title {
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  color: var(--text);
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.r {
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.14);
}
.rk {
  font-size: 12px;
  color: var(--muted2);
  margin-bottom: 6px;
}
.rv {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.btn {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(226, 183, 20, 0.1);
  color: var(--accent);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  transition:
    transform 0.12s var(--smooth),
    background 0.18s var(--smooth),
    border-color 0.18s var(--smooth);
}
.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(226, 183, 20, 0.25);
  background: rgba(226, 183, 20, 0.14);
}
.btn:active {
  transform: translateY(0);
}
.btn-ghost {
  background: rgba(0, 0, 0, 0.16);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

/* Responsive tweaks */
@media (max-width: 860px) {
  body {
    overflow: auto;
  }
  .topbar {
    height: auto;
    padding: 18px;
    align-items: flex-start;
    gap: 14px;
    flex-direction: column;
  }
  .controls {
    width: 100%;
    justify-content: space-between;
  }
  .stats {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .text {
    font-size: 24px;
    min-height: 190px;
  }
  .caret {
    height: 28px;
  }
}

/* Bouton quiz dans la topbar */
.btn-quiz {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  white-space: nowrap;
}

/* Sur mobile : le bouton prend toute la largeur si tu veux */
@media (max-width: 860px) {
  .btn-quiz {
    width: 100%;
  }
}
