/* Atelier Factory 0.3 — interface sobre : l'attention va aux cartes. Mobile d'abord. */

:root {
  --fond: #efede8;
  --panneau: #ffffff;
  --encre: #1f2326;
  --doux: #6b7176;
  --ligne: #dcd8d0;
  --action: #23282c;
  --action-texte: #ffffff;
  --ok: #2f6b3f;
  --ok-fond: #e8f2ea;
  --erreur: #a3372b;
  --erreur-fond: #fbf1ef;
  --attention: #8a5a12;
  --attention-fond: #fbf3e2;
  --choisie: #eef3f8;
  --rayon: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--encre);
  background: var(--fond);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); min-height: 100vh; }
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.3rem, 1rem + 1.2vw, 1.75rem); }
h2 { font-size: 1.05rem; }
.cache, [hidden] { display: none !important; }
.aide { color: var(--doux); font-size: 0.85rem; margin: 0.35rem 0 0; line-height: 1.4; }
.ok { color: var(--ok); }
.note { font-size: 0.8rem; color: var(--attention); background: var(--attention-fond); border-radius: 7px; padding: 7px 9px; margin: 10px 0 0; }

/* --- Barre du haut --- */
.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 10px 16px;
  background: var(--panneau); border-bottom: 1px solid var(--ligne);
}
.marque { display: flex; align-items: baseline; gap: 8px; margin-right: auto; }
.marque strong { font-size: 1.05rem; }
.badge { font-size: 0.72rem; color: var(--doux); border: 1px solid var(--ligne); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.choix { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--doux); flex: 1 1 220px; max-width: 360px; }
.choix select, .choix input { flex: 1; min-width: 0; }
.choix.qui { flex: 1 1 160px; max-width: 220px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

button, select, input, textarea { font: inherit; font-size: 0.9rem; }
button {
  border: 1px solid var(--action); background: var(--action); color: var(--action-texte);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 38px;
}
button.secondaire { background: transparent; color: var(--action); }
button:hover:not(:disabled) { filter: brightness(1.15); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, tr:focus-visible, summary:focus-visible { outline: 2px solid #4a7fb5; outline-offset: 2px; }
select, textarea, input:not([type="color"]):not([type="range"]):not([type="checkbox"]) {
  width: 100%; border: 1px solid var(--ligne); border-radius: 7px; padding: 7px 9px; background: #fff; color: var(--encre); min-height: 36px;
}
textarea { resize: vertical; line-height: 1.35; }
fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: #f3f2ef; color: var(--doux); }

/* --- Mise en page : une colonne sur téléphone, fiche + travail sur grand écran --- */
.page { display: grid; gap: 16px; padding: 16px; max-width: 1680px; margin: 0 auto; }
.panneau, .bloc { background: var(--panneau); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 16px; min-width: 0; }
.panneau { align-self: start; order: 2; } /* téléphone : la liste d'abord, la fiche ensuite */
@media (min-width: 1000px) { .panneau { order: 0; } }
.travail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.atelier-cartes { display: grid; gap: 16px; align-items: start; }

@media (min-width: 1000px) {
  .page { grid-template-columns: 330px minmax(0, 1fr); }
}
@media (min-width: 1360px) {
  .atelier-cartes { grid-template-columns: minmax(0, 1fr) 400px; }
  .editeur { position: sticky; top: 74px; max-height: calc(100vh - 90px); overflow: auto; }
}

/* --- Fiche --- */
fieldset { border: 0; border-top: 1px solid var(--ligne); margin: 14px 0 0; padding: 12px 0 0; min-width: 0; }
legend { font-weight: 650; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--doux); padding: 0 6px 0 0; }
.champ { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; min-width: 0; }
.champ label { font-size: 0.8rem; color: var(--doux); }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.couleurs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.couleur { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.72rem; color: var(--doux); }
.couleur input { width: 100%; height: 38px; border: 1px solid var(--ligne); border-radius: 7px; padding: 2px; background: #fff; cursor: pointer; }
.raretes { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.85rem; table-layout: fixed; }
.raretes th { text-align: left; font-weight: 500; color: var(--doux); font-size: 0.75rem; padding: 0 4px 4px; }
.raretes td { padding: 3px 4px; }
.raretes th:first-child, .raretes td.code { font-weight: 700; width: 32px; }
.raretes th:nth-child(3) { width: 86px; }
.raretes th:last-child { width: 58px; }
.raretes select, .raretes input { padding-left: 6px; padding-right: 4px; }
/* 0.3 : effets en ligne par rareté */
.raretes.effets th:nth-child(3) { width: 112px; }
.raretes.effets th:last-child { width: 112px; }
.raretes.effets th:nth-child(2) { width: auto; }
.raretes.effets td.intensite { display: flex; align-items: center; gap: 6px; }
.raretes.effets input[type="range"] { flex: 1; min-width: 0; margin: 0; }
.raretes.effets output { font-size: 0.75rem; color: var(--doux); min-width: 2.6em; text-align: right; font-variant-numeric: tabular-nums; }
.json summary { cursor: pointer; margin-top: 14px; font-size: 0.85rem; color: var(--doux); }
.json pre { font-size: 0.72rem; background: #f6f5f2; border: 1px solid var(--ligne); border-radius: 7px; padding: 10px; overflow: auto; max-height: 320px; }

/* --- Contrôles généraux --- */
.controles { border-radius: var(--rayon); padding: 10px 14px; font-size: 0.86rem; border: 1px solid var(--ligne); background: var(--panneau); }
.controles .bilan { margin: 0 0 4px; font-weight: 600; color: var(--encre); }
.controles[data-etat="erreurs"] { border-color: #e2b4ad; background: var(--erreur-fond); }
.controles[data-etat="erreurs"] ul { color: var(--erreur); }
.controles ul { margin: 0; padding-left: 18px; }
.controles p.ok { margin: 0; }

/* --- Liste des joueurs --- */
.entete-bloc { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.compte { color: var(--doux); font-weight: 400; font-size: 0.9rem; }
.tableau-defilant { overflow-x: auto; border: 1px solid var(--ligne); border-radius: 8px; }
table.liste { width: 100%; border-collapse: collapse; font-size: 0.84rem; min-width: 600px; }
.liste th { position: sticky; top: 0; background: #f6f5f2; text-align: left; font-weight: 600; font-size: 0.75rem; color: var(--doux); padding: 8px; border-bottom: 1px solid var(--ligne); white-space: nowrap; }
.liste td { padding: 7px 8px; border-bottom: 1px solid #eeebe5; vertical-align: top; }
.liste tbody tr { cursor: pointer; }
.liste tbody tr:hover { background: #faf9f6; }
.liste tbody tr.choisie { background: var(--choisie); box-shadow: inset 3px 0 0 #4a7fb5; }
.liste tbody tr.a-probleme { background: var(--erreur-fond); }
.liste tbody tr.a-probleme.choisie { box-shadow: inset 3px 0 0 var(--erreur); }
.liste td.num, .liste td.mono { font-variant-numeric: tabular-nums; white-space: nowrap; }
.liste td.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; }
.liste td.nom .sous { display: block; color: var(--doux); font-size: 0.78rem; margin-top: 2px; }
.liste tbody tr.a-probleme[data-index] td { border-bottom: 0; }
.liste tr.ligne-controle td { padding: 0 8px 8px 16px; }
.liste tr.ligne-controle ul { margin: 0; padding-left: 16px; color: var(--erreur); font-weight: 600; font-size: 0.82rem; }
.mineur { display: inline-block; margin-left: 6px; font-size: 0.7rem; color: var(--attention); border: 1px solid #e6cf9f; border-radius: 99px; padding: 0 6px; }
.statut, .puce { display: inline-block; font-size: 0.74rem; border-radius: 99px; padding: 2px 8px; white-space: nowrap; border: 1px solid var(--ligne); }
.statut-brouillon { color: var(--doux); background: #f3f2ef; }
.statut-validee { color: var(--ok); background: var(--ok-fond); border-color: #bcd9c3; }
.statut-verrouillee { color: #fff; background: var(--action); border-color: var(--action); }
.puces { display: flex; flex-wrap: wrap; gap: 4px; }
.puce.ok { color: var(--ok); background: var(--ok-fond); border-color: #bcd9c3; }
.puce.attention { color: var(--attention); background: var(--attention-fond); border-color: #e6cf9f; }

.rapport { border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 0.85rem; background: #f6f5f2; border: 1px solid var(--ligne); }
.rapport p { margin: 0 0 4px; }
.rapport .attention { color: var(--attention); }
.rapport .erreur { color: var(--erreur); font-weight: 600; margin: 4px 0 0; padding-left: 18px; }
.rapport p.erreur { padding-left: 0; }

/* --- Éditeur de la carte choisie --- */
.entete-editeur { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; }
.identifiant { font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; color: var(--doux); }
.apercus { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 4px; padding: 12px 10px 8px; background: #e4e1da; border-radius: 8px; }
.apercus figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.apercus canvas { width: 100%; max-width: 252px; height: auto; aspect-ratio: 63 / 88; border-radius: 3.4%/2.4%; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18); }
.apercus figcaption { font-size: 0.75rem; color: var(--doux); }
.zone-statut { margin-top: 10px; padding: 10px 0; border-bottom: 1px solid var(--ligne); }
.etapes { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0 0 10px; font-size: 0.78rem; }
.etapes li { flex: 1; text-align: center; padding: 5px 4px; border-radius: 6px; background: #f3f2ef; color: var(--doux); }
.etapes li.actif { background: var(--action); color: #fff; font-weight: 600; }
.blocages { margin: 8px 0 0; padding-left: 18px; color: var(--erreur); font-size: 0.82rem; }
.zone-statut .ok { margin: 8px 0 0; font-size: 0.85rem; }
.champs-carte { border: 0; padding: 0; margin: 0; }
.autorisations, .verso-special { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: #f6f5f2; display: grid; gap: 6px; }
.titre-bloc { margin: 0; font-size: 0.78rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--doux); }
.case { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; cursor: pointer; min-height: 28px; }
.case input { width: 18px; height: 18px; accent-color: var(--action); flex: none; }
.ligne-photo { display: flex; gap: 8px; }
.ligne-photo select { flex: 1; min-width: 0; }
.ligne-photo button { flex: none; padding: 6px 10px; }
input[type="range"] { width: 100%; accent-color: var(--action); }
.qualite { font-size: 0.78rem; margin: 6px 0 0; color: var(--doux); }
.qualite[data-niveau="trop-petite"], .qualite[data-niveau="absente"] { color: var(--erreur); }
.qualite[data-niveau="ok"], .qualite[data-niveau="vectorielle"] { color: var(--ok); }

/* --- Planches --- */
.planche { display: grid; gap: 16px; }
.entete-planche .actions { margin-top: 12px; }
.ligne-planche { margin-top: 10px; }
.ecartees { margin: 8px 0 0; padding-left: 18px; font-size: 0.82rem; color: var(--attention); }
.ecartees:empty { display: none; }
.avertissement { font-size: 0.8rem; color: var(--attention); background: var(--attention-fond); border-radius: 7px; padding: 8px 10px; margin: 12px 0 0; }
.faces-planche { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.faces-planche figure { margin: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.faces-planche img { width: 100%; max-width: 560px; aspect-ratio: 210 / 297; border: 1px solid var(--ligne); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); background: #fff; }
.faces-planche figcaption { font-size: 0.78rem; color: var(--doux); }

/* --- Journal --- */
.journal summary { cursor: pointer; font-weight: 600; }
.journal ol { list-style: none; margin: 12px 0 0; padding: 0; font-size: 0.82rem; max-height: 340px; overflow: auto; }
.journal li { display: grid; grid-template-columns: 9.5em 9em minmax(0, 1fr); gap: 8px; padding: 5px 0; border-bottom: 1px solid #eeebe5; }
.journal time, .journal .qui { color: var(--doux); font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .journal li { grid-template-columns: 1fr; gap: 0; }
}

/* --- Pied --- */
.pied { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px 18px; font-size: 0.8rem; color: var(--doux); max-width: 1680px; margin: 0 auto; }
#annonce[data-genre="erreur"] { color: var(--erreur); }

/* --- Impression (PDF) : seulement les planches, une par page, à l'échelle exacte --- */
#impression { display: none; }
@media print {
  html, body { background: #fff !important; margin: 0; padding: 0; }
  body > *:not(#impression) { display: none !important; }
  #impression { display: block !important; }
  .feuille { width: 210mm; height: 297mm; overflow: hidden; break-after: page; page-break-after: always; }
  .feuille:last-child { break-after: auto; page-break-after: auto; }
  .feuille svg { display: block; width: 100%; height: 100%; }
}

/* --- 0.4 : connexion, compte, enregistrement, conflits, espace Factory --- */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.carte-connexion { width: min(100%, 380px); background: var(--panneau); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.carte-connexion h1 { font-size: 1.35rem; }
.marque-connexion { margin: 0; display: flex; align-items: baseline; gap: 8px; }
.erreur-connexion { margin: 0; min-height: 1.2em; color: var(--erreur); font-size: 0.85rem; }
.compte-connecte { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--doux); }
.compte-connecte strong { color: var(--encre); font-weight: 600; }
button.petit { min-height: 30px; padding: 4px 10px; font-size: 0.8rem; }
.etat-enregistrement { align-self: center; font-size: 0.8rem; color: var(--doux); }
.etat-enregistrement[data-etat="attente"] { color: var(--attention); font-weight: 600; }
.etat-enregistrement[data-etat="ok"] { color: var(--ok); }
.etat-enregistrement[data-etat="erreur"] { color: var(--erreur); font-weight: 600; }
.version-carte { font-size: 0.75rem; color: var(--doux); }
.conflits { background: var(--erreur-fond); border: 1px solid var(--erreur); border-radius: var(--rayon); padding: 14px 16px; color: var(--encre); }
.conflits h2 { color: var(--erreur); margin-bottom: 6px; }
.conflits ul { margin: 8px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.conflits li { background: #fff; border-radius: 8px; padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.conflits li p { margin: 0; flex: 1 1 320px; font-size: 0.88rem; line-height: 1.4; }
.factory h2 { margin-bottom: 10px; }
.factory table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.factory th, .factory td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--ligne); vertical-align: top; }
.form-club { display: grid; gap: 10px; margin-top: 14px; align-items: end; }
@media (min-width: 760px) { .form-club { grid-template-columns: 1fr 1fr auto; } }
#lien-publication a { color: var(--action); font-weight: 600; }
fieldset:disabled input:not([type="color"]):not([type="range"]):not([type="checkbox"]), fieldset:disabled select { background: #f3f2ef; color: var(--doux); }
@media (max-width: 699px) { .barre { position: static; } }
