/* Onglet Charte graphique. S’appuie sur les jetons et composants de styles.css.
   La page est la charte elle-même : les éléments marqués .edit servent à la modifier et disparaissent à l’impression. */

.charte {
  /* Valeurs de départ, réécrites par charte.js. */
  --c-principale: #5b21b6;
  --c-principale-claire: #d3c3ea;
  --c-principale-sombre: #35136a;
  --c-secondaire: #ffd60a;
  --c-secondaire-claire: #fff3b8;
  --c-secondaire-sombre: #947c06;
  --c-texte: #1c1b22;
  --c-fond: #faf9f6;
  --cover-ink: #faf9f6;
  --f-titres: var(--display);
  --f-texte: var(--sans);
  --w-titres: 400;
  --w-texte: 400;
  --lh-texte: 1.5;
}

/* Champs de formulaire */
.form-stack { display: grid; gap: 14px; }
.form-field { display: grid; gap: 6px; min-width: 0; font-size: .875rem; font-weight: 600; }
.form-field input[type="text"],
.form-field input[type="number"],
.form-field textarea,
.form-field select {
  width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px;
  background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--control);
  font: 400 1rem/1.4 var(--sans);
}
.form-field textarea { padding: 10px 12px; resize: vertical; }
.form-field [aria-invalid="true"] { box-shadow: inset 0 0 0 2.5px var(--bad); }
.input-unit { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; }
.google-field { display: grid; gap: 6px; }
.form-hint { color: var(--ink-soft); font-size: .8125rem; line-height: 1.45; }
.input-unit input[type="number"] { width: 90px; }
.example-note { margin-bottom: 16px; padding: 10px 12px; border-radius: 12px; background: var(--wash); color: var(--ink-soft); font-size: .875rem; font-weight: 400; }
.sub-title { margin: 36px 0 12px; font-size: 1.0625rem; font-weight: 700; }
.section-body { min-width: 0; }
.section-wide { grid-column: 1 / -1; min-width: 0; }
.section-wide > .sub-title:first-child { margin-top: 12px; }
.section-body > .sub-title:first-child, .section-body > .edit + .sub-title { margin-top: 28px; }
.sub-intro { margin: -4px 0 12px; color: var(--ink-soft); font-size: .9375rem; max-width: 70ch; }
.btn-ink { background: var(--ink); color: var(--sheet); }
.btn-ink:hover { background: color-mix(in srgb, var(--ink) 82%, var(--sheet)); }
.file-btn { position: relative; cursor: pointer; }
.file-btn:has(:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
.small-btn { width: 36px; height: 36px; }
#clearSpace, #lineHeight { --c: var(--ink); }
a.btn { text-decoration: none; }

/* Couverture : un bandeau pleine largeur dans la couleur principale, que le panneau Identité recouvre. */
.cover-grid {
  max-width: var(--page); margin-inline: auto; padding: 0 var(--gutter) 48px;
  display: grid; column-gap: 36px; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); grid-template-areas: "form cover";
}
.identity {
  grid-area: form; position: relative; z-index: 2; align-self: start; margin-top: 28px;
  padding: 20px 24px 24px; border-radius: 20px; background: var(--sheet); box-shadow: var(--lift);
}
.cover { grid-area: cover; position: relative; min-width: 0; padding: 44px 0 56px; color: var(--cover-ink); }
.cover-band { position: absolute; z-index: 0; inset: 0 -100vw -44px; background: var(--c-principale); forced-color-adjust: none; }
.cover-inner { position: relative; z-index: 1; container-type: inline-size; forced-color-adjust: none; }
.cover-logo {
  display: grid; place-items: center; width: 112px; height: 112px; padding: 16px; border-radius: 26px;
  background: var(--c-fond); box-shadow: 0 12px 30px -14px rgb(0 0 0 / .5);
}
.cover-logo img { width: 100%; height: 100%; object-fit: contain; }
.cover-eyebrow { margin-top: 28px; font: 600 .875rem/1.3 var(--f-texte); letter-spacing: .08em; text-transform: uppercase; }
.cover-name {
  margin-top: 6px; font-family: var(--f-titres); font-weight: var(--w-titres);
  font-size: clamp(44px, 12cqi, 116px); line-height: 1; letter-spacing: -.01em; overflow-wrap: anywhere; text-wrap: balance;
}
.cover-tagline { margin-top: 14px; max-width: 34ch; font: 400 1.375rem/1.35 var(--f-texte); text-wrap: balance; }
.cover-description { margin-top: 12px; max-width: 60ch; font-family: var(--f-texte); font-size: 1rem; line-height: var(--lh-texte); }
.cover-description:empty, .cover-tagline:empty { display: none; }
@media (max-width: 959px) {
  .cover-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "cover" "form"; row-gap: 16px; }
  .identity { margin-top: 0; }
}

/* Logo */
.edit-panel { display: grid; gap: 14px; padding: 18px; border-radius: 16px; background: var(--sheet); box-shadow: inset 0 0 0 1px var(--rule); }
.dropzone {
  display: grid; justify-items: center; gap: 6px; padding: 22px 16px; border: 2px dashed var(--control); border-radius: 14px;
  text-align: center; cursor: pointer; transition: background-color .15s;
}
.dropzone:hover, .dropzone.is-over { background: var(--wash); }
.dropzone:has(:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
.dropzone small { color: var(--ink-soft); font-size: .8125rem; }
.logo-file { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .875rem; }
.logo-settings { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px 28px; }
.inline-field { display: flex; align-items: center; gap: 12px; }
@media (max-width: 560px) { .logo-settings { grid-template-columns: minmax(0, 1fr); } }

.logo-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 20px 16px; }
.logo-stage {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; padding: 14%; overflow: hidden; border-radius: 14px;
  background: var(--stage, var(--c-fond)); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .08); forced-color-adjust: none;
}
.logo-stage img { width: 100%; height: 100%; object-fit: contain; }
.logo-tile p { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: .875rem; font-weight: 600; }
.logo-tile .mark { width: 20px; height: 20px; padding: 3.5px; }
[data-variant="dark"] { --stage: var(--c-texte); }
[data-variant="brand"] { --stage: var(--c-principale); }
[data-variant="black"] img { filter: brightness(0); }
[data-variant="white"] { --stage: var(--c-texte); }
[data-variant="white"] img, [data-variant="brand"] img { filter: brightness(0) invert(1); }
[data-dont="stretch"] img { transform: scaleX(1.5); }
[data-dont="rotate"] img { transform: rotate(-18deg); }
[data-dont="recolor"] img { filter: hue-rotate(150deg) saturate(1.5); }
[data-dont="effect"] img { filter: drop-shadow(6px 8px 0 rgb(0 0 0 / .45)) blur(.7px); }
[data-dont="busy"] { --stage: conic-gradient(from 40deg, var(--c-secondaire), var(--c-principale-claire), var(--c-secondaire-sombre), var(--c-principale), var(--c-secondaire-claire), var(--c-secondaire)); }

.logo-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 20px; }
.logo-rules figure { margin: 0; }
.logo-rules figcaption { margin-top: 8px; color: var(--ink-soft); font-size: .9375rem; }
.logo-rules strong { color: var(--ink); }
.rule-stage {
  display: grid; place-items: center; min-height: 230px; padding: 20px; border-radius: 14px;
  background: var(--c-fond); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .08); forced-color-adjust: none;
}
.clear-space {
  padding: var(--clear, 24px);
  background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--c-principale) 30%, transparent) 0 2px, transparent 2px 8px);
  outline: 1.5px dashed color-mix(in srgb, var(--c-texte) 60%, transparent);
}
.clear-space img { display: block; height: 96px; width: auto; background: var(--c-fond); outline: 1.5px dashed color-mix(in srgb, var(--c-texte) 60%, transparent); }
.min-size { height: var(--min, 32px); width: auto; }

/* Couleurs */
.palette { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 16px; }
.color-card { overflow: hidden; border-radius: 18px; background: var(--sheet); box-shadow: inset 0 0 0 1px var(--rule); }
.color-hero {
  display: flex; flex-direction: column; justify-content: flex-end; min-height: 128px; padding: 16px 18px;
  background: var(--hero-bg); color: var(--hero-ink); forced-color-adjust: none;
}
.color-name { font-family: var(--f-titres); font-weight: var(--w-titres); font-size: 1.875rem; line-height: 1.05; }
.color-hero-code { margin-top: 4px; font: 500 .8125rem/1.4 var(--mono); }
.shades { list-style: none; margin: 0; padding: 4px 0; }
.shade {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 36px; grid-template-areas: "swatch main reset" "swatch ink ink";
  align-items: center; gap: 6px 10px; padding: 10px 14px;
}
.shade + .shade { border-top: 1px solid var(--rule); }
.shade-swatch {
  grid-area: swatch; align-self: start; position: relative; width: 40px; height: 40px; border-radius: 10px;
  background: var(--c); box-shadow: inset 0 0 0 1.5px var(--control); cursor: pointer; forced-color-adjust: none;
}
.shade-swatch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.shade-swatch:has(:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
.shade-main { grid-area: main; display: grid; gap: 2px; min-width: 0; }
.shade-label { color: var(--ink-soft); font-size: .8125rem; font-weight: 600; }
.shade-input {
  width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 0; border-radius: 9px;
  background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--control); font: 600 .9375rem var(--mono);
}
.shade-input[aria-invalid="true"] { box-shadow: inset 0 0 0 2.5px var(--bad); }
.shade [data-role="auto"] { grid-area: reset; }
.shade-ink { grid-area: ink; display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: .8125rem; }
.shade-ink .mark { width: 18px; height: 18px; padding: 3px; }
.ink-chip, .cell-chip {
  display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 7px;
  background: var(--chip-bg); color: var(--chip-ink); font: 400 .875rem/1 var(--f-titres);
  box-shadow: inset 0 0 0 1px var(--control); forced-color-adjust: none;
}

.legend { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--ink-soft); font-size: .875rem; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend .mark { width: 20px; height: 20px; padding: 3.5px; }
.matrix-wrap { position: relative; overflow-x: auto; border-radius: 14px; background: var(--sheet); box-shadow: inset 0 0 0 1px var(--rule); }
.matrix { width: 100%; min-width: 860px; table-layout: fixed; border-collapse: separate; border-spacing: 3px; font-size: .8125rem; }
.matrix thead th:first-child { width: 168px; }
.matrix th { padding: 6px; text-align: left; font-weight: 600; line-height: 1.25; vertical-align: bottom; }
.matrix thead th { min-width: 76px; }
.matrix tbody th { white-space: nowrap; vertical-align: middle; }
.chip-dot {
  display: inline-block; width: 14px; height: 14px; margin-right: 6px; border-radius: 4px; vertical-align: -2px;
  background: var(--c); box-shadow: inset 0 0 0 1px var(--control); forced-color-adjust: none;
}
.matrix td { padding: 0; }
.matrix td a {
  display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 4px 6px; border-radius: 8px;
  background: color-mix(in srgb, var(--st) 14%, var(--sheet)); color: var(--ink); text-decoration: none; line-height: 1.2;
}
.matrix td a:hover { background: color-mix(in srgb, var(--st) 28%, var(--sheet)); }
.cell-chip { width: 24px; height: 24px; font-size: .8125rem; }
.cell-ratio { display: block; font-weight: 700; font-variant-numeric: tabular-nums; }
.cell-level { display: block; color: var(--ink-soft); font-size: .75rem; white-space: nowrap; }
.matrix td.same { border-radius: 8px; background: var(--wash); color: var(--ink-soft); text-align: center; }

/* Typographie */
.type-edit { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 560px) { .type-edit { grid-template-columns: minmax(0, 1fr); } }
.font-editor, .type-settings { min-width: 0; margin: 0; padding: 16px 18px 18px; border: 0; border-radius: 16px; background: var(--sheet); box-shadow: inset 0 0 0 1px var(--rule); }
.font-editor { display: grid; gap: 12px; align-content: start; }
.font-editor legend { float: left; width: 100%; padding: 0; font-size: 1rem; font-weight: 700; }
.font-editor legend + * { clear: both; }
.type-settings { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: end; gap: 14px 28px; }
.type-settings .form-field:not(.inline-field) { flex: 1 1 220px; }
.line-height-row { flex: 1 1 260px; grid-template-columns: 80px minmax(0, 1fr) 48px; }

.specimens { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 20px 16px; margin: 24px 0 0; }
.specimen-figure { margin: 0; min-width: 0; }
.specimen-paint {
  min-height: 240px; padding: 22px 24px; border-radius: 18px; overflow-wrap: anywhere;
  background: var(--c-fond); color: var(--c-texte); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .08); forced-color-adjust: none;
}
.specimen-figure figcaption { margin-top: 8px; color: var(--ink-soft); font-size: .9375rem; }
.specimen-figure figcaption strong { color: var(--ink); }
.specimen-aa { font-size: 5.5rem; line-height: 1; }
.specimen-sample { margin-top: 12px; font-size: 1.75rem; line-height: 1.15; }
.specimen-paragraph { margin-top: 12px; font-size: 1rem; line-height: var(--lh-texte); }
[data-font="titres"] .specimen-paint { font-family: var(--f-titres); font-weight: var(--w-titres); }
[data-font="texte"] .specimen-paint { font-family: var(--f-texte); font-weight: var(--w-texte); }
.sample-field { margin-top: 14px; max-width: 520px; }

.table-wrap { position: relative; overflow-x: auto; }
.scale-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.scale-table th, .scale-table td { padding: 12px 14px 12px 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: baseline; }
.scale-table thead th { color: var(--ink-soft); font-size: .8125rem; font-weight: 600; }
.scale-table .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.scale-table td.preview { width: 45%; color: var(--ink); overflow-wrap: anywhere; }
.scale-table .need { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.scale-table .need .mark { width: 18px; height: 18px; padding: 3px; }
.scale-table td small { display: block; margin-top: 2px; color: var(--ink-soft); font-size: .75rem; }

/* Export */
.export-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.export-actions .field-msg { flex-basis: 100%; margin-top: 0; }
.code-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 28px 0 12px; }
.code-head .sub-title { margin: 0; }
.code-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.code {
  max-height: 460px; margin: 0; padding: 16px 18px; overflow: auto; border-radius: 14px;
  background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule);
  font: 400 .8125rem/1.6 var(--mono); white-space: pre; tab-size: 2;
}

/* Charte finale : des planches A4 paysage. Toutes les mesures suivent la largeur de la planche (cqi),
   si bien que l’écran et le PDF ont la même mise en page. */
.final { max-width: var(--page); margin-inline: auto; padding: 48px var(--gutter) 64px; }
.final::before { content: ""; display: block; height: 1px; margin: -48px 0 48px; background: var(--rule); }
.final-head { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 16px 48px; align-items: end; margin-bottom: 28px; }
.final-head h2 { font: 400 clamp(1.875rem, 2.8vw, 2.25rem)/1.08 var(--display); text-wrap: balance; }
@media (max-width: 859px) { .final-head { grid-template-columns: minmax(0, 1fr); } }
.sheets-scroll { position: relative; overflow-x: auto; padding: 4px 4px 12px; margin: -4px; }
.sheets { display: grid; gap: 32px; min-width: 720px; container-type: inline-size; }
.sheet {
  --sheet-rule: color-mix(in srgb, var(--c-texte) 30%, var(--c-fond));
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; aspect-ratio: 297 / 210; overflow: hidden;
  padding: 4.2cqi 5cqi 2.4cqi; border-radius: 6px; box-shadow: var(--lift);
  background: var(--c-fond); color: var(--c-texte);
  font-family: var(--f-texte); font-weight: var(--w-texte); font-size: 1.15cqi; line-height: 1.45;
  forced-color-adjust: none;
}
.sheet-head { padding-bottom: 1.6cqi; border-bottom: max(1px, .09cqi) solid var(--sheet-rule); }
.sheet-head h3 { font-family: var(--f-titres); font-weight: var(--w-titres); font-size: 2.1cqi; line-height: 1.1; }
.sheet-body { display: grid; grid-template-columns: 26% minmax(0, 1fr); gap: 4.5cqi; min-height: 0; padding: 3.2cqi 0 2.4cqi; }
.sheet-text { max-width: 30ch; }
.sheet-text p + p { margin-top: 1.3cqi; }
.sheet-foot { display: flex; gap: 6cqi; padding-top: 1cqi; border-top: max(1px, .09cqi) solid var(--sheet-rule); font-size: .85cqi; }

.sheet-cover { grid-template-rows: minmax(0, 1fr); align-items: center; padding: 6cqi 7cqi; background: var(--c-principale); color: var(--cover-ink); }
.sheet-logo-plate { display: grid; place-items: center; width: 11cqi; height: 11cqi; padding: 1.6cqi; border-radius: 2.4cqi; background: var(--c-fond); }
.sheet-logo-plate img { width: 100%; height: 100%; object-fit: contain; }
.sheet-eyebrow { margin-top: 4cqi; font-size: 1.1cqi; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.sheet-brand { margin-top: .6cqi; font-family: var(--f-titres); font-weight: var(--w-titres); font-size: 8cqi; line-height: 1; overflow-wrap: anywhere; }
.sheet-tagline { margin-top: 1.6cqi; max-width: 34ch; font-size: 1.9cqi; line-height: 1.3; }

.sheet-logos { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 2cqi; min-height: 0; }
.sheet-logo-main { display: flex; align-items: center; justify-content: center; min-height: 0; padding: 3cqi; border-radius: 1cqi; box-shadow: inset 0 0 0 max(1px, .09cqi) var(--sheet-rule); }
.sheet-logo-main img { width: 100%; height: 100%; object-fit: contain; }
.sheet-variants { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.4cqi; }
.sheet-variants span { display: block; margin-top: .6cqi; font-size: .95cqi; }
.sheet .logo-stage { border-radius: .8cqi; }

.sheet-colors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.6cqi; min-height: 0; }
.sheet-color-col { display: grid; grid-template-rows: 2fr 1fr 1fr; gap: 1cqi; min-height: 0; }
.sheet-color-col.neutrals { grid-template-rows: 1fr 1fr; }
.sheet-swatch {
  display: flex; flex-direction: column; justify-content: flex-end; gap: .2cqi; min-height: 0; padding: 1.1cqi 1.3cqi;
  border-radius: .9cqi; background: var(--sw); color: var(--sw-ink); box-shadow: inset 0 0 0 max(1px, .09cqi) var(--sheet-rule);
}
.sheet-swatch strong { font-size: 1.2cqi; }
.sheet-swatch.big strong { font-family: var(--f-titres); font-weight: var(--w-titres); font-size: 2cqi; line-height: 1.1; }
.sheet-swatch span { font: 500 .9cqi/1.35 var(--mono); }

.sheet-type-main { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 2.4cqi; min-height: 0; }
.sheet-alphabet { font-size: 3.8cqi; line-height: 1.15; }
.sheet-styles { display: grid; grid-template-columns: 30% minmax(0, 1fr); align-content: start; align-items: baseline; gap: .9cqi 2cqi; margin: 0; overflow: hidden; }
.sheet-styles dt { font-size: 1.15cqi; }
.sheet-styles dt small { display: block; font-size: .85cqi; }
.sheet-styles dd { margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 1.6cqi; line-height: 1.2; }
.sheet-type[data-font="titres"] :is(.sheet-alphabet, dd) { font-family: var(--f-titres); font-weight: var(--w-titres); }
.sheet-type[data-font="texte"] :is(.sheet-alphabet, dd) { font-family: var(--f-texte); }

/* Impression et PDF : seules les planches, une par page A4 paysage. */
@media print {
  @page { size: A4 landscape; margin: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { background: #fff; }
  body > :not(main), main > :not(#charte-finale), .final-head, .final > .code-head, .final > .code { display: none !important; }
  .final { max-width: none; padding: 0; }
  .final::before { display: none; }
  .sheets-scroll { overflow: visible; margin: 0; padding: 0; }
  .sheets { display: block; min-width: 0; }
  .sheet { width: 297mm; height: 210mm; aspect-ratio: auto; border-radius: 0; box-shadow: none; break-inside: avoid; break-after: page; }
  .sheet:last-child { break-after: auto; }
}
