/* ============================================================
   La Dictée — thème "encre de nuit"
   Palette : nuit d'encre, papier crème, violet encre d'école
   Signature : la copie est une page de cahier ligné, en sombre
   ============================================================ */

:root {
  --night:   #0d0e14;
  --panel:   #15171f;
  --panel-2: #1b1e29;
  --line:    #272b3a;
  --paper:   #ece8db;
  --muted:   #8c90a4;
  --ink:     #8b7cff;   /* encre violette */
  --ink-dim: #5a4fb0;
  --ok:      #4ade80;
  --warn:    #f5b041;
  --bad:     #f87171;
  --radius:  14px;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  background:
    radial-gradient(1100px 600px at 80% -10%, rgba(139, 124, 255, .08), transparent 60%),
    var(--night);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}

main { max-width: 880px; margin: 0 auto; padding: 28px 20px 64px; }

h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: .01em; }
h2 { font-size: 1.35rem; margin-bottom: 14px; color: var(--paper); }

.eyebrow {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .22em;
  color: var(--ink); font-weight: 600; margin-bottom: 10px;
}
.hint  { font-size: .85rem; color: var(--muted); }
.count { font-size: .85rem; color: var(--muted); font-family: var(--font-body); font-weight: 400; }

/* ---------- Accueil ---------- */
.hero { text-align: center; margin: 8vh 0 36px; }
.hero h1 {
  font-size: clamp(3.2rem, 9vw, 5.2rem);
  line-height: 1;
}
.hero h1 em { font-style: italic; color: var(--ink); }
.tagline { color: var(--muted); margin-top: 12px; font-size: 1.05rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 18px;
}

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 22px; }
.pane {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.pane h2 { margin-bottom: 0; }
.pane .btn { margin-top: auto; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: .82rem; color: var(--muted); font-weight: 500; }

input[type="text"] {
  background: var(--night);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--paper);
  font: 500 1rem var(--font-body);
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s;
}
input[type="text"]:focus-visible { border-color: var(--ink); }
.code-input {
  font-family: var(--font-mono); font-size: 1.15rem; letter-spacing: .35em;
  text-transform: uppercase; text-align: center;
}

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--paper);
  cursor: pointer;
  font: 600 .95rem var(--font-body);
  padding: 12px 18px;
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:hover:not(:disabled)  { border-color: var(--ink); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #0c0a1d; }
.btn.primary:hover:not(:disabled) { background: #a094ff; }
.btn.danger  { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn.big     { font-size: 1.05rem; padding: 15px 22px; width: 100%; }

.error {
  background: rgba(248, 113, 113, .1);
  border: 1px solid rgba(248, 113, 113, .4);
  border-radius: 10px;
  color: var(--bad);
  font-size: .9rem;
  margin-bottom: 16px;
  padding: 10px 14px;
}
.ok-text { color: var(--ok); }

.foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 28px; }

/* ---------- Barre du lobby ---------- */
.bar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 22px;
}
.back { color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--paper); }
.code-chip {
  background: var(--panel); border: 1px dashed var(--ink-dim); border-radius: 10px;
  color: var(--paper); cursor: pointer; display: flex; gap: 10px; align-items: baseline;
  padding: 8px 14px; margin: 0 auto;
}
.code-chip .code-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); }
.code-chip .code-value { font-family: var(--font-mono); font-size: 1.2rem; font-weight: 700; letter-spacing: .25em; color: var(--ink); }
.me-chip { font-size: .85rem; color: var(--muted); }

.view-title { font-size: 2rem; margin-bottom: 18px; }

/* ---------- Joueurs ---------- */
.players { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.player {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px;
}
.player.done    { border-color: rgba(74, 222, 128, .45); }
.player.offline { opacity: .45; }
.p-name { font-weight: 500; }
.p-tag  { font-size: .8rem; color: var(--muted); }
.player.done .p-tag { color: var(--ok); }

/* ---------- Hôte ---------- */
.host-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.upload {
  display: block; margin-top: 10px;
  border: 1px dashed var(--ink-dim); border-radius: 10px;
  padding: 16px; text-align: center; cursor: pointer;
  color: var(--ink); font-weight: 500; font-size: .92rem;
  transition: border-color .15s, background .15s;
}
.upload:hover { border-color: var(--ink); background: rgba(139, 124, 255, .06); }
.upload input[type="file"] { display: none; }
.launch { display: flex; flex-direction: column; gap: 10px; }

.waiting-msg { color: var(--muted); text-align: center; padding: 8px 0; }
.dots::after { content: ''; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- Décompte ---------- */
.countdown-view { text-align: center; padding-top: 16vh; }
.countdown-number {
  font-family: var(--font-display);
  font-size: clamp(7rem, 24vw, 13rem);
  color: var(--ink);
  line-height: 1;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.06); opacity: .85; } }

/* ---------- Dictée : la page de cahier (signature) ---------- */
.play-head { display: flex; justify-content: space-between; align-items: baseline; }
.timer { font-family: var(--font-mono); font-size: 1.3rem; color: var(--ink); }

.audio-zone { padding: 14px 18px; }
.audio-zone audio { width: 100%; height: 40px; }

.copy-card { padding-bottom: 16px; }
.copy-label { display: block; font-weight: 600; margin-bottom: 10px; }

.copy {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 31px,
      rgba(139, 124, 255, .18) 31px,
      rgba(139, 124, 255, .18) 32px
    ),
    var(--night);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-dim); /* marge du cahier */
  border-radius: 8px;
  color: var(--paper);
  font: 500 1.05rem/2 var(--font-body);
  padding: 6px 18px;
  outline: none;
  caret-color: var(--ink);
}
.copy:focus-visible { border-color: var(--ink); border-left-color: var(--ink); }
.copy:disabled { opacity: .6; }

.copy-foot { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.save-state { color: var(--bad); font-size: .8rem; transition: color .3s; }
.save-state.saved { color: var(--ok); }
.copy-foot .btn { margin-left: auto; }
.copy-foot .danger { margin-left: 0; }

/* ---------- Résultats ---------- */
.scoreboard { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.score-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px;
}
.score-row.is-me { border-color: var(--ink); }
.rank { width: 2.2em; font-size: 1.1rem; }
.score { margin-left: auto; font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem; color: var(--ink); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; font-size: .8rem; color: var(--muted); }
.lg { padding-left: 16px; position: relative; }
.lg::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
              width: 10px; height: 10px; border-radius: 3px; }
.lg.ok::before     { background: var(--ok); }
.lg.approx::before { background: var(--warn); }
.lg.miss::before   { background: var(--bad); }
.lg.extra::before  { background: var(--muted); }

.diff-text, .original-text { font-size: 1.05rem; line-height: 2; }
.original-text { color: var(--muted); font-style: italic; font-family: var(--font-display); font-size: 1.15rem; }

.w        { border-radius: 4px; padding: 1px 3px; }
.w.ok     { color: var(--ok); }
.w.approx { color: var(--warn); background: rgba(245, 176, 65, .12); }
.w.miss   { color: var(--bad); background: rgba(248, 113, 113, .12); text-decoration: underline dotted; }
.w.extra  { color: var(--muted); text-decoration: line-through; }

.finish-actions { text-align: center; margin-top: 8px; }

/* ---------- Responsive & accessibilité ---------- */
@media (max-width: 640px) {
  .split, .host-grid { grid-template-columns: 1fr; }
  .hero { margin-top: 5vh; }
  .bar { flex-wrap: wrap; }
  .code-chip { order: 3; width: 100%; justify-content: center; }
  .copy-foot { flex-wrap: wrap; }
  .copy-foot .btn { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .countdown-number, .dots::after { animation: none; }
  * { transition: none !important; }
}
