/* =========================================================================
   Tableau numérique (cahier Seyès) — vue #/tableau. Classes préfixées « tb- ».
   La vue occupe toute la hauteur sous la barre de l'application (tout l'écran en projection) ;
   la hauteur exacte est posée par js/app/views/tableau.js.
   Cibles tactiles ≥ 44 px, barre d'outils utilisable debout au tableau.
   ========================================================================= */

main.contenu[data-vue='tableau'] { max-width: none; padding: 8px 10px calc(8px + var(--sab)); }
body.projection main.contenu[data-vue='tableau'] { padding: 0 0 var(--sab); }
/* En projection, le bouton « Quitter » est dans la barre d'outils du tableau (il ne cache pas d'outil). */
body.projection main.contenu[data-vue='tableau'] ~ .bouton-sortie-projection { display: none !important; }

.tb-racine { display: flex; flex-direction: column; gap: 8px; height: calc(100dvh - 130px); min-height: 300px; }
.tb-racine[data-barre='bas'] { flex-direction: column-reverse; }
body.projection .tb-racine { gap: 0; }

/* ---------- Barre d'outils ---------- */
.tb-barre {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px;
  background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon-l); box-shadow: var(--ombre);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
body.projection .tb-barre { border-radius: 0; border-width: 0 0 1px; box-shadow: none; padding-top: calc(6px + var(--sai)); }
body.projection .tb-racine[data-barre='bas'] .tb-barre { border-width: 1px 0 0; padding-top: 6px; }
.tb-groupe { display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 16px; background: var(--surface-2); }
.tb-espace { flex: 1 1 0; min-width: 0; }

.tb-bouton, .tb-couleur, .tb-epaisseur, .tb-taille, .tb-mode, .tb-titre-page {
  border: 0; background: transparent; color: var(--texte); cursor: pointer; padding: 0; margin: 0;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; font: inherit;
}
.tb-bouton { width: 48px; height: 48px; flex: none; display: inline-grid; place-items: center; border-radius: 13px; transition: background .12s; }
.tb-bouton .ico { width: 25px; height: 25px; }
.tb-bouton:hover:not(:disabled) { background: var(--surface); }
.tb-bouton[aria-pressed='true'] { background: var(--rose-clair); color: var(--rose-fonce); box-shadow: inset 0 0 0 2px var(--rose); }
.tb-bouton:disabled { opacity: .35; cursor: default; }
.tb-bouton.tb-danger { color: var(--rouge); }
.tb-bouton.tb-quitter { width: auto; display: inline-flex; gap: 6px; padding: 0 14px 0 10px; font-weight: 600; background: var(--rose-clair); color: var(--rose-fonce); }
.tb-barre :focus-visible, .tb-rail :focus-visible { outline: 3px solid var(--rose); outline-offset: 1px; }

/* Couleurs : pastilles rondes, la couleur choisie est entourée */
.tb-couleur { width: 44px; height: 48px; flex: none; display: inline-grid; place-items: center; border-radius: 13px; }
.tb-couleur::before { content: ''; width: 28px; height: 28px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); transition: transform .12s; }
.tb-couleur[aria-pressed='true']::before { transform: scale(1.1); box-shadow: 0 0 0 3px var(--surface-2), 0 0 0 5.5px var(--c); }

/* Épaisseurs, tailles de gomme et de texte, mode de gomme */
.tb-epaisseur, .tb-taille { width: 44px; height: 48px; flex: none; display: inline-grid; place-items: center; border-radius: 13px; }
.tb-mode { min-height: 48px; padding: 0 14px; border-radius: 13px; font-weight: 500; font-size: .9rem; color: var(--texte-doux); white-space: nowrap; }
.tb-epaisseur[aria-pressed='true'], .tb-taille[aria-pressed='true'], .tb-mode[aria-pressed='true'] {
  background: var(--surface); color: var(--texte); box-shadow: 0 1px 4px rgba(0, 0, 0, .08), inset 0 0 0 2px var(--rose);
}
.tb-pastille { display: block; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.tb-rond { display: block; border-radius: 50%; border: 2px solid var(--texte-doux); background: var(--surface); }
.tb-taille span { font-family: var(--police-cursive); line-height: 1; color: var(--texte); pointer-events: none; }

/* Pages : précédente, titre (ouvre les vignettes), suivante, nouvelle */
.tb-titre-page {
  height: 48px; min-width: 90px; max-width: 210px; display: inline-flex; flex-direction: column; justify-content: center;
  align-items: flex-start; padding: 0 10px; border-radius: 13px; text-align: left; overflow: hidden;
}
.tb-titre-page:hover { background: var(--surface); }
.tb-num { font-size: .72rem; color: var(--texte-doux); line-height: 1.2; }
.tb-nom { max-width: 100%; font-weight: 600; font-size: .9rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1100px) {
  .tb-barre { gap: 4px; padding: 4px; }
  .tb-bouton { width: 44px; height: 44px; }
  .tb-couleur, .tb-epaisseur, .tb-taille { height: 44px; }
  .tb-mode { min-height: 44px; padding: 0 10px; }
  .tb-titre-page { height: 44px; max-width: 150px; }
}

/* ---------- Zone de dessin et rail (défilement, zoom) ---------- */
.tb-corps {
  flex: 1 1 auto; min-height: 0; display: flex; overflow: hidden;
  background: #F1ECEF; border: 1px solid var(--ligne); border-radius: var(--rayon-l); box-shadow: var(--ombre);
}
body.projection .tb-corps { border: 0; border-radius: 0; box-shadow: none; }
.tb-zone {
  position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: contain;
}
.tb-canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; max-width: none; display: block; touch-action: none; }
.tb-direct { cursor: crosshair; }
.tb-racine[data-outil='texte'] .tb-direct { cursor: text; }
.tb-racine[data-outil='gomme'] .tb-direct { cursor: cell; }

.tb-rail {
  flex: none; width: 58px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0;
  background: var(--surface); border-left: 1px solid var(--ligne); user-select: none; -webkit-user-select: none;
}
.tb-rail-espace { flex: 1; min-height: 8px; }
.tb-zoom { min-height: 18px; font-size: .72rem; color: var(--texte-doux); font-variant-numeric: tabular-nums; text-align: center; }

/* Surcouches : chargement (discret, n'apparaît que s'il dure) et page indisponible hors ligne */
.tb-surcouche { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; }
.tb-chargement { pointer-events: none; animation: tb-apparait .2s .25s both; }
.tb-tourne { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--rose-bord); border-top-color: var(--rose); animation: tb-tourne .8s linear infinite; }
.tb-indispo { background: rgba(251, 248, 246, .72); }
.tb-indispo-carte { width: min(440px, 90%); padding: 18px 20px; text-align: center; background: var(--surface); border-radius: var(--rayon-l); box-shadow: var(--ombre-forte); }
@keyframes tb-apparait { from { opacity: 0; } }
@keyframes tb-tourne { to { transform: rotate(360deg); } }

/* Zone de saisie du texte : posée sur la ligne d'écriture, dans la cursive du tableau */
.tb-zone textarea.tb-saisie {
  position: absolute; left: 0; top: 0; z-index: 2; transform-origin: 0 0; box-sizing: content-box;
  width: auto; height: auto; min-height: 0; margin: 0; padding: 0 6px; border: 0; border-radius: 4px;
  background: rgba(255, 255, 255, .55); box-shadow: none; outline: 2px dashed var(--rose); outline-offset: 3px;
  resize: none; overflow: hidden; white-space: pre; font-weight: 400; transition: none;
  -webkit-user-select: text; user-select: text; touch-action: manipulation;
}
.tb-zone textarea.tb-saisie:focus { border: 0; box-shadow: none; outline: 2px dashed var(--rose-fonce); }

/* ---------- Panneau des pages (vignettes et archives) ---------- */
.tb-vignettes { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tb-carte { position: relative; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon); }
.tb-carte.actuelle { border-color: var(--rose); box-shadow: 0 0 0 3px var(--rose-clair); }
.tb-carte-ouvrir { display: flex; flex-direction: column; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit; touch-action: manipulation; }
.tb-carte-image { display: block; aspect-ratio: 4 / 5; overflow: hidden; background: #fff; border-bottom: 1px solid var(--ligne); }
.tb-carte-image[data-fond='seyes'] { background-image: repeating-linear-gradient(to bottom, transparent 0 9px, #DCE2F4 9px 10px); }
.tb-carte-image[data-fond='quadrillage'] { background-image: linear-gradient(#E3E8F5 1px, transparent 1px), linear-gradient(90deg, #E3E8F5 1px, transparent 1px); background-size: 7px 7px; }
.tb-carte-image img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.tb-carte-image img:not([src]) { visibility: hidden; }
.tb-carte-texte { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 8px 10px 10px; }
.tb-carte-titre { font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-carte-date { font-size: .75rem; color: var(--texte-doux); }
.tb-carte .tb-carte-menu { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .92); box-shadow: var(--ombre); }
.tb-carte-nouvelle {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 180px;
  border: 2px dashed var(--ligne-forte); border-radius: var(--rayon); background: var(--surface-2); color: var(--texte-doux);
  font: inherit; font-weight: 500; cursor: pointer; touch-action: manipulation;
}
.tb-carte-nouvelle .ico { width: 28px; height: 28px; }
.tb-archives { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 18px; }
.tb-liste-archives { width: 100%; }
.tb-archive { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.tb-archive-titre { flex: 1; min-width: 160px; font-weight: 500; }
.tb-archive-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- Impression d'une page (images découpées en feuilles A4, voir lib/impression.js) ---------- */
@media print {
  .tb-imp-page { margin: 0; }
  .tb-imp-img { display: block; width: 100%; height: auto; }
}
