/* Bureau à l'échelle (page Setup et fiches tapis) : plateau, pièces posées dessus, repère écran, bouton « Voir en grand » et sa boîte de dialogue. */

/* Plateau : papier mat, fil très discret du bois, chant avant légèrement ombré (côté utilisateur) */
.bureau {
  position: relative; aspect-ratio: 2 / 1; overflow: hidden; isolation: isolate; container-type: inline-size;
  border: 1px solid var(--sg-champ); border-radius: 3px;
  background:
    linear-gradient(to bottom, transparent 92%, color-mix(in srgb, var(--sg-encre) 7%, transparent)),
    repeating-linear-gradient(to bottom, transparent 0 5px, color-mix(in srgb, var(--sg-ecume) 28%, transparent) 5px 6px),
    var(--sg-papier);
  box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--sg-encre) 12%, transparent), inset 0 1px 0 var(--sg-blanc);
}

/* Pièces : ordre d'empilement explicite (tapis, gabarit, repose-poignets, clavier, souris, clips) */
.piece { position: absolute; opacity: 0; pointer-events: none; }
.piece.tapis {
  z-index: 1; background-size: cover; background-position: center; border-radius: 1.2cqi;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sg-encre) 22%, transparent),
    0 .15cqi .3cqi color-mix(in srgb, var(--sg-encre) 28%, transparent),
    0 .6cqi 1.4cqi color-mix(in srgb, var(--sg-encre) 16%, transparent);
}
.piece.tapis.vide { box-shadow: none; }
.piece.gabarit { z-index: 2; border: 2px dashed var(--sg-lave); border-radius: .8cqi; background: color-mix(in srgb, var(--sg-lave) 10%, transparent); }
.piece.gabarit.pour-souris { border-radius: 45% / 35%; }
.piece.repose {
  z-index: 3; border-radius: 1.6cqi / 3.2cqi;
  background: linear-gradient(to bottom, var(--sg-encre-survol), var(--sg-encre) 70%);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--sg-blanc) 18%, transparent), 0 .25cqi .5cqi color-mix(in srgb, var(--sg-encre) 35%, transparent);
}
.piece.clavier, .piece.souris { height: auto; filter: drop-shadow(0 .2cqi .35cqi color-mix(in srgb, var(--sg-encre) 40%, transparent)); }
.piece.clavier { z-index: 4; }
.piece.souris { z-index: 5; }
.piece.clips { z-index: 6; display: flex; gap: 12%; align-items: center; }
.piece.clips i { width: 22%; aspect-ratio: 1; background: var(--sg-sceau); border-radius: 50%; box-shadow: inset 0 0 0 .25cqi color-mix(in srgb, var(--sg-encre) 35%, transparent), 0 .15cqi .3cqi color-mix(in srgb, var(--sg-encre) 40%, transparent); }
@media (prefers-reduced-motion: no-preference) {
  .piece { transition: left .4s var(--sg-courbe), top .4s var(--sg-courbe), width .4s var(--sg-courbe), height .4s var(--sg-courbe), opacity .3s ease; }
}

/* Repère écran : le pied d'un écran de 24 pouces vu de dessus, contre le mur */
.ecran {
  position: absolute; z-index: 7; top: 0; left: 50%; transform: translateX(-50%); width: max-content; min-width: 34%; padding-inline: 1.5cqi;
  padding: .3cqi 0 .45cqi; text-align: center; background: var(--sg-encre); color: var(--sg-papier);
  border-radius: 0 0 .6cqi .6cqi; font-size: clamp(10px, 1.5cqi, 14px); line-height: 1.3; letter-spacing: .04em; white-space: nowrap;
}

/* Bouton « Voir en grand » */
.agrandir { margin-top: var(--sg-3); min-height: 44px; padding: 0 var(--sg-4); border: 1px solid var(--sg-champ); border-radius: var(--sg-rayon); background: var(--sg-blanc); color: var(--sg-encre); font-size: var(--sg-t-petit); font-weight: 500; cursor: pointer; }
@media (hover: hover) { .agrandir:hover { border-color: var(--sg-encre); } }

/* Boîte de dialogue : base.css remet margin à 0 partout, on rend au dialog modal son centrage */
dialog.bureau-grand {
  position: fixed; inset: 0; margin: auto;
  width: min(calc(100vw - 2 * var(--sg-2)), 1200px); max-width: none;
  height: fit-content; max-height: calc(100dvh - 2 * var(--sg-2));
  padding: var(--sg-3); border: 0; border-radius: var(--sg-rayon);
  background: var(--sg-papier); color: var(--sg-encre); overflow: auto; overscroll-behavior: contain;
  box-shadow: 0 24px 64px color-mix(in srgb, var(--sg-encre) 45%, transparent);
}
dialog.bureau-grand[open] { display: flex; flex-direction: column; gap: var(--sg-3); }
dialog.bureau-grand::backdrop { background: color-mix(in srgb, var(--sg-encre) 74%, transparent); }
html:has(dialog.bureau-grand[open]) { overflow: hidden; }
.bureau-grand .entete-grand { display: flex; align-items: center; justify-content: space-between; gap: var(--sg-4); }
.bureau-grand h2 { font-size: var(--sg-t-h3); }
.bureau-grand .fermer-grand { flex: none; min-height: 44px; padding: 0 var(--sg-4); font-size: var(--sg-t-petit); }
.bureau-grand .cadre-grand { display: flex; justify-content: center; min-width: 0; }
/* Aussi grand que possible : largeur disponible, ou deux fois la hauteur restante (en-tête, légende et marges ôtés) */
.bureau-grand .cadre-grand .bureau { flex: none; margin: 0; max-width: none; width: min(100%, max(280px, calc((100dvh - 170px) * 2))); }
.bureau-grand .legende-grand { color: var(--sg-gris); font-size: var(--sg-t-petit); text-align: center; max-width: var(--sg-mesure); margin-inline: auto; }
@media (min-width: 768px) {
  dialog.bureau-grand { width: min(calc(100vw - 2 * var(--sg-6)), 1200px); max-height: calc(100dvh - 2 * var(--sg-6)); padding: var(--sg-5) var(--sg-6) var(--sg-6); }
  dialog.bureau-grand[open] { gap: var(--sg-4); }
  .bureau-grand .cadre-grand .bureau { width: min(100%, max(320px, calc((100dvh - 260px) * 2))); }
}
@media (prefers-reduced-motion: no-preference) {
  dialog.bureau-grand[open] { animation: sg-bureau-entree .24s var(--sg-courbe); }
  dialog.bureau-grand[open]::backdrop { animation: sg-bureau-fond .24s ease; }
}
@keyframes sg-bureau-entree { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes sg-bureau-fond { from { opacity: 0; } }

/* Fiche produit */
.bureau-fiche { margin: var(--sg-5) 0 0; }
.bureau-fiche .cote { margin-top: var(--sg-2); font-size: var(--sg-t-legende); color: var(--sg-gris); }
