/* ==========================================================================
   Synar-IA — site de cours · charte graphique
   Fond marine, texte crème, accent ambre, accent secondaire sauge.
   Montserrat 700 pour les titres, le logo et les chiffres ; Open Sans pour le texte.
   Mobile-first : les pages élève sont pensées pour un téléphone, le tableau de bord
   pour un vidéoprojecteur (contraste élevé, gros chiffres).
   ========================================================================== */

:root {
  --ink: #0F1E2E;
  --ink-soft: #16283D;
  --ink-deep: #0a1622;
  --paper: #F2E9E1;
  --paper-dim: #cfc6bb;
  --grey: #6B7280;
  --amber: #d97441;
  --amber-glow: #f0a060;
  --sage: #6F8F7E;
  --sage-soft: #8aa898;

  --font-title: "Montserrat", "Segoe UI", Arial, sans-serif;
  --font-body: "Open Sans", "Segoe UI", Arial, sans-serif;

  --radius: 14px;
  --gap: 16px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  background-image: linear-gradient(180deg, var(--ink-soft) 0%, var(--ink) 40%, var(--ink-deep) 100%);
  background-attachment: fixed;
  color: var(--paper);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.5;
  padding-inline: 16px;
  padding-block: 0 40px;
}

h1, h2, h3, .num { font-family: var(--font-title); font-weight: 700; margin: 0; line-height: 1.15; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
a { color: var(--amber-glow); }

.sub { font-weight: 300; color: var(--paper-dim); }
.label {
  font-family: var(--font-body); font-weight: 600; font-size: 0.72rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--paper-dim);
}
.muted { color: var(--grey); }
.amber { color: var(--amber); }
.sage { color: var(--sage-soft); }
.center { text-align: center; }
.hidden { display: none !important; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* --- Logo texte -------------------------------------------------------- */
.logo {
  font-family: var(--font-title); font-weight: 700; letter-spacing: 0.04em;
  color: var(--paper); text-decoration: none; white-space: nowrap;
}
.logo span { color: var(--amber); }
.logo.big { font-size: clamp(2.4rem, 9vw, 5rem); }

/* --- En-tête ------------------------------------------------------------ */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 14px 10px; flex-wrap: wrap;
}
.topbar .logo { font-size: 1.25rem; }
.topbar .right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; background: var(--ink-soft);
  border: 1px solid rgba(242, 233, 225, 0.15); font-size: 0.9rem;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sage-soft); }
.chip.off .dot { background: var(--grey); }

/* --- Mise en page ------------------------------------------------------ */
.wrap { max-width: 720px; margin: 0 auto; }
.wrap.wide { max-width: 1400px; }
.stack > * + * { margin-top: var(--gap); }

.card {
  background: var(--ink-soft); border: 1px solid rgba(242, 233, 225, 0.10);
  border-radius: var(--radius); padding: 18px;
}
.card.flat { background: transparent; }
.card.accent { border-color: var(--amber); }
.card.sage { border-color: var(--sage); }

.tag {
  display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 0.75rem;
  font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  background: rgba(242, 233, 225, 0.08); color: var(--paper-dim);
}
.tag.amber { background: var(--amber); color: var(--ink); }
.tag.sage { background: var(--sage); color: var(--ink); }

.question { font-size: clamp(1.35rem, 5vw, 2rem); margin-block: 10px 16px; }

/* --- Formulaires -------------------------------------------------------- */
input[type="text"], textarea, select {
  width: 100%; font: inherit; color: var(--paper); background: var(--ink-deep);
  border: 1px solid rgba(242, 233, 225, 0.22); border-radius: 10px; padding: 12px 14px;
}
input[type="text"]:focus, textarea:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--amber); }
textarea { min-height: 120px; resize: vertical; }
textarea.tall { min-height: 200px; }
.field { margin-bottom: 14px; }
.field .label { display: block; margin-bottom: 6px; }
.hint { font-size: 0.85rem; color: var(--paper-dim); }

/* --- Boutons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-title); font-weight: 700; font-size: 1rem;
  padding: 12px 20px; border-radius: 12px; cursor: pointer; text-decoration: none;
  border: 2px solid var(--amber); background: var(--amber); color: var(--ink);
  min-height: 48px; transition: transform 0.05s ease, filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--paper); border-color: rgba(242, 233, 225, 0.35); }
.btn.ghost:hover { border-color: var(--paper); }
.btn.sage { background: var(--sage); border-color: var(--sage); color: var(--ink); }
.btn.danger { background: transparent; border-color: #b04a3a; color: #e8a094; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.85rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.active { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }

/* Gros boutons de vote (pouce) */
.votes { display: grid; gap: 12px; margin-block: 8px 14px; }
.vote {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  min-height: 76px; padding: 14px 18px; border-radius: 16px; cursor: pointer;
  font-family: var(--font-title); font-weight: 700; font-size: 1.15rem; line-height: 1.25;
  background: var(--ink-deep); color: var(--paper);
  border: 2px solid rgba(242, 233, 225, 0.25);
  -webkit-tap-highlight-color: transparent; transition: border-color 0.15s, background 0.15s;
}
.vote .key {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(242, 233, 225, 0.10); font-size: 1rem;
}
.vote:active { transform: scale(0.985); }
.vote.selected { border-color: var(--amber-glow); background: rgba(217, 116, 65, 0.18); }
.vote.selected .key { background: var(--amber); color: var(--ink); }
.vote.correct { border-color: var(--amber); background: rgba(217, 116, 65, 0.28); }
.vote.correct .key { background: var(--amber); color: var(--ink); }
.vote.wrong { border-color: var(--grey); color: var(--paper-dim); background: transparent; }
.vote.wrong .key { background: var(--grey); color: var(--ink); }
.vote:disabled { cursor: default; }
.vote.dim { opacity: 0.55; }

/* --- Barres de résultats ------------------------------------------------ */
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: end; }
.bar .txt { font-weight: 600; overflow-wrap: anywhere; }
.bar .num { font-size: 1.15rem; white-space: nowrap; }
.bar .num small { font-family: var(--font-body); font-weight: 400; color: var(--paper-dim); font-size: 0.85rem; }
.bar .track { grid-column: 1 / -1; height: 18px; border-radius: 9px; background: rgba(242, 233, 225, 0.08); overflow: hidden; }
.bar .fill { height: 100%; width: 0; border-radius: 9px; background: var(--grey); transition: width 0.4s ease, background 0.3s; }
.bar.correct .fill { background: var(--amber); }
.bar.other .fill { background: var(--sage); }
.bar.correct .txt { color: var(--amber-glow); }
.bars.big .bar .txt { font-size: 1.35rem; }
.bars.big .bar .num { font-size: 1.8rem; }
.bars.big .bar .track { height: 30px; border-radius: 15px; }

.count { font-family: var(--font-title); font-weight: 700; }
.kpi { display: flex; gap: 14px; flex-wrap: wrap; }
.kpi .box { flex: 1 1 140px; background: var(--ink-deep); border-radius: 12px; padding: 12px 14px; }
.kpi .box .num { font-size: 2rem; }
.kpi .box .num.amber { color: var(--amber-glow); }

/* --- Résultat après révélation ----------------------------------------- */
.reveal { border-left: 4px solid var(--amber); padding: 12px 16px; background: rgba(217, 116, 65, 0.10); border-radius: 0 12px 12px 0; }
.reveal .verdict { font-family: var(--font-title); font-weight: 700; font-size: 1.3rem; }
.reveal.good .verdict { color: var(--amber-glow); }
.reveal.bad { border-left-color: var(--grey); background: rgba(107, 114, 128, 0.15); }
.reveal.bad .verdict { color: var(--paper-dim); }
.status { min-height: 1.5em; font-size: 0.95rem; color: var(--paper-dim); }
.status.ok { color: var(--sage-soft); }
.status.err { color: #e8a094; }

/* --- Écran d'attente / inscription ------------------------------------- */
.hero { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }
.hero .pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--amber); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(0.8); opacity: 0.5; } 50% { transform: scale(1.3); opacity: 1; } }
.hero form { width: 100%; max-width: 380px; }
.hero input[type="text"] { font-size: 1.3rem; text-align: center; font-family: var(--font-title); font-weight: 700; }

/* --- Mails types --------------------------------------------------------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs .btn { flex: 1 1 auto; min-height: 48px; }
.mail {
  background: var(--paper); color: var(--ink); border-radius: 12px; padding: 16px 18px;
  font-family: var(--font-body); font-size: 0.98rem;
}
.mail .head { font-size: 0.85rem; color: #4b5563; border-bottom: 1px solid #d9d0c6; padding-bottom: 8px; margin-bottom: 10px; }
.mail .head b { color: var(--ink); }
.mail .subject { font-family: var(--font-title); font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; color: var(--ink); }
.mail .body { white-space: pre-wrap; }
.context { font-size: 0.92rem; color: var(--paper-dim); border-left: 3px solid var(--sage); padding-left: 12px; }

/* --- Post-its (mur des « ce que je changerais ») ------------------------ */
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.postit {
  background: var(--paper); color: var(--ink); border-radius: 4px; padding: 14px 16px;
  font-size: 1rem; box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35); transform: rotate(-0.6deg);
}
.postit:nth-child(2n) { transform: rotate(0.8deg); background: #FAF6F4; }
.postit:nth-child(3n) { transform: rotate(-1.2deg); background: #f0dfcf; }
.postit .who { font-family: var(--font-title); font-weight: 700; font-size: 0.8rem; color: var(--ink); margin-top: 8px; }

/* --- Comparaison de productions ---------------------------------------- */
.compare { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .compare { grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); } }
.prod { display: flex; flex-direction: column; background: var(--ink-soft); border-radius: var(--radius); border: 2px solid rgba(242, 233, 225, 0.12); overflow: hidden; }
.prod.selected { border-color: var(--amber); }
.prod .ph { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: rgba(242, 233, 225, 0.06); }
.prod .ph .letter { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--amber); color: var(--ink); font-family: var(--font-title); font-weight: 700; font-size: 1.3rem; }
.prod .ph .who { font-family: var(--font-title); font-weight: 700; }
.prod .pb { padding: 14px 16px; white-space: pre-wrap; overflow: auto; max-height: 60vh; font-size: 0.98rem; }
.prod details { padding: 0 16px 12px; font-size: 0.9rem; color: var(--paper-dim); }
.prod details summary { cursor: pointer; color: var(--sage-soft); font-weight: 600; }
.prod .change { padding: 10px 16px; border-top: 1px dashed rgba(242, 233, 225, 0.18); font-style: italic; color: var(--paper-dim); }

/* --- Tableau de bord prof ---------------------------------------------- */
body.prof { font-size: 16px; }
.prof .layout { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 1100px) { .prof .layout { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); } }
.actnav { display: flex; gap: 8px; flex-wrap: wrap; }
.actnav .btn { flex: 1 1 120px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.controls .btn { flex: 1 1 auto; }
.big-item { font-size: clamp(1.5rem, 3.2vw, 2.6rem); font-family: var(--font-title); font-weight: 700; line-height: 1.2; }
.students { display: flex; flex-wrap: wrap; gap: 6px; }
.students .chip { font-size: 0.85rem; padding: 4px 10px; }
.students .chip button { border: 0; background: none; color: var(--grey); cursor: pointer; font-size: 0.9rem; padding: 0 0 0 4px; }
.students .chip button:hover { color: #e8a094; }

table.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.grid th, table.grid td { padding: 6px 8px; text-align: left; border-bottom: 1px solid rgba(242, 233, 225, 0.10); vertical-align: top; }
table.grid th { font-weight: 600; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--paper-dim); }
table.grid td.num { font-family: var(--font-title); font-weight: 700; }
table.grid tr.miss td { color: #e8a094; }
.tablewrap { overflow-x: auto; }

.sublist { display: grid; gap: 10px; }
.subrow { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 10px 12px; border-radius: 10px; background: var(--ink-deep); }
.subrow input[type="checkbox"] { width: 22px; height: 22px; margin-top: 4px; accent-color: var(--amber); }
.subrow .excerpt { color: var(--paper-dim); font-size: 0.9rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.subrow .excerpt.open { display: block; }
.subrow .who { font-family: var(--font-title); font-weight: 700; }

/* --- Page QR ------------------------------------------------------------- */
.qrpage { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; text-align: center; padding-block: 24px; }
.qrpage img { width: min(70vh, 90vw, 640px); height: auto; border-radius: 24px; background: var(--paper); padding: 12px; }
.qrpage .url { font-family: var(--font-title); font-weight: 700; font-size: clamp(1.4rem, 4.5vw, 3rem); color: var(--amber-glow); overflow-wrap: anywhere; }

/* --- Plein écran comparaison ------------------------------------------- */
body.fullscreen { padding-block: 12px 24px; }
.fullscreen .compare .prod .pb { max-height: 55vh; font-size: 1.05rem; }

/* --- Bandeau hors ligne -------------------------------------------------- */
.offline { position: fixed; left: 0; right: 0; bottom: 0; background: #b04a3a; color: #fff; text-align: center; padding: 8px; font-weight: 600; z-index: 10; }

/* Petits écrans : un peu plus compact */
@media (max-width: 420px) {
  body { font-size: 16px; }
  .card { padding: 14px; }
  .vote { min-height: 68px; font-size: 1.05rem; }
}
/* Projection : agrandir sur grands écrans */
@media (min-width: 1400px) {
  body.prof { font-size: 18px; }
}
