/* l'attribut hidden l'emporte toujours sur un display posé plus bas */
[hidden] { display: none !important; }

/* Éditeur ArtWall Perso — mobile d'abord (390 px), aucune ressource externe. */

* { box-sizing: border-box; }

:root {
  --encre: #1c1c1c;
  --encre-douce: #5a5a5a;
  --papier: #ffffff;
  --fond: #f4f3f0;
  --liseret: #e3e1dc;
  --accent: #1c1c1c;
  --danger: #b3261e;
  --rayon: 12px;
  --touche-min: 44px;
}

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--encre);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.visuellement-cache {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

/* ------------------------------------------------ entête */
.entete {
  flex: 0 0 auto;
  padding: 10px 14px;
  background: var(--papier);
  border-bottom: 1px solid var(--liseret);
}

.entete__ligne {
  display: flex;
  align-items: center;
  gap: 8px;
}

.entete__pastille {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #2e9e5b;
  flex: 0 0 auto;
}

.entete__titre {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entete__mention {
  font-size: 0.72rem;
  color: var(--encre-douce);
  flex: 0 0 auto;
}

/* ------------------------------------------------ scène */
.scene {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  position: relative;
}

.scene__toile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
}

.scene__toile canvas {
  display: block;
  touch-action: none;
}

/* Ombre portée au mur, lumière venant de la droite comme sur les rendus PSD :
   portée sur le conteneur (les deux calques du canevas ensemble). */
.scene__toile .canvas-container { filter: drop-shadow(-1px 2px 3px rgba(0, 0, 0, 0.12)); }
.scene__toile[data-rendu="cadre"] .canvas-container {
  filter: drop-shadow(-7px 10px 11px rgba(0, 0, 0, 0.20)) drop-shadow(-1px 2px 2px rgba(0, 0, 0, 0.16));
}
.scene__toile[data-rendu="toile"] .canvas-container {
  filter: drop-shadow(-5px 7px 8px rgba(0, 0, 0, 0.18)) drop-shadow(-1px 1px 2px rgba(0, 0, 0, 0.14));
}

.scene__etat {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
  color: var(--encre-douce);
}

.scene__etat--erreur p { color: var(--danger); }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--liseret);
  border-top-color: var(--encre);
  border-radius: 50%;
  animation: tourne 0.9s linear infinite;
}

@keyframes tourne { to { transform: rotate(360deg); } }

/* ------------------------------------------------ outils */
.outils {
  flex: 0 0 auto;
  background: var(--papier);
  border-top: 1px solid var(--liseret);
  display: flex;
  flex-direction: column;
  /* hauteur FIXE : un panneau qui grandit rétrécirait le tableau sous le doigt */
  height: 42dvh;
}
.outils.replie { height: auto; }
.outils__panneaux { flex: 1 1 auto; min-height: 0; }

.outils__poignee {
  width: 100%;
  min-height: 28px;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0 2px;
}

.outils__chevron {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: #c9c6bf;
  transition: transform 0.15s ease;
}

.outils.replie .outils__chevron { transform: rotate(180deg); }

.outils__onglets {
  display: flex;
  border-bottom: 1px solid var(--liseret);
}

.onglet {
  flex: 1 1 0;
  min-height: var(--touche-min);
  border: 0;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--encre-douce);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  padding: 0 6px;
}

.onglet.is-actif {
  color: var(--encre);
  border-bottom-color: var(--encre);
}

.outils__panneaux {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.panneau { padding: 14px; }
.panneau[hidden] { display: none; }

.panneau__vide {
  margin: 8px 0 4px;
  color: var(--encre-douce);
  font-size: 0.88rem;
}

/* ------------------------------------------------ champs */
.champ { margin: 0 0 14px; }

.champ > label,
.champ__libelle,
.champ legend {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--encre-douce);
  margin: 0 0 6px;
  padding: 0;
}

.champ__valeur {
  float: right;
  font-weight: 400;
  text-transform: none;
  color: var(--encre);
}

.champ__ligne {
  display: flex;
  align-items: center;
  gap: 8px;
}

.champ--case .case {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--touche-min);
  font-size: 0.95rem;
  font-weight: 400;
  text-transform: none;
  color: var(--encre);
}

.champ--case .case input { width: 20px; height: 20px; }

textarea,
select,
input[type="text"],
input[type="number"] {
  width: 100%;
  min-height: var(--touche-min);
  font-size: max(16px, 1rem);   /* ≥ 16px : Safari iOS n'ouvre/ferme pas le clavier au focus */
  font-family: inherit;
  color: var(--encre);
  background: var(--fond);
  border: 1px solid var(--liseret);
  border-radius: var(--rayon);
  padding: 10px 12px;
  -webkit-appearance: none;
  appearance: none;
}

textarea { resize: vertical; line-height: 1.4; }

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--encre-douce) 50%),
                    linear-gradient(135deg, var(--encre-douce) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

input[type="range"] {
  width: 100%;
  height: var(--touche-min);
  accent-color: var(--accent);
}

input[type="color"] {
  width: var(--touche-min);
  height: var(--touche-min);
  min-height: var(--touche-min);
  padding: 4px;
  border: 1px solid var(--liseret);
  border-radius: 10px;
  background: var(--papier);
  cursor: pointer;
  flex: 0 0 auto;
}

.couleur-ligne {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.palette {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.palette__pastille {
  width: var(--touche-min);
  height: var(--touche-min);
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.12);
  cursor: pointer;
  padding: 0;
}

.palette__pastille.is-actif {
  outline: 2px solid var(--encre);
  outline-offset: 1px;
}

.groupe-boutons { display: flex; gap: 6px; }

.controles { margin-top: 6px; }

.controles__actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* ------------------------------------------------ boutons */
.bouton {
  min-height: var(--touche-min);
  border: 1px solid var(--liseret);
  border-radius: var(--rayon);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0 16px;
  cursor: pointer;
  background: var(--papier);
  color: var(--encre);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.bouton--plein { width: 100%; }

.bouton--primaire { background: var(--encre); color: var(--papier); border-color: var(--encre); }
.bouton--secondaire { background: var(--papier); color: var(--encre); }
.bouton--danger { background: var(--papier); color: var(--danger); border-color: #e6b7b3; }
.bouton--panier { width: 100%; background: var(--encre); color: var(--papier); border-color: var(--encre); }
.bouton--panier:disabled { background: #c9c6bf; color: #fff; border-color: #c9c6bf; cursor: not-allowed; }

.bouton:active { opacity: 0.75; }

.aide { font-size: 0.78rem; color: var(--encre-douce); margin: 6px 0 0; }

.message {
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: var(--encre);
}
.message--erreur { color: var(--danger); }
.message--succes { color: #2e9e5b; }

.prix {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 4px 0 14px;
}

.prix__total {
  margin-left: 8px;
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--encre-douce);
}

.prix-des {
  margin: -6px 0 12px;
  font-size: 0.82rem;
  color: var(--encre-douce);
}

/* petite animation d'attente pour le détourage */
.attente {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: tourne 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

/* ------------------------------------------------ panier */
.bouton--panier { margin-top: 10px; }

#voir-situation { margin-bottom: 8px; }

.mention-panier {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--encre-douce);
}

/* ------------------------------------------------ vue « en situation » */
.situation {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #1c1c1c;
}

.situation__toile {
  display: block;
  width: 100%;
  height: 100%;
}

.situation__fermer {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
