/* Didactica — « cahier d'école » : vert ardoise, orange crayon, papier blanc. Polices servies par le site. */
@import url('/polices/atkinson-hyperlegible/400.css');
@import url('/polices/atkinson-hyperlegible/700.css');
@import url('/polices/bricolage-grotesque/latin-600.css');
@import url('/polices/bricolage-grotesque/latin-800.css');

:root {
  --bg: #F3F5F1; --surface: #FFFFFF; --ink: #18231D; --muted: #55615A; --line: #D5DDD6;
  --green: #1F6B4F; --green-soft: #E3F0E9; --orange: #C25E0E; --orange-soft: #FCEBDD; --danger: #A8321E;
  --f-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --f-body: 'Atkinson Hyperlegible', 'Segoe UI', Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111814; --surface: #18221C; --ink: #E7EEE9; --muted: #A3B0A8; --line: #2D3A32;
    --green: #5FC49A; --green-soft: #1D3328; --orange: #F2994A; --orange-soft: #3A2717; --danger: #F08A73; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111814; --surface: #18221C; --ink: #E7EEE9; --muted: #A3B0A8; --line: #2D3A32;
  --green: #5FC49A; --green-soft: #1D3328; --orange: #F2994A; --orange-soft: #3A2717; --danger: #F08A73; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.5;
  padding: 0 max(16px, env(safe-area-inset-left)) 48px max(16px, env(safe-area-inset-right));
}
a { color: var(--green); }
.wrap { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
.etroit { max-width: 720px; }

/* En-tête */
.entete { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 22px 0 14px; border-bottom: 3px solid var(--green); }
.marque { display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.marque b { font-family: var(--f-display); font-weight: 800; font-size: 30px; letter-spacing: -.02em; color: var(--green); line-height: 1; }
.marque span { color: var(--muted); font-size: 14px; }
.nav { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: 15px; }
.nav a { text-decoration: none; font-weight: 700; padding: 6px 2px; border-bottom: 2px solid transparent; }
.nav a[aria-current="page"] { border-bottom-color: var(--orange); color: var(--ink); }
.nav button { font: inherit; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 2px; text-decoration: underline; }

h1 { font-family: var(--f-display); font-weight: 800; font-size: clamp(28px, 5vw, 42px); line-height: 1.08; margin: 0; text-wrap: balance; max-width: 22ch; }
h2 { font-family: var(--f-display); font-weight: 600; font-size: 21px; margin: 0; }
.lead { margin: 10px 0 0; color: var(--muted); max-width: 62ch; font-size: 17px; }
.etape { display: flex; flex-direction: column; gap: 12px; }
.etape > h2 { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.etape > h2 em { font-style: normal; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--orange); }

.panneau { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.rangee { display: flex; flex-wrap: wrap; gap: 12px; }
.champ { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.rangee > .champ { flex: 1 1 180px; }
.lbl { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.aide { font-size: 14px; color: var(--muted); margin: 0; }
select, textarea, input[type=text], input[type=email], input[type=password], input[type=number] {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; min-height: 44px;
}
textarea { min-height: 170px; resize: vertical; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* Choix du mode */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.mode { font: inherit; text-align: left; color: inherit; cursor: pointer; background: var(--surface); border: 2px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.mode b { font-size: 16px; }
.mode span { font-size: 14px; color: var(--muted); }
.mode[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); }

.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; background: var(--bg); font-size: 15px; cursor: pointer; min-height: 40px; }
.puce input { accent-color: var(--green); width: 18px; height: 18px; margin: 0; }
.puce:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
details.options { border: 1px dashed var(--line); border-radius: 8px; padding: 10px 14px; }
details.options summary { cursor: pointer; font-weight: 700; font-size: 15px; }
details.options .puces { margin-top: 10px; }

/* Photos */
.photos { border: 2px dashed var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.photos-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.vignettes { display: flex; gap: 10px; flex-wrap: wrap; }
.vignette { position: relative; width: 96px; }
.vignette img { width: 96px; height: 120px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; background: #fff; }
.vignette .etat { font-size: 12px; font-weight: 700; display: block; margin-top: 4px; }
.vignette .etat.ok { color: var(--green); }
.vignette .etat.attente { color: var(--orange); }
.vignette button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 16px; cursor: pointer; line-height: 1; }

.consentement { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.consentement input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--green); flex: none; }

/* Boutons */
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn { font: inherit; font-weight: 700; border: 0; border-radius: 8px; padding: 12px 18px; min-height: 44px; cursor: pointer; background: var(--green); color: #fff; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn:not(.alt) { color: #0E1511; } }
.btn.alt { background: transparent; color: var(--green); border: 2px solid var(--green); }
.btn.orange { background: var(--orange); }
.btn.petit { padding: 7px 12px; min-height: 36px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--danger); border: 2px solid var(--danger); }
.btn[disabled] { opacity: .45; cursor: not-allowed; filter: grayscale(.6); }
.statut { font-size: 15px; color: var(--muted); }
.statut.err { color: var(--danger); font-weight: 700; }

/* Budget */
.budget { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px; }
.budget b { color: var(--ink); font-variant-numeric: tabular-nums; }
.jauge { width: 80px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.jauge i { display: block; height: 100%; background: var(--green); }

/* Aperçu « papier » */
.apercu-zone { overflow-x: auto; }
.feuille { color: #111; width: 100%; max-width: 794px; margin: 0 auto; padding: 44px 48px; border-radius: 4px; box-shadow: 0 1px 0 var(--line), 0 8px 24px rgba(0,0,0,.08); text-align: left; }
.feuille h3 { font-size: 1.35em; margin: 0 0 4px; }
.feuille h4 { font-size: 1.07em; margin: 0 0 4px; }
.feuille p { margin: 0 0 6px; }
.feuille .f-ligne { color: #333; }
.feuille .f-progression { border: 1px solid #999; padding: 8px 12px; margin: 10px 0 16px; }
.feuille .f-annonce { margin: 8px 0 12px; }
.feuille .f-corps { margin-top: 18px; }
.feuille .f-corps.deux-colonnes { column-count: 2; column-gap: 32px; column-rule: 1px solid #999; }
.feuille .f-ex { break-inside: avoid; margin: 0 0 22px; }
.feuille .f-bareme { font-size: .9em; color: #444; }
.feuille .f-consigne { margin-bottom: 8px; }
.feuille .f-partie { font-weight: 700; margin-top: 10px; }
.feuille .f-item { margin: 0 0 8px; }
.feuille .f-choix { padding-left: 1.5em; }
.feuille .f-trait { border-bottom: 1px solid #777; }
.feuille .f-cadre { border: 1px solid #666; margin: 4px 0 8px; padding: 4px 6px; }
.feuille .f-fait { margin-top: 6px; }
.feuille .f-quadrillage { margin: 4px 0 10px; border: 1px solid #c8c8c8; background-image: linear-gradient(#c8c8c8 1px, transparent 1px), linear-gradient(90deg, #c8c8c8 1px, transparent 1px); background-size: 19px 19px; position: relative; max-width: 100%; }
.feuille .f-quadrillage.udc span { display: inline-block; width: 19px; height: 19px; font-size: 10px; text-align: center; line-height: 19px; background: #ededed; color: #555; float: right; }
.feuille .f-corrige { border-top: 2px dashed #999; margin-top: 28px; padding-top: 12px; }
.feuille .f-refs { font-size: 11px; color: #666; margin-top: 18px; }
.feuille .f-pied { margin-top: 24px; font-size: 11px; color: #555; text-align: right; }
.vide { text-align: center; color: var(--muted); padding: 48px 12px; background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; }
.vide b { display: block; font-size: 18px; color: var(--ink); margin-bottom: 6px; }
.notes { font-size: 15px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; margin: 0; padding-left: 18px; }
.attente { display: flex; gap: 12px; align-items: center; }
.rond { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--green); animation: tourne 1s linear infinite; flex: none; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* Écran « Masquer » (plein écran) */
.masquer { position: fixed; inset: 0; z-index: 50; background: #0d1210; color: #fff; display: flex; flex-direction: column; }
.masquer-haut { padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.masquer-haut b { font-family: var(--f-display); font-size: 20px; }
.masquer-haut p { margin: 0; font-size: 15px; color: #cfd8d2; }
.masquer-toile { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 8px; overflow: hidden; }
.masquer-toile canvas { max-width: 100%; max-height: 100%; touch-action: none; cursor: crosshair; background: #fff; box-shadow: 0 0 0 1px #333; }
.masquer-bas { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; background: #151c18; }
.masquer-bas .groupe { display: flex; gap: 10px; flex-wrap: wrap; }
.masquer .btn.alt { color: #fff; border-color: #8fa89a; }
.masquer .compteur { font-size: 14px; color: #cfd8d2; }

/* Listes et tableaux */
.liste { display: flex; flex-direction: column; gap: 10px; }
.carte { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.carte .infos { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 260px; }
.carte .infos b { overflow-wrap: anywhere; }
.carte .meta { font-size: 14px; color: var(--muted); }
.etiquette { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); }
.etiquette.orange { background: var(--orange-soft); color: var(--orange); }
.tableau { width: 100%; border-collapse: collapse; font-size: 15px; }
.tableau th, .tableau td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tableau th { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tableau td.num { text-align: right; font-variant-numeric: tabular-nums; }
.defile { overflow-x: auto; }
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.chiffre { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.chiffre span { display: block; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.chiffre b { font-size: 28px; }
.onglets { display: flex; gap: 6px; flex-wrap: wrap; }
.onglets button { font: inherit; font-weight: 700; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
.onglets button[aria-pressed="true"] { background: var(--green); color: #fff; border-color: var(--green); }
pre.json { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border-radius: 8px; padding: 10px; font-size: 13px; max-height: 260px; overflow: auto; margin: 0; }

/* Accueil */
.accueil { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; align-items: start; }
.atouts { margin: 18px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.atouts li { display: flex; gap: 10px; }
.atouts li::before { content: ''; flex: none; width: 10px; height: 10px; margin-top: 7px; border-radius: 2px; background: var(--orange); }
.formules { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.formule { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.formule b { font-family: var(--f-display); font-size: 18px; }
.formule .prix { font-size: 24px; font-weight: 700; color: var(--green); }
.formule .prix small { font-size: 14px; color: var(--muted); font-weight: 400; }
.formule span { font-size: 14px; color: var(--muted); }

/* Pages légales */
.legal h2 { margin-top: 18px; }
.legal p, .legal li { max-width: 70ch; }
.a-completer { background: var(--orange-soft); color: var(--orange); font-weight: 700; padding: 0 4px; border-radius: 3px; }

.pied { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; }

@media (max-width: 760px) {
  .accueil { grid-template-columns: 1fr; }
  .feuille { padding: 22px 16px; }
  .feuille .f-corps.deux-colonnes { column-count: 1; }
  .entete { padding-top: 16px; }
  .marque b { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.tableau select { min-width: 170px; width: auto; }
.tableau td:first-child { min-width: 180px; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .masquer-haut p { font-size: 14px; }
  .masquer-bas { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .masquer-bas .groupe { display: contents; }
  .masquer-bas .compteur { grid-column: 1 / -1; order: -1; }
  .masquer-bas .btn { padding: 10px 8px; font-size: 15px; min-height: 44px; }
  .masquer-bas [data-a="valider"] { grid-column: 1 / -1; }
}
