/* ==========================================================
   redaction.css — L'ATELIER DE MISE EN PAGE
   ---------------------------------------------------------
   Le journaliste compose sa page dans un plan de travail de
   794 x 1123 px (A4) : c'est exactement la page qui sera
   imprimée/affichée au lecteur, à la même taille.

   À gauche   : les outils (ajout, calques, page)
   Au centre  : la page, avec les poignées de sélection
   À droite   : les réglages de la zone sélectionnée
   ========================================================== */

:root {
  color-scheme: light;

  --atelier-fond:     #26231f;
  --atelier-panneau:  #1e1c19;
  --atelier-bord:     #3a352e;
  --atelier-texte:    #ddd5c6;
  --atelier-texte-2:  #9a9284;
  --atelier-accent:   #a98a4b;
  --atelier-accent-2: #c0a05e;

  --papier:    #f4efe2;
  --encre:     #1c1a17;
  --danger:    #a8443c;
  --ok:        #4c7a4e;

  --poignee: #2f6fd0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--atelier-fond);
  color: var(--atelier-texte);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ==========================================================
   BARRE HAUTE
   ========================================================== */

.haut {
  height: 54px;
  flex: none;
  background: #171512;
  border-bottom: 1px solid var(--atelier-bord);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

.haut .marque {
  font-family: Georgia, serif;
  font-size: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #e8dfcb;
}

.haut .marque em { font-style: normal; color: var(--atelier-accent); }

.haut .spacer { flex: 1; }

.haut .qui {
  font-size: 12.5px;
  color: var(--atelier-texte-2);
  letter-spacing: .4px;
}

.haut .qui b { color: var(--atelier-texte); }

.btn {
  background: #2c2924;
  border: 1px solid #464036;
  color: var(--atelier-texte);
  border-radius: 4px;
  padding: 7px 13px;
  cursor: pointer;
  transition: background .14s, border-color .14s, transform .05s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { background: #38342d; border-color: #5d5343; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn.or {
  background: var(--atelier-accent);
  border-color: var(--atelier-accent-2);
  color: #241f16;
  font-weight: 600;
}
.btn.or:hover:not(:disabled) { background: #c0a05e; }

.btn.vert { border-color: #3f6b42; color: #b9d8bb; }
.btn.vert:hover:not(:disabled) { background: #2c3f2e; }

.btn.rouge { border-color: #6d3733; color: #e0b0ab; }
.btn.rouge:hover:not(:disabled) { background: #402523; }

.btn.petit { padding: 4px 9px; font-size: 12.5px; }

.btn .raccourci {
  font-size: 11px;
  opacity: .6;
  margin-left: 5px;
}

/* ==========================================================
   CORPS : trois colonnes
   ========================================================== */

.corps {
  flex: 1;
  display: flex;
  min-height: 0;
}

.panneau {
  flex: none;
  background: var(--atelier-panneau);
  border-right: 1px solid var(--atelier-bord);
  overflow-y: auto;
  overflow-x: hidden;
}

.panneau.gauche { width: 268px; }
.panneau.droite  { width: 296px; border-right: none; border-left: 1px solid var(--atelier-bord); }

section.bloc { border-bottom: 1px solid var(--atelier-bord); padding: 12px 13px 15px; }

section.bloc > h3 {
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--atelier-texte-2);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
}

section.bloc > h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--atelier-bord);
}

/* ---------- champs de formulaire ---------- */

.champ { margin-bottom: 9px; }

.champ label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--atelier-texte-2);
  margin-bottom: 3px;
}

.champ input[type=text],
.champ input[type=number],
.champ select,
.champ textarea {
  width: 100%;
  background: #121110;
  border: 1px solid #3a352e;
  border-radius: 3px;
  color: var(--atelier-texte);
  padding: 6px 8px;
  font-size: 13px;
}

.champ input:focus,
.champ select:focus,
.champ textarea:focus {
  outline: none;
  border-color: var(--atelier-accent);
  box-shadow: 0 0 0 2px rgba(169,138,75,.16);
}

.champ textarea { resize: vertical; min-height: 60px; }

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

.range input[type=range] { flex: 1; accent-color: var(--atelier-accent); }

.range .valeur {
  font-size: 12px;
  color: var(--atelier-texte-2);
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.range select { width: auto; flex: 1; }

.range input[type=color] {
  width: 34px;
  height: 26px;
  padding: 0;
  border: 1px solid #3a352e;
  border-radius: 3px;
  background: none;
  cursor: pointer;
}

.case { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; cursor: pointer; }
.case input { accent-color: var(--atelier-accent); }

.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grille2 .champ { margin-bottom: 0; }

/* ---------- boutons d'ajout ---------- */

.outils { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

.outils .btn {
  width: 100%;
  min-width: 0;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
}

.outils .btn > span:not(.ico) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.outils .btn .ico { font-size: 14px; width: 15px; flex: none; text-align: center; }

/* ---------- liste des calques ---------- */

.calques { list-style: none; }

.calques li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 3px;
}

.calques li:hover { background: #262320; }

.calques li.actif {
  background: #2f2b24;
  border-color: var(--atelier-accent);
}

.calques li .nom {
  flex: 1;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calques li .type {
  font-size: 10px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--atelier-texte-2);
  background: #100f0e;
  border-radius: 2px;
  padding: 1px 5px;
}

.calques li .mini {
  border: none;
  background: none;
  color: var(--atelier-texte-2);
  cursor: pointer;
  padding: 1px 3px;
  font-size: 12px;
  border-radius: 2px;
}

.calques li .mini:hover { background: #3a352e; color: #fff; }
.calques li .mini:disabled { opacity: .25; cursor: not-allowed; }

.calques .vide-liste {
  color: var(--atelier-texte-2);
  font-size: 12.5px;
  font-style: italic;
  padding: 8px 2px;
}

/* ==========================================================
   PLAN DE TRAVAIL
   ========================================================== */

.plan {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 26px 30px 60px;
  background:
    radial-gradient(ellipse at 50% 0%, #322d26 0%, var(--atelier-fond) 70%);
  position: relative;
}

/* repère de découpe : les marges du journal */
.plan .marge {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity .15s;
}

.plan.affiche-marges .marge { opacity: 1; }

.marge .haut,
.marge .bas {
  position: absolute;
  left: 0;
  right: 0;
  height: 46px;
  border-color: rgba(169,138,75,.5);
  border-style: dashed;
  border-width: 0;
}

.marge .haut { top: 0; border-bottom-width: 1px; }
.marge .bas  { bottom: 0; border-top-width: 1px; }

.marge .gauche,
.marge .droite {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 46px;
  border-color: rgba(169,138,75,.5);
  border-style: dashed;
  border-width: 0;
}

.marge .gauche { left: 0; border-right-width: 1px; }
.marge .droite { right: 0; border-left-width: 1px; }

/* la feuille, à taille réelle */
.feuille-travail {
  position: relative;
  width: 794px;
  height: 1123px;
  background: var(--papier);
  color: var(--encre);
  flex: none;
  transform-origin: top left;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  user-select: none;
}

/* grille */
.plan.grille .feuille-travail::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 900;
  background-image:
    linear-gradient(to right, rgba(47,111,208,.16) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(47,111,208,.16) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ==========================================================
   ZONES
   ========================================================== */

.zone {
  position: absolute;
  cursor: move;
  outline: 1px dashed rgba(47,111,208,0);
  transition: outline-color .12s;
}

.zone:hover { outline-color: rgba(47,111,208,.45); }

.zone.selectionnee {
  outline: 1.5px solid var(--poignee);
  outline-offset: 0;
  z-index: 10000 !important;
}

.zone.verrouillee { cursor: default; }
.zone.verrouillee:hover { outline-color: rgba(169,138,75,.5); }

.zone.editable .contenu {
  cursor: text;
  min-height: 12px;
}

/* Le plan bloque la sélection globale : on la réautorise en édition. */
.zone.editable .contenu[contenteditable="true"],
.zone.editable .contenu[contenteditable="true"] * {
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
  caret-color: var(--encre);
}

.zone.editable .contenu:focus {
  outline: none;
}

.zone.editable .contenu:empty::before {
  content: attr(data-placeholder);
  color: rgba(28,26,23,.35);
  font-style: italic;
}

/* survol pendant le déplacement */
.zone.deplacee { opacity: .85; }

/*guides d'alignement */
.guide {
  position: absolute;
  background: #e0407a;
  z-index: 20000;
  pointer-events: none;
  display: none;
}

.guide.vertical   { width: 1px; top: 0; bottom: 0; }
.guide.horizontal { height: 1px; left: 0; right: 0; }

/* ---------- poignées de redimensionnement ---------- */

.poignees { position: absolute; inset: 0; display: none; }
.zone.selectionnee .poignees { display: block; }
.zone.verrouillee .poignees { display: none !important; }

.poignee {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1.5px solid var(--poignee);
  border-radius: 2px;
  z-index: 20001;
}

.poignee[data-poignee=no]   { left: -5px;  top: -5px;  cursor: nwse-resize; }
.poignee[data-poignee=n]    { left: 50%; top: -5px;  margin-left: -5px; cursor: ns-resize; }
.poignee[data-poignee=ne]   { right: -5px; top: -5px;  cursor: nesw-resize; }
.poignee[data-poignee=e]    { right: -5px; top: 50%;  margin-top: -5px; cursor: ew-resize; }
.poignee[data-poignee=se]   { right: -5px; bottom: -5px; cursor: nwse-resize; }
.poignee[data-poignee=s]    { left: 50%; bottom: -5px; margin-left: -5px; cursor: ns-resize; }
.poignee[data-poignee=sw]   { left: -5px; bottom: -5px; cursor: nesw-resize; }
.poignee[data-poignee=w]    { left: -5px; top: 50%; margin-top: -5px; cursor: ew-resize; }

.poignees .mesure {
  position: absolute;
  left: 50%;
  bottom: -22px;
  transform: translateX(-50%);
  background: var(--poignee);
  color: #fff;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
}

/* ==========================================================
   BANDEAU D'OUTILS DE TEXTE (flottant)
   ========================================================== */

.barre-texte {
  position: fixed;
  z-index: 30000;
  background: #1b1917;
  border: 1px solid #4a4339;
  border-radius: 5px;
  padding: 5px;
  display: none;
  gap: 3px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
  flex-wrap: wrap;
  max-width: 460px;
}

.barre-texte.visible { display: flex; }

.barre-texte button {
  background: #2c2924;
  border: 1px solid #3f3a32;
  color: var(--atelier-texte);
  border-radius: 3px;
  min-width: 28px;
  height: 26px;
  padding: 0 7px;
  cursor: pointer;
  font-size: 13px;
}

.barre-texte button:hover { background: #3a352d; }
.barre-texte button.actif { background: var(--atelier-accent); color: #241f16; border-color: #c0a05e; }

.barre-texte select {
  background: #2c2924;
  border: 1px solid #3f3a32;
  color: var(--atelier-texte);
  border-radius: 3px;
  height: 26px;
  padding: 0 4px;
  font-size: 12.5px;
  max-width: 132px;
}

.barre-texte select.large { max-width: 168px; }

.barre-texte input[type=color] {
  width: 28px;
  height: 26px;
  padding: 0;
  border: 1px solid #3f3a32;
  border-radius: 3px;
  background: none;
  cursor: pointer;
}

.barre-texte .sep { width: 1px; align-self: stretch; background: #3f3a32; margin: 0 3px; }

.barre-texte .taille-champ {
  background: #121110;
  border: 1px solid #3f3a32;
  color: var(--atelier-texte);
  border-radius: 3px;
  height: 26px;
  width: 50px;
  padding: 0 5px;
  font-size: 12.5px;
  text-align: center;
}

.barre-texte .taille-champ:focus { outline: none; border-color: var(--atelier-accent); }

/* ==========================================================
   LISTE DES ARTICLES
   ========================================================== */

.liste-articles { list-style: none; }

.liste-articles li {
  padding: 8px 9px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 4px;
}

.liste-articles li:hover { background: #262320; }

.liste-articles li.actif {
  background: #2f2b24;
  border-color: var(--atelier-accent);
}

.liste-articles .t {
  font-size: 13px;
  color: var(--atelier-texte);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 3px;
}

.liste-articles .m {
  font-size: 11px;
  color: var(--atelier-texte-2);
  display: flex;
  gap: 7px;
  align-items: center;
}

.etiquette {
  font-size: 10px;
  letter-spacing: .7px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid;
}

.etiquette.publie   { color: #9fd0a3; border-color: #3f6b42; }
.etiquette.brouillon { color: #d6c48f; border-color: #6d5f36; }
.etiquette.page-n   { color: #8fb4e0; border-color: #3a5a80; }

/* ==========================================================
   ÉTAT VIDE
   ========================================================== */

.etat-vide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--atelier-texte-2);
  text-align: center;
  padding: 40px;
  pointer-events: none;
}

.etat-vide .g { font-size: 30px; letter-spacing: 4px; text-transform: uppercase; color: #6d665a; }
.etat-vide p { max-width: 420px; font-size: 13.5px; line-height: 1.6; }

/* ==========================================================
   BARRE D'ÉTAT
   ========================================================== */

.etat {
  height: 30px;
  flex: none;
  background: #141210;
  border-top: 1px solid var(--atelier-bord);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  font-size: 12px;
  color: var(--atelier-texte-2);
}

.etat .spacer { flex: 1; }
.etat .indicateur { display: flex; align-items: center; gap: 6px; }
.etat .pastille { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.etat .pastille.sale { background: var(--atelier-accent); }
.etat .pastille.erreur { background: var(--danger); }

.etat .viseur { color: var(--atelier-texte); font-variant-numeric: tabular-nums; }

/* ==========================================================
   CONNEXION (page de garde)
   ========================================================== */

.garde {
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    radial-gradient(ellipse at 50% 20%, #322c25 0%, #1a1815 70%);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.garde.ouvert { display: flex; }

.garde .boite {
  width: min(420px, 100%);
  background: var(--papier);
  color: var(--encre);
  border-radius: 4px;
  padding: 30px 32px;
  box-shadow: 0 30px 70px rgba(0,0,0,.6);
}

.garde h1 {
  font-family: Georgia, serif;
  font-size: 22px;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 5px;
}

.garde .expl {
  text-align: center;
  font-size: 13.5px;
  color: var(--encre);
  opacity: .8;
  margin-bottom: 20px;
  line-height: 1.55;
}

.garde label {
  display: block;
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #7d766a;
  margin-bottom: 4px;
}

.garde input {
  width: 100%;
  padding: 9px 11px;
  font-size: 15px;
  font-family: Georgia, serif;
  background: #fbf8f0;
  border: 1px solid #d9cfb4;
  border-radius: 3px;
  color: var(--encre);
  margin-bottom: 12px;
}

.garde input:focus {
  outline: none;
  border-color: var(--atelier-accent);
  box-shadow: 0 0 0 3px rgba(169,138,75,.18);
}

.garde button.valider {
  width: 100%;
  padding: 11px;
  background: var(--encre);
  color: var(--papier);
  border: none;
  border-radius: 3px;
  font-family: Georgia, serif;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 6px;
}

.garde button.valider:hover:not(:disabled) { background: #322d26; }
.garde button.valider:disabled { opacity: .5; cursor: wait; }

.garde .msg {
  margin-top: 15px;
  padding: 11px 13px;
  border-radius: 3px;
  font-size: 13.5px;
  line-height: 1.5;
  display: none;
}

.garde .msg.visible { display: block; }
.garde .msg.attente { background: #efe6cd; border: 1px solid #d8c69a; }
.garde .msg.erreur  { background: #f4dede; border: 1px solid #d0a0a0; }

.garde .msg .ref {
  font-family: "Courier New", monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
}

.garde .retour {
  text-align: center;
  margin-top: 15px;
  font-size: 12.5px;
}

.garde .retour a { color: #8c2f2f; }

/* ==========================================================
   NOTIFICATIONS
   ========================================================== */

.note {
  position: fixed;
  right: 18px;
  bottom: 44px;
  z-index: 40000;
  background: #1b1917;
  border: 1px solid #4a4339;
  border-left: 3px solid var(--atelier-accent);
  border-radius: 4px;
  padding: 11px 16px;
  color: var(--atelier-texte);
  font-size: 13px;
  box-shadow: 0 12px 34px rgba(0,0,0,.6);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  max-width: 340px;
}

.note.visible { opacity: 1; transform: translateY(0); }
.note.ok { border-left-color: var(--ok); }
.note.erreur { border-left-color: var(--danger); }

/* Toast avec action (ex. « Zone supprimée. [Annuler] ») : cliquable. */
.note.avec-action { pointer-events: auto; display: flex; align-items: center; gap: 12px; }
.note-action {
  flex: none;
  background: var(--atelier-accent);
  border: 1px solid var(--atelier-accent-2);
  color: #241f16;
  font-weight: 600;
  border-radius: 3px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12.5px;
}
.note-action:hover { background: var(--atelier-accent-2); }

/* Suppression d'article : état « armé », en attente du 2e clic. */
.btn.arme {
  border-color: var(--danger) !important;
  background: #402523 !important;
  color: #f0c0bb !important;
  animation: pulse-arme 1s ease-in-out infinite;
}
@keyframes pulse-arme {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168,68,60,.0); }
  50% { box-shadow: 0 0 0 3px rgba(168,68,60,.35); }
}

/* ==========================================================
   ADAPTATIONS
   ========================================================== */

@media (max-width: 1100px) {
  .panneau.gauche { width: 210px; }
  .panneau.droite  { width: 250px; }
}

@media (max-width: 900px) {
  .corps { flex-direction: column; }
  .panneau { width: 100% !important; max-height: 220px; border: none; border-top: 1px solid var(--atelier-bord); }
  .plan { padding: 14px; }
}

/* Aide contextuelle discrète */
.aide-editeur { font-size: 11.5px; line-height: 1.5; color: var(--atelier-texte-2); margin: 0 0 10px; }
.btn:focus-visible, .calques li:focus-visible { outline: 2px solid #c69a46; outline-offset: 3px; }
