/* Atelier de cartes, maquette « Salle de commandement » (docs/EDITOR.md, page Atelier) : palette à gauche, carte
   sur sa planche au centre, document à droite. Chargé après editor.css : seules les couleurs, matières et la
   disposition changent ; ids, écouteurs et logique d'editor.js restent les mêmes. */
:root{color-scheme:light;--ed-paper:#fdf6e4;--ed-paper-2:#efe3c4;--ed-ink:#22385a;--ed-ink-soft:#4b5a73;--ed-line:#d8c7a2;--ed-coral:#d9452f;--ed-azure:#2f6fd6;--ed-orange-hi:#f39a4a;--ed-orange-lo:#e0662d;--ed-orange-edge:#7e3420;--ed-wood-hi:#c8945c;--ed-wood-lo:#a8743f;--muted:var(--ed-ink-soft);--text:var(--ed-ink)}
body{color:var(--ed-ink);background:linear-gradient(#e9d8b4,#dcc59a) fixed}
.visually-hidden{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
h2{color:var(--ed-ink)}
label>span{color:var(--ed-ink-soft)}
:focus-visible{outline-color:var(--ed-orange-lo)}

/* Boutons : papier crème, encre marine, ombre pleine ; « Tester la carte » en orange. */
button{border:2px solid var(--ed-ink);border-radius:12px;background:var(--ed-paper);color:var(--ed-ink);box-shadow:0 3px 0 var(--ed-ink)}
button:hover:not(:disabled){border-color:var(--ed-ink);background:#fff9ec}
button:active:not(:disabled){transform:translateY(2px);box-shadow:0 1px 0 var(--ed-ink)}
button.primary,#test{border:2px solid var(--ed-orange-edge);background:linear-gradient(var(--ed-orange-hi),var(--ed-orange-lo));color:var(--cc-ink);box-shadow:0 4px 0 var(--ed-orange-edge);font:800 19px/1 var(--font-heading);letter-spacing:.03em;text-transform:uppercase}
button.primary:hover:not(:disabled),#test:hover:not(:disabled){background:linear-gradient(#f6a65a,#e66f36)}
input,select,textarea{border:2px solid var(--ed-line);border-radius:9px;background:#fff;color:var(--ed-ink);box-shadow:none}
select{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2322385a' stroke-width='2'/%3E%3C/svg%3E");background-position:right 11px center;background-repeat:no-repeat}
select option{background:#fff;color:var(--ed-ink)}
input[type=checkbox]{accent-color:var(--ed-orange-lo)}

/* Barre du haut : titre, badge Jouable (dans la carte), Annuler, Tester, Retour au jeu, langue. */
header.editor-topbar{width:calc(100% - 32px);margin:14px auto 0;border:2px solid var(--ed-ink);border-radius:16px;background:var(--ed-paper);box-shadow:0 4px 0 var(--ed-ink)}
.editor-brand .logo-star{color:#f08a2c}
.editor-brand .brand-name{color:var(--ed-ink)}.editor-brand .brand-name b{color:var(--ed-coral)}
.editor-brand .brand-sep{background:var(--ed-line)}
header.editor-topbar h1{color:var(--ed-ink)}
header.editor-topbar .tool-button{background:var(--ed-paper)}
header.editor-topbar select{background-color:var(--ed-paper)}
header.editor-topbar .tool-button,header.editor-topbar select{height:46px;min-height:46px;border:2px solid var(--ed-ink);border-radius:12px;color:var(--ed-ink);box-shadow:0 3px 0 var(--ed-ink)}
header.editor-topbar .tool-button:hover{border-color:var(--ed-ink);background:#fff9ec}
.editor-header-tools #test{height:46px;min-height:46px;padding:0 20px;box-shadow:0 3px 0 var(--ed-orange-edge)}
main{width:calc(100% - 32px);padding:16px 0 24px}
/* L'introduction et le pas-à-pas restent accessibles dans la colonne de droite (« Comment créer une carte »). */
main>.intro{display:none}

/* Trois colonnes sur un écran : palette, carte, document. */
.workspace{grid-template-columns:clamp(270px,22vw,320px) minmax(0,1fr) clamp(280px,22vw,330px);gap:18px}
/* Ordinateur : la palette s'arrête au bas de la planche centrale (elle défile dedans si besoin). La carte fixe la
   hauteur de la rangée : la palette n'y contribue pas (height:0) et en prend toute la hauteur (min-height:100%). */
@media(min-width:1181px){.workspace>.editor-controls{align-self:stretch;height:0;min-height:100%;max-height:none}}
.editor-controls,.editor-document{position:sticky;top:12px;display:flex;flex-direction:column;max-height:calc(100dvh - 140px);min-width:0;border:2px solid var(--ed-ink);border-radius:16px;background:var(--ed-paper);box-shadow:0 4px 0 var(--ed-ink);overflow:hidden}
.editor-controls>h2{display:none}
.editor-sections{flex:1;min-height:0;overflow:auto}
.editor-sections>details{border-bottom:2px solid var(--ed-line)}
.editor-sections>details:last-child{border-bottom:0}
.editor-sections>details>summary{background:var(--ed-paper);color:var(--ed-ink);font:800 19px/1.2 var(--font-heading)}
.editor-sections>details>summary:is(:hover,:focus-visible),.editor-sections>details[open]>summary{background:var(--ed-paper-2);color:var(--ed-ink)}
.editor-sections>details>summary::before{content:"";width:10px;height:10px;border:solid var(--ed-ink);border-width:0 2.5px 2.5px 0;transform:rotate(-45deg);margin-right:2px}
.editor-sections>details[open]>summary::before{transform:rotate(45deg) translate(-2px,-2px)}
.palette-tools>summary{pointer-events:none}.palette-tools>summary::before{display:none}
.palette-panel{grid-template-columns:minmax(0,1fr)}
.palette-panel label>span{min-height:0}
.palette-panel p,.notice,.generator-note,.validation-body p,.mission-options>p{color:var(--ed-ink-soft)}
#brush-info{padding:8px 10px;border-radius:10px;background:var(--ed-paper-2);color:var(--ed-ink)}
.palette{grid-template-columns:repeat(3,minmax(0,1fr))}
.palette button{border:2px solid var(--ed-line);border-radius:10px;background:#fff9ec;color:var(--ed-ink);box-shadow:none}
.palette button:hover:not(:disabled){background:#fff;color:var(--ed-ink)}
.palette button[aria-pressed=true]{background:#fff9ec;border-color:var(--ed-orange-lo);box-shadow:0 0 0 2px var(--ed-orange-hi)}
.steps li{border:2px solid var(--ed-line);border-radius:10px;background:#fff9ec;color:var(--ed-ink)}
.steps{flex-direction:column;gap:6px;padding:0 12px}
.editor-guide>summary{color:var(--ed-ink)}

/* Signaler un problème : en bas du document, sans icône d'alerte. */
.editor-report{flex:none;padding:10px 12px;border-top:2px solid var(--ed-line)}
.editor-report #feedback-editor-open{width:100%;min-height:44px;padding:0 12px;font:700 14px/1 var(--font-ui)}

/* Boutons segmentés (segmented.js) : la liste d'origine reste présente, invisible. */
.seg-source{position:absolute!important;width:1px!important;height:1px!important;min-height:0!important;padding:0!important;border:0!important;opacity:0;pointer-events:none;clip-path:inset(50%)}
.seg-group{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px;padding:3px;border:2px solid var(--ed-ink);border-radius:11px;background:var(--ed-paper-2)}
.seg-group button{min-height:38px;margin:0;padding:4px 6px;border:0;border-radius:8px;background:none;box-shadow:none;color:var(--ed-ink);font:700 13px/1.15 var(--font-ui)}
.seg-group button:hover:not(:disabled){background:#fff9ec}
.seg-group button[aria-pressed=true]{background:var(--ed-ink);color:var(--ed-paper)}
#team+.seg-group button[data-value="0"][aria-pressed=true]{background:var(--ed-coral)}
#team+.seg-group button[data-value="1"][aria-pressed=true]{background:var(--ed-azure)}
.seg-group button:active{transform:none}
.seg-source:focus-visible+.seg-group{outline:3px solid var(--ed-ink);outline-offset:2px}
@media(pointer:coarse){.seg-group button{min-height:44px}}

/* La carte sur sa planche en bois, avec son nom, sa taille et le badge Jouable. */
.map-panel{padding:16px;border:0;border-radius:18px;background:linear-gradient(var(--ed-wood-hi),var(--ed-wood-lo));box-shadow:inset 0 2px 0 #e2b47e,0 12px 26px #3b271a44}
.map-heading{display:flex;align-items:center;gap:10px;margin-bottom:10px;padding:0;border:0}
/* Nom, état « Jouable » puis taille sur une ligne ; la case survolée et le brouillon restauré juste dessous. */
.map-heading h2{flex:0 1 auto}
.map-heading #playability{flex:1 1 auto;min-width:0;flex-wrap:nowrap;align-items:center;gap:8px;margin:0;padding:6px 10px}
.map-heading #playability span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.map-heading #dimensions{flex:none;margin-left:auto}
.map-heading h2{min-width:0;padding:7px 12px;border:2px solid var(--ed-ink);border-radius:10px;background:var(--ed-paper);font-size:19px}
#dimensions{padding:6px 10px;border-radius:9px;background:#22385ae6;color:var(--ed-paper);font:700 13px/1 var(--font-ui)}
.playability{padding:8px 12px;border:2px solid #3f7d2c;border-radius:12px;background:#dff0d3}
.playability strong{color:#2c5a1e}.playability span{color:#2c4a23}
.playability[data-state=incomplete]{border-color:#a8650f;background:#fbe9c4}
.playability[data-state=incomplete] strong{color:#7a4708}.playability[data-state=incomplete] span{color:#5a3a12}
.map-scroll{border:3px solid #fbf3df;border-radius:8px;box-shadow:0 3px 0 #6b4a2a;max-height:calc(100dvh - 260px)}
.map-status{display:flex;flex-wrap:wrap;gap:4px 16px;margin:0 0 10px;padding:7px 12px;border:2px solid var(--ed-ink);border-radius:10px;background:var(--ed-paper);color:var(--ed-ink);font:600 13px/1.3 var(--font-ui)}
.map-status p{margin:0}.map-status #draft-status:empty{display:none}

/* Ordinateur étroit : document sous la palette, la carte garde la place. */
@media(max-width:1180px) and (min-width:801px){
 .workspace{grid-template-columns:clamp(270px,30vw,320px) minmax(0,1fr)}
 .editor-document{grid-column:1;position:static;max-height:none}
 .editor-controls{max-height:none;position:static}
}
/* Téléphone : la carte d'abord, puis la palette, puis le document ; Annuler et Tester restent en haut. */
@media(max-width:800px){
 header.editor-topbar{width:calc(100% - 16px);margin-top:8px}
 main{width:calc(100% - 16px);padding-top:12px}
 .workspace{display:flex;flex-direction:column;align-items:stretch;gap:12px}
 .map-panel{order:-1;padding:10px}
 .editor-controls,.editor-document{position:static;max-height:none}
 .map-scroll{max-height:56dvh}
 .editor-header-tools{flex-wrap:wrap;gap:8px}
 .editor-header-tools #test{flex:1 1 60%;order:-1}
 .editor-header-tools .home-link{flex:1}
}
/* Téléphone paysage : la carte à gauche sur toute la hauteur, les outils défilent à droite. */
@media(max-height:520px) and (orientation:landscape){
 header.editor-topbar{min-height:0;margin-top:6px;padding:6px 10px}
 .editor-brand{display:none}
 .editor-header-tools{flex:1;flex-wrap:nowrap}.editor-header-tools #test{flex:1;font-size:16px}
 main{padding-top:8px}
 .workspace{display:grid;grid-template-columns:minmax(0,1fr) minmax(250px,290px);gap:10px}
 .map-panel{grid-column:1;grid-row:1/span 2;position:sticky;top:8px;align-self:start;padding:8px}
 .editor-controls,.editor-document{grid-column:2;position:static;max-height:none}
 .map-heading{margin-bottom:6px}.map-heading h2{font-size:15px;padding:4px 8px}
 .playability{margin:0;padding:4px 8px}.playability span{display:none}
 .map-scroll{max-height:calc(100dvh - 150px)}
 .map-status{display:none}
}
@media(prefers-reduced-motion:reduce){button:active:not(:disabled){transform:none}}

/* A sibling button opens the family: no nested buttons and a 32 px touch target. */
.palette-model{position:relative;min-width:0;flex:0 0 84px}
.palette-model>[data-brush]{width:100%;height:100%}
.palette .variant-toggle{position:absolute;right:2px;top:2px;display:grid;place-items:center;width:32px;height:32px;min-height:32px;padding:0;font-size:24px;line-height:1;background:#fff9ec;border-radius:50%}
.variant-palette{grid-column:1/-1;display:flex;gap:7px;overflow:auto;padding:5px;border:1px solid var(--ed-line);border-radius:8px}
.variant-palette[hidden]{display:none}
.variant-palette button{flex:0 0 76px;display:flex;flex-direction:column;align-items:center;padding:4px;font-size:11px}
.variant-palette button[aria-pressed=true]{outline:2px solid var(--ed-orange-hi);outline-offset:-2px}
.variant-palette canvas{width:56px;height:56px}

.cell[data-building=port]:not(:hover),.cell[data-building=field_port]:not(:hover){box-shadow:none}
/* Validation : le bouton ne colle ni au titre du panneau ni au bilan ; messages lisibles sur le papier clair. */
.validation-body{display:flex;flex-direction:column;align-items:flex-start;gap:10px;padding-top:10px}
.validation-body>p,.validation-body>#problems{margin:0}
.validation-body>#problems:empty{display:none}
#problems .error{color:#a3271a}
#problems .warning{color:#7a5200}
/* Corps des panneaux : un souffle sous le titre, pour que le premier libellé ou bouton ne touche pas sa bordure. */
.editor-sections>details>:not(summary):first-of-type,.palette-tools>.palette-panel{padding-top:8px}
/* Annuler : à côté de la carte qu'il modifie, flèche + libellé (icône seule sur petit écran). */
.map-heading .undo-button{flex:none;display:inline-flex;align-items:center;gap:6px;min-height:44px;padding:0 14px;border:2px solid var(--ed-ink);border-radius:10px;background:var(--ed-paper);color:var(--ed-ink);box-shadow:0 3px 0 var(--ed-ink);font:800 14px/1 var(--font-ui);cursor:pointer}
.map-heading .undo-button svg{flex:none}
.map-heading .undo-button:disabled{opacity:.45;cursor:default;box-shadow:0 3px 0 #22385a55}
@media(max-width:760px){.map-heading .undo-button{width:44px;padding:0;justify-content:center}.map-heading .undo-button span{display:none}}
/* Titre de la carte sur une ligne : coupé proprement plutôt que lettre à lettre quand la place manque. */
.map-heading h2{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.map-heading #playability{flex:1 1 0}
@media(max-width:760px){.map-heading{flex-wrap:wrap;row-gap:8px}.map-heading h2{flex:1 1 100%}}

/* Barre du haut : quand la place manque (tablette), les commandes passent sous le titre au lieu de le recouvrir. */
header.editor-topbar{flex-wrap:wrap;row-gap:10px}

/* Grille masquée : ni traits ni coordonnées, la carte se lit comme en partie (survol et focus restent visibles). */
#grid.grid-hidden .cell{border-color:transparent}
#grid.grid-hidden .cell .coord{display:none}
/* En-tête de la carte : titre, état et Annuler à la même hauteur (44 px). */
.map-heading h2{box-sizing:border-box;height:44px;padding-top:0;padding-bottom:0;line-height:40px}
.map-heading #playability{box-sizing:border-box;height:44px;padding-top:0;padding-bottom:0}
@media(max-width:760px){.map-heading h2{height:auto;line-height:1.2;padding-top:6px;padding-bottom:6px}}
/* Boutons d'une même rangée (Nouvelle carte / Générer, Importer / Exporter) : même hauteur, libellés centrés. */
:is(.dimension-tools,.template-tools,.file-actions){align-items:stretch}
:is(.dimension-tools,.template-tools,.file-actions)>button{display:flex;align-items:center;justify-content:center;min-height:52px;line-height:1.2}
:is(.dimension-tools,.template-tools,.file-actions)>label{align-self:end}
/* Pastille des dimensions alignée sur le titre, l'état et Annuler (44 px). */
.map-heading #dimensions{box-sizing:border-box;display:inline-flex;align-items:center;height:44px;padding:0 12px;border-radius:10px;font-size:14px}
/* L’état de la carte se lit en entier (trois lignes au plus) au lieu d'être coupé par des points de suspension. */
@media(min-width:761px){.map-heading #playability{height:auto;min-height:44px;padding-top:4px;padding-bottom:4px}.map-heading #playability span{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;white-space:normal;font-size:12px;line-height:1.3}}

#grid .objective-cell{box-shadow:inset 0 0 0 2px #ffd265}
.objective-marker{position:absolute;top:1px;right:1px;z-index:1;min-width:1.25em;padding:1px 3px;border-radius:4px;background:#ffd265;color:#22385a;font-weight:800}
#objective-place[aria-pressed=true]{outline:2px solid #d77738;outline-offset:2px}
#objective-problem{font-weight:700}
/* Téléphone : Tester, Menu principal et la langue sur une seule ligne (avant : la langue passait seule dessous). */
@media(max-width:760px){
 .editor-header-tools{flex-wrap:nowrap;gap:6px}
 .editor-header-tools #test{flex:1 1 auto;min-width:0;order:0;padding:0 12px}
 .editor-header-tools .home-link{flex:0 1 auto;min-width:0;padding:4px 10px;text-align:center;line-height:1.1}
 .editor-header-tools #language{flex:0 0 auto;width:auto;max-width:112px;padding-left:10px;padding-right:28px}
}
