/*
 * OptGeo web — feuille de style. D'après OptGeo 3.03 de Jean-Marie Biansan (GNU GPL v2 ou ultérieure).
 * Aucune police ni ressource extérieure : polices du système.
 * L'application remplit exactement la fenêtre (ou le cadre) qu'on lui donne, sans défilement de la page.
 */
:root {
  --fond: #eef1f5;
  --barre: #ffffff;
  --texte: #1b1f24;
  --doux: #5a6370;
  --bord: #c9d0d9;
  --accent: #1a5fd0;
  --accent-clair: #e3ecfb;
  --danger: #b3261e;
  --ombre: 0 4px 18px rgba(0, 0, 0, 0.18);
  --rayon: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--fond); color: var(--texte); }
/* Pas de zoom de la page au pincement ni au double toucher, où que commence le geste (palette, panneau,
   bandeau…) : seul le dessin se zoome, à deux doigts. Le défilement des panneaux et des listes reste permis. */
html, body, #app { touch-action: pan-x pan-y; }
body { font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.icone { width: 24px; height: 24px; flex: none; }

/* ------------------------------------------------------------------ */
/* Disposition : barre en haut ; palette à gauche (paysage) ou en bas */
/* (portrait) ; la zone de dessin prend toute la place restante.      */
/* ------------------------------------------------------------------ */
#app {
  position: fixed; inset: 0;
  display: grid;
  grid-template-areas: "barre barre" "palette zone";
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: auto minmax(0, 1fr);
}
#barre { grid-area: barre; }
#palette { grid-area: palette; }
#zone { grid-area: zone; }
@media (max-aspect-ratio: 1/1) {
  #app { grid-template-areas: "barre" "zone" "palette"; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
}

/* Barre du haut */
#barre {
  display: flex; align-items: center; gap: 2px; padding: 2px 4px;
  background: var(--barre); border-bottom: 1px solid var(--bord); min-width: 0; overflow: hidden;
}
#barre .groupe { display: flex; gap: 2px; padding-left: 4px; border-left: 1px solid var(--bord); }
.titre { flex: 1 1 auto; min-width: 0; padding: 0 8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bouton-barre {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: 48px; height: 50px; padding: 2px 6px; border: 0; border-radius: 8px; background: transparent; color: var(--texte);
}
.bouton-barre span { font-size: 11px; line-height: 1.1; white-space: nowrap; }
.bouton-barre:hover { background: var(--accent-clair); }
.bouton-barre[aria-pressed="true"], .bouton-barre[aria-expanded="true"] { background: var(--accent); color: #fff; }
.bouton-barre:disabled { opacity: 0.35; cursor: default; background: transparent; }
.seulement-etroit { display: none; }
@media (max-width: 760px) {
  #barre .modes { display: none; }
  .seulement-etroit { display: flex; }
}
@media (max-width: 400px) {
  .bouton-barre { min-width: 44px; padding: 2px 3px; }
  .titre { font-size: 13px; padding: 0 4px; }
}
@media (max-height: 420px) and (min-aspect-ratio: 1/1) {
  .bouton-barre { height: 44px; }
  .bouton-barre span { display: none; }
}

/* Palette des objets (onglets des familles) */
#palette { background: var(--barre); border-right: 1px solid var(--bord); overflow: hidden; }
#palette-onglets { display: flex; flex-direction: column; gap: 2px; padding: 4px; height: 100%; overflow-y: auto; }
.onglet {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 66px; min-height: 56px; padding: 4px 2px; border: 0; border-radius: 8px; background: transparent;
}
.onglet span { font-size: 11.5px; line-height: 1.15; text-align: center; }
.onglet:hover { background: var(--accent-clair); }
.onglet[aria-expanded="true"] { background: var(--accent); color: #fff; }
@media (max-aspect-ratio: 1/1) {
  #palette { border-right: 0; border-top: 1px solid var(--bord); }
  #palette-onglets { flex-direction: row; justify-content: space-around; height: auto; overflow: hidden; }
  .onglet { flex: 1 1 0; width: auto; min-height: 52px; }
}
@media (max-height: 420px) and (min-aspect-ratio: 1/1) {
  .onglet { min-height: 48px; width: 60px; }
}

/* Zone de dessin */
#zone { position: relative; overflow: hidden; min-width: 0; min-height: 0; background: #d9dde3; }
#dessin { position: absolute; left: 0; top: 0; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair; }

/* Volet des outils d'une famille (par-dessus le dessin) */
.volet {
  position: absolute; z-index: 30; left: 0; top: 0; bottom: 0; width: min(330px, 92%);
  background: var(--barre); box-shadow: var(--ombre); padding: 8px; overflow-y: auto;
}
.volet h2 { margin: 2px 4px 8px; font-size: 16px; }
.volet .outils { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.outil {
  display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 8px; text-align: left;
  border: 1px solid var(--bord); border-radius: 8px; background: #fff;
}
.outil:hover, .outil:focus-visible { border-color: var(--accent); background: var(--accent-clair); }
.outil .icone { width: 30px; height: 30px; }
@media (max-aspect-ratio: 1/1) {
  .volet { top: auto; right: 0; width: auto; max-height: 72%; border-radius: 12px 12px 0 0; }
}

/* Bandeau de consigne */
/* Le bandeau est posé PAR-DESSUS le dessin (il ne le décale pas). Son texte laisse passer les touchers
   vers le dessin ; seuls ses boutons les reçoivent. */
#bandeau {
  position: absolute; z-index: 20; left: 0; right: 0; top: 0; max-height: 45%; overflow-y: auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 10px;
  background: rgba(255, 255, 255, 0.95); border-bottom: 1px solid var(--bord); box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  pointer-events: none;
}
#bandeau.deplie { pointer-events: auto; }
#bandeau-texte { flex: 1 1 240px; margin: 0; font-size: 15.5px; font-weight: 500; white-space: pre-line; }
#bandeau-boutons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#bandeau-boutons > * { pointer-events: auto; }
#bandeau-boutons button, .rester {
  min-height: 44px; padding: 6px 12px; border: 1px solid var(--bord); border-radius: 8px; background: #fff; font-size: 14px;
}
#bandeau-boutons .deplier { display: none; }
/* Petit écran : bandeau compact sur une ligne (consigne abrégée, boutons secondaires derrière « Plus »),
   qui laisse libres les boutons de zoom à droite. */
@media (max-width: 560px), (max-height: 420px) {
  #bandeau { flex-wrap: nowrap; gap: 6px; padding: 4px 6px; right: 58px; }
  #bandeau-texte { flex: 1 1 0; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #bandeau-boutons { flex: 0 0 auto; flex-wrap: nowrap; gap: 4px; }
  #bandeau-boutons button, .rester { padding: 4px 8px; font-size: 13.5px; }
  #bandeau-boutons .deplier { display: inline-block; }
  #bandeau:not(.deplie) #bandeau-boutons .secondaire { display: none; }
  #bandeau.deplie { flex-wrap: wrap; max-height: 60%; }
  #bandeau.deplie #bandeau-texte { flex-basis: 100%; white-space: pre-line; overflow: visible; }
  #bandeau.deplie #bandeau-boutons { flex-wrap: wrap; }
}
#bandeau-boutons button.principal { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
#bandeau-boutons button[aria-pressed="true"] { background: #1b1f24; color: #fff; }
.rester { display: inline-flex; align-items: center; gap: 6px; }
.rester input { width: 20px; height: 20px; }

/* Message bref */
.message {
  position: absolute; z-index: 40; left: 50%; bottom: var(--bas-message, 74px); transform: translateX(-50%); max-width: calc(100% - 24px);
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px;
  background: #1b1f24; color: #fff; box-shadow: var(--ombre); font-size: 14.5px;
}
.message.erreur { background: var(--danger); }
/* la bulle laisse passer les touchers vers le dessin (seul son bouton les reçoit) : elle ne bloque jamais un point visé */
.message { pointer-events: none; }
.message button { pointer-events: auto; }
.message button { min-height: 44px; padding: 4px 12px; border: 1px solid #fff; border-radius: 8px; background: transparent; color: #fff; font-weight: 600; }

/* Coordonnées (souris) */
#coordonnees {
  position: absolute; z-index: 10; left: 6px; bottom: 6px; padding: 2px 6px; border-radius: 6px;
  background: rgba(255,255,255,0.85); font-size: 12px; color: var(--doux); pointer-events: none; font-variant-numeric: tabular-nums;
}
#coordonnees:empty { display: none; }
@media (pointer: coarse) { #coordonnees { display: none; } }

/* Boutons de vue (le conteneur laisse passer les touchers entre les boutons : pas de zone morte) */
#vue-boutons { position: absolute; z-index: 21; right: 8px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
#vue-boutons button { pointer-events: auto; }
#vue-boutons button {
  width: 46px; height: 46px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--bord); border-radius: 50%; background: rgba(255,255,255,0.95); box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
@media (max-height: 300px) { #vue-boutons { flex-direction: row; top: auto; bottom: 8px; transform: none; } }

/* Barre contextuelle de l'objet sélectionné : en bas du dessin, ou en haut (classe « en-haut », sous le
   bandeau) quand elle couvrirait l'objet choisi (60-app.js, placerBarreContexte). Largeur ajustée à son
   contenu : une ligne de boutons sous le nom de l'objet. */
#barre-contexte {
  position: absolute; z-index: 16; left: 0; right: 0; bottom: 8px; margin: 0 auto; width: fit-content; width: -moz-fit-content; max-width: calc(100% - 70px);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; padding: 4px 6px;
  background: rgba(255,255,255,0.97); border: 1px solid var(--bord); border-radius: 12px; box-shadow: var(--ombre);
}
#barre-contexte.en-haut { top: var(--haut-barre, 8px); bottom: auto; }
#contexte-nom { flex: 1 0 100%; width: 0; min-width: 0; text-align: center; font-size: 12.5px; color: var(--doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#barre-contexte button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 48px; min-height: 48px; padding: 2px 6px;
  border: 0; border-radius: 8px; background: transparent; font-size: 11px;
}
#barre-contexte button:hover { background: var(--accent-clair); }
#barre-contexte button[data-ctx="supprimer"] { color: var(--danger); }

/* Loupe */
.loupe { position: absolute; z-index: 25; left: 0; top: 0; pointer-events: none; }
.loupe canvas { display: block; border-radius: 50%; border: 3px solid #1b1f24; box-shadow: var(--ombre); background: #d9dde3; }
.loupe-texte { margin-top: 3px; padding: 2px 6px; border-radius: 6px; background: rgba(27,31,36,0.85); color: #fff; font-size: 12px; white-space: pre; text-align: center; }

/* Panneau des propriétés (non modal) */
#panneau {
  position: absolute; z-index: 35; right: 0; top: 0; bottom: 0; width: min(410px, 58%);
  display: flex; flex-direction: column; background: #fff; box-shadow: var(--ombre); border-left: 1px solid var(--bord);
}
#panneau.large { width: min(680px, 86%); }
#panneau .tete { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--bord); }
#panneau h2 { flex: 1; margin: 0; font-size: 16.5px; }
#panneau .fermer { width: 44px; height: 44px; border: 0; border-radius: 8px; background: transparent; display: flex; align-items: center; justify-content: center; }
#panneau-corps { flex: 1 1 auto; overflow-y: auto; padding: 8px 12px 16px; -webkit-overflow-scrolling: touch; }
#panneau-pied, .dialogue .pied { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; padding: 8px; border-top: 1px solid var(--bord); }
#panneau-pied button, .dialogue .pied button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding: 6px 14px;
  border: 1px solid var(--bord); border-radius: 8px; background: #fff; font-size: 15px;
}
#panneau-pied button .icone, .dialogue .pied button .icone { width: 20px; height: 20px; }
button.principal { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff; font-weight: 600; }
button.danger { color: var(--danger); border-color: #e6b8b5 !important; }
button:disabled { opacity: 0.45; cursor: default; }
@media (max-aspect-ratio: 1/1) {
  #panneau, #panneau.large { left: 0; right: 0; top: auto; width: auto; height: 64%; border-left: 0; border-top: 1px solid var(--bord); border-radius: 14px 14px 0 0; }
}
@media (max-height: 420px) and (min-aspect-ratio: 1/1) { #panneau { width: min(410px, 66%); } }

/* Menu et popovers */
.menu {
  position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(380px, 94vw); overflow-y: auto; padding: 6px 8px 24px;
  background: #fff; box-shadow: var(--ombre);
}
.menu section h2 { margin: 12px 6px 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--doux); }
.menu h3 { margin: 8px 8px 2px; font-size: 13px; color: var(--accent); }
.items { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; padding: 6px 10px; text-align: left;
  border: 0; border-radius: 8px; background: transparent; width: 100%;
}
.item:hover, .item:focus-visible { background: var(--accent-clair); }
.item kbd { font: 12px ui-monospace, Menlo, Consolas, monospace; color: var(--doux); }
.item[aria-checked]::after { content: ""; width: 34px; height: 20px; border-radius: 10px; background: #c8ced6; flex: none; box-shadow: inset 0 0 0 2px #c8ced6; }
.item[aria-checked="true"]::after { background: var(--accent); box-shadow: inset 22px 0 0 2px var(--accent), inset 14px 0 0 2px #fff; }
.item[aria-checked] span { flex: 1; }
.popover {
  position: fixed; z-index: 50; right: 6px; top: 56px; width: min(330px, calc(100vw - 12px)); max-height: calc(100% - 64px); overflow-y: auto;
  padding: 8px; background: #fff; border-radius: 12px; box-shadow: var(--ombre); display: flex; flex-direction: column; gap: 2px;
}
.zooms { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; }
.zooms button { min-width: 44px; min-height: 44px; border: 1px solid var(--bord); border-radius: 8px; background: #fff; }
.zooms button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Interrupteurs, champs */
.interrupteur { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 2px 4px; cursor: pointer; }
.interrupteur input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.formulaire h3 { margin: 16px 0 4px; font-size: 14.5px; color: var(--accent); }
.champ { margin: 8px 0; border: 0; padding: 0; min-width: 0; }
fieldset.champ { border: 1px solid var(--bord); border-radius: 8px; padding: 4px 10px 8px; }
fieldset.champ legend { padding: 0 4px; font-weight: 600; font-size: 14px; }
.champ > label, .etiquette { display: block; margin: 2px 0; font-size: 14px; font-weight: 500; }
.champ.inactif { opacity: 0.5; }
input[type=text], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 6px 10px; border: 1px solid #aab3be; border-radius: 8px; background: #fff; font-size: 16px;
}
textarea { min-height: 200px; resize: vertical; }
.saisie { display: flex; align-items: center; gap: 6px; min-width: 0; }
.saisie input { flex: 1 1 auto; min-width: 0; }
.unite { color: var(--doux); font-size: 14px; white-space: nowrap; }
.conversion { display: block; font-size: 12.5px; color: var(--doux); }
.champ.point { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 8px; }
.champ.point legend { grid-column: 1 / -1; }
.champ.point > label { margin: 0; }
.compteur { display: inline-flex; align-items: center; gap: 4px; }
.compteur input { width: 92px; text-align: center; }
.pas { width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; border: 1px solid var(--bord); border-radius: 8px; background: #fff; }
.radios { display: flex; flex-direction: column; }
.radios.en-ligne { flex-direction: row; flex-wrap: wrap; gap: 0 12px; }
.radio { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-size: 14.5px; }
.radio input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.note { font-size: 13px; color: var(--doux); margin: 6px 0; }
.note.avertissement { color: #8a5300; }
.mesure { font-size: 16px; font-weight: 600; }
.erreur-champ, .erreur-generale { color: var(--danger); font-size: 13.5px; font-weight: 600; margin: 4px 0; }
.en-erreur input { border-color: var(--danger); }
.grille-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.grille-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 0 10px; }
.trois { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 8px; margin-top: 6px; }
.trois label { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.cases { display: flex; flex-wrap: wrap; gap: 0 12px; }
.boutons-ligne { display: flex; flex-wrap: wrap; gap: 6px; }
.boutons-ligne button, button.petit { min-height: 44px; padding: 4px 10px; border: 1px solid var(--bord); border-radius: 8px; background: #fff; font-size: 13.5px; }

/* Couleurs : pastilles dessinées et nom écrit (jamais d'émoji) */
.pastille { display: inline-block; width: 18px; height: 18px; flex: none; border-radius: 50%; border: 1px solid #4a5260; vertical-align: middle; }
.pastille.blanche { background: linear-gradient(90deg, #ff0000 0 33%, #00a000 33% 66%, #0000ff 66%); }
.champ-couleur { position: relative; }
.nuance-courante { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 12px; border: 1px solid #aab3be; border-radius: 8px; background: #fff; }
.nuancier { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 4px; margin-top: 6px; padding: 6px; border: 1px solid var(--bord); border-radius: 8px; background: #fafbfc; }
.nuance { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 2px 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; font-size: 13px; text-align: left; }
.nuance:hover { border-color: var(--accent); }
.nuance.autre input { width: 28px; height: 28px; padding: 0; border: 0; background: none; }

/* Sommets d'un polygone / polycercle */
.table-sommets { display: flex; flex-direction: column; gap: 8px; }
.ligne-sommet { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 8px; padding: 6px; border: 1px solid var(--bord); border-radius: 8px; }
.tete-sommet { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px; }
.tete-sommet .outils { display: flex; gap: 4px; }
.cote { grid-column: 1 / -1; border-top: 1px dashed var(--bord); padding-top: 4px; }
.detail-arc { padding-left: 8px; }

/* Boîtes de dialogue */
.voile { position: fixed; z-index: 100; inset: 0; display: flex; align-items: center; justify-content: center; padding: 10px; background: rgba(15, 20, 30, 0.45); }
.dialogue {
  display: flex; flex-direction: column; width: min(540px, 100%); max-height: 100%;
  background: #fff; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); outline: none;
}
.dialogue.large { width: min(920px, 100%); }
.dialogue h2 { margin: 0; padding: 12px 16px 6px; font-size: 18px; }
.dialogue .corps { flex: 1 1 auto; overflow-y: auto; padding: 4px 16px 12px; -webkit-overflow-scrolling: touch; white-space: normal; }
.dialogue .corps > p { white-space: pre-line; }
.liste-choix { display: flex; flex-direction: column; gap: 6px; }
.liste-choix button { min-height: 48px; padding: 6px 12px; border: 1px solid var(--bord); border-radius: 8px; background: #fff; text-align: left; }
.liste-cotes fieldset { margin: 6px 0; }
.choix-ligne { border: 1px solid var(--bord); border-radius: 8px; }

/* Exemples */
.exemples input[type=search] { margin-bottom: 8px; }
.deux-colonnes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; min-height: 0; }
@media (max-width: 640px) { .deux-colonnes { grid-template-columns: minmax(0, 1fr); } }
.liste-exemples { max-height: 55vh; overflow-y: auto; padding-right: 4px; }
.groupe-exemples h3 { margin: 10px 0 4px; font-size: 13.5px; color: var(--accent); }
.exemple { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 48px; margin: 2px 0; padding: 6px 10px; text-align: left; border: 1px solid var(--bord); border-radius: 8px; background: #fff; }
.exemple small { color: var(--doux); font-size: 12px; }
.exemple[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-clair); }
.apercu-exemple { max-height: 55vh; overflow-y: auto; }
.apercu-exemple h3 { margin: 4px 0; font-size: 15px; }
.description { white-space: pre-wrap; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; margin: 0; }
@media (max-width: 640px) { .liste-exemples { max-height: 34vh; } .apercu-exemple { max-height: 22vh; } }

/* Tableau des coordonnées */
.tableau-defilant { overflow: auto; max-height: 70vh; border: 1px solid var(--bord); border-radius: 8px; }
table.coordonnees { border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.coordonnees th { position: sticky; top: 0; background: #f2f4f7; padding: 6px; text-align: right; }
table.coordonnees td { padding: 6px; text-align: right; border-top: 1px solid #edf0f3; }
table.coordonnees tr.choisi td { background: #dff3df; }
.a-propos p { margin: 8px 0; }

/* Impression : seulement le dessin (et le commentaire) */
#impression { display: none; }
@media print {
  @page { size: landscape; margin: 10mm; }
  html, body { overflow: visible; height: auto; background: #fff; }
  #app, .voile { display: none !important; }
  #impression { display: block; }
  #impression h1 { font-size: 14pt; margin: 0 0 4mm; }
  .dessin-imprime svg { display: block; width: 100%; height: auto; max-height: 170mm; }
  #impression pre { white-space: pre-wrap; font: 10pt/1.3 sans-serif; margin-top: 4mm; }
}

/* Petits écrans : barre en icônes seules (libellé dans l'infobulle et pour les lecteurs d'écran) */
@media (max-width: 440px) {
  .bouton-barre span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .bouton-barre { height: 48px; }
  .titre { font-size: 14px; }
  #panneau-pied button, .dialogue .pied button { flex: 1 1 auto; justify-content: center; padding: 6px 8px; font-size: 14px; }
  #panneau-pied button .icone, .dialogue .pied button .icone { display: none; }
}
/* le message bref ne doit cacher ni les boutons ni le titre du panneau */
body.panneau-ouvert .message { bottom: auto; top: 8px; }
/* paysage : panneau à droite sur toute la hauteur ; le message va dans la partie libre, à gauche */
@media (min-aspect-ratio: 1/1) {
  body.panneau-ouvert:not(.panneau-large) .message { left: 8px; transform: none; max-width: calc(100% - min(410px, 58%) - 24px); }
  body.panneau-ouvert.panneau-large .message { top: auto; bottom: 74px; }
}
@media (min-aspect-ratio: 1/1) and (max-height: 420px) {
  body.panneau-ouvert:not(.panneau-large) .message { max-width: calc(100% - min(410px, 66%) - 24px); }
}
@media (max-width: 560px) {
  #barre-contexte { left: 4px; right: 4px; width: auto; max-width: none; flex-wrap: nowrap; padding: 2px; }
  #contexte-nom { display: none; }
  #barre-contexte button { flex: 1 1 0; min-width: 0; font-size: 10px; line-height: 1.1; white-space: normal; text-align: center; padding: 2px 1px; }
  #vue-boutons { top: 40%; }
}
/* Faible hauteur (téléphone en paysage) : une seule ligne d'icônes, sans le nom de l'objet ni les
   libellés (ils restent en infobulle et pour les lecteurs d'écran) */
@media (max-height: 500px) and (min-width: 561px) {
  #barre-contexte { flex-wrap: nowrap; padding: 2px 4px; gap: 2px; }
  #contexte-nom { display: none; }
  #barre-contexte button { min-width: 46px; min-height: 46px; padding: 2px; }
  #barre-contexte button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
/* Appareil tactile sans souris : les raccourcis clavier du menu ne servent à rien */
@media (hover: none) and (pointer: coarse) { .item kbd { display: none; } }
/* Portrait : panneau des propriétés sur la moitié de la hauteur, la scène reste visible au-dessus ;
   le bouton « Agrandir le panneau » (en-tête) le passe aux 7/8 */
#panneau .basculer-taille { display: none; }
@media (max-aspect-ratio: 1/1) {
  #panneau, #panneau.large { height: 50%; min-height: 240px; }
  #panneau.agrandi { height: 88%; }
  #panneau .basculer-taille { display: flex; }
  #panneau.agrandi .basculer-taille svg { transform: rotate(180deg); }
}
/* Portrait, panneau ouvert : boutons de zoom dans la partie visible du dessin, au-dessus du panneau */
@media (max-aspect-ratio: 1/1) { body.panneau-ouvert #vue-boutons { top: 25%; } }
