/* ==========================================================================
   Studio carte de visite : formulaire (papier) + table lumineuse (encre)
   ========================================================================== */

.studio { background: var(--papier); color: var(--encre); padding: calc(var(--section) + 1rem) 0 var(--section); position: relative; }
.studio .titre-section h2 em { color: var(--magenta); }
.studio__grille { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: clamp(1.5rem, 3vw, 3rem); align-items: start; }

/* ---------- Formulaire ---------- */
.formulaire { display: grid; gap: 1.2rem; }
.etape { border: 0; margin: 0; padding: 1.6rem; background: var(--blanc); border-radius: var(--rayon); box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 12px 30px -18px rgba(0,0,0,.25); }
.etape legend { float: left; width: 100%; padding: 0; margin-bottom: 1.2rem; display: flex; align-items: center; gap: .8rem; font: 700 1.15rem/1 var(--f-titre); }
.etape legend + * { clear: both; }
.etape__num { font: 500 var(--t-xs)/1 var(--f-texte); letter-spacing: .2em; color: var(--blanc); background: var(--encre); border-radius: 999px; padding: .45rem .6rem; }

.champs { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.champ { display: grid; gap: .35rem; }
.champ--large { grid-column: 1 / -1; }
.champ span { font-size: var(--t-xs); letter-spacing: .14em; text-transform: uppercase; color: #6d6d75; }
.champ input {
  font: 400 1rem/1.3 var(--f-texte); color: var(--encre); width: 100%;
  padding: .8rem .9rem; border-radius: var(--rayon-s); border: 1.5px solid var(--papier-2); background: #FBFAF8;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.champ input::placeholder { color: #b3b0aa; }
.champ input:focus { outline: none; border-color: var(--magenta); background: var(--blanc); box-shadow: 0 0 0 4px var(--magenta-voile); }
.champ input.is-modifie, .champ textarea.is-modifie { border-color: var(--cyan); }
.champ textarea {
  font: 400 1rem/1.45 var(--f-texte); color: var(--encre); width: 100%; resize: vertical; min-height: 5.2rem;
  padding: .8rem .9rem; border-radius: var(--rayon-s); border: 1.5px solid var(--papier-2); background: #FBFAF8;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.champ textarea::placeholder { color: #b3b0aa; }
.champ textarea:focus { outline: none; border-color: var(--magenta); background: var(--blanc); box-shadow: 0 0 0 4px var(--magenta-voile); }
.champ__aide { font-size: .8rem; color: #85838c; }
.champ__aide.is-ia { color: var(--magenta); }
.champ__aide.is-ia::before { content: "✦ "; }

/* Choix de l'orientation */
.orientation { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1.2rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--papier-2); }
.orientation__titre { width: 100%; font-size: var(--t-xs); letter-spacing: .14em; text-transform: uppercase; color: #6d6d75; margin-bottom: .2rem; }
.orientation label { cursor: pointer; }
.orientation input { position: absolute; opacity: 0; }
.orientation label span { display: inline-flex; align-items: center; gap: .55rem; padding: .6rem .95rem; border-radius: 999px; border: 1.5px solid var(--papier-2); font-size: .92rem; transition: all .2s; }
.orientation label input:checked + span { border-color: var(--encre); background: var(--encre); color: var(--blanc); }
.orientation input:focus-visible + span { outline: 2px solid var(--magenta); outline-offset: 2px; }
.orientation i { display: inline-block; border: 1.5px solid currentColor; border-radius: 2px; }
.ico-paysage { width: 17px; height: 11px; }
.ico-portrait { width: 11px; height: 17px; }
.ico-auto { width: 14px; height: 14px; border-style: dashed !important; border-radius: 50% !important; }

/* Dépôts de fichiers */
.depots { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.depot {
  position: relative; display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: .9rem; min-height: 96px;
  padding: .9rem; border: 1.5px dashed #cfc9bf; border-radius: var(--rayon-s); cursor: pointer; background: #FBFAF8;
  transition: border-color .2s, background .2s;
}
.depot:hover, .depot.is-survol { border-color: var(--magenta); background: #fff5fa; }
.depot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.depot__visuel {
  width: 64px; height: 64px; border-radius: 6px; display: grid; place-items: center; overflow: hidden;
  background: var(--papier) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' fill='none' stroke='%23E4007C' stroke-width='1.6'%3E%3Cpath d='M13 18V5M7.5 10.5 13 5l5.5 5.5M4 21h18'/%3E%3C/svg%3E") center no-repeat;
}
.depot--option .depot__visuel { filter: grayscale(1) opacity(.6); }
.depot.is-rempli .depot__visuel { background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 12px 12px; filter: none; }
.depot__visuel img { max-width: 90%; max-height: 90%; object-fit: contain; }
.depot__texte { display: grid; gap: .2rem; font-size: .95rem; line-height: 1.25; }
.depot__texte small { color: #77757f; font-size: var(--t-xs); overflow-wrap: anywhere; }
.depot.is-erreur { border-color: #d0021b; }
.depot__retirer {
  position: absolute; top: -10px; right: -10px; z-index: 2; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: var(--encre); color: var(--blanc); font: 400 18px/1 var(--f-texte); cursor: pointer;
  display: grid; place-items: center; padding: 0 0 2px; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: background .2s, transform .2s;
}
.depot__retirer:hover { background: var(--magenta); transform: scale(1.08); }

/* Interrupteur QR */
.interrupteur { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; cursor: pointer; }
.interrupteur + .interrupteur { margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px solid var(--papier-2); }
.interrupteur input { position: absolute; opacity: 0; }
.interrupteur__piste { width: 48px; height: 28px; border-radius: 999px; background: #d6d1c8; position: relative; transition: background .25s; }
.interrupteur__piste::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--blanc); box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .25s; }
.interrupteur input:checked + .interrupteur__piste { background: var(--magenta); }
.interrupteur input:checked + .interrupteur__piste::after { transform: translateX(20px); }
.interrupteur input:focus-visible + .interrupteur__piste { outline: 2px solid var(--magenta); outline-offset: 3px; }
.interrupteur b { display: block; font-weight: 500; }
.interrupteur small { color: #6d6d75; font-size: .85rem; }

.formulaire__erreur { margin: 0; padding: .9rem 1rem; border-radius: var(--rayon-s); background: #fde8ef; color: #9a0045; font-size: .95rem; }
.formulaire__actions { display: grid; gap: .7rem; }
.formulaire__actions .bouton { padding-block: 1.25rem; font-size: var(--t-s); }
.bouton--retouche { --fond: var(--encre); color: var(--blanc); flex-direction: column; gap: .35rem; }
.bouton--retouche small { font-size: .68rem; letter-spacing: .1em; opacity: .65; text-transform: none; }
.bouton--retouche:hover { --fond: #26262c; }
.bouton[disabled] { opacity: .6; pointer-events: none; }
.lien-exemple { justify-self: center; background: none; border: 0; cursor: pointer; font: 400 var(--t-s)/1 var(--f-texte); color: #6d6d75; text-decoration: underline; text-underline-offset: 4px; padding: .5rem; }
.lien-exemple:hover { color: var(--magenta); }

/* ---------- Table lumineuse ---------- */
.table {
  position: sticky; top: 90px; color: var(--blanc); border-radius: calc(var(--rayon) + 4px); overflow: hidden;
  background:
    radial-gradient(70% 55% at 50% 38%, rgba(228,0,124,.16), transparent 70%),
    linear-gradient(var(--encre-2), var(--encre));
  box-shadow: 0 30px 70px -30px rgba(0,0,0,.6);
}
.table::before { /* quadrillage de table de montage */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 24px 24px;
}
.table__barre { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.table__titre { font-size: var(--t-xs); letter-spacing: .3em; text-transform: uppercase; color: var(--gris); }
.table__outils { display: flex; gap: .35rem; }
.outil { background: transparent; color: var(--gris-clair); border: 1px solid rgba(255,255,255,.14); border-radius: 999px; padding: .45rem .85rem; font: 400 var(--t-xs)/1 var(--f-texte); letter-spacing: .12em; text-transform: uppercase; cursor: pointer; transition: all .2s; }
.outil:hover { color: var(--blanc); border-color: rgba(255,255,255,.4); }
.outil.is-actif, .outil[aria-pressed="true"] { background: var(--blanc); color: var(--encre); border-color: var(--blanc); }
.table[data-etat="vide"] .outil, .table[data-etat="chargement"] .outil { opacity: .35; pointer-events: none; }

.table__plateau { position: relative; padding: clamp(3rem, 6vw, 4.5rem) clamp(2.4rem, 6vw, 4.5rem) clamp(2.6rem, 5vw, 3.6rem); }
.epreuve { position: relative; perspective: 1400px; color: var(--gris-clair); }

/* Rognage : le canvas contient la page avec fond perdu (91 × 61), on montre le format fini */
.rogne { position: absolute; inset: 0; overflow: hidden; }
.epreuve { --L: 85; --H: 55; margin-inline: auto; transition: width .5s; }
.epreuve.is-portrait { --L: 55; --H: 85; width: min(62%, 300px); }
.carte3d--epreuve { aspect-ratio: var(--L) / var(--H); }
.rogne canvas { position: absolute; width: calc((var(--L) + 6) / var(--L) * 100%); height: calc((var(--H) + 6) / var(--H) * 100%); left: calc(-3 / var(--L) * 100%); top: calc(-3 / var(--H) * 100%); }
.epreuve.is-fond-perdu .carte3d { aspect-ratio: calc(var(--L) + 6) / calc(var(--H) + 6); }
.epreuve.is-fond-perdu .carte3d__face { border-radius: 0; }
.epreuve.is-fond-perdu .rogne canvas { width: 100%; height: 100%; left: 0; top: 0; }
.epreuve.is-fond-perdu .rogne::after { /* trait de coupe en surimpression */
  content: ""; position: absolute; left: calc(3 / (var(--L) + 6) * 100%); right: calc(3 / (var(--L) + 6) * 100%); top: calc(3 / (var(--H) + 6) * 100%); bottom: calc(3 / (var(--H) + 6) * 100%);
  border: 1px dashed var(--cyan); box-shadow: 0 0 0 999px rgba(0,0,0,.28);
}

.carte3d__vide {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: .8rem; text-align: center;
  border: 1.5px dashed rgba(255,255,255,.18); border-radius: 5px; color: var(--gris); font-size: var(--t-s); letter-spacing: .08em;
  backface-visibility: hidden;
}
.carte3d__vide img { opacity: .5; width: 40px; height: auto; }
.carte3d__vide p { margin: 0; }
.table:not([data-etat="vide"]) .carte3d__vide { display: none; }
.table[data-etat="vide"] .carte3d--epreuve .carte3d__face { visibility: hidden; }

/* Chargement : la carte « s'imprime » */
.balayage { position: absolute; inset: 0; pointer-events: none; opacity: 0; border-radius: 5px; overflow: hidden; }
.table[data-etat="chargement"] .balayage { opacity: 1; }
.table[data-etat="chargement"] .carte3d--epreuve .carte3d__face--recto { visibility: visible; background: #141418; }
.balayage::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(228,0,124,.75) 1px, transparent 1.6px); background-size: 9px 9px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%, #000 60%, transparent); mask-image: linear-gradient(90deg, transparent, #000 40%, #000 60%, transparent);
  -webkit-mask-size: 50% 100%; mask-size: 50% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  animation: impression 2.2s ease-in-out infinite;
}
.balayage::after { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--magenta); box-shadow: 0 0 18px 4px rgba(228,0,124,.6); animation: tete 2.2s ease-in-out infinite; }
@keyframes impression { from { -webkit-mask-position: -60% 0; mask-position: -60% 0; } to { -webkit-mask-position: 160% 0; mask-position: 160% 0; } }
@keyframes tete { from { left: -2%; } to { left: 102%; } }

.table[data-etat="pret"] .carte3d--epreuve { animation: pose .9s cubic-bezier(.2,.8,.2,1); }
@keyframes pose { from { transform: translateY(18px) rotateX(18deg) scale(.96); opacity: 0; } }

/* Progression */
.progression { position: relative; list-style: none; margin: 0; padding: 0 1.6rem 1.6rem; display: none; gap: .65rem; font-size: .95rem; color: var(--gris); }
.table[data-etat="chargement"] .progression { display: grid; }
.progression li { display: flex; align-items: center; gap: .8rem; transition: color .3s; }
.progression i { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.2); flex: none; position: relative; }
.progression li.is-encours { color: var(--blanc); }
.progression li.is-encours i { border-color: var(--magenta); border-top-color: transparent; animation: tourne .8s linear infinite; }
.progression li.is-fait { color: var(--gris-clair); }
.progression li.is-fait i { border-color: var(--magenta); background: var(--magenta) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.2'%3E%3Cpath d='M4 8.5 7 11l5-6'/%3E%3C/svg%3E") center / 12px no-repeat; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* Résultat */
.resultat { position: relative; padding: 0 1.6rem 1.6rem; display: grid; gap: 1.2rem; }
.resultat[hidden] { display: none; }
.resultat__analyse { margin: 0; font-weight: 300; color: var(--gris-clair); font-size: .98rem; border-left: 2px solid var(--magenta); padding-left: 1rem; }
.resultat__charte { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.nuancier { display: flex; }
.nuancier span { width: 34px; height: 34px; border-radius: 50%; margin-right: -8px; border: 2px solid var(--encre-2); position: relative; }
.nuancier span:hover::after { content: attr(data-hex); position: absolute; bottom: 120%; left: 50%; translate: -50% 0; font-size: .7rem; background: var(--blanc); color: var(--encre); padding: .2rem .4rem; border-radius: 4px; white-space: nowrap; }
.resultat__polices { margin: 0 0 0 .6rem; font-size: var(--t-s); color: var(--gris-clair); }
.resultat__polices b { color: var(--blanc); font-weight: 500; }
.resultat__actions { display: flex; flex-wrap: wrap; gap: .7rem; }
.bouton--ligne-clair { border-color: rgba(255,255,255,.3); color: var(--blanc); }
.bouton--ligne-clair:hover { border-color: var(--blanc); }

@media (max-width: 980px) {
  .studio__grille { grid-template-columns: 1fr; }
  .table { position: relative; top: 0; }
}
@media (max-width: 620px) {
  .champs, .depots { grid-template-columns: 1fr; }
  .etape { padding: 1.2rem; }
  .table__barre { flex-direction: column; align-items: flex-start; }
}
