/* Tableau à la craie (tâche 2.5, A9).
   Dans .tableau, 1 px vaut une unité de tableau (1 000 unités = largeur du
   rectangle du tableau) : la couche est ensuite agrandie d'un bloc par
   transform: scale(), calculé par js/tableau/tableau.js. Les tailles d'écriture
   viennent de js/tableau/parametres.js (TAILLES) et doivent y rester alignées :
   corps 39, titre 54, formule 34, interligne 1,15 ; espaces 4 et 6. */

.tableau {
  --craie: #f3f0e7;
  --craie-jaune: #f6e08a;
  --craie-rose: #f4b9a6;
  --craie-surlignage: rgb(250 226 120 / 20%);
  --craie-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='2' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 -1.1 1.32'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  /* Superposition dans la salle : tableau peint < écriture (1) < calque
     d'avant-plan (2, sans pointeur) < flèches de pages (3). */
  z-index: 1;
  pointer-events: none;
  color: var(--craie);
  font-family: "Patrick Hand", cursive;
  font-size: 39px;
  line-height: 1.15;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

/* Zone de mesure : même style, sans agrandissement, hors de l'écran. */
.tableau.tableau-mesure {
  position: fixed;
  left: -20000px;
  top: 0;
  transform: none;
  visibility: hidden;
}
.tableau-mesure .tableau-element { position: relative; left: 0; top: 0; width: 100%; }

.tableau-page { position: absolute; inset: 0; }

.tableau-element {
  position: absolute;
  overflow-wrap: break-word;
  border-radius: 10px;
  transition: background-color 250ms ease, box-shadow 250ms ease;
}

/* Grain de craie : légère irrégularité de l'écriture, fixée (même rendu à chaque rappel). */
.craie {
  -webkit-mask-image: var(--craie-grain);
  mask-image: var(--craie-grain);
  -webkit-mask-size: 220px 220px;
  mask-size: 220px 220px;
  text-shadow: 0 0 1px rgb(255 255 255 / 35%);
}

/* Titre : plus grand, centré dans la colonne, souligné d'un trait de craie. */
.tableau-titre { text-align: center; font-size: 54px; line-height: 1.1; }
.tableau-titre .tableau-texte {
  display: inline-block;
  padding: 0 10px 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 10' preserveAspectRatio='none'%3E%3Cpath d='M3 6 C 90 3.5, 200 7.5, 397 4.5' fill='none' stroke='%23f3f0e7' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") left bottom / 100% 9px no-repeat;
}

/* Puce : point de craie et retrait suspendu. */
.tableau-puce { padding-left: 38px; }
.tableau-puce::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 0.55em;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--craie);
  opacity: 0.92;
}

/* Nom (personne, notion) et date : couleurs de craie distinctes. */
.tableau-nom { color: var(--craie-jaune); }
.tableau-date { color: var(--craie-rose); }

/* Formule (KaTeX) centrée dans la colonne. */
.tableau-formule .katex-display { margin: 0; }
.tableau-formule .katex { font-size: 34px; color: var(--craie); }
.tableau-formule-rendu { text-align: center; }

/* Chaîne fléchée : cases bordées, flèches de craie ; passe à la ligne entre deux cases. */
.tableau-chaine {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 10px;
}
.tableau-maillon { display: inline-flex; align-items: center; max-width: 100%; }
.tableau-case {
  display: inline-block;
  max-width: 100%;
  padding: 2px 10px 4px;
  border: 3px solid var(--craie);
  border-radius: 14px;
}
.tableau-fleche {
  flex: none;
  width: 42px;
  height: 22px;
  margin: 0 4px;
  fill: none;
  stroke: var(--craie);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Bloc de hauteur connue (schéma, image : phase 5). */
.tableau-bloc { overflow: hidden; }

/* Schéma de la bibliothèque (js/tableau/schemas.js) : cadre à la taille du
   dessin, mis à l'échelle du bloc ; traits Rough.js en SVG, textes et formules
   posés au-dessus, centrés en hauteur sur leur position. */
.schema-cadre { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.schema-dessin { position: absolute; left: 0; top: 0; overflow: visible; }
.schema-texte { position: absolute; white-space: nowrap; line-height: 1.15; }
.schema-formule { position: absolute; white-space: nowrap; }
.schema-formule .katex-display { margin: 0; }
.schema-formule .katex { font-size: 34px; }

/* Image projetée (js/tableau/images.js) : encadrée comme une projection, légende
   au corps (deux lignes au plus) et mention plus petite, centrées sous l'image ;
   pour une image carrée ou en hauteur, à sa droite. */
.tableau-figure { margin: 0; display: flex; flex-direction: column; align-items: center; }
/* Image carrée ou en hauteur : légende et mention à droite, l'image garde toute la hauteur du bloc. */
.tableau-figure-cote { flex-direction: row; justify-content: center; }
.tableau-figure-textes { display: flex; flex-direction: column; }
.tableau-figure-textes .tableau-legende, .tableau-figure-textes .tableau-mention { text-align: left; }
/* Fond clair d'écran de projection : une image à fond transparent (carte, dessin au trait) reste
   lisible sur le vert du tableau ; une photo, opaque, le recouvre. */
.tableau-projection { display: block; box-sizing: content-box; object-fit: contain; border-style: solid;
                 border-color: var(--craie); border-radius: 6px; background: #f4f1e8; }
.tableau-legende { width: 100%; text-align: center; display: -webkit-box; -webkit-line-clamp: 2;
                   -webkit-box-orient: vertical; overflow: hidden; }
.tableau-mention { width: 100%; text-align: center; line-height: 1.15; opacity: 0.75; display: -webkit-box;
                   -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tableau-mention a { color: inherit; text-decoration: underline; pointer-events: auto; }
.tableau-mention a:focus-visible { outline: 2px solid var(--craie); outline-offset: 2px; }

/* Écriture : l'élément apparaît de gauche à droite. */
.tableau-ecriture { animation: tableau-ecrire 450ms ease-out both; }
@keyframes tableau-ecrire {
  from { clip-path: inset(-20px 100% -20px -20px); }
  to { clip-path: inset(-20px -20px -20px -20px); }
}
@media (prefers-reduced-motion: reduce) {
  .tableau-ecriture { animation: none; }
}

/* Désignation : léger surlignage pendant le geste. */
.tableau-surligne {
  background-color: var(--craie-surlignage);
  box-shadow: 0 0 0 8px var(--craie-surlignage);
}

/* Flèches de pages, en pixels d'écran (non agrandies). */
.tableau-navigation {
  position: absolute;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 3;
  font: 14px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.tableau-navigation[hidden] { display: none; }
/* Dans la salle, ces mêmes commandes suivent le bandeau et sa mise en page.
   Le tableau agrandi et les pages d'essai gardent leur position dans la scène. */
.tableau-navigation-bandeau { position: static; transform: none; flex: 0 0 auto; z-index: auto; }
.tableau-fleche-page {
  min-width: 36px;
  min-height: 32px;
  padding: 2px 10px;
  border: 1px solid rgb(0 0 0 / 12%);
  border-radius: 8px;
  background: rgb(255 255 255 / 85%);
  color: #3b3a36;
  font-size: 18px;
  line-height: 1;
}
.tableau-fleche-page:disabled { opacity: 0.45; cursor: default; }
.tableau-numero {
  padding: 6px 12px;
  border-radius: 8px;
  background: rgb(255 255 255 / 92%);
  color: #2f2e2a;
  white-space: nowrap;
}
.tableau-ancienne-page ~ .tableau-navigation .tableau-numero,
.tableau-navigation-ancienne .tableau-numero { background: #fff3cf; }

/* Extrait étudié (mission des cours) : passage exact au corps du tableau, source plus petite à droite. */
.tableau-extrait { padding-left: 18px; border-left: 3px solid var(--craie); }
.tableau-extrait-texte { white-space: pre-line; }
.tableau-extrait-source { text-align: right; opacity: 0.8; margin-top: 4px; line-height: 1.15; }
