/* =============================================================================================
   css/editeur.css (Lucas, vague 4, 27-28/11/2026) : l'éditeur libre des visuels (js/editeur.js)
   et la section « Mes modèles » des pages Réseaux sociaux et Imprimés. Toutes les classes commencent
   par « ed- ». Les couleurs passent par les jetons du socle ; dans la fenêtre, le creux est le sable
   neutre (règle des fenêtres) et le violet reste aux boutons, aux liens et au contour clavier.
   ============================================================================================= */

/* ---------- La fenêtre : presque tout l'écran à l'ordinateur, tout l'écran au téléphone ---------- */
.llv-voile:has(> .ed-fenetre) {
    padding: 12px max(12px, env(safe-area-inset-right, 0px)) 12px max(12px, env(safe-area-inset-left, 0px));
}
.llv-fenetre.ed-fenetre {
    width: 100%;
    max-width: none;
    height: calc(100dvh - 24px);
    max-height: none;
    overflow: hidden;
}
.ed-fenetre .llv-fenetre__tete { padding: 12px 72px 10px 20px; }
.ed-fenetre .llv-fenetre__titre { font-size: 21px; }
.ed-fenetre .llv-fenetre__desc { margin-top: 2px; font-size: 14px; }
.ed-fenetre .llv-fenetre__croix { top: 10px; right: 12px; }
.ed-fenetre .llv-fenetre__corps {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.ed-fenetre .llv-fenetre__pied { position: relative; z-index: 4; background: var(--objet); }

/* La zone de saisie cachée de fabric (le clavier du téléphone s'ouvre grâce à elle) */
.ed-saisie-cachee { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }

/* ---------- La mise en page : barre du haut, la page et ses réglages, la barre du bas (téléphone) ---------- */
.ed {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
}
.ed-barre {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 8px 12px;
    border-bottom: var(--filet);
    background: var(--objet);
}
.ed-barre__groupe { display: flex; align-items: center; gap: 6px; flex: none; }
.ed-barre__espace { flex: 1 1 auto; min-width: 0; }
.ed-barre__faces { flex: none; }
.ed-barre__faces .llv-onglets { width: auto; }
.ed-barre .llv-btn--icone { width: 40px; min-width: 40px; min-height: 40px; }
.ed-zoom {
    min-width: 64px;
    height: 40px;
    padding: 0 8px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--encre-2);
    font: 600 14px/1 var(--police);
    transition: background-color var(--t-survol) ease, color var(--t-survol) ease;
}
.ed-zoom:hover { background: var(--sable); color: var(--encre); }
.ed-zoom:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.ed-entier { display: none; }
.ed-entier[hidden] { display: none !important; }

.ed-centre {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 344px;
    min-height: 0;
}
.ed-scene {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--sable);
    outline: none;
}
.ed-scene:focus-visible { box-shadow: inset 0 0 0 3px var(--violet); }
.ed-scene .canvas-container { position: absolute !important; left: 0; top: 0; opacity: 0; transition: opacity var(--t-entree) ease; }
.ed-scene.est-prete .canvas-container { opacity: 1; }
.ed-scene canvas { touch-action: none; }

/* L'attente : la forme de la page, immobile, et ce qui se passe */
.ed-attente {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 16px;
    padding: 24px;
    background: var(--sable);
}
.ed-attente[hidden] { display: none; }
.ed-attente__page {
    width: min(56vh, 70vw, 420px);
    max-height: 60vh;
    border-radius: 6px;
    background: var(--sable-fort);
}
.ed-attente__texte { display: inline-flex; align-items: center; gap: 10px; font: 600 15px/1.4 var(--police); color: var(--encre-2); }
.ed-attente .llv-erreur-page { max-width: 420px; }

/* ---------- Le panneau des réglages (ordinateur) ---------- */
.ed-panneau {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: grid;
    align-content: start;
    gap: 24px;
    padding: 16px 16px 28px;
    border-left: var(--filet);
    background: var(--objet);
    scrollbar-width: thin;
    scrollbar-color: rgba(34, 23, 38, 0.3) transparent;
}
.ed-panneau::-webkit-scrollbar { width: 10px; }
.ed-panneau::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 999px; background: rgba(34, 23, 38, 0.3) padding-box; }
.ed-section { display: grid; gap: 14px; min-width: 0; }
.ed-section + .ed-section { padding-top: 20px; border-top: var(--filet); }
.ed-section__titre { font: 800 16px/1.3 var(--police); color: var(--encre); }
.ed-note { font-size: 15px; line-height: 1.5; color: var(--encre-2); }
.ed-ajouter { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ed-ajouter .llv-btn { justify-content: flex-start; padding-left: 12px; padding-right: 10px; }
.ed-rangee { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-deux { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ed-icones { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-dispo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ed-dispo .llv-btn { justify-content: flex-start; padding-left: 12px; }
.ed-dispo .ed-supprimer { grid-column: 1 / -1; justify-content: center; }
.ed-panneau .llv-volet, .ed-feuille .llv-volet { min-width: 0; }

/* Le pas à pas (taille, épaisseur, opacité) */
.ed-pas { display: grid; gap: 6px; min-width: 0; }
.ed-pas .llv-champ__libelle { margin: 0; }
.ed-pas__ligne { display: flex; align-items: center; gap: 6px; }
.ed-pas__saisie {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 132px;
    height: 44px;
    padding: 0 10px;
    border: 1.5px solid var(--trait-champ-fenetre);
    border-radius: var(--rayon-champ);
    background: var(--champ);
}
.ed-pas__saisie:focus-within { border: 2px solid var(--encre); padding: 0 9.5px; outline: 2px solid var(--violet); outline-offset: 2px; }
.ed-pas__valeur {
    width: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--encre);
    font: 600 16px/1 var(--police);
    text-align: center;
    outline: none;
}
.ed-pas__unite { flex: none; font: 500 14px/1 var(--police); color: var(--encre-2); }

/* Les choix en barre (alignement, cadre) et les boutons à deux états (gras, italique) */
.ed-segment { flex-wrap: wrap; }
.ed-segment .llv-onglet { padding: 0 12px; }
.ed-bascule[aria-pressed="true"] { border-color: var(--encre); background: var(--objet); color: var(--encre); font-weight: 700; box-shadow: inset 0 0 0 1px var(--encre); }
.ed-bascule--gras span { font-weight: 800; }
.ed-bascule--italique span { font-style: italic; }
.ed-bascule[aria-disabled="true"] { cursor: not-allowed; color: var(--encre-3); border-color: rgba(34, 23, 38, 0.3); }

/* Les polices : chacune écrite dans sa police ; choisie = creux + bord encre + coche */
.ed-polices { display: grid; gap: 8px; }
.ed-police {
    position: relative;
    display: grid;
    gap: 2px;
    min-height: 56px;
    padding: 8px 14px;
    border: 1.5px solid var(--trait-champ-fenetre);
    border-radius: var(--rayon-champ);
    background: var(--objet);
    color: var(--encre);
    text-align: left;
    transition: background-color var(--t-survol) ease, border-color var(--t-survol) ease;
}
.ed-police:hover { border-color: var(--encre); background: var(--objet-survol); }
.ed-police[aria-checked="true"] { border: 2px solid var(--encre); padding: 7.5px 13.5px; background: var(--creux); }
.ed-police:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.ed-police__nom { font-size: 21px; line-height: 1.2; }
.ed-police__role { font: 400 14px/1.3 var(--police); color: var(--encre-2); }
.ed-police .llv-coche { top: -9px; right: -9px; }

/* Les couleurs du kit */
.ed-nuancier { display: flex; flex-wrap: wrap; gap: 2px; margin: -2px; }
.ed-teinte {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
}
.ed-teinte__rond {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    box-shadow: inset 0 0 0 1.5px rgba(34, 23, 38, 0.5);
    transition: transform var(--t-survol) var(--courbe);
}
.ed-teinte:hover .ed-teinte__rond { transform: scale(1.08); }
.ed-teinte[aria-checked="true"] .ed-teinte__rond { box-shadow: inset 0 0 0 1.5px rgba(34, 23, 38, 0.5), 0 0 0 2px var(--objet), 0 0 0 4px var(--encre); }
.ed-teinte__coche { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.ed-teinte__coche svg { width: 16px; height: 16px; }
.ed-teinte:focus-visible { outline: 3px solid var(--violet); outline-offset: -1px; }
.ed-teinte--aucune .ed-teinte__rond {
    background: linear-gradient(135deg, transparent 45%, var(--rouge) 45%, var(--rouge) 55%, transparent 55%), #FFFFFF;
}
.ed-autre-couleur { max-width: 220px; }

/* Les alertes (photo trop petite, QR trop petit) */
.ed-alerte-boite:empty { display: none; }
.ed-alerte {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--peche);
    color: var(--peche-t);
    font: 500 15px/1.45 var(--police);
}
.ed-alerte svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.ed-alerte--info { background: var(--cyan); color: var(--cyan-t); }

/* La légende des repères d'impression (les mêmes couleurs que l'atelier d'Imprimés) */
.ed-legende { display: grid; gap: 6px; margin: -4px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--encre-2); }
.ed-legende[hidden] { display: none; }
.ed-legende li { display: flex; align-items: center; gap: 8px; }
.ed-legende__ech { flex: none; width: 22px; height: 12px; border-radius: 3px; }
.ed-legende__ech--fp { background: rgba(214, 40, 106, 0.18); border: 1.5px solid rgba(214, 40, 106, 0.45); }
.ed-legende__ech--coupe { border: 2px solid #C81E4E; }
.ed-legende__ech--secu { border: 2px dashed #2F6DB0; }

/* Les éléments de la page (pour en choisir un au clavier ou au doigt) */
.ed-elements { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin: 0; padding: 0; list-style: none; }
.ed-element {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 6px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--encre);
    font: 500 15px/1.3 var(--police);
    text-align: left;
}
.ed-element:hover { background: var(--sable-survol); }
.ed-element:focus-visible { outline: 3px solid var(--violet); outline-offset: 0; }
.ed-element svg { width: 20px; height: 20px; flex: none; color: var(--encre-2); }
.ed-element__nom { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-element__verrou { display: inline-flex; color: var(--encre-3); }
.ed-raccourcis { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; margin: 0; font-size: 14px; }
.ed-raccourcis dt { color: var(--encre-2); }
.ed-raccourcis dd { margin: 0; font-weight: 600; color: var(--encre); text-align: right; }

/* ---------- Ajouter une photo, une forme (fenêtres) ---------- */
.ed-photos { display: grid; gap: 22px; }
.ed-photos__groupe { display: grid; gap: 10px; justify-items: start; }
.ed-photos__titre { font: 800 16px/1.3 var(--police); color: var(--encre); }
.ed-photos__grille { display: grid; gap: 10px; width: 100%; grid-template-columns: repeat(auto-fill, minmax(min(100%, 112px), 1fr)); }
.ed-vignette {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    padding: 0;
    border: 1.5px solid var(--trait-champ-fenetre);
    border-radius: 12px;
    background: var(--sable);
    transition: border-color var(--t-survol) ease, transform 120ms var(--courbe);
}
.ed-vignette img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ed-vignette--logo img { object-fit: contain; padding: 14%; }
.ed-vignette:hover { border-color: var(--encre); }
.ed-vignette:active { transform: scale(0.98); }
.ed-vignette:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.ed-photos .llv-champ__erreur:not([hidden]) { display: flex; gap: 6px; align-items: flex-start; }
.ed-formes { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.ed-forme { justify-items: center; text-align: center; min-height: 112px; align-content: center; }
.ed-forme__dessin { display: grid; place-items: center; width: 48px; height: 48px; color: var(--encre); }
.ed-forme__dessin svg { width: 40px; height: 40px; }
.ed-ajout-texte { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ed-tuile-texte { min-height: 92px; align-content: center; }
.ed-tuile-texte__apercu { font-size: 26px; line-height: 1.15; color: var(--encre); }
.ed-tuile-texte__apercu--texte { font-size: 18px; }

/* ---------- Le téléphone : la barre du bas et la feuille qui monte ---------- */
.ed-outils { display: none; }
.ed-feuille { display: none; }

@media (max-width: 899.98px) {
    .llv-voile:has(> .ed-fenetre) { padding: 0; }
    .llv-fenetre.ed-fenetre {
        height: 100dvh;
        max-height: 100dvh;
        border-width: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .ed-fenetre .llv-fenetre__tete { padding: calc(10px + env(safe-area-inset-top, 0px)) 64px 8px 16px; }
    .ed-fenetre .llv-fenetre__titre { font-size: 20px; }
    .ed-ordi { display: none !important; }
    /* « Voir en entier » : un rond posé en bas à droite de la page, seulement quand on a zoomé */
    .ed-entier { position: absolute; right: 12px; bottom: 12px; z-index: 2; display: inline-flex; }
    .ed-barre .llv-btn--icone { width: 44px; min-width: 44px; min-height: 44px; }
    .ed-pas .llv-btn--icone.llv-btn--petit, .ed-feuille__tete .llv-btn--icone.llv-btn--petit { width: 44px; min-width: 44px; min-height: 44px; }
    .ed-note, .ed-element { font-size: 16px; }
    .ed-barre { gap: 6px; padding: 6px max(10px, env(safe-area-inset-right, 0px)) 6px max(10px, env(safe-area-inset-left, 0px)); }
    .ed-sauver { width: 44px; min-width: 44px; padding: 0; }
    .ed-sauver .llv-btn__txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .ed-telecharger { padding: 8px 14px; }
    .ed--faces .ed-barre { flex-wrap: wrap; }
    .ed--faces .ed-barre__faces { order: 5; flex: 1 1 100%; }
    .ed--faces .ed-barre__faces .llv-onglets { width: 100%; }
    .ed-centre { grid-template-columns: minmax(0, 1fr); }
    .ed-panneau { display: none; }
    .ed-outils {
        display: flex;
        align-items: stretch;
        gap: 2px;
        padding: 6px max(6px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
        border-top: var(--filet);
        background: var(--objet);
    }
    .ed-outil {
        flex: 1 1 0;
        min-width: 0;
        display: grid;
        justify-items: center;
        align-content: center;
        gap: 3px;
        min-height: 56px;
        padding: 4px 2px;
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: var(--encre);
        font: 600 13px/1.15 var(--police);
        transition: background-color var(--t-survol) ease, transform 120ms var(--courbe);
    }
    .ed-outil span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .ed-outil svg { width: 24px; height: 24px; }
    .ed-outil:active { background: var(--sable); transform: scale(0.97); }
    .ed-outil:focus-visible { outline: 3px solid var(--violet); outline-offset: -3px; }
    .ed-outil[aria-expanded="true"] { background: var(--sable); box-shadow: inset 0 0 0 2px var(--encre); }
    .ed-feuille {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 3;
        display: flex;
        flex-direction: column;
        max-height: min(54%, 440px);
        border-top: 2px solid var(--encre);
        border-radius: 18px 18px 0 0;
        background: var(--objet);
        opacity: 0;
        transform: translateY(24px);
        transition: transform var(--t-fenetre) var(--courbe), opacity var(--t-court) ease;
    }
    .ed-feuille[hidden] { display: none; }
    .ed-feuille.est-ouverte { opacity: 1; transform: none; }
    .ed-feuille__tete { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 6px 16px; }
    .ed-feuille__titre { font: 800 17px/1.3 var(--police); color: var(--encre); }
    .ed-feuille__corps {
        display: grid;
        align-content: start;
        gap: 18px;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 4px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    }
    .ed-feuille .ed-section + .ed-section { padding-top: 16px; }
    .ed-feuille .ed-section__titre { display: none; }
    .ed-feuille .ed-champ-texte textarea, .ed-feuille textarea { min-height: 96px; }
    .ed-ajouter, .ed-dispo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ed-police__nom { font-size: 20px; }
}
@media (max-width: 380px) {
    .ed-telecharger { padding: 8px 12px; }
    .ed-ajout-texte { grid-template-columns: minmax(0, 1fr); }
}

/* Les notifications ne couvrent pas les boutons de l'éditeur : en bas à droite à l'ordinateur,
   au-dessus de la barre du bas au téléphone. */
body:has(.ed-fenetre) .llv-notifs { top: auto !important; bottom: 24px !important; }
@media (max-width: 899.98px) {
    body:has(.ed-fenetre) .llv-notifs { bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important; }
}

/* ---------- « Mes modèles » (pages Réseaux sociaux et Imprimés) ---------- */
.ed-mm { display: grid; gap: 14px; min-width: 0; }
.ed-mm__tete { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.ed-mm__titres { display: grid; gap: 4px; min-width: 0; }
.ed-mm__creer[hidden] { display: none; }
.ed-mm.est-vide .ed-mm__sous-titre { display: none; }
.ed-mm__grille { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.ed-mm__grille.est-vide { grid-template-columns: minmax(0, 1fr); }
.ed-mm__vide {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 12px 16px;
    border: var(--vide-trait);
    border-radius: var(--rayon-creux);
    background: var(--vide-fond);
}
.ed-mm__vide-ic { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 999px; background: var(--creux); color: var(--encre-2); }
.ed-mm__vide-ic svg { width: 18px; height: 18px; }
.ed-mm__vide-texte { flex: 1 1 260px; min-width: 0; font-size: 15px; line-height: 1.5; color: var(--encre-2); }
.ed-mm__vide-texte strong { color: var(--encre); font-weight: 700; }
@media (max-width: 899.98px) { .ed-mm__vide-texte { font-size: 16px; } .ed-mm__vide .llv-btn { margin-left: 50px; } }
@media (max-width: 380px) { .ed-mm__vide .llv-btn { margin-left: 0; } }
.ed-mm__carte { display: grid; gap: 12px; align-content: start; min-width: 0; }
.ed-mm__vignette {
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 10px;
    background: var(--creux);
    color: var(--encre-3);
}
.ed-mm__vignette img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 0 0 1px rgba(34, 23, 38, 0.12); animation: llv-apparait var(--t-entree) ease both; }
.ed-mm__vignette svg { width: 32px; height: 32px; }
.ed-mm__textes { display: grid; gap: 4px; min-width: 0; }
.ed-mm__textes[hidden], .ed-mm__actions[hidden] { display: none; }
.ed-mm__nom { font: 700 17px/1.3 var(--police); color: var(--encre); overflow-wrap: anywhere; }
.ed-mm__meta { font-size: 14px; line-height: 1.4; color: var(--encre-2); }
.ed-mm__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-mm__renommage { display: grid; gap: 10px; }
.ed-mm__renommage .llv-groupe-btn { gap: 8px; }
@media (max-width: 899.98px) {
    .ed-mm__grille { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .ed-mm__carte { grid-template-columns: 96px minmax(0, 1fr); align-items: start; column-gap: 14px; row-gap: 10px; }
    .ed-mm__vignette { aspect-ratio: 1 / 1; }
    .ed-mm__meta { font-size: 16px; }
    .ed-mm__actions { grid-column: 1 / -1; }
    .ed-mm__renommage { grid-column: 1 / -1; }
}
@media (max-width: 380px) {
    .ed-mm__carte { grid-template-columns: 76px minmax(0, 1fr); }
}

/* Les boutons « Modifier librement » posés dans Réseaux sociaux et Imprimés */
.ed-libre { justify-self: center; }

@media (prefers-reduced-motion: reduce) {
    .ed-feuille, .ed-scene .canvas-container, .ed-teinte__rond, .ed-outil, .ed-vignette { transition: none; }
    .ed-mm__vignette img { animation: none; }
}
