@font-face { font-family: "Fraunces"; src: url(fonts/fraunces.woff2) format("woff2"); font-weight: 400 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces-italic.woff2) format("woff2"); font-weight: 400 800; font-style: italic; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url(fonts/bricolage.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "DM Mono"; src: url(fonts/dmmono-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Mono"; src: url(fonts/dmmono-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }

/* Formes : cartes 18px, boutons 12px, pastilles et stickers en pilule. */
:root {
  --fond: #FBF7F0;
  --surface: #FFFFFF;
  --encre: #221F1B;
  --gris: #5A554E;
  --trait: #221F1B;
  --foret: #005446;
  --foret-texte: #FBF7F0;
  --orange: #F56231;
  --orange-texte: #B83E14;
  --brun: #84462E;
  --peche: #FCECCF;
  --rose: #FFB2FF;
  --lime: #CBFF94;
  --violet: #B675FF;
  --ombre: #221F1B;
  --point: rgba(34, 31, 27, .09);
  --sortie: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #17150F;
    --surface: #221F1B;
    --encre: #FBF7F0;
    --gris: #BDB5A8;
    --trait: #FBF7F0;
    --foret: #0A6152;
    --orange-texte: #FF8A5E;
    --peche: #3A2A1C;
    --ombre: #000000;
    --point: rgba(251, 247, 240, .07);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Taille du texte réglée par le téléphone (Dynamic Type sur iPhone). */
html { font-size: 100%; font: -apple-system-body; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--encre);
  background-color: var(--fond);
  background-image: radial-gradient(var(--point) 1px, transparent 1.2px);
  background-size: 22px 22px;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 34rem;
  margin: 0 auto;
  padding: max(1.25rem, env(safe-area-inset-top)) 1rem calc(7rem + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 600; margin: 0; letter-spacing: -.02em; }
h1 { font-size: 2.6rem; line-height: 1.05; font-variation-settings: "opsz" 144; }
h2 { font-size: 1.7rem; line-height: 1.1; font-variation-settings: "opsz" 96; }
h3 { font-size: 1.3rem; line-height: 1.2; }
em { font-style: italic; color: var(--orange-texte); }
p { margin: .5rem 0; }
button { font: inherit; color: inherit; }

.mono, .pastille, .jour small, .etiquette {
  font-family: "DM Mono", ui-monospace, monospace;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .75rem;
}
.pastille {
  display: inline-block;
  flex-shrink: 0;
  white-space: nowrap;
  padding: .3rem .7rem;
  border: 2px solid var(--trait);
  border-radius: 999px;
  background: var(--surface);
}
.pastille.orange { background: var(--orange); color: #221F1B; }
.pastille.lime { background: var(--lime); color: #221F1B; }
.rangee { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.tete { margin: .5rem 0 1.5rem; }
.tete h1 { margin-top: 1rem; }
.cap {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--gris);
  margin-top: .75rem;
}

.carte {
  position: relative;
  background: var(--surface);
  border: 2.5px solid var(--trait);
  border-radius: 18px;
  box-shadow: 5px 5px 0 var(--ombre);
  padding: 1.25rem;
  margin: 1.5rem 0;
}
.carte.foret { background: var(--foret); color: var(--foret-texte); border-color: var(--trait); }
.carte.foret em { color: var(--lime); }
.carte.peche { background: var(--peche); }

.sticker {
  position: absolute;
  top: -.9rem;
  right: 1rem;
  transform: rotate(6deg);
  padding: .35rem .8rem;
  border: 2px solid #221F1B;
  border-radius: 999px;
  font-family: "DM Mono", monospace;
  font-size: .7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #221F1B;
  background: var(--lime);
}
.sticker.rose { background: var(--rose); transform: rotate(-5deg); }
.sticker.violet { background: var(--violet); }

.etiquette { color: var(--gris); display: block; margin-bottom: .35rem; }
.carte.foret .etiquette { color: var(--lime); }

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 3.25rem;
  padding: .8rem 1.2rem;
  border: 2.5px solid var(--trait);
  border-radius: 12px;
  background: var(--surface);
  color: var(--encre);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ombre);
  transition: transform 140ms var(--sortie), box-shadow 140ms var(--sortie);
}
.bouton:active { transform: translate(2px, 2px) scale(.98); box-shadow: 1px 1px 0 var(--ombre); }
.bouton.plein { background: var(--orange); color: #221F1B; }
.bouton.large { width: 100%; }
.bouton.fait { background: var(--lime); color: #221F1B; }
.bouton:disabled { opacity: .45; cursor: default; }
.boutons { display: grid; gap: .75rem; margin-top: 1rem; }
.lien { background: none; border: 0; padding: .5rem 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; color: inherit; }

.semaine { display: grid; grid-template-columns: repeat(7, 1fr); gap: .35rem; margin: 1rem 0; }
.jour {
  display: grid;
  justify-items: center;
  gap: .15rem;
  padding: .5rem 0;
  border: 2px solid var(--trait);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: transform 140ms var(--sortie);
}
.jour:active { transform: scale(.95); }
.jour b { font-size: 1.05rem; }
.jour.fait { background: var(--foret); color: var(--foret-texte); }
.jour.choisi { outline: 3px solid var(--orange); outline-offset: 2px; }
.jour:disabled { opacity: .35; cursor: default; }

.compte { display: flex; gap: .3rem; margin: .75rem 0 .25rem; }
.compte i { flex: 1; height: .55rem; border-radius: 999px; border: 2px solid currentColor; }
.compte i.plein { background: currentColor; }

.habitude {
  display: flex;
  gap: .9rem;
  align-items: flex-start;
  padding: .9rem 0;
  border-top: 2px dashed color-mix(in srgb, var(--trait) 25%, transparent);
  cursor: pointer;
}
.habitude:first-of-type { border-top: 0; }
.habitude input { position: absolute; opacity: 0; pointer-events: none; }
.case {
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  border: 2.5px solid var(--trait);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  place-items: center;
  transition: background-color 160ms ease;
}
.case svg { width: 1.1rem; height: 1.1rem; opacity: 0; transform: scale(.6); transition: opacity 160ms var(--sortie), transform 200ms var(--sortie); }
.habitude input:checked + .case { background: var(--lime); }
.habitude input:checked + .case svg { opacity: 1; transform: scale(1); }
.habitude input:focus-visible + .case { outline: 3px solid var(--orange); outline-offset: 2px; }
.habitude small { display: block; color: var(--gris); }

details { margin-top: .75rem; }
summary { cursor: pointer; font-weight: 600; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "+ "; font-family: "DM Mono", monospace; }
details[open] summary::before { content: "- "; }

.pyramide { display: grid; gap: .3rem; justify-items: center; margin-top: 1rem; }
.etage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.2rem;
  padding: .3rem .6rem;
  border: 2px solid var(--trait);
  border-radius: 10px;
  font-size: .85rem;
  text-align: center;
  line-height: 1.2;
  background: var(--surface);
}
.etage { font: inherit; font-size: .85rem; color: #221F1B; cursor: pointer; transition: transform 140ms var(--sortie); }
.etage:active { transform: scale(.97); }
.etage.foret { background: var(--foret); color: var(--foret-texte); }
.etage.orange { background: var(--orange); }
.etage.violet { background: var(--violet); }
.etage.lime { background: var(--lime); }
.etage.rose { background: var(--rose); }
.etage.valide { font-weight: 600; }
.etage.encours { font-weight: 700; box-shadow: 4px 4px 0 var(--ombre); outline: 3px solid var(--trait); outline-offset: 2px; }
.etage.ferme { border-style: dashed; opacity: .6; }
.etage.plustard { border-style: dotted; opacity: .35; }
.consigne { margin: .4rem 0 0; font-size: .75rem; color: var(--gris); }

/* Page de lecture d'une marche : tout l'écran, comme une page de livre */
.voile.plein-ecran .feuille { max-height: 100dvh; height: 100dvh; border-radius: 0; }
.lecture p { line-height: 1.6; margin: 0 0 .9rem; }
.lecture h3 { margin-top: 1.5rem; }
.lecture-tete { margin: -1.5rem -1.25rem 1.25rem; padding: 2rem 1.25rem 1.25rem; border-bottom: 2.5px solid var(--trait); color: #221F1B; }
.lecture-tete h2 { margin: .4rem 0 0; font-family: "Fraunces", serif; font-size: 1.7rem; line-height: 1.15; }
.lecture-tete.foret { background: var(--foret); color: var(--foret-texte); }
.lecture-tete.orange { background: var(--orange); }
.lecture-tete.violet { background: var(--violet); }
.lecture-tete.lime { background: var(--lime); }
.lecture-tete.rose { background: var(--rose); }

.defile {
  overflow: hidden;
  margin: 2rem -1rem;
  padding: .7rem 0;
  background: var(--brun);
  color: #FBF7F0;
  border-block: 2.5px solid var(--trait);
  transform: rotate(-1.5deg);
}
.defile div { display: flex; width: max-content; animation: defile 28s linear infinite; }
.defile span { font-family: "Fraunces", serif; font-style: italic; font-size: 1.35rem; padding-right: 1.5rem; white-space: nowrap; }
@keyframes defile { to { transform: translateX(-50%); } }

.bandeau {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: 1rem;
  margin: 1rem 0;
  border: 2.5px solid var(--trait);
  border-radius: 18px;
  background: var(--peche);
}
.bandeau.alerte { background: var(--orange); color: #221F1B; }
.bandeau p { margin: 0; }

.liste-zero .habitude { padding: 1rem 0; }
textarea {
  width: 100%;
  min-height: 5.5rem;
  margin-top: .35rem;
  padding: .75rem;
  border: 2.5px solid var(--trait);
  border-radius: 12px;
  background: var(--surface);
  color: var(--encre);
  font: inherit;
  resize: vertical;
}
label.champ { display: block; margin-top: 1rem; font-weight: 600; }

.resultats { display: grid; gap: .6rem; margin-top: 1rem; }
.resultat { display: grid; grid-template-columns: 1fr auto; gap: .2rem .75rem; align-items: center; }
.resultat .compte { grid-column: 1 / -1; margin: 0; }

.pied { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; margin-top: 2rem; }
.pied .bouton { flex: 1 1 12rem; }

/* Voile : fête, blocage, installation */
.voile {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  background: rgba(23, 21, 15, .55);
  transition: opacity 220ms ease;
}
@starting-style { .voile { opacity: 0; } .feuille { transform: translateY(12%); } }
.feuille {
  max-height: 88dvh;
  overflow: auto;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  background: var(--fond);
  border: 2.5px solid var(--trait);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1);
}
.fete {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  overflow: hidden;
  background: var(--foret);
  color: var(--foret-texte);
  text-align: center;
  transition: opacity 300ms ease;
}
@starting-style { .fete { opacity: 0; } .fete .contenu { transform: scale(.94); } }
.fete .contenu { max-width: 26rem; transition: transform 420ms var(--sortie); }
.fete h1 { font-size: 3rem; }
.fete em { color: var(--lime); }
.fete .bouton { margin-top: 1.5rem; }
.fete .sticker { position: static; display: inline-block; margin: 0 .25rem 1rem; }
.confetti { position: absolute; top: -2rem; width: .7rem; height: 1.1rem; border: 1.5px solid #221F1B; border-radius: 3px; animation: tombe 3.2s var(--sortie) forwards; }
@keyframes tombe { to { transform: translateY(110dvh) rotate(540deg); } }

.apercu {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  padding: .6rem .75rem calc(.6rem + env(safe-area-inset-bottom));
  background: #221F1B;
  border-top: 3px solid var(--orange);
}
/* La barre d'aperçu ne doit pas cacher le bas des volets. */
.apercu ~ .voile .feuille { padding-bottom: 5.5rem; }
.apercu span { color: var(--orange); align-self: center; white-space: nowrap; padding-right: .3rem; }
.apercu button {
  flex: none;
  padding: .45rem .7rem;
  border: 1.5px solid #FBF7F0;
  border-radius: 999px;
  background: transparent;
  color: #FBF7F0;
  font-family: "DM Mono", monospace;
  font-size: .75rem;
  cursor: pointer;
}
.apercu button.actif { background: var(--orange); border-color: var(--orange); color: #221F1B; }

.vide { min-height: 70dvh; display: grid; align-content: center; }

@media (prefers-reduced-motion: reduce) {
  .defile div, .confetti { animation: none; }
  .confetti { display: none; }
  * { transition-duration: 0ms !important; }
}

/* Carte verte cliquable de la semaine 0 */
.carte-clic { display: block; width: 100%; text-align: left; font: inherit; cursor: pointer; transition: transform 140ms var(--sortie), box-shadow 140ms var(--sortie); }
.carte-clic:active { transform: translate(2px, 2px) scale(.99); box-shadow: 2px 2px 0 var(--ombre); }
.carte-clic .voir { display: inline-block; margin-top: .5rem; font-weight: 600; color: var(--lime); text-decoration: underline; text-underline-offset: 3px; }
.feuille h3 { margin: 1.25rem 0 .5rem; font-size: 1rem; }
.prepa { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.prepa li { padding: .6rem .8rem; border: 2px solid var(--trait); border-radius: 12px; background: var(--surface); }
.prepa small { display: block; color: var(--gris); margin-top: .2rem; }

/* Installer : étapes qui se déroulent */
.deroule { margin: 0; flex: 1; }
.deroule summary::before, .deroule[open] summary::before { content: none; }
.deroule summary small::after { content: " ▾"; }
.deroule[open] summary small::after { content: " ▴"; }
.etapes { margin: .75rem 0 .5rem; padding-left: 1.3rem; display: grid; gap: .45rem; }
.etapes li::marker { font-family: "DM Mono", monospace; font-weight: 500; color: var(--orange); }

/* Signal de réussite */
.gagne .case { animation: gagne 520ms var(--sortie); }
@keyframes gagne { 0% { transform: scale(.8); } 45% { transform: scale(1.25) rotate(-6deg); box-shadow: 0 0 0 8px color-mix(in srgb, var(--lime) 55%, transparent); } 100% { transform: scale(1); } }
.bravo {
  position: fixed; left: 50%; bottom: calc(5rem + env(safe-area-inset-bottom)); z-index: 40;
  display: flex; gap: .75rem; align-items: center;
  padding: .75rem 1.1rem; border: 2.5px solid #221F1B; border-radius: 999px;
  background: var(--lime); color: #221F1B; box-shadow: 3px 3px 0 #221F1B;
  transform: translateX(-50%) rotate(-2deg);
  transition: transform 260ms var(--sortie), opacity 260ms ease;
}
@starting-style { .bravo { opacity: 0; transform: translateX(-50%) translateY(1rem) scale(.95); } }
@media (prefers-reduced-motion: reduce) { .gagne .case { animation: none; } }
.apercu ~ .bravo { bottom: 8.5rem; }

/* Onglets du bas : le parcours et la bibliothèque, toujours à portée du pouce */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: grid; grid-template-columns: 1fr 1fr; gap: .5rem;
  padding: .6rem .75rem calc(.6rem + env(safe-area-inset-bottom));
  background: var(--fond); border-top: 2.5px solid var(--trait);
}
.onglets button {
  padding: .7rem .5rem; border: 2px solid var(--trait); border-radius: 999px;
  background: var(--surface); color: var(--encre);
  font: 600 .9rem/1.2 "Bricolage Grotesque", system-ui, sans-serif;
  cursor: pointer; transition: transform 140ms var(--sortie);
}
.onglets button:active { transform: scale(.97); }
.onglets button.actif { background: var(--encre); color: var(--fond); }
main:has(~ .apercu) .onglets { bottom: 3.6rem; }
.fiches { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .6rem; }
.fiches li { padding: .8rem 1rem; border: 2px solid var(--trait); border-radius: 14px; background: var(--surface); box-shadow: 3px 3px 0 var(--ombre); }
.fiches small { display: block; margin-top: .25rem; color: var(--gris); }
