/* Amiri, servie par le site (aucune police chargée depuis l'extérieur) */
@font-face {
  font-family: "Amiri";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/polices/amiri-arabic-400-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Amiri";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/polices/amiri-arabic-700-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

:root {
  --bg: #f4efe2;
  --surface: #fffdf8;
  --field: #f6f1e6;
  --text: #1b1a17;
  --muted: #5d584e;
  --line: #e0d5bd;
  --line-strong: #c9bb9b;
  --accent: #155e4a;
  --accent-hover: #0f4a3a;
  --accent-text: #ffffff;
  --accent-soft: #e1eee7;
  --gold: #7a5a12;
  --ok: #1b6b43;
  --ok-soft: #e1f2e8;
  --danger: #ac3329;
  --danger-soft: #fbe7e4;
  --focus: #1f5fbf;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(40, 30, 10, .05), 0 10px 30px rgba(70, 50, 10, .07);
  --motif: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%237a5a12' stroke-opacity='.13' stroke-width='1'%3E%3Crect x='27' y='27' width='42' height='42'/%3E%3Crect x='27' y='27' width='42' height='42' transform='rotate(45 48 48)'/%3E%3Ccircle cx='48' cy='48' r='9'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513;
    --surface: #17201c;
    --field: #1d2823;
    --text: #eef0ee;
    --muted: #a9b2ac;
    --line: #2b3832;
    --line-strong: #41524a;
    --accent: #5cc3a5;
    --accent-hover: #7bd3b9;
    --accent-text: #07201a;
    --accent-soft: #1a332c;
    --gold: #dcb867;
    --ok: #74d3a0;
    --ok-soft: #15301f;
    --danger: #f39087;
    --danger-soft: #3b1d1a;
    --focus: #8ab4ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .3);
    --motif: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%23dcb867' stroke-opacity='.07' stroke-width='1'%3E%3Crect x='27' y='27' width='42' height='42'/%3E%3Crect x='27' y='27' width='42' height='42' transform='rotate(45 48 48)'/%3E%3Ccircle cx='48' cy='48' r='9'/%3E%3C/g%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

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

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  background-color: var(--bg);
  background-image: var(--motif);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

[hidden] { display: none !important; }

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Arabe : Amiri, assez d'interligne pour que les voyelles ne soient jamais rognées */
.ar, [lang="ar"] {
  font-family: "Amiri", "Noto Naskh Arabic", "Geeza Pro", "Arabic Typesetting", serif;
  font-size: 1.3em;
  line-height: 1.5;
  font-weight: 400;
  font-feature-settings: normal;
  letter-spacing: 0;
}
bdi.ar { padding-inline: .08em; }
.bloc-ar { display: block; text-align: right; }

a { color: var(--accent); text-underline-offset: .18em; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* ---------- Mise en page ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 16px 6px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: .95rem;
  color: inherit;
  text-decoration: none;
  min-height: 44px;
}
.brand::before {
  content: "";
  flex: none;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.brand small { color: var(--muted); font-weight: 500; font-size: .9em; }

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 4px 16px 48px;
}

.hero { padding: 20px 0 18px; }
.hero .titre-ar { display: block; color: var(--gold); font-size: clamp(1.9rem, 8vw, 2.5rem); line-height: 1.6; margin-bottom: 2px; }
.hero h1 { font-size: clamp(1.55rem, 5.5vw, 2.1rem); letter-spacing: -.015em; line-height: 1.2; }
.hero p { color: var(--muted); margin-top: 8px; }

h2 { font-size: 1.15rem; line-height: 1.3; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.pied {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px 28px;
  color: var(--muted);
  font-size: .88rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  justify-content: space-between;
  align-items: center;
}
.pied a { color: var(--muted); display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 12px;
  border: 1.5px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.secondaire { background: transparent; color: var(--accent); }
.btn.secondaire:hover { background: var(--accent-soft); }
.btn.discret { background: transparent; color: var(--text); border-color: var(--line-strong); font-weight: 550; }
.btn.discret:hover { background: var(--field); }
.btn.danger { background: transparent; color: var(--danger); border-color: currentColor; font-weight: 550; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.petit { min-height: 44px; padding: 8px 14px; font-size: .92rem; }
.btn.large { width: 100%; }
.btn[aria-disabled="true"] { opacity: .6; cursor: progress; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* ---------- Accueil ---------- */

.tuiles { display: grid; gap: 12px; }

.tuile {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  min-height: 84px;
}
a.tuile:hover { border-color: var(--accent); }
a.tuile:active { transform: scale(.995); }
.tuile .pastille {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 750;
  font-size: 1.05rem;
}
.tuile.question .pastille { background: var(--accent); color: var(--accent-text); }
.tuile h2 { font-size: 1.08rem; }
.tuile p { color: var(--muted); font-size: .92rem; margin-top: 2px; line-height: 1.4; }
.tuile .fleche { color: var(--muted); font-size: 1.4rem; line-height: 1; }
.tuile.fermee { background: transparent; box-shadow: none; border-style: dashed; }
.tuile.fermee .pastille { background: var(--field); color: var(--muted); }
.tuile.fermee h2 { color: var(--muted); }

.note-anonymat {
  margin-top: 22px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: .93rem;
  line-height: 1.5;
}

/* ---------- QCM ---------- */

.retour {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; color: var(--muted); text-decoration: none; font-size: .95rem;
}
.retour:hover { color: var(--text); }

.qcm-tete {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -16px;
  padding: 10px 16px 12px;
  background: var(--bg);
  background-image: var(--motif);
}
.qcm-infos { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; color: var(--muted); font-weight: 550; }
.barre { height: 6px; border-radius: 99px; background: var(--line); margin-top: 8px; overflow: hidden; }
.barre > div { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s ease; }

.enonce {
  font-size: clamp(1.2rem, 4.8vw, 1.45rem);
  line-height: 1.75;
  font-weight: 650;
  letter-spacing: -.005em;
  margin: 14px 0 18px;
  outline: none;
}
.enonce:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 6px; }

.options { display: grid; gap: 10px; }

.option {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 10px 14px;
  text-align: left;
  font: inherit;
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s, background-color .15s, opacity .15s;
}
@media (hover: hover) {
  .option:hover:not([aria-disabled="true"]) { border-color: var(--accent); background: var(--accent-soft); }
}
.option:active:not([aria-disabled="true"]) { border-color: var(--accent); background: var(--accent-soft); }
.option .lettre {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: .9rem;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--muted);
}
.option .libelle { min-width: 0; overflow-wrap: anywhere; }
.option .libelle[dir="rtl"] { text-align: right; }
.option[aria-disabled="true"] { cursor: default; }
.option.juste { border-color: var(--ok); background: var(--ok-soft); }
.option.juste .lettre { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.option.faux { border-color: var(--danger); background: var(--danger-soft); }
.option.faux .lettre { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.option.eteinte { opacity: .55; }

.verdict { font-weight: 700; font-size: 1.05rem; margin-top: 18px; min-height: 1px; }
.verdict.juste { color: var(--ok); }
.verdict.faux { color: var(--danger); }

.explication {
  margin-top: 8px;
  padding: 14px 16px;
  border-left: 4px solid var(--gold);
  background: var(--surface);
  border-radius: 0 12px 12px 0;
  line-height: 1.8;
}
.explication .bonne { display: block; font-weight: 600; margin-bottom: 4px; }

.suite { margin-top: 18px; }

.intro-qcm ul { margin: 14px 0 0; padding-left: 1.2em; color: var(--muted); }
.intro-qcm li + li { margin-top: 4px; }

/* Résultat */
.score {
  text-align: center;
  padding: 28px 20px;
}
.score .valeur { font-size: clamp(3rem, 16vw, 4.2rem); font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--accent); }
.score .valeur small { font-size: .42em; color: var(--muted); font-weight: 650; letter-spacing: 0; }
.score h1 { font-size: 1.25rem; margin-top: 12px; }
.score p { color: var(--muted); margin-top: 6px; }

.revue { margin-top: 28px; }
.revue h2 { margin-bottom: 12px; }
.revue ol { list-style: none; padding: 0; display: grid; gap: 12px; }
.revue li { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.revue .q { font-weight: 650; line-height: 1.75; }
.revue .num { color: var(--muted); font-weight: 600; margin-right: 4px; }
.revue .ligne { margin-top: 6px; line-height: 1.75; }
.revue .ligne b { font-weight: 650; }
.revue .vous { color: var(--danger); }
.revue .bonne { color: var(--ok); }
.revue .exp { margin-top: 8px; color: var(--muted); line-height: 1.75; }

/* ---------- Question anonyme ---------- */

.formulaire label { display: block; font-weight: 650; margin-bottom: 8px; }
textarea {
  display: block;
  width: 100%;
  min-height: 9.5em;
  padding: 14px;
  font: inherit;
  font-size: 1.05rem;    /* au moins 16 px : iOS ne zoome pas */
  line-height: 1.7;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  resize: vertical;
  unicode-bidi: plaintext;  /* une question tapée en arabe s'aligne à droite */
}
textarea:focus { border-color: var(--accent); }
textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.formulaire .btn { margin-top: 14px; }
.erreur { color: var(--danger); font-weight: 600; margin-top: 10px; }
.erreur:empty { margin: 0; }
.rassurance { margin-top: 18px; color: var(--muted); font-size: .92rem; line-height: 1.55; }

.envoyee { text-align: center; padding: 32px 20px; margin-top: 20px; }
.envoyee .coche {
  width: 60px; height: 60px; margin: 0 auto 14px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ok-soft); color: var(--ok);
  font-size: 1.8rem; font-weight: 800;
}
.envoyee h1 { font-size: 1.35rem; outline: none; }
.envoyee p { color: var(--muted); margin-top: 6px; }
.envoyee .btn { margin-top: 22px; }

/* ---------- Admin ---------- */

.admin main { max-width: 900px; }
.admin .top, .admin .pied { max-width: 900px; }

.connexion { max-width: 420px; margin: 24px auto 0; }
.connexion h1 { font-size: 1.35rem; margin-bottom: 14px; }
.champ {
  display: block; width: 100%;
  min-height: 48px; padding: 10px 14px;
  font: inherit; font-size: 1.05rem;
  color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: 12px;
}
.champ:focus { border-color: var(--accent); }

.onglets {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 8px 0 18px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-x: auto;
}
.onglets a {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.onglets a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.compte {
  display: inline-grid; place-items: center;
  min-width: 1.6em; height: 1.6em; padding: 0 .4em;
  border-radius: 99px;
  background: var(--accent); color: var(--accent-text);
  font-size: .78rem; font-weight: 700;
}

.reglages { display: grid; gap: 14px; margin-bottom: 8px; }
@media (min-width: 680px) { .reglages { grid-template-columns: 1fr 1fr; } }
.reglages fieldset { border: 0; padding: 0; min-width: 0; }
.reglages legend { font-weight: 650; margin-bottom: 8px; padding: 0; }
.reglages .aide { color: var(--muted); font-size: .86rem; margin-top: 6px; line-height: 1.45; }

.segments { display: flex; gap: 6px; flex-wrap: wrap; }
.segments label, .bascule {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  font-size: .95rem;
}
.segments input[type="radio"] { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segments label:has(input[type="radio"]:checked) { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.segments label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.bascule input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.bascule:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.etat-enregistre { color: var(--ok); font-size: .86rem; font-weight: 600; min-height: 1.4em; margin-top: 6px; }

.barre-outils { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 14px; }
.barre-outils h1 { font-size: 1.3rem; outline: none; }

.liste-questions { list-style: none; padding: 0; display: grid; gap: 12px; }
.qe {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.qe .quand { color: var(--muted); font-size: .85rem; font-weight: 550; }
.qe .texte { margin-top: 6px; font-size: 1.12rem; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.qe .actions { margin-top: 12px; gap: 8px; }
.qe .lib-reponse { display: block; margin-top: 12px; font-size: .85rem; font-weight: 650; color: var(--muted); }
.qe textarea.reponse { min-height: 4.6em; margin-top: 4px; padding: 10px 12px; font-size: 1rem; line-height: 1.6; background: var(--field); }
.qe textarea.reponse:focus { background: var(--surface); }
.qe .etat-reponse { color: var(--ok); font-size: .82rem; font-weight: 600; min-height: 1.3em; margin-top: 4px; }
.qe.traitee textarea.reponse { background: transparent; }
.qe.traitee { border-left-color: var(--line-strong); box-shadow: none; background: transparent; }
.qe.traitee .texte { color: var(--muted); font-size: 1rem; }
.vide { color: var(--muted); padding: 20px; text-align: center; border: 1.5px dashed var(--line-strong); border-radius: 14px; }
.sous-titre { font-size: 1rem; color: var(--muted); margin: 26px 0 10px; }

/* Statistiques */
.resume-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.resume-stats .card { padding: 14px 16px; }
.resume-stats .chiffre { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.resume-stats .leg { color: var(--muted); font-size: .86rem; margin-top: 2px; }

.stats { list-style: none; padding: 0; display: grid; gap: 10px; }
.stat { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.stat .entete { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: baseline; }
.stat .num { color: var(--muted); font-weight: 700; font-size: .9rem; }
.stat .q { font-weight: 600; line-height: 1.7; }
.stat .taux { font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .taux.bas { color: var(--danger); }
.stat .taux.moyen { color: var(--gold); }
.stat .taux.haut { color: var(--ok); }
.stat .jauge { height: 8px; border-radius: 99px; background: var(--danger-soft); margin: 10px 0 6px; overflow: hidden; }
.stat .jauge > div { height: 100%; background: var(--ok); }
.stat .detail { color: var(--muted); font-size: .9rem; line-height: 1.6; }
.stat details { margin-top: 6px; font-size: .92rem; }
.stat summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.repartition { list-style: none; padding: 0; margin-top: 6px; display: grid; gap: 6px; }
.repartition li { display: grid; grid-template-columns: 1fr auto; gap: 10px; line-height: 1.6; padding: 4px 8px; border-radius: 8px; }
.repartition li.bonne { background: var(--ok-soft); }
.repartition .n { font-variant-numeric: tabular-nums; font-weight: 650; }

/* Projection */
.projection { text-align: center; }
.projection img {
  display: block;
  width: min(100%, 70vh, 520px);
  aspect-ratio: 1;
  margin: 8px auto 16px;
  background: #fff;
  border-radius: 16px;
  padding: 8px;
}
.projection .adresse { font-size: clamp(1.4rem, 5vw, 2.4rem); font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.projection p { color: var(--muted); margin-top: 6px; }
.projection .actions { justify-content: center; }
.reglages + .projection { margin-top: 16px; }
.projection:fullscreen { background: #fff; color: #111; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 24px; }
.projection:fullscreen img { width: min(80vh, 90vw); padding: 0; }
.projection:fullscreen p { color: #444; }
.projection:fullscreen .btn { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .option.juste, .option.faux { border-width: 3px; }
  .barre > div, .stat .jauge > div { background: Highlight; }
}
