/*
 * Thinkspark School · feuille de style commune (portail et fiches).
 * Jetons repris du système de design Thinkspark Admin (admin.thinkspark.dev),
 * clair par défaut, sombre si le système le demande. Version « ludique » pour les devoirs :
 * mêmes couleurs et mêmes polices, des cibles plus grandes et un peu de mouvement.
 */
@font-face { font-family: "Geist"; src: url("fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
:root {
  --ground: #F4F3EF;
  --panel: #EAE8E1;
  --raised: #FBFAF6;
  --line: #D9D5CC;
  --ink: #161614;
  --mute: #625E57;
  --hero: #0B3A1F;
  --on-hero: #EAF6EE;
  --accent-text: #1B6B3A;
  --brand: #0B3A1F;
  --deep: #0B3A1F;
  --on-deep: #D8F7E4;
  --paper: #FBFAF6;
  --paper-ink: #2A2A28;
  --warn: #8A5200;
  --warn-soft: #F6E7C8;
  --danger: #A3261A;
  --danger-soft: #F7DDD8;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 22px;
  --space-6: 34px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-pill: 999px;
  --lift: 0 1px 1px rgba(40,30,10,0.10), 0 14px 30px rgba(40,30,10,0.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #111110;
    --panel: #1D1D1B;
    --raised: #2A2A27;
    --line: #36352F;
    --ink: #F4F3EF;
    --mute: #A8A39B;
    --hero: #3DDC84;
    --on-hero: #062B14;
    --accent-text: #3DDC84;
    --brand: #3DDC84;
    --deep: #0B3A1F;
    --on-deep: #D8F7E4;
    --paper: #ECEAE3;
    --paper-ink: #2A2A28;
    --warn: #FBBF24;
    --warn-soft: #2A2108;
    --danger: #FF8A7A;
    --danger-soft: #33110D;
    color-scheme: dark;
  }
}
/* Sombre forcé : sur <html> (réglage « Sombre »), ou sur un conteneur toujours sombre (le viseur du scan). */
:root[data-theme="dark"], [data-theme="dark"] {
  --ground: #111110;
  --panel: #1D1D1B;
  --raised: #2A2A27;
  --line: #36352F;
  --ink: #F4F3EF;
  --mute: #A8A39B;
  --hero: #3DDC84;
  --on-hero: #062B14;
  --accent-text: #3DDC84;
  --brand: #3DDC84;
  --deep: #0B3A1F;
  --on-deep: #D8F7E4;
  --paper: #ECEAE3;
  --paper-ink: #2A2A28;
  --warn: #FBBF24;
  --warn-soft: #2A2108;
  --danger: #FF8A7A;
  --danger-soft: #33110D;
  color-scheme: dark;
}
.ta-root { background: var(--ground); color: var(--ink); min-height: 100dvh; }

/* ── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body.ts {
  font-family: "Geist", system-ui, sans-serif; font-size: 15px; line-height: 22px;
  background: var(--ground); color: var(--ink); min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
.ts :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.ts-grain::after {
  content: ""; position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .48 0 0 0 0 .44 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ts-grain::after { opacity: .22; mix-blend-mode: screen; } }
[data-theme="dark"] .ts-grain::after { opacity: .22; mix-blend-mode: screen; }
.ts-wrap { max-width: 720px; margin: 0 auto; padding: 22px 16px 64px; display: flex; flex-direction: column; gap: 22px; }
.hidden { display: none !important; }

/* ── Texte ────────────────────────────────────────────────────────────── */
.mono, .label, .micro, .badge, .num { font-family: "Geist Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.label { margin: 0; font-size: 10px; line-height: 14px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
.micro { font-size: 9px; line-height: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; }
.display { margin: 0; font-size: clamp(30px, 6vw, 44px); line-height: 1.04; font-weight: 500; letter-spacing: -.035em; text-wrap: balance; }
.title { margin: 0; font-size: 30px; line-height: 33px; font-weight: 500; letter-spacing: -.035em; text-wrap: balance; }
.heading { margin: 0; font-size: 19px; line-height: 24px; font-weight: 500; letter-spacing: -.02em; }
.mute { color: var(--mute); }
.small { font-size: 13px; line-height: 19px; }
a { color: var(--accent-text); }

/* ── Icône Iconista ───────────────────────────────────────────────────── */
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: butt; stroke-linejoin: miter; }
.ic--lg { width: 30px; height: 30px; }
.ic--xl { width: 40px; height: 40px; }

/* ── Barre du haut ────────────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.brand b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--hero); color: var(--on-hero); font: 600 13px/1 "Geist Mono", monospace; }
.stars { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--panel); font: 600 14px/1 "Geist Mono", monospace; --ic-accent: var(--warn); }
.stars .ic { width: 18px; height: 18px; }

/* ── Boutons ──────────────────────────────────────────────────────────── */
.btn {
  appearance: none; border: 0; height: 48px; padding: 0 22px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 500 15px/1 "Geist", system-ui, sans-serif; text-decoration: none; cursor: pointer;
  background: var(--raised); color: var(--ink); transition: transform .12s ease, opacity .12s ease;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .4; cursor: not-allowed; transform: none; }
.btn--hero { background: var(--hero); color: var(--on-hero); font-weight: 600; }
.btn--solid { background: var(--ink); color: var(--ground); font-weight: 600; }
.btn--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.btn--ghost { background: transparent; }
.btn--block { display: flex; width: 100%; }
.btn--xl { height: 58px; font-size: 17px; border-radius: 14px; }
.btn .ic { width: 20px; height: 20px; }
.bar { display: flex; gap: 8px; }
.bar > .btn { flex: 1; }

/* ── Pastilles ────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 6px; font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; background: var(--raised); color: var(--ink); white-space: nowrap; }
.badge--hero { background: var(--hero); color: var(--on-hero); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--ok { background: transparent; padding: 0; color: var(--accent-text); }
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 9px; border: 1px solid currentColor; border-radius: 999px; font: 500 9px/1 "Geist Mono", monospace; letter-spacing: .14em; text-transform: uppercase; }

/* ── Panneaux ─────────────────────────────────────────────────────────── */
.panel { border-radius: 14px; padding: 22px; background: var(--panel); display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel--raised { background: var(--raised); }
.panel--deep { background: var(--deep); color: var(--on-deep); }
.panel--deep .label, .panel--deep .mute { color: var(--on-deep); opacity: .8; }
.panel--deep .btn--hero { background: var(--on-deep); color: var(--deep); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ── Progression ──────────────────────────────────────────────────────── */
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; display: flex; }
.meter > span { background: var(--hero); border-radius: 3px; transition: width .4s ease; }
.panel--deep .meter { background: rgba(216,247,228,.2); }
.panel--deep .meter > span { background: var(--on-deep); }
.figures { display: flex; gap: 0; }
.figures > div { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 4px 0 4px 16px; border-left: 1px solid currentColor; border-left-color: color-mix(in srgb, currentColor 22%, transparent); }
.figures > div:first-child { padding-left: 0; border-left: 0; }
.figure { font: 400 30px/30px "Geist Mono", monospace; letter-spacing: -.02em; }

/* ── Lignes ───────────────────────────────────────────────────────────── */
.rows { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; min-width: 0; }
.rows > .row:first-child { border-top-color: transparent; }
a.row:hover .row__title { text-decoration: underline; text-underline-offset: 3px; }
.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row__title { font-size: 16px; line-height: 22px; font-weight: 500; }
.row__meta { font-size: 13px; line-height: 18px; color: var(--mute); }
.tile-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--raised); flex: none; --ic-accent: var(--accent-text); }

/* ── Avis ─────────────────────────────────────────────────────────────── */
.notice { border-radius: 14px; padding: 16px 22px; display: flex; gap: 12px; align-items: flex-start; background: var(--panel); }
.notice--warn { background: var(--warn-soft); }
.notice--warn .label { color: var(--warn); }
.notice p { margin: 4px 0 0; }
.empty { border-radius: 14px; padding: 34px 22px; background: var(--panel); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.empty p { margin: 0; color: var(--mute); max-width: 46ch; }

/* ── Champs et choix ──────────────────────────────────────────────────── */
.input { appearance: none; width: 100%; height: 54px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--ground); color: var(--ink); font: 500 19px/1 "Geist", sans-serif; }
.input::placeholder { color: var(--mute); font-weight: 400; }
.input:focus { outline: 2px solid var(--ink); outline-offset: 0; }
.input.ok { border-color: var(--accent-text); background: color-mix(in srgb, var(--hero) 10%, var(--ground)); }
.input.ko { border-color: var(--danger); background: var(--danger-soft); }
.choices { display: grid; gap: 8px; }
.choice { appearance: none; border: 1px solid var(--line); background: var(--ground); color: var(--ink); border-radius: 10px; min-height: 56px; padding: 14px 16px; font: 500 17px/1.25 "Geist", sans-serif; text-align: left; cursor: pointer; transition: transform .12s ease; }
.choice:hover { border-color: var(--mute); }
.choice:active { transform: scale(.98); }
.choice.ok { border-color: var(--accent-text); background: color-mix(in srgb, var(--hero) 12%, var(--ground)); color: var(--ink); }
.choice.ko { border-color: var(--danger); background: var(--danger-soft); }
.choice:disabled { cursor: default; }

/* ── Bouton son ───────────────────────────────────────────────────────── */
.say { appearance: none; border: 0; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; background: var(--ink); color: var(--ground); flex: none; transition: transform .12s ease; --ic-accent: var(--hero); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .say { --ic-accent: var(--deep); } }
[data-theme="dark"] .say { --ic-accent: var(--deep); }
.say:active { transform: scale(.9); }
.say--sm { width: 36px; height: 36px; border-radius: 8px; }
.say--sm .ic { width: 18px; height: 18px; }
.say--xl { width: 96px; height: 96px; border-radius: 22px; margin: 4px auto 18px; background: var(--hero); color: var(--on-hero); --ic-accent: var(--on-hero); }
.say--xl .ic { width: 44px; height: 44px; }
.say.playing { animation: pulse .6s ease infinite alternate; }

/* ── Mouvement (ludique, sobre) ───────────────────────────────────────── */
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.06); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pop { animation: pop .35s ease; }
.shake { animation: shake .4s ease; }
.rise { animation: rise .3s ease both; }
@media (prefers-reduced-motion: reduce) { .pop, .shake, .rise, .say.playing { animation: none; } }

/* ── Thème clair / foncé ──────────────────────────────────────────────── */
.theme { appearance: none; border: 0; width: 40px; height: 32px; border-radius: 999px; background: var(--panel); color: var(--ink); display: grid; place-items: center; cursor: pointer; --ic-accent: var(--warn); }
.theme .ic { width: 18px; height: 18px; }
.topbar__end { display: flex; align-items: center; gap: 8px; }

/* ── Matières ─────────────────────────────────────────────────────────── */
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.subject { display: flex; flex-direction: column; gap: 14px; padding: 16px; border-radius: 14px; background: var(--raised); color: var(--ink); text-decoration: none; min-height: 128px; transition: transform .12s ease; --ic-accent: var(--accent-text); }
.subject:hover { transform: translateY(-2px); }
.subject:active { transform: scale(.98); }
.subject__name { font-size: 16px; line-height: 20px; font-weight: 500; letter-spacing: -.01em; }
.subject__meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.subject .ic { width: 28px; height: 28px; }
.back { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; color: var(--mute); text-decoration: none; font-size: 14px; margin-left: -6px; }
.back .ic { width: 18px; height: 18px; }
.ext { font: 500 11px/1 "Geist Mono", monospace; color: var(--mute); letter-spacing: .04em; }

/* ── Pied ─────────────────────────────────────────────────────────────── */
.foot { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; padding-top: 18px; border-top: 1px solid var(--line); color: var(--mute); }
.foot a { color: inherit; }
@media (max-width: 640px) { .ts-wrap { padding-top: 16px; gap: 18px; } .panel { padding: 18px; } }
