/* Note de délégation — mise en page institutionnelle limpide */

@page {
  size: A4;
  margin: 16mm 15mm 18mm;
}

*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --ink: #1a2332;
  --ink-soft: #3d4a5c;
  --muted: #6b7785;
  --line: #d8dee6;
  --paper: #ffffff;
  --page: #f4f6f8;
  --civic: #2c5282;
  --civic-tint: #eef4fa;
  --warm: #6b5344;
  --warm-tint: #f7f3ee;
  --ok: #2f5d56;
  --ok-tint: #eef6f4;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --measure: 38rem;
}

html {
  background: var(--page);
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ── Toolbar ── */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--ink);
  color: #fff;
}

.toolbar-back {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  white-space: nowrap;
}

.toolbar-back:hover {
  color: #fff;
}

.toolbar-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
  text-align: center;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar button {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  white-space: nowrap;
}

.toolbar button.btn-primary {
  background: #3d7ab5;
  color: #fff;
}

.toolbar button.btn-ghost {
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.toolbar button.btn-save {
  background: #2f5d56;
  color: #fff;
}

.edit-status {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.9;
  text-align: center;
}

.edit-status[data-kind="ok"] {
  color: #9ae6b4;
}

.edit-status[data-kind="edit"] {
  color: #bee3f8;
}

.edit-status[data-kind="info"] {
  color: rgba(255, 255, 255, 0.75);
}

/* ── Mode édition (même aperçu) ── */
body.is-editing .doc [data-edit] {
  outline: 1.5px dashed rgba(44, 82, 130, 0.45);
  outline-offset: 3px;
  border-radius: 2px;
  cursor: text;
  transition: outline-color 0.12s ease, background-color 0.12s ease;
}

body.is-editing .doc [data-edit]:hover,
body.is-editing .doc [data-edit]:focus {
  outline-color: var(--civic);
  outline-style: solid;
  background: rgba(44, 82, 130, 0.04);
}

body.is-editing .doc [data-edit]:focus {
  outline-width: 2px;
}

body.is-editing .hub-grid--footer {
  pointer-events: none;
  opacity: 0.45;
}

/* ── Hub ── */
.hub {
  max-width: 720px;
  margin: 40px auto 72px;
  padding: 0 24px;
}

.hub-head {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--ink);
}

.hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.hub-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.hub-card--deck {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.hub-card--deck .hub-card-num,
.hub-card--deck .hub-card-cta {
  color: #7eb0d8;
}

.hub-card--deck .hub-card-title {
  color: #fff;
}

.hub-card--deck .hub-card-desc {
  color: rgba(255, 255, 255, 0.7);
}

.hub-card--deck:hover {
  border-color: var(--civic);
  box-shadow: 0 8px 24px rgba(26, 35, 50, 0.2);
}

.hub-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  min-height: 180px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hub-card:hover {
  border-color: var(--civic);
  box-shadow: 0 8px 24px rgba(26, 35, 50, 0.08);
}

.hub-card--note {
  background: var(--civic-tint);
  border-color: #c5d4e4;
}

.hub-card-num {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--civic);
}

.hub-card-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hub-card-desc {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.45;
  flex: 1;
}

.hub-card-cta {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--civic);
}

.masthead-role {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.4;
}

.role-frame {
  margin: 0 0 22px;
  padding: 14px 16px;
  background: var(--civic-tint);
  border-left: 3px solid var(--civic);
  font-size: 15px;
  color: var(--ink);
  line-height: 1.45;
}

.block--alone {
  border-bottom: none;
  padding-bottom: 8px;
}

.colophon a {
  color: var(--civic);
  font-weight: 600;
  text-decoration: none;
}

.colophon a:hover {
  text-decoration: underline;
}
/* ── Document ── */
.doc {
  max-width: 720px;
  margin: 32px auto 72px;
  padding: 48px 52px 40px;
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(26, 35, 50, 0.06), 0 12px 40px rgba(26, 35, 50, 0.06);
}

/* ── Masthead ── */
.masthead {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--ink);
  margin-bottom: 0;
}

.masthead-org {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--civic);
}

.masthead-doc {
  margin: 0 0 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.masthead h1,
.delegation-title {
  margin: 0 0 20px;
  font-family: var(--serif);
  font-size: clamp(22px, 3.6vw, 30px);
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hub-head .delegation-title {
  margin: 0 0 18px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.3;
}

.masthead .delegation-title {
  padding-bottom: 4px;
}

.masthead-who {
  margin: 0;
  font-size: 15px;
  color: var(--ink-soft);
}

.masthead-who strong {
  color: var(--ink);
  font-weight: 700;
}

.sep {
  margin: 0 6px;
  color: var(--muted);
}

/* ── TOC ── */
.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 20px 0 36px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.toc a {
  font-size: 13px;
  font-weight: 600;
  color: var(--civic);
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Blocks ── */
.block {
  margin-bottom: 40px;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--line);
}

.block:last-of-type {
  border-bottom: none;
  margin-bottom: 24px;
}

.block-label {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--civic);
}

.block h2 {
  margin: 0 0 20px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink);
}

/* ── Legal / Article ── */
.legal {
  margin-bottom: 24px;
  padding: 16px 18px;
  background: var(--page);
  border-left: 3px solid var(--ink);
}

.legal--follow {
  margin-top: 28px;
  margin-bottom: 8px;
}

.masthead .masthead-who {
  margin-bottom: 16px;
}

.masthead .delegation-title {
  margin-bottom: 0;
}

.legal-art {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.legal-text {
  margin: 0;
  font-size: 15.5px;
  color: var(--ink);
  line-height: 1.5;
}

/* ── Mandate list ── */
.mandate {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: mandate;
}

.mandate li {
  counter-increment: mandate;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 4px 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.mandate li:last-child {
  border-bottom: 1px solid var(--line);
}

.mandate li::before {
  content: counter(mandate, decimal-leading-zero);
  font-size: 13px;
  font-weight: 700;
  color: var(--civic);
  padding-top: 3px;
}

.mandate-title {
  grid-column: 2;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.mandate-body {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.55;
}

.mandate-line {
  position: relative;
  padding-left: 14px;
}

.mandate-line::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--civic);
  opacity: 0.45;
}

/* ── Prose ── */
.prose {
  max-width: var(--measure);
}

.prose p {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--ink-soft);
}

.prose p:last-child {
  margin-bottom: 0;
}

.prose-emphasis {
  margin: 0;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 18px !important;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink) !important;
}

/* Emphase auto-cadrée : pas de double filet en bas de section */
.block:has(.prose-emphasis:last-child) {
  border-bottom: none;
  padding-bottom: 28px;
}

/* ── 3 niveaux d’utilité ── */
.levels {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.levels:has(> :nth-child(3)) {
  grid-template-columns: repeat(3, 1fr);
}

.level-card {
  padding: 18px 16px 16px;
  background: var(--civic-tint);
  border-radius: 4px;
}

.level-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--civic);
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.level-card ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.level-card li {
  position: relative;
  padding: 8px 0 8px 12px;
  border-top: 1px solid rgba(44, 82, 130, 0.12);
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.level-card li:first-child {
  border-top: none;
  padding-top: 0;
}

.level-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.85em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--civic);
  opacity: 0.5;
}

.level-card li:first-child::before {
  top: 0.55em;
}

.split-note--ok {
  margin-top: 4px;
  padding-top: 0;
  border-top: none;
  color: var(--ok);
  font-size: 14.5px;
}

/* ── Split : hors / dans ── */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.split-panel {
  padding: 20px 20px 18px;
  border-radius: 4px;
}

.split-panel--out {
  background: var(--warm-tint);
}

.split-panel--in {
  background: var(--ok-tint);
}

.split-panel h3 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.split-panel--out h3 {
  color: var(--warm);
}

.split-panel--in h3 {
  color: var(--ok);
}

.split-intro {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.split-panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.split-panel li {
  position: relative;
  padding: 8px 0 8px 14px;
  border-top: 1px solid rgba(26, 35, 50, 0.08);
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.split-panel li:first-of-type {
  border-top: none;
  padding-top: 0;
}

.split-panel li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.85em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
}

.split-panel--out li::before {
  background: var(--warm);
  opacity: 0.55;
}

.split-panel--in li::before {
  background: var(--ok);
  opacity: 0.55;
}

.split-panel li strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14.5px;
  color: var(--ink);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.split-note {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(107, 83, 68, 0.2);
  font-size: 13.5px;
  color: var(--warm);
  line-height: 1.45;
}

/* ── Rules (méthode) ── */
.rules {
  margin: 0 0 24px;
  padding: 0;
}

.rule {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 12px 20px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  margin: 0;
}

.rule:last-of-type {
  border-bottom: 1px solid var(--line);
}

.rule dt {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--civic);
  padding-top: 2px;
}

.rule dd {
  margin: 0;
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* ── Callout commissions ── */
.callout {
  padding: 22px 24px;
  background: var(--civic-tint);
  border-radius: 4px;
}

.callout-label {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--civic);
}

.callout h3 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.callout p {
  margin: 0;
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.55;
  max-width: var(--measure);
}

/* ── Colophon ── */
.colophon {
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--ink);
  text-align: center;
}

.colophon p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.colophon p:first-child {
  font-weight: 600;
  color: var(--ink-soft);
}

.hub-grid--footer {
  margin-top: 20px;
  text-align: left;
}

.hub-grid--footer .hub-card {
  min-height: 150px;
}

.hub-card--current {
  outline: 2px solid var(--civic);
  outline-offset: -1px;
}

/* ── Print ── */
@media print {
  html {
    background: #fff !important;
  }

  body {
    background: #fff !important;
    font-size: 11pt;
    line-height: 1.5;
    color: #1a2332;
  }

  .no-print,
  .toolbar,
  .toc,
  .hub-grid--footer,
  .edit-status {
    display: none !important;
  }

  .doc {
    margin: 0;
    padding: 0;
    max-width: none;
    width: 100%;
    box-shadow: none;
    background: #fff;
  }

  .masthead {
    margin-bottom: 8mm;
    padding-bottom: 6mm;
  }

  .delegation-title {
    font-size: 18pt;
  }

  .block {
    break-inside: avoid;
    margin-bottom: 7mm;
    padding-bottom: 5mm;
  }

  .block:last-of-type,
  .block--alone {
    border-bottom: none;
    margin-bottom: 0;
  }

  .levels {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .mandate li {
    break-inside: avoid;
    padding: 10px 0;
  }

  .rule {
    break-inside: avoid;
  }

  .colophon {
    margin-top: 8mm;
    padding-top: 5mm;
  }

  .level-card,
  .split-panel,
  .callout,
  .legal,
  .role-frame {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

@media (max-width: 680px) {
  .doc {
    margin: 0;
    padding: 28px 20px 36px;
    box-shadow: none;
  }

  .split,
  .hub-grid,
  .hub-grid--3,
  .levels {
    grid-template-columns: 1fr;
  }

  .rule {
    grid-template-columns: 1fr;
    gap: 4px;
  }

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

  .toolbar-title,
  .edit-status {
    display: none;
  }

  .toolbar-actions {
    gap: 6px;
  }

  .toolbar button {
    padding: 7px 10px;
    font-size: 12px;
  }
}
