/* ============================================================
   TCF CE Trainer — sharp mono
   Chrome is monospace (the app talking). Content is sans (the French).
   ============================================================ */

:root {
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;

  --bg: #faf9f6;
  --bg-2: #f1f0ea;
  --surface: #ffffff;
  --line: #e1e0d8;
  --line-2: #c9c8be;
  --fg: #16161a;
  --fg-dim: #6c6c75;
  --accent: #9a6000;
  --accent-bg: #ffb020;
  --accent-ink: #1a1204;
  --ok: #10794a;
  --ok-bg: #e2f6ec;
  --no: #b3271d;
  --no-bg: #fdeae8;

  --r: 4px;
  --gut: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d;
    --bg-2: #131318;
    --surface: #16161c;
    --line: #26262f;
    --line-2: #3a3a47;
    --fg: #eceef1;
    --fg-dim: #8b8b97;
    --accent: #ffb020;
    --accent-bg: #ffb020;
    --accent-ink: #180f00;
    --ok: #43d68a;
    --ok-bg: #0f2a1d;
    --no: #ff6b60;
    --no-bg: #2c1310;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── boot ───────────────────────────────────────────────── */
.boot {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--mono); font-size: 13px; color: var(--fg-dim);
}
.boot-dot { width: 8px; height: 8px; background: var(--accent-bg); animation: pulse 1s steps(2, end) infinite; }
@keyframes pulse { 0%,49% { opacity: 1 } 50%,100% { opacity: .15 } }

/* ── shell ──────────────────────────────────────────────── */
.screen { min-height: 100dvh; display: flex; flex-direction: column; animation: fade .18s ease both; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.wrap {
  width: 100%; max-width: 620px; margin: 0 auto;
  padding: 0 var(--gut) calc(40px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 26px; flex: 1;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) var(--gut) 14px;
  max-width: 620px; margin: 0 auto; width: 100%;
}

.brand { font-family: var(--mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
.brand-dot { color: var(--accent); }

.icon-btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em;
  background: none; border: 1px solid var(--line); color: var(--fg-dim);
  padding: 6px 10px; border-radius: var(--r); cursor: pointer;
}
.icon-btn:hover { color: var(--fg); border-color: var(--line-2); }

/* ── hero ───────────────────────────────────────────────── */
.hero { padding-top: 14px; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 12px;
}
.hero-title { font-size: clamp(34px, 11vw, 46px); line-height: 1.02; letter-spacing: -.03em; margin: 0 0 14px; font-weight: 600; }
.hero-sub { margin: 0; color: var(--fg-dim); font-size: 14px; }

.bigscore { display: flex; align-items: baseline; gap: 2px; margin: 4px 0 10px; }
.bigscore .num:first-child { font-size: clamp(58px, 20vw, 84px); line-height: 1; letter-spacing: -.04em; }
.bigscore-of { font-family: var(--mono); font-size: 24px; color: var(--fg-dim); }

/* ── fields / labels ────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 10px; }
.micro {
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--fg-dim);
}
.hint { margin: 0; font-size: 13px; color: var(--fg-dim); line-height: 1.45; }

/* ── segmented control ──────────────────────────────────── */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented.sm { grid-template-columns: repeat(2, 1fr); }
.seg {
  font-family: var(--mono); font-size: 13px; cursor: pointer;
  background: var(--bg-2); color: var(--fg-dim);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 11px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: background .12s, color .12s, border-color .12s;
}
.seg small { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; opacity: .65; }
.seg:hover { color: var(--fg); }
.seg[aria-checked="true"] {
  background: var(--accent-bg); color: var(--accent-ink); border-color: var(--accent-bg); font-weight: 600;
}
.seg[aria-checked="true"] small { opacity: .8; }

/* ── buttons ────────────────────────────────────────────── */
.btn {
  font-family: var(--mono); font-size: 14px; cursor: pointer;
  border-radius: var(--r); border: 1px solid var(--line);
  padding: 15px 18px; background: var(--bg-2); color: var(--fg);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; transition: transform .1s, background .12s, border-color .12s;
}
.btn:active { transform: scale(.985); }
.btn-lg { padding: 19px 20px; font-size: 15px; }
.btn-primary {
  background: var(--accent-bg); color: var(--accent-ink); border-color: var(--accent-bg);
  font-weight: 600; justify-content: center;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-arrow { transition: transform .15s; }
.btn-primary:hover .btn-arrow { transform: translateX(3px); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { border-color: var(--line-2); background: var(--bg-2); }
.btn-danger { color: var(--no); }
.btn[disabled] { opacity: .4; pointer-events: none; }

.stack { display: flex; flex-direction: column; gap: 8px; }

.tag {
  font-family: var(--mono); font-size: 11px; color: var(--fg-dim);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px;
}

/* ── stat strip / grid ──────────────────────────────────── */
.statstrip { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.statstrip > div { padding: 14px 10px; text-align: center; border-right: 1px solid var(--line); }
.statstrip > div:last-child { border-right: 0; }
.statstrip .v { font-family: var(--mono); font-size: 20px; display: block; letter-spacing: -.02em; }
.statstrip .k { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-dim); }

.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.statcard { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; background: var(--bg-2); }
.statcard .v { font-family: var(--mono); font-size: 28px; letter-spacing: -.03em; display: block; }
.statcard .k { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-dim); }

/* ── quiz ───────────────────────────────────────────────── */
.progressbar { height: 2px; background: var(--line); max-width: 620px; width: calc(100% - 2 * var(--gut)); margin: 0 auto 18px; }
#progressfill { height: 100%; width: 0; background: var(--accent-bg); transition: width .28s ease; }
.progress-meta { font-family: var(--mono); font-size: 13px; }
.progress-meta .sep { color: var(--fg-dim); margin: 0 2px; }
.score-meta { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-dim); }
.quiz-wrap { gap: 16px; }

.qmeta { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  border: 1px solid var(--line); color: var(--fg-dim); padding: 4px 9px; border-radius: 999px;
}
.chip-dim { opacity: .7; }
.chip-accent { border-color: var(--accent-bg); color: var(--accent); }

/* ── audio player ───────────────────────────────────────── */
.player {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px;
}
.pl-toggle {
  width: 52px; height: 52px; flex-shrink: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--accent-bg); color: var(--accent-ink); border: 1px solid var(--accent-bg); border-radius: var(--r);
}
.pl-toggle:active { transform: scale(.96); }
.pl-toggle svg { width: 20px; height: 20px; fill: currentColor; }
.player .i-pause,
.player[data-state="playing"] .i-play { display: none; }
.player[data-state="playing"] .i-pause { display: block; }
.pl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pl-body input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent-bg); cursor: pointer; }
.pl-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--fg-dim); }
.pl-error { margin: 0; color: var(--no); font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.qprompt { margin: 0; font-size: 14px; color: var(--fg-dim); line-height: 1.45; }

/* the passage always reads as a light document, in both themes */
.doccard {
  margin: 0; background: #fff; border: 1px solid var(--line);
  border-radius: var(--r); padding: 8px; cursor: zoom-in; position: relative; overflow: hidden;
}
.doccard img { display: block; width: 100%; height: auto; border-radius: 2px; }
.doccard-hint {
  position: absolute; right: 12px; bottom: 12px;
  font-family: var(--mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
  background: rgba(12,12,14,.76); color: #fff; padding: 4px 8px; border-radius: 999px; pointer-events: none;
}
.qtext {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; font-size: 17px; line-height: 1.6;
}

.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 15px; cursor: pointer; color: var(--fg);
  font-family: var(--sans); font-size: 16px; line-height: 1.4;
  transition: border-color .12s, background .12s, transform .1s;
}
.choice:hover:not(:disabled) { border-color: var(--line-2); }
.choice:active:not(:disabled) { transform: scale(.99); }
.choice .letter {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  border: 1px solid var(--line-2); border-radius: 3px;
  min-width: 24px; height: 24px; display: grid; place-items: center; flex-shrink: 0; margin-top: 1px;
  color: var(--fg-dim);
}
.choice[data-state="picked"] { border-color: var(--accent-bg); background: var(--bg-2); }
.choice[data-state="picked"] .letter { border-color: var(--accent-bg); color: var(--accent); }
.choice[data-state="correct"] { border-color: var(--ok); background: var(--ok-bg); }
.choice[data-state="correct"] .letter { border-color: var(--ok); color: var(--ok); }
.choice[data-state="wrong"] { border-color: var(--no); background: var(--no-bg); }
.choice[data-state="wrong"] .letter { border-color: var(--no); color: var(--no); }
.choice:disabled { cursor: default; }
.choice[data-state="muted"] { opacity: .5; }

/* spoken-choice questions: the options are only in the audio */
.choices.letters { display: grid; grid-template-columns: repeat(4, 1fr); }
.choices.letters .choice { justify-content: center; padding: 18px 0; }
.choices.letters .letter { min-width: 34px; height: 34px; font-size: 15px; margin: 0; }

.quiz-foot { margin-top: auto; padding-top: 8px; }

/* ── summary / lists ────────────────────────────────────── */
.sumlist { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.sumrow {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; width: 100%;
  font-family: var(--sans); color: var(--fg); font-size: 14px;
}
.sumrow:last-child { border-bottom: 0; }
.sumrow:hover { background: var(--bg-2); }
.sumrow .mark { font-family: var(--mono); font-size: 12px; width: 18px; flex-shrink: 0; }
.sumrow .mark.ok { color: var(--ok); }
.sumrow .mark.no { color: var(--no); }
.sumrow .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-dim); font-family: var(--mono); font-size: 12px; }
.sumrow .rate { font-family: var(--mono); font-size: 12px; color: var(--fg-dim); }
.empty { padding: 22px 14px; text-align: center; color: var(--fg-dim); font-family: var(--mono); font-size: 12px; background: var(--surface); }

/* ── sujets ─────────────────────────────────────────────── */
.sujetlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.sujet {
  border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2);
  padding: 14px; cursor: pointer; text-align: left; color: var(--fg); font-family: var(--sans);
  display: flex; flex-direction: column; gap: 6px;
}
.sujet:hover { border-color: var(--accent-bg); }
.sujet .t { font-size: 14px; font-weight: 600; }
.sujet .m { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-dim); }
.sujet .bar { height: 2px; background: var(--line); margin-top: 2px; }
.sujet .bar > i { display: block; height: 100%; background: var(--accent-bg); }

/* ── zoom overlay ───────────────────────────────────────── */
.zoom {
  position: fixed; inset: 0; z-index: 90; background: #0a0a0c;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  touch-action: none; overflow: hidden;
}
.zoom-stage { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; }
.zoom-stage img {
  max-width: 100%; max-height: 100%; transform-origin: 0 0; will-change: transform;
  background: #fff; user-select: none; -webkit-user-drag: none;
}
.zoom-close {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 14px; z-index: 3;
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em;
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.22);
  padding: 8px 12px; border-radius: var(--r); cursor: pointer; backdrop-filter: blur(8px);
}
.zoom-hint {
  position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); left: 0; right: 0; z-index: 3;
  text-align: center; font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
  color: rgba(255,255,255,.55); margin: 0; pointer-events: none;
}

@media (min-width: 560px) {
  .statgrid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
