/* Palette pensée pour le daltonisme : les couleurs se distinguent par la luminosité (sapin très sombre,
   vermillon moyen, or et neige clairs), pas seulement par la teinte. */
:root { --vert: #0b3323; --sapin: #145a3a; --rouge: #c8371f; --rouge-fonce: #a3281a; --or: #f4c95d; --creme: #f7f1e6; --encre: #1d1a16; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.vh { position: absolute !important; inset: auto !important; width: 1px !important; height: 1px !important; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body { margin: 0; min-height: 100vh; background: var(--vert); color: var(--creme);
  font: 1.0625rem/1.5 system-ui, sans-serif; overflow-wrap: anywhere; }
header, main { max-width: 46rem; margin: 0 auto; padding: 0 .75rem; }
header { text-align: center; }
h1 { font-family: Georgia, serif; color: var(--or); font-size: 1.75rem; margin: 1rem 0 .5rem; }

.bandeau { position: sticky; top: 0; z-index: 2; background: var(--rouge); color: #fff;
  text-align: center; padding: .4rem .75rem; border-bottom: 3px solid var(--or); }
.bandeau p { margin: 0; }
#rebours { font-weight: 700; }
#phrase { font-size: .9rem; }
@media (max-height: 30rem) { .bandeau { position: static; } }

button { font: inherit; cursor: pointer; border-radius: .5rem; border: 2px solid var(--or);
  background: transparent; color: inherit; padding: .5rem 1rem; min-height: 2.75rem; min-width: 2.75rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.action, #partager { background: var(--rouge); color: #fff; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
dialog :focus-visible { outline-color: var(--rouge); }
.outils { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin: 1rem 0; }

#message { text-align: center; font-weight: 700; color: var(--or); }
fieldset { border: 2px solid var(--or); border-radius: .75rem; min-width: 0; }
legend { font-weight: 700; padding: 0 .5rem; }
#themes label { display: flex; align-items: center; gap: .75rem; padding: .6rem .25rem; cursor: pointer; }
#themes input { width: 1.5rem; height: 1.5rem; flex: none; accent-color: var(--rouge); }
#valider { display: block; margin: 1rem auto; }

#grille { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; padding: 0; list-style: none; }
@media (min-width: 36rem) { #grille { grid-template-columns: repeat(6, 1fr); gap: .75rem; } }
.porte { position: relative; display: block; width: 100%; aspect-ratio: 1; padding: 0; border: 0;
  perspective: 20rem; background: var(--creme); }
.porte span { position: absolute; inset: 0; display: grid; place-items: center; border-radius: .5rem;
  font: 700 1.5rem Georgia, serif; }
.porte { background: var(--or); }
.porte .fond { color: var(--vert); }
.porte .fond::after { content: var(--n) / ""; margin-left: .3rem; }
.porte .battant { background: var(--rouge); color: #fff; border: 2px solid var(--or);
  transform-origin: left; transition: transform .7s ease; box-shadow: inset 0 0 0 3px rgb(255 255 255 / .12); }
/* Damier vermillon / neige, comme un sucre d'orge. */
.neige-porte .battant { background: var(--creme); color: var(--rouge-fonce); border-color: var(--rouge); }
.porte.fermee .battant { border-style: dashed; }
.porte.fermee .battant::after { content: "🔒" / ""; position: absolute; top: .2rem; right: .25rem; font-size: .7rem; }
.porte.aujourdhui { outline: 3px solid var(--or); outline-offset: 3px; }
.porte.aujourdhui::after { content: "Aujourd’hui" / ""; position: absolute; left: 50%; bottom: -.15rem; transform: translateX(-50%);
  background: var(--or); color: var(--encre); font: 700 .6rem/1.4 system-ui, sans-serif; padding: 0 .2rem; border-radius: .25rem; white-space: nowrap; }
.porte.ouverte .battant { transform: rotateY(-105deg); color: transparent; }
/* Le battant ouvert passe sous les portes voisines, sans cacher leur numéro. */
.porte { z-index: 1; }
.porte.ouverte { z-index: 0; }

dialog { width: min(34rem, calc(100% - 1.5rem)); max-height: calc(100% - 1.5rem); border: 4px solid var(--or);
  border-radius: 1rem; background: var(--creme); color: var(--encre); padding: 1rem 1.25rem; }
dialog::backdrop { background: rgb(0 0 0 / .7); }
dialog h2 { font-family: Georgia, serif; color: var(--rouge-fonce); margin: .25rem 0 .75rem; line-height: 1.25; }
dialog button { border-color: var(--rouge); }
dialog a { color: var(--rouge-fonce); font-weight: 700; }
#case-jour { margin: 0; font-weight: 700; color: var(--sapin); }
.texte { white-space: pre-line; }
img, audio { max-width: 100%; height: auto; }
.liste-choix { display: grid; gap: .5rem; }
.memory { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.memory .carte { aspect-ratio: 1; padding: 0; min-width: 0; font-size: 1.5rem; }
.retour, .reponse { font-weight: 700; }
.bon { border: 3px dashed var(--rouge); border-radius: .5rem; padding: .75rem; text-align: center; font-weight: 700; }

.pluie { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.pluie span { position: absolute; top: -2rem; animation: chute linear infinite; opacity: .6; }
#fete { z-index: 3; }
#fete span { font-size: 1.75rem; opacity: 1; animation-iteration-count: 1; animation-fill-mode: both; }
@keyframes chute { to { transform: translateY(110vh) rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pluie { display: none; } .porte .battant { transition: none; } }

#archive { display: none; }
@media print {
  body { background: #fff; color: #000; }
  body > * { display: none !important; }
  body > #archive { display: block !important; padding: 0 1rem; }
  #archive h1, #archive h2 { color: #000; }
  article { border-top: 1px solid #000; }
  h2, h3 { break-after: avoid; }
}
