/* Devoirs · EL ADAB — mêmes couleurs que les autres sites EL ADAB (salat, coran) */

:root {
  --bg: #f4efe2;
  --surface: #fffdf8;
  --field: #f6f1e6;
  --text: #1b1a17;
  --muted: #5d584e;
  --line: #e0d5bd;
  --line-strong: #8f8268;
  --accent: #155e4a;
  --accent-hover: #0f4a3a;
  --accent-text: #ffffff;
  --accent-soft: #e1eee7;
  --gold: #7a5a12;
  --ok: #1b6b43;
  --ok-soft: #e1f2e8;
  --warn: #8a4b00;
  --warn-soft: #fbefd9;
  --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: #6f8279;
    --accent: #5cc3a5;
    --accent-hover: #7bd3b9;
    --accent-text: #07201a;
    --accent-soft: #1a332c;
    --gold: #dcb867;
    --ok: #74d3a0;
    --ok-soft: #15301f;
    --warn: #f0b86a;
    --warn-soft: #33260f;
    --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; }
h1:focus, h2:focus { outline: none; }

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

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

.top, main, .pied { width: 100%; max-width: 760px; margin: 0 auto; }
.espace .top, .espace main, .espace .pied { max-width: 960px; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  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; }
.qui { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .92rem; }

main { flex: 1; padding: 4px 16px 48px; }

.hero { padding: 20px 0 18px; }
.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; }
.surtitre { color: var(--muted); font-size: .9rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

h1 { font-size: 1.45rem; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; line-height: 1.3; }
h3 { font-size: 1.02rem; line-height: 1.35; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card, .pile > * + * { margin-top: 14px; }

.pied {
  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; }
.pied nav { display: flex; gap: 16px; }

/* ---------- 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-align: center;
  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; }

.lien {
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 0; border: 0; background: none; font: inherit;
  color: var(--accent); text-decoration: underline; text-underline-offset: .18em; cursor: pointer;
}
.lien.danger { color: var(--danger); }

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

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

/* ---------- Champs ---------- */

.groupe + .groupe, .groupe + fieldset, fieldset + .groupe, fieldset + fieldset { margin-top: 18px; }
label, .etiquette, legend { display: block; font-weight: 650; margin-bottom: 6px; }
label .facultatif, legend .facultatif { font-weight: 450; color: var(--muted); }
.aide { color: var(--muted); font-size: .9rem; line-height: 1.45; margin: -2px 0 8px; }

.champ, textarea, select.champ {
  display: block; width: 100%;
  min-height: 48px; padding: 10px 14px;
  font: inherit; font-size: 1.05rem;   /* au moins 16 px : iOS ne zoome pas */
  color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: 12px;
}
textarea { min-height: 6.5em; line-height: 1.6; resize: vertical; unicode-bidi: plaintext; }
textarea.grand { min-height: 12em; }
.champ:focus, textarea:focus { border-color: var(--accent); }
.champ:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.champ.code { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: 1.35rem; letter-spacing: .12em; text-transform: uppercase; }
.deux { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 520px) { .deux { grid-template-columns: 1fr 1fr; } }

.case { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; margin: 0; cursor: pointer; }
.case input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }
.cases { display: flex; flex-wrap: wrap; gap: 0 18px; }

.erreur { color: var(--danger); font-weight: 600; margin-top: 8px; }
.erreur:empty { display: none; }
.erreur-champ { color: var(--danger); font-weight: 600; font-size: .95rem; margin: 6px 0 0; }
.erreur-champ:empty { display: none; }

.resume-erreurs {
  border: 2px solid var(--danger);
  background: var(--danger-soft);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.resume-erreurs h2 { font-size: 1.02rem; color: var(--danger); }
.resume-erreurs ul { margin: 6px 0 0; padding-left: 1.2em; }
.resume-erreurs a { color: var(--danger); font-weight: 600; }

.note {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: .95rem;
  line-height: 1.5;
}
.note.attention { background: var(--warn-soft); color: var(--text); border-left: 4px solid var(--warn); }
.note + .card, .note + form, .card + .note { margin-top: 14px; }

/* ---------- Élèves : devoirs ---------- */

.tuiles { display: grid; gap: 12px; }
.tuile {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.tuile:hover { border-color: var(--accent); }
.tuile h3 { font-size: 1.08rem; }
.tuile p { color: var(--muted); font-size: .92rem; margin-top: 2px; line-height: 1.45; }
.tuile .fleche { color: var(--muted); font-size: 1.5rem; line-height: 1; }
.tuile .badges { margin-top: 6px; }
.vide { color: var(--muted); padding: 22px; text-align: center; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); }

.titre-section { margin: 26px 0 12px; }
.titre-section:first-child { margin-top: 6px; }

.echeance { color: var(--muted); margin-top: 4px; }
.echeance strong { color: var(--text); }
.consignes {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
}
.consignes:empty { display: none; }

.boutons-fichiers { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 520px) { .boutons-fichiers.deux-boutons { grid-template-columns: 1fr 1fr; } }

.fichiers-choisis { list-style: none; padding: 0; margin-top: 12px; display: grid; gap: 8px; }
.fichiers-choisis:empty { display: none; }
.fichier-choisi {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
}
.fichier-choisi .vignette {
  width: 48px; height: 48px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); font-size: .7rem; font-weight: 750; text-transform: uppercase; letter-spacing: .03em;
  object-fit: cover; overflow: hidden;
}
.fichier-choisi .nom { min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.fichier-choisi .nom small { display: block; color: var(--muted); }
.total-fichiers { color: var(--muted); font-size: .9rem; margin-top: 8px; }

.progression { margin-top: 16px; }
progress {
  display: block; width: 100%; height: 12px;
  appearance: none; -webkit-appearance: none;
  border: 0; border-radius: 99px; background: var(--line); overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; transition: width .2s ease; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
.progression p { margin-top: 8px; color: var(--muted); font-weight: 600; }

.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; }
.envoyee p { color: var(--muted); margin-top: 6px; }
.envoyee ul { list-style: none; padding: 0; margin-top: 14px; display: grid; gap: 4px; overflow-wrap: anywhere; }
.envoyee .btn { margin-top: 22px; }

/* ---------- Pastilles ---------- */

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 10px; border-radius: 99px;
  font-size: .82rem; font-weight: 650; line-height: 1.6;
  background: var(--field); color: var(--muted); border: 1px solid var(--line);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.retard { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.attention { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Espace professeurs / admin ---------- */

.connexion { max-width: 420px; margin: 24px auto 0; }
.connexion h1 { margin-bottom: 14px; }

.onglets {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 8px 0 20px;
  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); }

.barre-outils {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.barre-outils .filtre { display: flex; align-items: center; gap: 8px; }
.barre-outils .filtre label { margin: 0; font-weight: 600; color: var(--muted); }
.barre-outils .filtre select { min-width: 12em; width: auto; }

.liste-devoirs { display: grid; gap: 12px; }
.devoir-ligne { grid-template-columns: 1fr auto; }
.devoir-ligne .compteur { text-align: right; font-size: .9rem; color: var(--muted); line-height: 1.3; }
.devoir-ligne .compteur b { display: block; font-size: 1.35rem; color: var(--text); }
.devoir-ligne.ferme { background: transparent; box-shadow: none; border-style: dashed; }

.entete-devoir { margin: 6px 0 16px; }
.entete-devoir .meta { color: var(--muted); margin-top: 4px; }

.manquants { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding: 0; list-style: none; }
.manquants li { padding: 2px 12px; border-radius: 99px; background: var(--field); border: 1px solid var(--line); font-size: .92rem; }

.depot .tete { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.depot .tete h3 { font-size: 1.08rem; }
.depot .quand { color: var(--muted); font-size: .92rem; }
.depot .message {
  margin-top: 10px; padding: 10px 14px;
  border-left: 3px solid var(--line-strong); background: var(--field); border-radius: 0 10px 10px 0;
  white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext;
}
.depot .fichiers { list-style: none; padding: 0; margin-top: 10px; display: grid; gap: 6px; }
.depot .fichiers li {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px;
  padding: 6px 0; border-top: 1px solid var(--line);
}
.depot .fichiers .nom { overflow-wrap: anywhere; min-width: 0; }
.depot .fichiers .nom small { color: var(--muted); margin-left: 6px; }
.depot .fichiers .liens { display: flex; gap: 16px; }
.depot .fichiers .liens a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.depot .pied-depot { display: flex; justify-content: flex-end; margin-top: 4px; }

.classe .code-affiche {
  display: inline-block;
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 1.5rem; font-weight: 700; letter-spacing: .14em;
  padding: 2px 12px; margin-top: 6px;
  background: var(--field); border: 1px dashed var(--line-strong); border-radius: 10px;
}
.classe .lien-eleves { margin-top: 8px; overflow-wrap: anywhere; color: var(--muted); font-size: .95rem; }
.classe .profs-classe { color: var(--muted); margin-top: 6px; font-size: .95rem; }

details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 4px; }
details > summary {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; cursor: pointer; font-weight: 650; color: var(--accent);
  list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; display: inline-block; width: 1em; font-size: 1.3em; line-height: 1; transition: transform .15s ease; }
details[open] > summary::before { transform: rotate(90deg); }
details > .contenu { padding: 6px 0 4px; }

.mdp-affiche {
  margin-top: 14px; padding: 16px;
  border: 2px solid var(--accent); border-radius: 12px; background: var(--accent-soft);
}
.mdp-affiche .valeur {
  display: inline-block; margin: 6px 0;
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 1.4rem; font-weight: 700; letter-spacing: .08em;
  user-select: all;
}

.stockage { margin-top: 26px; color: var(--muted); font-size: .9rem; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
