/* Type : test de frappe. Le reste (barre des menus, fond, boutons) vient de /assets/dado.css. */
:root {
  --t-text: var(--paper);
  --t-sub: rgba(243, 239, 230, .3);
  --t-main: var(--amber);
  --t-error: var(--bad);
  --t-error-extra: #a8574c;
  --t-grid: rgba(243, 239, 230, .07);
  --t-mono: var(--f-mono);
}

.type-page { display: flex; flex-direction: column; min-height: calc(100vh - 60px); }
.type-head { margin-bottom: 28px; transition: opacity .25s ease; }

/* ---------- réglages ---------- */
.config {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 44px;
  font: 500 12.5px/1 var(--f-mono);
  transition: opacity .25s ease;
}
.group {
  display: flex;
  align-items: center;
  padding: 3px 5px;
  background: var(--glass);
  border: 1px solid var(--edge);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.group button {
  padding: 8px 9px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--dim);
  font: inherit;
  cursor: pointer;
  transition: color .125s ease, background .125s ease;
}
.group button:hover { color: var(--paper); }
.group button.on { color: var(--amber); }
.group .ic { margin-right: 6px; }

body.typing .config,
body.typing .type-head,
body.typing .menubar,
body.typing .hints { opacity: 0; pointer-events: none; }
.menubar { transition: opacity .25s ease; }

/* ---------- zone de frappe ---------- */
.test { position: relative; }

.live {
  height: 2.4rem;
  display: flex;
  gap: 18px;
  align-items: baseline;
  padding: 0 .3em;
  font: 500 2rem/1 var(--t-mono);
  color: var(--t-main);
}
#liveWpm { font-size: 1rem; color: var(--dim); }

.caps {
  position: absolute;
  top: -36px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--amber);
  color: #1d1203;
  font: 600 12px/1 var(--f-mono);
}

.words-wrap {
  position: relative;
  font: 400 2rem var(--t-mono);
  height: 5.4em; /* 3 lignes */
  overflow: hidden;
  cursor: text;
}
.input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  resize: none;
  font-size: 16px; /* pas de zoom sur iOS */
  pointer-events: none;
}
.words {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  user-select: none;
  transition: filter .25s ease, opacity .25s ease;
}
.word {
  position: relative;
  margin: .25em .3em;
  line-height: 1.25em;
  border-bottom: .05em solid transparent;
  color: var(--t-sub);
}
.word.error { border-bottom-color: var(--t-error); }
letter { display: inline-block; transition: color .06s linear; }
letter.correct { color: var(--t-text); }
letter.incorrect { color: var(--t-error); }
letter.extra { color: var(--t-error-extra); }

.caret {
  position: absolute;
  top: 0;
  left: 0;
  width: .09em;
  height: 1.2em;
  margin-top: .03em;
  border-radius: 4px;
  background: var(--t-main);
  box-shadow: 0 0 14px var(--amber);
  transition: transform .09s ease-out;
  z-index: 2;
}
.caret.idle { animation: blink 1s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.focus-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font: 500 15px var(--f-mono);
  color: var(--paper);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
body.blurred .words { filter: blur(4px); opacity: .3; }
body.blurred .caret { opacity: 0; animation: none; }
body.blurred .focus-hint { opacity: 1; }

.icon-btn {
  display: block;
  margin: 32px auto 0;
  padding: 10px 18px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--dim);
  font: 1.2rem var(--f-mono);
  cursor: pointer;
  transition: color .125s ease, background .125s ease;
}
.icon-btn:hover { color: var(--paper); background: var(--glass); }

/* ---------- résultat ---------- */
.result { animation: rise .3s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.rl { display: block; font: 500 13px/1.3 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.res-top { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: stretch; }
.big { display: flex; flex-direction: column; gap: 14px; }
.big b { display: block; font: 800 4.4rem/1 var(--f-display); font-stretch: 80%; letter-spacing: -.03em; color: var(--amber); }

.chart {
  position: relative;
  height: 230px;
  min-width: 0;
  padding: 10px;
  background: var(--glass);
  border: 1px solid var(--edge);
  border-radius: 18px;
}
.chart canvas { width: 100%; height: 100%; display: block; }
.tip {
  position: absolute;
  top: -12px;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--glass-hi);
  border: 1px solid var(--edge);
  font: 500 12px var(--f-mono);
  white-space: nowrap;
  pointer-events: none;
}

.res-stats {
  display: grid;
  grid-template-columns: repeat(5, auto);
  justify-content: space-between;
  gap: 20px;
  margin-top: 28px;
}
.res-stats b { display: block; margin-top: 4px; font: 500 1.9rem/1.1 var(--f-mono); color: var(--paper); }
.res-stats b.small { font-size: 1rem; line-height: 1.6; color: var(--amber); }
.rnote { display: block; color: var(--dim); font: 12px var(--f-mono); margin-top: 4px; }
.rnote.pb { color: var(--ok); }

.res-actions { display: flex; justify-content: center; gap: 10px; margin-top: 30px; }

.history { margin-top: 36px; }
.history table { width: 100%; margin-top: 10px; border-collapse: collapse; font: 13px var(--f-mono); }
.history th { text-align: left; color: var(--dim); font-weight: 500; padding: 7px 8px; border-bottom: 1px solid var(--edge); }
.history td { padding: 7px 8px; border-bottom: 1px solid var(--edge); }
.history td:nth-child(3) { color: var(--amber); }

/* ---------- raccourcis ---------- */
.hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
  margin-top: auto;
  padding-top: 40px;
  color: var(--dim);
  font: 12px var(--f-mono);
  transition: opacity .25s ease;
}
kbd {
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(243, 239, 230, .14);
  color: var(--paper);
  font: 11px var(--f-mono);
}

/* ---------- téléphone ---------- */
@media (max-width: 640px) {
  .config { gap: 6px; margin-bottom: 28px; font-size: 11.5px; }
  .group button { padding: 7px 6px; }
  .words-wrap, .live { font-size: 1.45rem; }
  .res-top { grid-template-columns: 1fr; }
  .big { flex-direction: row; gap: 32px; }
  .big b { font-size: 3.2rem; }
  .res-stats { grid-template-columns: repeat(2, 1fr); }
  .res-stats b { font-size: 1.5rem; }
  .history td:nth-child(2), .history th:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .caret, .words, .result { transition: none; animation: none; }
}
