/* Canevas Export — feuille de style */
:root {
  --bg: #f6efe2;
  --panel: #fffdf7;
  --ink: #3a322b;
  --muted: #8a7f6f;
  --line: #e5dcc8;
  --accent: #a63d2f;
  --accent-dark: #8a3024;
  --accent-soft: #fbece6;
  --ok: #2e7d4f;
  --err: #b3261e;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(80, 60, 30, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.wrap {
  margin: 0 auto;
  padding: 0 12px;
}

/* ---------- En-tête ---------- */
.app-header {
  background: linear-gradient(135deg, #a63d2f, #7c2f24);
  color: #fff;
  padding-top: 14px;
  padding-bottom: 12px;
  text-align: center;
}

.app-header h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.app-header h1 .logo {
  flex: none;
  vertical-align: middle;
}

.app-header h1 span {
  font-style: italic;
  font-weight: normal;
}

.tagline {
  margin: 3px 0 0;
  opacity: 0.9;
  font-size: 0.88rem;
}

/* ---------- Pied de page ---------- */
.app-footer {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  padding-bottom: 24px;
  color: var(--muted);
  font-size: 0.84rem;
}

.app-footer .muted {
  font-size: 0.76rem;
}

/* ---------- Disposition ---------- */
.app-ui {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
  align-items: start;
}

/* Les colonnes du grid ne doivent pas être forcées à s'élargir par leur contenu
   (sinon un grand canvas d'aperçu repousse toute la mise en page). */
.app-ui>.panel {
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 1.08rem;
  font-family: Georgia, "Times New Roman", serif;
}

.panel h2:not(:first-child) {
  margin-top: 26px;
}

.panel h3 {
  margin: 26px 0 10px;
  font-size: 1rem;
  font-family: Georgia, "Times New Roman", serif;
}

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  flex: none;
}

.photo-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  font-size: 0.9rem;
  font-weight: 600;
}

.photo-info .thumb {
  position: relative;
  flex: none;
  line-height: 0;
}

.photo-info img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

/* ---------- Champs ---------- */
.row-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
  font-size: 0.92rem;
}

.row-field input {
  width: 90px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}

.row-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.dim-hint {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.check-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 18px;
  font-size: 0.92rem;
  cursor: pointer;
}

.check-field input {
  margin-top: 4px;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 11px 18px;
  cursor: pointer;
  text-align: center;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.05s;
}

.btn:hover:not(:disabled) {
  background: #faf4e9;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-example {
  display: block;
  width: 100%;
  margin-top: 10px;
}

/* Bouton principal : fond accent, texte blanc, plus marqué que la base. */
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

/* ---------- Complexité ---------- */
.difficulty {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border: none;
  margin: 0 0 6px;
  padding: 0;
}

.difficulty legend {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
  grid-column: 1 / -1;
}

.diff-card {
  display: block;
  position: relative;
  padding: 10px 2px;
  text-align: center;
  overflow-wrap: break-word;
}

.diff-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.diff-card:hover {
  border-color: #cfbfa4;
}

.diff-card.selected,
.diff-card.selected:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.diff-title {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
}

.diff-sub {
  display: block;
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--muted);
}

/* ---------- Zone de dépôt ----------
   Reprend la classe .btn (bordure, fond, rayon, curseur) ; seule la mise en
   page intérieure et l'accent au survol / focus / drag sont spécifiques. */
.dropzone {
  display: block;
  padding: 26px 18px;
}

.dropzone:hover,
.dropzone:focus,
.dropzone.dragover {
  outline: none;
}

.dz-icon {
  font-size: 1.8rem;
  margin: 0 0 6px;
}

.dz-main {
  margin: 0 0 4px;
  font-weight: 600;
}

.dz-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.error {
  margin: 12px 0 0;
  color: var(--err);
  background: #fdecea;
  border: 1px solid #f3c2bd;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
}

/* ---------- Résultat ---------- */
.result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.result-titles h2 {
  margin-bottom: 4px;
}

.summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.preview-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.zoom {
  display: flex;
  gap: 6px;
  flex: none;
}

.btn-small {
  padding: 5px 10px;
  font-size: 0.9rem;
  line-height: 1;
}

/* Bouton compact rond (croix de la miniature, symboles de zoom). */
.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  line-height: 1;
}

/* Croix « enlever cette photo » : plus petite, posée sur le coin de la miniature. */
.btn-clear {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  line-height: 1;
  position: absolute;
  top: -10px;
  right: -10px;
}

.preview-wrap {
  margin-top: 10px;
  width: 100%;
  max-width: 100%;
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: repeating-conic-gradient(#f5f0e4 0 25%, #eae2d1 0 50%) 0 0 / 24px 24px;
  padding: 10px;
}

.preview-wrap canvas {
  display: block;
  border: 1px solid #d8cdb4;
  -webkit-touch-callout: none;
  user-select: none;
}

.sym-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.sym-toggle input {
  margin: 0;
  cursor: pointer;
}

/* ---------- Légende ---------- */
.legend {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 0.86rem;
}

.swatch {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  flex: none;
}

.sym {
  min-width: 20px;
  text-align: center;
  background: #333;
  color: #fff;
  border-radius: 5px;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 1px 4px;
  flex: none;
  font-family: Arial, "Segoe UI Symbol", sans-serif;
}

.code {
  font-weight: 700;
  white-space: nowrap;
}

.lname {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}

.lcount {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Zone d'impression (masquée à l'écran) ---------- */
#printArea {
  display: none;
}

/* ---------- Impression / export PDF ----------
   Chaque page du modèle est une image plein-page (canvas → blob PNG) exposée
   dans #printArea. C'est le navigateur qui génère le PDF. */
@page {
  size: 210mm 297mm;
  margin: 0;
}

@media print {
  body {
    background: #fff;
    margin: 0;
  }

  body>*:not(#printArea) {
    display: none !important;
  }

  #printArea {
    display: block;
    color: #000;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-family:
      -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  }

  /* Page de grille : image au format exact de la page A4 portrait (plein cadre).
     Dimensions explicites 210×297 mm : un « height: auto » donnerait 297,07 mm
     et ferait déborder l'image d'un pixel sur une page blanche. */
  .print-page {
    page-break-after: always;
    break-after: page;
    margin: 0;
    padding: 0;
    width: 210mm;
    height: 297mm;
  }

  .print-page img {
    display: block;
    width: 100%;
    height: 100%;
  }

  /* Page de légende : démarre sur la page suivante grâce au break-after de la
     grille — pas de break-before ici (sinon double saut → page blanche). */
  .print-legend-page {
    width: 100%;
    height: 100%;
    page-break-after: auto;
    break-after: auto;
    background: #fff;
    padding: 14mm 12mm;
    box-sizing: border-box;
  }

  .print-legend-page h2 {
    margin: 0 0 4mm;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 20pt;
  }

  .print-legend-page .print-sub {
    margin: 0 0 6mm;
    font-size: 10.5pt;
    color: #333;
  }

  .print-legend-page .print-note {
    margin-top: 8mm;
    font-size: 8.5pt;
    color: #555;
  }

  .print-legend {
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5mm;
  }

  .print-legend .legend-item {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 8pt;
    padding: 2.5px 5px;
  }

  .print-legend .swatch {
    width: 16px;
    height: 16px;
  }

  .print-legend .sym {
    background: #fff;
    color: #000;
    border: 1px solid #999;
    min-width: 16px;
    font-size: 8pt;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .app-ui {
    grid-template-columns: 1fr;
  }
}

/* ---------- Blog & Article ---------- */
.page-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 12px 40px;
}

.blog-intro {
  padding: 16px 0 20px;
  color: var(--muted);
}

.posts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.post {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.post-date {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
}

.post h3 {
  margin: 0;
  font-size: 1.05rem;
  font-family: Georgia, "Times New Roman", serif;
}

.post h3 a {
  color: var(--ink);
  text-decoration: none;
}

.post h3 a:hover {
  color: var(--accent);
}

.post p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  flex: 1;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--muted);
  background: #fff;
}

.read-more {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.read-more:hover {
  color: var(--accent-dark);
}

/* ---------- Article ---------- */
.art-nav {
  padding: 16px 0 4px;
  font-size: 0.9rem;
}

.art-nav a {
  color: var(--accent);
  text-decoration: none;
}

.art-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  margin: 16px 0 8px;
}

.art-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.art-body h2 {
  font-family: Georgia, "Times New Roman", serif;
  margin-top: 28px;
}

.art-body a {
  color: var(--accent);
}

.art-body code {
  background: #f4eee0;
  padding: 1px 5px;
  border-radius: 4px;
}

.art-body ul {
  padding-left: 1.4em;
}

.art-body li {
  margin: 4px 0;
}
