/* ==========================================================================
   Générateur de cahier des charges (/outils/cahier-des-charges) — préfixe .cdc-
   Voir js/pages/tool-cdc.js. Le hero et les sections éditoriales réutilisent .st-* et .seo-* (static.css, seo.css).
   ========================================================================== */

.cdc-page .st-hero { padding-bottom: 32px; }

/* ---------- Zone de l'outil ---------- */
.cdc-tool { padding: 32px 0 56px; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cdc-shell { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 var(--gutter); }
.cdc-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 20px; }
.cdc-toolbar-text { margin: 0; max-width: 520px; font-size: var(--fs-sm); color: var(--ink-2); }
.cdc-toolbar-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.cdc-saved { display: inline-flex; align-items: center; gap: 6px; margin-right: 8px; font-size: var(--fs-xs); color: var(--success); }
.cdc-saved:empty { display: none; }

.cdc-grid { display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); gap: 32px; align-items: start; }

/* Volets formulaire / aperçu : visibles seulement sur petit écran */
.cdc-switch { display: none; position: sticky; top: var(--header-h); z-index: 30; gap: 8px; padding: 8px 0 12px; background: var(--surface); }
.cdc-switch-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: #fff; font-size: var(--fs-sm); font-weight: 600; color: var(--ink);
}
.cdc-switch-btn.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Formulaire en sections repliables ---------- */
.cdc-sec { border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; scroll-margin-top: 64px; }
.cdc-sec + .cdc-sec { margin-top: 12px; }
.cdc-sec > summary {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius-lg); list-style: none; cursor: pointer;
  transition: background 0.15s;
}
.cdc-sec > summary::-webkit-details-marker { display: none; }
.cdc-sec > summary:hover { background: var(--surface); }
.cdc-sec > summary:focus-visible { box-shadow: var(--focus); }
.cdc-sec[open] > summary { border-bottom: 1px solid var(--line); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.cdc-num {
  display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 700; transition: background 0.15s;
}
.cdc-sec[open] .cdc-num { background: var(--brand); }
.cdc-sec-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cdc-sec-title { font-weight: 700; line-height: 1.3; }
.cdc-sec-hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); color: var(--muted); }
.cdc-sec-count {
  flex-shrink: 0; padding: 3px 10px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--muted);
  font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums;
}
.cdc-sec-count.is-active { background: var(--brand-soft); color: var(--brand-ink); }
.cdc-chev { display: flex; flex-shrink: 0; color: var(--muted); transition: transform 0.2s var(--ease); }
.cdc-sec[open] .cdc-chev { transform: rotate(180deg); }
.cdc-sec-body { padding: 22px 18px 18px; }
.cdc-sec-foot { display: flex; justify-content: flex-end; margin-top: 4px; }
.cdc-sec-foot .btn { max-width: 100%; white-space: normal; text-align: left; line-height: 1.25; padding-top: 8px; padding-bottom: 8px; }
.cdc-only-narrow { display: none; }

.cdc-note { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 16px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.45; }
.cdc-note .icon { margin-top: 2px; color: var(--muted); }
.cdc-pair.form-row .field, .cdc-pair .cdc-cond .field { margin-bottom: 20px; }
.field .field-hint a { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.field .field-hint a:hover { color: var(--brand); }

/* Groupes de choix (cases et boutons radio présentés en cartes) */
.cdc-fs { min-width: 0; margin: 0 0 20px; padding: 0; border: 0; }
.cdc-legend { display: block; width: 100%; margin-bottom: 8px; padding: 0; font-size: var(--fs-sm); font-weight: 600; }
.cdc-legend .optional { font-weight: 400; color: var(--muted); }
.cdc-unset { float: right; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.cdc-unset:hover { color: var(--brand); }
.cdc-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 8px; }
.cdc-fs .field-hint { margin-top: 8px; }
.cdc-pick .choice-card-body { flex-direction: row; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm); font-size: var(--fs-sm); }
.cdc-pick .choice-card-title { line-height: 1.3; }
.cdc-tick {
  display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; border: 1.5px solid var(--line-strong);
  border-radius: 6px; background: #fff; color: transparent; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cdc-tick-round { border-radius: 50%; }
.cdc-pick:hover .cdc-tick { border-color: var(--ink); }
.choice-card input:checked + .choice-card-body .cdc-tick { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Aperçu et actions ---------- */
.cdc-preview-col {
  position: sticky; top: calc(var(--header-h) + 16px); display: flex; flex-direction: column; gap: 12px;
  max-height: calc(100vh - var(--header-h) - 32px); max-height: calc(100dvh - var(--header-h) - 32px);
}
.cdc-actions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.cdc-publish { width: 100%; min-height: 52px; font-size: var(--fs-md); }
.cdc-actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cdc-actions-row .btn { flex: 1 1 auto; }
.cdc-paper-scroll { flex: 1; min-height: 0; padding: 16px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-2); }

.cdc-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 56px 28px; border-radius: var(--radius); background: #fff; text-align: center; color: var(--muted); }
.cdc-empty p { margin: 0; max-width: 380px; }
.cdc-empty-title { font-size: var(--fs-md); font-weight: 700; color: var(--ink); }
.cdc-empty-icon { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; margin-bottom: 4px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); }
.cdc-empty .btn { margin-top: 12px; }

/* ---------- Le document (aperçu et impression) ---------- */
.cdc-doc {
  padding: 34px 40px 26px; border-top: 4px solid var(--brand); border-radius: 4px; background: #fff; box-shadow: var(--shadow-sm);
  font-size: 14px; line-height: 1.55; color: var(--ink); -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.cdc-doc-kicker { margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brand-hover); }
.cdc-doc-title { margin: 0 0 16px; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; overflow-wrap: anywhere; }
.cdc-doc-title.is-placeholder { color: var(--faint); }
.cdc-doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 20px; margin: 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cdc-doc-meta dt { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.cdc-doc-meta dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.cdc-doc-sec { margin-top: 22px; }
.cdc-doc-h {
  display: flex; align-items: center; gap: 10px; margin: 0 0 10px; padding-bottom: 7px; border-bottom: 1px solid var(--line);
  font-size: 15px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; break-after: avoid;
}
.cdc-doc-n {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-ink); font-size: 12px; font-weight: 700;
}
.cdc-doc-p { margin: 0 0 8px; white-space: pre-line; overflow-wrap: anywhere; }
.cdc-doc-row { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); gap: 12px; margin: 0 0 6px; }
.cdc-doc-row dt { color: var(--muted); font-weight: 500; }
.cdc-doc-row dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.cdc-doc-k { margin: 0 0 4px; color: var(--muted); font-weight: 500; }
.cdc-doc-list { margin: 0 0 8px; padding-left: 1.2em; }
.cdc-doc-list li { margin-bottom: 2px; overflow-wrap: anywhere; }
.cdc-doc-list li::marker { color: var(--brand); }
.cdc-doc-foot { margin-top: 28px; padding-top: 10px; border-top: 1px solid var(--line); text-align: center; font-size: 11px; color: var(--faint); }
.cdc-doc-foot a { color: inherit; text-decoration: none; }

/* ---------- Contenu éditorial ---------- */
.cdc-ex { max-width: 860px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; }
.cdc-ex-title { margin: 0; padding: 16px 22px; border-bottom: 1px solid var(--line); background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; }
.cdc-ex-list { margin: 0; padding: 0; list-style: none; }
.cdc-ex-row { padding: 16px 22px; border-bottom: 1px solid var(--line); }
.cdc-ex-row:last-child { border-bottom: 0; }
.cdc-ex-main { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px; }
.cdc-ex-k { font-weight: 700; }
.cdc-ex-v { color: var(--ink-2); }
.cdc-ex-why { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 0 126px; font-size: var(--fs-sm); line-height: 1.45; color: var(--muted); }
.cdc-ex-why .icon { margin-top: 3px; color: var(--brand); }

.cdc-more { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.cdc-more-col { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; }
.cdc-more-col h3 { margin: 0 0 12px; font-size: var(--fs-md); }
.cdc-more-col ul { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.cdc-more-col a { display: inline-flex; align-items: flex-start; gap: 6px; color: var(--ink-2); line-height: 1.4; }
.cdc-more-col a .icon { margin-top: 3px; color: var(--faint); transition: transform 0.15s, color 0.15s; }
.cdc-more-col a:hover { color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; }
.cdc-more-col a:hover .icon { color: var(--brand); transform: translateX(2px); }
.seo-section.cdc-share { padding: 36px 0 0; }

/* ---------- Petits écrans : un volet à la fois ---------- */
@media (max-width: 960px) {
  .cdc-grid { grid-template-columns: minmax(0, 1fr); }
  .cdc-switch { display: flex; }
  .cdc-tool[data-pane='form'] .cdc-preview-col { display: none; }
  .cdc-tool[data-pane='preview'] .cdc-form-col { display: none; }
  .cdc-preview-col { position: static; max-height: none; }
  .cdc-paper-scroll { overflow: visible; }
  .cdc-only-narrow { display: inline-flex; }
}

@media (max-width: 744px) {
  .cdc-tool { padding: 20px 0 40px; }
  .cdc-toolbar { margin-bottom: 8px; }
  .cdc-toolbar-actions { width: 100%; }
  .cdc-saved { flex: 1 1 100%; margin: 0; }
  .cdc-doc-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cdc-sec > summary { padding: 14px; gap: 12px; }
  .cdc-sec-body { padding: 18px 14px 14px; }
  .cdc-sec-count { display: none; }
  .cdc-actions-row .btn { flex: 1 1 calc(50% - 4px); white-space: normal; line-height: 1.25; padding-top: 8px; padding-bottom: 8px; }
  .cdc-actions-row .btn:first-child { flex-basis: 100%; }
  .cdc-publish { white-space: normal; line-height: 1.25; padding-top: 10px; padding-bottom: 10px; }
  .cdc-paper-scroll { padding: 10px; }
  .cdc-doc { padding: 24px 18px 20px; }
  .cdc-doc-title { font-size: 21px; }
  .cdc-doc-row { grid-template-columns: minmax(0, 1fr); gap: 0; margin-bottom: 10px; }
  .cdc-doc-row dt { font-size: 12px; }
  .cdc-more { grid-template-columns: minmax(0, 1fr); }
  .cdc-ex-row { padding: 14px 16px; }
  .cdc-ex-title { padding: 14px 16px; }
  .cdc-ex-main { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .cdc-ex-why { margin-left: 0; }
}

/* ---------- Impression : uniquement le document, sans en-tête ni pied de page du site ---------- */
@page cdc-print { size: A4; margin: 16mm 15mm 18mm; }

@media print {
  body:has(.cdc-doc) { display: block !important; min-height: 0 !important; padding: 0 !important; background: #fff !important; overflow: visible !important; }
  body:has(.cdc-doc) > :not(main) { display: none !important; }
  body:has(.cdc-doc) #app { min-height: 0; }
  .cdc-page > :not(.cdc-tool) { display: none !important; }
  .cdc-tool { padding: 0; border: 0; background: none; }
  .cdc-shell { max-width: none; padding: 0; }
  .cdc-toolbar, .cdc-switch, .cdc-form-col, .cdc-actions, .cdc-empty { display: none !important; }
  .cdc-grid { display: block; }
  .cdc-preview-col { position: static; display: block !important; max-height: none; overflow: visible; }
  .cdc-paper-scroll { overflow: visible; padding: 0; border: 0; border-radius: 0; background: none; }
  .cdc-doc { page: cdc-print; padding: 8mm 0 0; border-top: 4px solid var(--brand); border-radius: 0; box-shadow: none; font-size: 10.5pt; line-height: 1.5; color: #000; }
  .cdc-doc-title { font-size: 22pt; }
  .cdc-doc-sec { break-inside: avoid; }
  .cdc-doc-row, .cdc-doc-list li { break-inside: avoid; }
  .cdc-doc-foot { break-inside: avoid; color: #777; }
}
