/* Le coloriage mystère en ligne (prototype). Chargée par la seule page mystere-en-ligne.html, APRÈS maquette.css, dont
   elle ne prend que les couleurs et les polices. Tout ce qui est propre à la page porte le préfixe my.
   Téléphone d'abord, tenu en portrait : la grille prend l'écran, la légende est en bas, sur une rangée qui défile. */
html:has(.my-page) { overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }
.my-page { margin: 0; overflow: hidden; }
.my, .my *, .my-feuillet, .my-feuillet * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
.my [hidden], .my-feuillet [hidden] { display: none !important; }
.my button, .my-feuillet button { font: inherit; color: inherit; cursor: pointer; }

.my { position: fixed; inset: 0; display: grid; grid-template: 'barre' auto 'scene' minmax(0, 1fr) 'palette' auto / minmax(0, 1fr); height: 100dvh; background: var(--kraft); color: var(--encre); font-family: var(--texte, system-ui, sans-serif); font-size: 16px; line-height: 1.4; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* ---------- La barre ---------- */
.my__barre { grid-area: barre; display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: var(--papier); border-bottom: 1.5px solid var(--trait); }
.my-bouton { flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1.5px solid transparent; border-radius: 12px; background: none; color: var(--encre); text-decoration: none; transition: background 0.12s ease, opacity 0.12s ease; }
.my-bouton svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.my-bouton:hover { background: var(--kraft); }
.my-bouton:disabled { opacity: 0.3; cursor: default; background: none; }
.my__nom { flex: 0 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 4px; height: 44px; padding: 0 8px; border: 0; border-radius: 12px; background: none; font-family: var(--titre, Georgia, serif); font-weight: 620; font-size: 18px; letter-spacing: -0.01em; }
.my__nom span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.my__nom svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.my__nom:hover { background: var(--kraft); }
.my__reste { flex: none; display: flex; flex-direction: column; align-items: stretch; gap: 3px; margin: 0 4px 0 auto; font-size: 13.5px; font-weight: 600; color: var(--encre-douce); white-space: nowrap; }
.my__sur, .my__reste-avant { display: none; }
@media (max-width: 899px) { .my__barre .my-bouton { width: 40px; } .my__nom { padding: 0 4px; font-size: 17px; } }
.my__jauge { display: block; min-width: 70px; height: 6px; border-radius: 3px; background: var(--trait); overflow: hidden; }
.my__jauge i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--c-sapin-vif, #4fae78); transition: width 0.25s ease; }

/* ---------- La scène : la feuille, qu'on zoome et qu'on déplace ---------- */
.my__scene { grid-area: scene; position: relative; overflow: hidden; touch-action: none; cursor: grab; }
.my__scene--tire { cursor: grabbing; }
.my__scene--attente::after { content: ''; position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px; border: 3px solid var(--trait-fort); border-top-color: var(--encre); border-radius: 50%; animation: my-tourne 0.8s linear infinite; }
@keyframes my-tourne { to { transform: rotate(360deg); } }
/* Le SVG déborde de 240 px autour de la scène (DEBORD dans le script) et se déplace par transformation pendant un geste. */
.my__dessin { position: absolute; left: -240px; top: -240px; width: calc(100% + 480px); height: calc(100% + 480px); display: block; transform-origin: 0 0; will-change: transform; }
.my__feuille { fill: #fff; }
/* Une case vide : blanche, un filet gris. Une case remplie : sa couleur, bordée de sa couleur, pour que la grille
   disparaisse entre deux cases faites. Les cases remplies sont rangées en tête : les filets des cases vides restent
   ainsi par-dessus. */
.my__cases path { fill: #fff; stroke: #b7b0a4; stroke-width: 1px; vector-effect: non-scaling-stroke; stroke-linejoin: round; cursor: pointer; }
.my__cases path.vise { fill: #d3dae6; stroke: #6f7c93; cursor: cell; }
.my__cases path.faite { fill: var(--c); stroke: none; cursor: inherit; }
/* Le joint d'une case remplie : son contour, SOUS les cases, pour fermer le jour entre deux voisines sans mordre sur elles. */
.my__joints { pointer-events: none; }
.my__joints path { fill: none; stroke: var(--c); stroke-width: 1.5px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.my__cases path.refus { animation: my-refus 0.45s ease; }
@keyframes my-refus { 0%, 100% { fill: #fff; } 30%, 70% { fill: #f6c9bd; } }
.my__cases path.pose { animation: my-pose 0.3s ease-out; }
@keyframes my-pose { from { fill-opacity: 0.25; } to { fill-opacity: 1; } }
.my__signes { pointer-events: none; }
.my__signes text { font-family: Arial, Helvetica, sans-serif; font-weight: 700; fill: #7a7266; text-anchor: middle; dominant-baseline: central; }
.my__signes text.vise { fill: #1d1a16; }
/* De loin, les signes des petites cases ne sont que du bruit : le script les cache sous une taille lisible. */
.my__dessin[data-loin='2'] .my__signes text.petit, .my__dessin[data-loin='2'] .my__signes text.moyen, .my__dessin[data-loin='1'] .my__signes text.petit { display: none; }
.my__dessin--fini .my__cases path { cursor: inherit; }

.my__zoom { position: absolute; right: 8px; top: 8px; display: grid; gap: 4px; padding: 3px; border-radius: 14px; background: rgba(250, 246, 238, 0.92); box-shadow: 0 1px 0 rgba(29, 26, 22, 0.05), 0 8px 18px -10px rgba(29, 26, 22, 0.4); }
.my__zoom .my-bouton { width: 40px; height: 40px; }
.my__mot { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); max-width: calc(100% - 24px); margin: 0; padding: 7px 14px; border-radius: 999px; background: var(--encre); color: var(--papier); font-size: 14.5px; font-weight: 600; text-align: center; pointer-events: none; animation: my-mot 0.18s ease-out; }
.my__mot i { display: inline-block; width: 13px; height: 13px; margin: 0 5px -1px 2px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.75); }
@keyframes my-mot { from { opacity: 0; transform: translate(-50%, 6px); } }
.my__panne { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; font-weight: 600; }

/* L'écran de fin : un bandeau au bas de la scène, l'image finie reste visible au-dessus. */
.my__fin { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(calc(100% - 20px), 540px); padding: 14px 16px 14px; border-radius: 16px; background: var(--papier); box-shadow: 0 2px 0 rgba(29, 26, 22, 0.05), 0 22px 30px -14px rgba(29, 26, 22, 0.45); text-align: center; animation: my-fin 0.45s ease-out 0.25s backwards; }
@keyframes my-fin { from { opacity: 0; transform: translate(-50%, 14px); } }
.my__fin-titre { margin: 0; font-family: var(--titre, Georgia, serif); font-weight: 620; font-size: 21px; letter-spacing: -0.012em; }
.my__fin-nom { margin: 2px 0 12px; color: var(--encre-douce); font-size: 15px; }
.my__fin-gestes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0; }
.my__geste svg { flex: none; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.my__fin-suite { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; margin: 10px 0 0; font-size: 14.5px; }
.my__fin-suite a, .my__fin-suite button { padding: 4px 2px; border: 0; background: none; color: var(--encre-douce) !important; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.my__fin-suite a:hover, .my__fin-suite button:hover { color: var(--encre) !important; }
.my__geste { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 0 16px; border: 1.5px solid var(--encre); border-radius: 999px; background: none; font-weight: 700; font-size: 15.5px; }
.my__geste:hover { background: var(--kraft); }
.my__geste--plein { background: var(--encre); color: var(--papier) !important; }
.my__geste--plein:hover { background: #3a342c; }

/* ---------- La légende : une couleur, son signe, ce qui reste ---------- */
.my__palette { grid-area: palette; display: flex; gap: 8px; padding: 9px 10px calc(9px + env(safe-area-inset-bottom, 0px)); background: var(--papier); border-top: 1.5px solid var(--trait); overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.my__palette::-webkit-scrollbar { display: none; }
.my-couleur { flex: none; position: relative; display: grid; justify-items: center; gap: 7px; width: 54px; padding: 6px 0 2px; border: 0; background: none; }
.my-couleur b { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--c); color: var(--sur); font: 700 19px/1 Arial, Helvetica, sans-serif; box-shadow: inset 0 0 0 1.5px rgba(29, 26, 22, 0.22); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.my-couleur small { font-size: 12px; font-weight: 600; color: var(--encre-douce); line-height: 1.1; }
.my-couleur[aria-pressed='true'] b { transform: scale(1.06); box-shadow: inset 0 0 0 1.5px rgba(29, 26, 22, 0.22), 0 0 0 2.5px var(--papier), 0 0 0 5px var(--encre); }
.my-couleur[aria-pressed='true'] small { color: var(--encre); }
.my-couleur--finie b { opacity: 0.45; font-size: 0; }
.my-couleur--finie b::after { content: ''; width: 18px; height: 10px; border: solid var(--sur); border-width: 0 0 3px 3px; transform: translateY(-3px) rotate(-45deg); }
.my-couleur--finie small { visibility: hidden; }

/* ---------- Les feuillets : le choix du dessin, la confirmation ---------- */
.my-feuillet { width: min(100vw - 20px, 620px); max-height: min(100dvh - 20px, 760px); padding: 16px 18px 18px; border: 0; border-radius: 18px; background: var(--papier); color: var(--encre); font-family: var(--texte, system-ui, sans-serif); box-shadow: 0 30px 60px -20px rgba(29, 26, 22, 0.6); }
.my-feuillet::backdrop { background: rgba(29, 26, 22, 0.45); }
.my-feuillet--petit { width: min(100vw - 20px, 400px); text-align: center; }
.my-feuillet h2 { margin: 0; font-family: var(--titre, Georgia, serif); font-weight: 620; font-size: 23px; letter-spacing: -0.014em; line-height: 1.2; }
.my-feuillet__tete { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.my-feuillet__mot { margin: 6px 0 14px; color: var(--encre-douce); font-size: 14.5px; }

/* ---------- Les aides ---------- */
/* « Où ? » : en bas à droite de la scène, sous le pouce. */
.my__montrer { position: absolute; right: 8px; bottom: 10px; display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 11px; border: 1.5px solid var(--encre); border-radius: 999px; background: var(--papier); font-weight: 700; font-size: 15px; box-shadow: 0 8px 18px -10px rgba(29, 26, 22, 0.5); }
.my__montrer svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.my__montrer:hover { background: var(--kraft); }
/* Les anneaux : autour de la case montrée (fort) et des dernières cases d'une couleur. */
.my__reperes { pointer-events: none; }
.my__reperes circle { fill: none; stroke: #e0532f; stroke-width: 2.5px; vector-effect: non-scaling-stroke; animation: my-anneau 1.5s ease-in-out infinite; }
.my__reperes circle.fort { stroke: #1d1a16; stroke-width: 3.5px; animation-duration: 0.75s; }
@keyframes my-anneau { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: 0.25; } }
/* Au doigt, la pince zoome : les boutons + et − ne feraient que couvrir la feuille. */
@media (pointer: coarse) { .my__zoom-pas { display: none; } }
/* Pour les lecteurs d'écran seulement. */
.my__annonce { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.my :focus-visible, .my-feuillet :focus-visible { outline: 3px solid var(--c-ciel-fort, #2167a1); outline-offset: 2px; }

/* ---------- La galerie : les dessins en images, par section ---------- */
.my-galerie { width: min(100vw - 16px, 1040px); height: min(100dvh - 16px, 900px); max-height: none; padding: 0; overflow: hidden; }
.my-galerie[open] { display: grid; grid-template: auto minmax(0, 1fr) auto / minmax(0, 1fr); }
.my-galerie__pied { margin: 0; padding: 10px 16px; border-top: 1.5px solid var(--trait); text-align: center; font-size: 14.5px; }
.my-galerie__pied a { color: var(--encre) !important; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.my-galerie__tete { padding: 14px 16px 10px; border-bottom: 1.5px solid var(--trait); }
.my-galerie__sauts { display: flex; gap: 6px; margin: 10px -16px 0; padding: 0 16px 2px; overflow-x: auto; scrollbar-width: none; }
.my-galerie__sauts::-webkit-scrollbar { display: none; }
.my-galerie__sauts button { flex: none; height: 36px; padding: 0 14px; border: 1.5px solid var(--trait-fort); border-radius: 999px; background: #fff; font-weight: 600; font-size: 14.5px; }
.my-galerie__sauts button:hover { border-color: var(--encre); }
.my-galerie__corps { overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 20px; }
.my-galerie__corps h3 { margin: 18px 0 10px; font-family: var(--titre, Georgia, serif); font-weight: 620; font-size: 20px; letter-spacing: -0.012em; }
.my-galerie__liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 16px 12px; margin: 0; padding: 0; list-style: none; }
.my-carte { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.my-carte__image { position: relative; display: block; aspect-ratio: 260 / 368; border-radius: 4px; background: #fff; overflow: hidden; box-shadow: 0 0 0 1px rgba(29, 26, 22, 0.12), 0 10px 18px -12px rgba(29, 26, 22, 0.4); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.my-carte__image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.my-carte:hover .my-carte__image { transform: translateY(-3px); box-shadow: 0 0 0 1px rgba(29, 26, 22, 0.2), 0 18px 24px -14px rgba(29, 26, 22, 0.5); }
.my-carte[aria-current='true'] .my-carte__image { box-shadow: 0 0 0 3px var(--encre); }
.my-carte__image i { position: absolute; left: 0; bottom: 0; height: 6px; background: var(--c-sapin-vif, #4fae78); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8); }
.my-carte__image em { position: absolute; left: 6px; top: 6px; padding: 2px 9px; border-radius: 999px; background: var(--encre); color: var(--papier); font-style: normal; font-weight: 700; font-size: 12.5px; }
.my-carte__image em.fini { background: var(--c-sapin-fort, #167645); }
.my-carte strong { display: block; margin-top: 8px; font-weight: 700; font-size: 15px; line-height: 1.25; }
.my-carte small { display: block; color: var(--encre-douce); font-size: 12.5px; }

/* ---------- L'impression de l'image finie : elle seule, sur la page ---------- */
.my-impression { display: none; }
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  html:has(.my-page), .my-page { overflow: visible !important; background: #fff !important; }
  .my, .my-feuillet, .my__annonce { display: none !important; }
  .my-impression { display: block; width: 100%; height: auto; max-height: 277mm; object-fit: contain; }
}

/* ---------- Grand écran : la légende passe à droite, en colonnes ---------- */
@media (min-width: 900px) {
  .my { grid-template: 'barre barre' auto 'scene palette' minmax(0, 1fr) / minmax(0, 1fr) auto; }
  .my__barre { padding: 8px 14px; gap: 8px; }
  .my__nom { font-size: 20px; }
  .my__reste { flex-direction: row-reverse; align-items: center; gap: 12px; font-size: 15px; }
  .my__jauge { width: 150px; }
  .my__sur, .my__reste-avant { display: inline; }
  .my__palette { display: grid; grid-template-columns: repeat(3, 60px); align-content: start; gap: 14px 8px; padding: 18px 16px; border-top: 0; border-left: 1.5px solid var(--trait); overflow: hidden auto; }
  .my-couleur { width: 60px; }
  .my-couleur b { width: 50px; height: 50px; }
  .my__zoom { right: 12px; top: 12px; }
  .my__montrer { right: 12px; bottom: 14px; }
  .my-galerie__liste { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px 16px; }
  .my-galerie__tete, .my-galerie__corps { padding-left: 24px; padding-right: 24px; }
  .my-galerie__sauts { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .my *, .my-feuillet * { animation: none !important; transition: none !important; } }

/* ---------- Le mode jeu (prototype, plans/mystere-jeu.md) : la jauge, les pouvoirs, le film ---------- */
.my__pouvoirs { position: absolute; left: 8px; bottom: 10px; display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 999px; background: rgba(250, 246, 238, 0.94); box-shadow: 0 8px 18px -10px rgba(29, 26, 22, 0.5); }
/* La jauge : un anneau qui se remplit, le nombre de pouvoirs prêts au milieu. */
.my-charge { --part: 0; flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: radial-gradient(closest-side, var(--papier) 76%, transparent 78%), conic-gradient(var(--c-mandarine-vif, #dd8a46) calc(var(--part) * 360deg), var(--trait) 0); }
.my-charge b { font: 700 17px/1 var(--texte, system-ui, sans-serif); color: var(--encre-douce); }
.my-charge--prete b { color: var(--encre); }
.my-charge--prete { background: radial-gradient(closest-side, #ffe7b8 76%, transparent 78%), conic-gradient(var(--c-mandarine-vif, #dd8a46) calc(var(--part) * 360deg), var(--c-miel-clair, #ecd6a4) 0); }
.my-charge.gagne { animation: my-gagne 0.6s ease-out; }
@keyframes my-gagne { 0% { transform: scale(1); } 35% { transform: scale(1.35); } 100% { transform: scale(1); } }
.my-pouvoir { position: relative; flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1.5px solid var(--encre); border-radius: 50%; background: var(--papier); transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease; }
.my-pouvoir svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.my-pouvoir:hover:not(:disabled) { background: #ffe7b8; transform: translateY(-2px); }
.my-pouvoir:disabled { opacity: 0.32; border-color: var(--trait-fort); cursor: default; }
.my-pouvoir[aria-pressed='true'] { background: var(--encre); color: var(--papier); }
.my-pouvoir em { position: absolute; right: -3px; top: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--encre); color: var(--papier); font: 700 11.5px/18px var(--texte, system-ui, sans-serif); font-style: normal; text-align: center; }
.my__scene--vise, .my__scene--vise .my__cases path { cursor: crosshair; }
/* La couleur d'un pouvoir arrive en onde : chaque case attend son tour (retard posé par le script), puis s'allume. */
.my__cases path.onde { animation: my-onde 0.34s ease-out backwards; }
@keyframes my-onde { 0% { fill-opacity: 0; } 55% { fill-opacity: 1; filter: brightness(1.25); } 100% { fill-opacity: 1; filter: none; } }
.my__ondes { pointer-events: none; }
.my__ondes circle { fill: none; stroke: var(--encre); stroke-width: 3px; vector-effect: non-scaling-stroke; transform-box: fill-box; transform-origin: center; animation: my-anneau-onde 0.75s ease-out forwards; }
@keyframes my-anneau-onde { from { transform: scale(0.08); stroke-opacity: 0.9; } to { transform: scale(1); stroke-opacity: 0; } }
/* Le film : les joints de couleur se cachent, la grille revient, puis les cases se recolorient. */
.my__dessin--film .my__joints { display: none; }
.my__dessin--film .my__cases path { cursor: inherit; transition: fill 0.25s ease; }
@media (min-width: 900px) { .my__pouvoirs { left: 12px; bottom: 14px; gap: 8px; } }
