/* ══════════════════════════════════════════════════════════════════
   1000 — feuille de style de l'application.
   Hérite du langage visuel de wouam.fr (terminal sombre, Fira Code,
   #0d1117 / #161b22 / #30363d, accents purple & green).

   Elle est volontairement autonome : si le CDN Tailwind n'est pas
   disponible (premier lancement hors ligne), la page reste lisible.
   ══════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #0d1117;
  --bg-2:      #161b22;
  --bg-3:      #010409;
  --line:      #30363d;
  --txt:       #c9d1d9;
  --txt-dim:   #8b949e;
  --txt-hi:    #ffffff;
  --accent:    #a78bfa;   /* purple 400 */
  --ok:        #34d399;   /* emerald 400 */
  --ok-deep:   #059669;
  --warn:      #fbbf24;
  --radius:    8px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background-color: var(--bg);
  color: var(--txt);
  line-height: 1.5;
}

/* Filets de sécurité si Tailwind n'a pas pu être chargé */
.container { width: 100%; margin-inline: auto; max-width: 1280px; }
[hidden] { display: none !important; }

a { color: inherit; }
.lnk { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.lnk:hover { color: var(--txt-hi); }

:focus-visible {
  outline: 2px solid var(--ok);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--bg-2); color: var(--txt-hi);
  padding: .6rem 1rem; border: 1px solid var(--line);
}
.skip-link:focus { left: .5rem; top: .5rem; }

/* ── Onglets ──────────────────────────────────────────────────── */
.tabs { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: .6rem .9rem;
  font-size: .8rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--txt-dim); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--txt-hi); }
.tab[aria-current="page"] { color: var(--ok); border-bottom-color: var(--ok); font-weight: 700; }

/* ── Blocs génériques ─────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }
.h2 { font-size: 1.1rem; font-weight: 700; color: var(--txt-hi); margin: 0 0 .75rem; }
.h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--txt-dim); margin: 0 0 .5rem; }
.muted { color: var(--txt-dim); }
.small { font-size: .8rem; }
.stack > * + * { margin-top: 1rem; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .9rem;
  font-family: inherit; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--txt); background: transparent;
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: #21262d; color: var(--txt-hi); }
.btn-ok { border-color: var(--ok-deep); color: var(--ok); }
.btn-ok:hover { background: rgba(52, 211, 153, .12); }
.btn[aria-pressed="true"] { background: #21262d; color: var(--txt-hi); border-color: #4b5563; }
.btn-ok[aria-pressed="true"] { background: var(--ok-deep); color: #05231a; border-color: var(--ok); }
/* Un lemme n'est pas une étiquette d'interface : pas de capitales forcées. */
.btn-word { text-transform: none; font-size: .95rem; }
.btn-danger { border-color: #7f1d1d; color: #fca5a5; }
.btn-danger:hover { background: rgba(220, 38, 38, .15); }
.btn-icon {
  background: none; border: 0; color: var(--txt-dim);
  font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 .25rem;
}
.btn-icon:hover { color: var(--txt-hi); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.chip {
  display: inline-block; padding: .1rem .45rem;
  font-size: .65rem; text-transform: uppercase; letter-spacing: .05em;
  border: 1px solid var(--line); border-radius: 999px; color: var(--txt-dim);
}
.chip-ok    { border-color: var(--ok-deep); color: var(--ok); }
.chip-learn { border-color: #92400e; color: var(--warn); }
.chip-fn    { border-color: #3730a3; color: #a5b4fc; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-top: 1rem; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: #0b0f14; border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; text-align: center; }
.stat-v { font-size: 1.4rem; font-weight: 700; color: var(--txt-hi); font-variant-numeric: tabular-nums; }
.stat-k { font-size: .65rem; text-transform: uppercase; letter-spacing: .05em; color: var(--txt-dim); }

/* ── Filtres ──────────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.field {
  font-family: inherit; font-size: .8rem;
  background: #0b0f14; color: var(--txt);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .45rem .6rem;
}
.field:hover { border-color: #4b5563; }
#q { flex: 2 1 18rem; min-width: 10rem; }

.sheet-cats { margin-top: 1.5rem; }

/* ── Liste virtualisée ────────────────────────────────────────── */
.vlist {
  position: relative; overflow-y: auto; overscroll-behavior: contain;
  height: min(62vh, 640px);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-2);
  -webkit-overflow-scrolling: touch;
}
.vlist-spacer { position: relative; width: 100%; }
.vrow {
  position: absolute; left: 0; right: 0;
  display: flex; align-items: center; gap: .75rem;
  padding: 0 .75rem;
  border-bottom: 1px solid #21262d;
  contain: layout style;
}
.vrow-main { flex: 1 1 auto; min-width: 0; }
.vrow-lemma { font-size: 1rem; font-weight: 700; color: var(--txt-hi); }
.vrow-ipa { color: var(--txt-dim); font-size: .78rem; margin-left: .4rem; }
.vrow-sub { font-size: .7rem; color: var(--txt-dim); display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-top: .15rem; }
.vrow-actions { display: flex; gap: .35rem; flex: 0 0 auto; }
.vrow.is-known { background: rgba(52, 211, 153, .05); }
.vlist-empty { padding: 2rem; text-align: center; color: var(--txt-dim); }

/* ── Catégories ───────────────────────────────────────────────── */
.cats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.cat {
  text-align: left; width: 100%;
  background: #0b0f14; border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem; cursor: pointer; font-family: inherit; color: inherit;
  transition: border-color .15s, transform .15s;
}
.cat:hover { border-color: var(--ok); }
.cat-name { font-weight: 700; color: var(--txt-hi); font-size: .9rem; }
.cat-bar { height: 5px; border-radius: 999px; background: #21262d; margin-top: .55rem; overflow: hidden; }
.cat-fill { display: block; height: 100%; background: var(--ok-deep); }
.cat-num { font-size: .7rem; color: var(--txt-dim); margin-top: .35rem; }

/* ── Panneau de détail ────────────────────────────────────────── */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 720px) { .sheet { align-items: center; } }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.8); backdrop-filter: blur(2px); }
.sheet-panel {
  position: relative; z-index: 1;
  width: 100%; max-width: 42rem; max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.6);
  animation: sheet-in .18s ease-out;
}
@media (min-width: 720px) { .sheet-panel { border-radius: var(--radius); } }
@keyframes sheet-in { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.sheet-lemma { margin: 0; font-size: 1.5rem; font-weight: 700; color: var(--txt-hi); }
.sheet-meta { margin: .2rem 0 0; font-size: .75rem; color: var(--txt-dim); }
.sheet-body { padding: 1.25rem; overflow-y: auto; }
.sheet-foot { padding: .85rem 1.25rem; border-top: 1px solid var(--line); background: var(--bg-2); display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }

.sense { border-left: 2px solid var(--line); padding-left: .9rem; }
.sense + .sense { margin-top: 1.25rem; }
.sense-fr { color: var(--ok); font-weight: 700; }
.sense-note { font-size: .75rem; color: var(--warn); margin-top: .25rem; }
.ex { margin-top: .6rem; font-size: .85rem; }
.ex-en { color: var(--txt-hi); }
.ex-fr { color: var(--txt-dim); font-size: .8rem; }
.ex-say { background: none; border: 0; color: var(--txt-dim); cursor: pointer; font-size: .9rem; padding: 0 .2rem; }
.ex-say:hover { color: var(--ok); }

/* ── Jeux et révision ─────────────────────────────────────────── */
.badge {
  display: inline-block; margin-left: .35rem; padding: 0 .35rem;
  background: var(--ok-deep); color: #05231a; border-radius: 999px;
  font-size: .65rem; font-weight: 700; vertical-align: text-top;
}
.game-card:disabled { opacity: .45; cursor: not-allowed; }
.game-card:disabled:hover { border-color: var(--line); }

.game-progress { height: 4px; background: #21262d; border-radius: 999px; overflow: hidden; }
.game-progress > span { display: block; height: 100%; background: var(--ok); transition: width .3s; }

.game-sentence { font-size: 1.15rem; color: var(--txt-hi); line-height: 1.9; margin: .5rem 0; }
.blank {
  display: inline-block; min-width: 4.5rem; text-align: center;
  border-bottom: 2px solid var(--ok); color: var(--ok); font-weight: 700;
}

.options { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.option { justify-content: center; text-transform: none; font-size: .95rem; padding: .7rem; }
.option.is-right { border-color: var(--ok); background: rgba(52, 211, 153, .15); color: var(--ok); }
.option.is-wrong { border-color: #7f1d1d; background: rgba(220, 38, 38, .15); color: #fca5a5; }

.timer { height: 6px; background: #21262d; border-radius: 999px; overflow: hidden; }
.timer > span { display: block; height: 100%; width: 100%; background: var(--warn); }

.slot, .pool {
  display: flex; flex-wrap: wrap; gap: .4rem; padding: .6rem;
  border: 1px dashed var(--line); border-radius: var(--radius); min-height: 3.2rem;
}
.slot { background: #0b0f14; }
.slot.drop, .pool.drop { border-color: var(--ok); }
.slot.is-right { border-color: var(--ok); border-style: solid; }
.slot.is-wrong { border-color: #7f1d1d; border-style: solid; }
.tile {
  font-family: inherit; font-size: .9rem; cursor: grab;
  background: #21262d; color: var(--txt-hi);
  border: 1px solid var(--line); border-radius: 6px; padding: .35rem .6rem;
}
.tile:hover { border-color: var(--ok); }
.tile:disabled { cursor: default; opacity: .8; }

.field.is-right { border-color: var(--ok); }
.field.is-wrong { border-color: #7f1d1d; }

.feedback {
  margin-top: 1rem; padding: 1rem;
  border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--radius);
  background: #0b0f14;
}
.feedback.is-ok { border-left-color: var(--ok); }
.feedback.is-ko { border-left-color: #f87171; }
.fb-title { margin: 0 0 .35rem; font-weight: 700; }
.feedback.is-ok .fb-title { color: var(--ok); }
.feedback.is-ko .fb-title { color: #fca5a5; }
.fb-word { margin: 0 0 .5rem; font-size: .9rem; }
.feedback .btn { margin-top: .5rem; }

.review-card { text-align: center; padding: 1.5rem 0; }
.review-lemma { font-size: 2rem; font-weight: 700; color: var(--txt-hi); margin: 0; }
.review-example { color: var(--txt); margin-top: 1rem; font-size: 1rem; }
.review-card .sense { text-align: left; max-width: 34rem; margin: 1.25rem auto 0; }

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  z-index: 80; max-width: min(90vw, 32rem);
  background: var(--bg-2); color: var(--txt-hi);
  border: 1px solid var(--line); border-left: 3px solid var(--ok);
  border-radius: var(--radius); padding: .7rem 1rem; font-size: .82rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}

/* ── Écran de chargement ──────────────────────────────────────── */
.boot { text-align: center; padding: 4rem 1rem; color: var(--txt-dim); }
.boot-line { color: var(--ok); }
.boot-sub { font-size: .75rem; margin-top: .35rem; }

/* ── Divers ───────────────────────────────────────────────────── */
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .85rem; }
.kv dt { color: var(--txt-dim); }
.kv dd { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
