/* Kagu, « Jour » : un mur peint, une niche de lumière, des phrases. */

:root {
  /* couleurs : le mur, l'encre, la lumière (niche + sol), un seul accent */
  --mur: #B4CDBB;
  --encre: #16241F;
  --encre-douce: #2B4338;
  --lumiere: #FFF8E6;
  --sol-fond: #EBD9AC;
  --sol-avant: #FBF1D3;
  --accent: #9A2B16;          /* vermillon foncé : 4,5:1 sur le mur, 7:1 sur la lumière */

  /* surfaces des touches et leurs états */
  --touche: #D6E1CF;
  --touche-survol: #E6EEDF;
  --touche-appui: #A9C6B2;
  --touche-suivant: #93B49F;
  --touche-suivant-survol: #A2C0AE;
  --touche-suivant-appui: #7A9C87;
  --encre-survol: #22372F;
  --encre-appui: #2E463C;
  --bord-bas: 0 2px 0 rgba(22, 36, 31, 0.22);

  /* typographie */
  --serif: "Young Serif", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --t-info: 14px;
  --t-corps: 16px;
  --t-serif-s: 18px;
  --t-serif-m: 20px;

  /* formes et mouvement */
  --r-s: 9px;
  --r-m: 14px;
  --r-pill: 999px;
  --ease: cubic-bezier(.3, .7, .2, 1);

  --colonne: 430px;
  --marge: 16px;
  --apercu: 64px;             /* hauteur du meuble suivant qui dépasse en bas */
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--mur);
  color: var(--encre);
  font-family: var(--sans);
  font-size: var(--t-corps);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

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

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
a { color: inherit; }

:focus-visible { outline: 3px solid var(--encre); outline-offset: 3px; border-radius: 6px; }

/* ---------- colonne ---------- */
.screen {
  width: min(100%, var(--colonne));
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  padding: 0 var(--marge);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.screen.defile { scrollbar-width: none; overflow-y: auto; overflow-x: hidden; display: block; padding-bottom: 40px; }
.screen.defile::-webkit-scrollbar { display: none; }

/* ---------- haut de page ---------- */
.haut {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-top: max(2px, env(safe-area-inset-top));
}
.screen.defile .haut {
  position: sticky; top: 0; z-index: 3;
  margin: 0 calc(var(--marge) * -1);
  padding: 0 var(--marge);
  background: var(--mur);
}
.marque {
  font-family: var(--serif);
  font-size: 22px;
  text-decoration: none;
  display: inline-flex; align-items: center; min-height: 48px;
}
.lien {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 0 0 16px;
  font-size: var(--t-corps); font-weight: 500;
  text-decoration: underline; text-decoration-thickness: 0.08em; text-underline-offset: 0.2em;
}
.lien.gauche { padding: 0 16px 0 0; }

/* ---------- écran 1 : niche écho + pastilles ---------- */
.niche-zone {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  padding-bottom: 54px;           /* réserve des pastilles : rien ne bouge quand elles apparaissent */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.niche {
  background: var(--lumiere);
  border-radius: var(--r-s);
  box-shadow: inset 0 7px 9px -6px rgba(22, 36, 31, 0.2);
  width: 40px; height: 90px;
  transition: width 340ms var(--ease), height 340ms var(--ease);
}
.pastilles {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 6px;
  height: 48px;
  visibility: hidden;
}
.pastilles.visible { visibility: visible; }
.pastille {
  flex: 1;
  border-radius: var(--r-pill);
  background: var(--touche);
  box-shadow: var(--bord-bas);
  font-family: var(--sans);
  font-weight: 500;
  font-size: var(--t-serif-m);
  touch-action: manipulation;
}

/* ---------- la phrase ---------- */
.phrases { flex: none; padding: 8px 0 10px; }
.grande {
  margin: 0;
  font-family: var(--serif);
  font-size: 27px;
  line-height: 1.42;
  letter-spacing: -0.003em;
}
.petite {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: var(--t-serif-s);
  line-height: 1.7;
  color: var(--encre-douce);
}

.hole {
  position: relative;
  display: inline-block;
  min-width: 1.4em;
  padding: 0 0.12em;
  line-height: 1.15;
  text-align: center;
  font-variant-numeric: lining-nums proportional-nums;
  color: var(--encre);
  border-radius: 0.22em;
  cursor: pointer;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
/* zone de toucher : la hauteur de la ligne, sans chevaucher la ligne voisine */
.hole::before { content: ""; position: absolute; inset: -4px -10px; }
.hole .n {
  display: inline-block;
  text-decoration: underline;
  text-decoration-thickness: 0.075em;
  text-underline-offset: 0.16em;
}
.hole.actif { background: var(--accent); color: var(--lumiere); }
.hole.actif .n { text-decoration-color: transparent; }
.hole.actif:focus-visible { outline: none; }
.petite .hole { min-width: 1.7em; color: var(--encre); }
.petite .hole.actif { color: var(--lumiere); }

/* ---------- action ---------- */
.action { flex: none; display: flex; flex-direction: column; align-items: stretch; }
.cta {
  height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: var(--r-m);
  background: var(--encre);
  color: var(--lumiere);
  font-size: var(--t-serif-s);
  font-weight: 600;
  letter-spacing: 0.002em;
  padding: 0 16px;
  touch-action: manipulation;
}
.cta .nb { font-family: var(--serif); font-weight: 400; font-size: 1.08em; }
.cta .petit { display: block; font-size: var(--t-info); font-weight: 500; line-height: 1.2; opacity: 0.8; }
.cta .gros { display: block; font-size: var(--t-corps); line-height: 1.25; }
.cta.rien { background: transparent; color: var(--encre); cursor: default; font-weight: 500; }

/* ---------- pavé ---------- */
.pave {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin: 6px 0 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.touche {
  height: clamp(48px, 7.2dvh, 60px);
  border-radius: var(--r-m);
  background: var(--touche);
  box-shadow: var(--bord-bas);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 28px;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
.touche.texte { font-size: var(--t-corps); }
.touche.suivant { background: var(--touche-suivant); }

/* ---------- écran 2 ---------- */
.haut2 { flex-direction: column; align-items: flex-start; justify-content: center; margin-bottom: 0; }
.rappel {
  min-height: 48px;
  max-width: 100%;
  text-align: left;
  font-size: var(--t-corps);
  white-space: nowrap;
  text-decoration: underline; text-decoration-thickness: 0.07em; text-underline-offset: 0.22em;
  color: var(--encre-douce);
}
.rappel .nb, .fiche .nb { font-family: var(--serif); font-size: 1.08em; color: var(--encre); }
.note, .changement { margin: -8px 0 6px; font-size: var(--t-info); line-height: 1.35; color: var(--encre-douce); }
.note.cachee { visibility: hidden; }
.changement { margin-top: -4px; color: var(--encre); }
.remettre {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 6px; margin-left: 2px;
  font-weight: 600;
  text-decoration: underline; text-decoration-thickness: 0.08em; text-underline-offset: 0.2em;
}

.snap {
  flex: 1 1 0;
  min-height: 0;
  margin: 0 calc(var(--marge) * -1);
  padding: 0 var(--marge);
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.snap::-webkit-scrollbar { display: none; }
.page {
  height: var(--page-h, 100%);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  padding-bottom: 6px;
}
.snap-fin { height: var(--apercu); }
.stage { flex: 1 1 0; min-height: 120px; position: relative; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }

.nom {
  margin: 6px 0 4px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.08;
}
.ligne { margin: 0 0 8px; font-family: var(--serif); font-size: var(--t-serif-m); line-height: 1.3; }
.pile { font-style: normal; color: var(--accent); }
.argument { margin: 0 0 8px; font-size: var(--t-corps); line-height: 1.4; color: var(--encre); }
.argument span { display: block; }
.argument .plinthe { font-size: var(--t-info); color: var(--encre-douce); margin-top: 2px; }
.prix { margin: 0; display: flex; align-items: baseline; gap: 10px; }
.prix-v { font-family: var(--serif); font-size: 22px; line-height: 1.2; }
.prix-f { font-size: var(--t-corps); color: var(--encre-douce); }
.fiche { margin: 0; font-size: var(--t-corps); line-height: 1.45; color: var(--encre-douce); }

.compteur {
  position: fixed;
  right: max(var(--marge), calc(50vw - var(--colonne) / 2 + var(--marge)));
  bottom: max(10px, env(safe-area-inset-bottom));
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  background: var(--touche);
  box-shadow: var(--bord-bas);
  font-family: var(--serif);
  font-size: var(--t-serif-s);
  white-space: nowrap;
  touch-action: manipulation;
}

/* page « à 1 ou 2 cm près » */
.page.pres { justify-content: flex-start; padding-top: 24px; }
.pres-titre { margin: 0 0 6px; font-family: var(--serif); font-weight: 400; font-size: 36px; line-height: 1.1; }
.pres-sous { margin: 0 0 14px; font-size: var(--t-corps); color: var(--encre-douce); }
.pres-liste { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.pres-ligne {
  display: block; width: 100%; min-height: 48px; padding: 8px 0; text-align: left;
  font-family: var(--serif); font-size: var(--t-serif-m); line-height: 1.35;
  text-decoration: underline; text-decoration-thickness: 0.065em; text-underline-offset: 0.2em;
  text-decoration-color: rgba(22, 36, 31, 0.55);
}
.pres-vide { font-family: var(--serif); font-size: var(--t-serif-m); line-height: 1.35; }

/* ---------- vue d'ensemble ---------- */
.tris { display: flex; gap: 2px; }
.tri { min-height: 48px; padding: 0 10px; font-size: var(--t-corps); font-weight: 500; color: var(--encre-douce); }
.tri:last-child { padding-right: 0; }
.tri[aria-pressed="true"] {
  color: var(--encre);
  text-decoration: underline; text-decoration-thickness: 0.09em; text-underline-offset: 0.25em;
}
.ens-titre { margin: 4px 0 10px; font-family: var(--serif); font-size: 24px; line-height: 1.25; }
.rangees { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 12px; }
.cellule { display: block; text-align: left; width: 100%; min-width: 0; padding: 0; border-radius: var(--r-m); }
.cellule svg { display: block; width: 100%; height: 188px; overflow: visible; }
.cellule .ens-nom { display: block; margin-top: 8px; font-family: var(--serif); font-size: var(--t-serif-s); line-height: 1.2; }
.cellule .ens-info { display: block; margin-top: 2px; font-size: var(--t-corps); color: var(--encre); }

/* ---------- écran 3 : la photo ---------- */
.scene {
  flex: 0 1 min(540px, 64dvh);
  min-height: 90px;
  border-radius: var(--r-m);
  overflow: hidden;
  margin-bottom: 14px;
  background: #E3D6C6;
}
.scene svg { display: block; width: 100%; height: 100%; }
.scene .voile { opacity: 0; transition: opacity 700ms var(--ease); }
.scene.lue .voile { opacity: 1; }

.lecture { flex: none; }
.lecture .grande { font-size: 25px; line-height: 1.4; }
.mots { margin: 10px 0 0; font-size: var(--t-corps); line-height: 1.45; }
.verifier { margin: 6px 0 0; font-size: var(--t-info); color: var(--encre-douce); }
.action3 { margin: auto 0 0; padding-top: 14px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.screen.edite .mots, .screen.edite .verifier { display: none; }
.screen.edite .action3 { padding-bottom: 0; }

/* ---------- mouvement : la niche, le chiffre, le meuble, rien d'autre ---------- */
@media (prefers-reduced-motion: reduce) {
  .niche, .scene .voile { transition: none; }
}

/* ---------- survol (souris) puis appui (doigt) : l'appui gagne toujours ---------- */
@media (hover: hover) {
  .touche:hover, .pastille:hover, .compteur:hover { background: var(--touche-survol); }
  .touche.suivant:hover { background: var(--touche-suivant-survol); }
  .cta:hover { background: var(--encre-survol); }
  .cta.rien:hover { background: transparent; }
}
.cta:active { background: var(--encre-appui); }
.cta.rien:active { background: transparent; }
.touche:active, .pastille:active, .compteur:active {
  background: var(--touche-appui);
  box-shadow: none;
  transform: translateY(2px);
}
.touche.suivant:active { background: var(--touche-suivant-appui); }
.lien:active, .marque:active, .rappel:active, .tri:active, .pres-ligne:active,
.cellule:active, .remettre:active { opacity: 0.55; }
