/* Mise en forme des articles (éditeur riche du panel).
   Fichier partagé : chargé par le site (src/app/layout.tsx) ET par le panel (éditeur + aperçu),
   pour que ce qui est écrit dans le panel s'affiche exactement pareil sur le site.
   Liste des balises et classes autorisées : src/lib/richText.ts (vérification serveur). */

.article-body {
  --ab-text: #d1d5db;
  --ab-strong: #ffffff;
  --ab-muted: #9ca3af;
  --ab-accent: var(--primary, #22d3ee);
  --ab-surface: #121216;
  --ab-surface-2: #17171d;
  --ab-border: rgba(255, 255, 255, 0.1);

  color: var(--ab-text);
  font-size: 1.0625rem;
  line-height: 1.75;
  overflow-wrap: break-word;
}

/* Espacement vertical commun : la marge vient du bloc précédent, jamais du premier */
.article-body > * {
  margin: 0 0 1.25em;
}

.article-body > *:last-child {
  margin-bottom: 0;
}

/* --- Titres --- */
.article-body h2,
.article-body h3,
.article-body h4 {
  font-family: var(--font-rajdhani), "Rajdhani", system-ui, sans-serif;
  color: var(--ab-strong);
  font-weight: 800;
  line-height: 1.2;
  text-wrap: balance;
  margin-top: 2em;
}

.article-body > h2:first-child,
.article-body > h3:first-child,
.article-body > h4:first-child {
  margin-top: 0;
}

.article-body h2 {
  font-size: 1.9rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--ab-border);
}

.article-body h3 {
  font-size: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.article-body h4 {
  font-size: 1.2rem;
}

/* --- Texte --- */
.article-body p {
  margin-bottom: 1.25em;
}

.article-body p.is-lead {
  font-size: 1.2em;
  line-height: 1.65;
  color: #e5e7eb;
}

.article-body strong {
  color: var(--ab-strong);
  font-weight: 700;
}

.article-body em {
  font-style: italic;
}

.article-body u {
  text-underline-offset: 3px;
}

.article-body s {
  color: var(--ab-muted);
}

.article-body mark {
  background: color-mix(in srgb, var(--ab-accent) 30%, transparent);
  color: var(--ab-strong);
  padding: 0.05em 0.3em;
  border-radius: 4px;
}

.article-body sup,
.article-body sub {
  font-size: 0.72em;
  line-height: 0;
}

.article-body a {
  color: var(--ab-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: opacity 0.15s;
}

.article-body a:hover {
  opacity: 0.75;
}

.article-body .txt-center {
  text-align: center;
}

.article-body .txt-right {
  text-align: right;
}

.article-body .txt-left {
  text-align: left;
}

/* --- Listes --- */
.article-body ul,
.article-body ol {
  padding-left: 1.5em;
}

.article-body ul {
  list-style: disc;
}

.article-body ol {
  list-style: decimal;
}

.article-body li {
  margin-bottom: 0.5em;
}

.article-body li::marker {
  color: var(--ab-accent);
}

.article-body li > ul,
.article-body li > ol {
  margin: 0.5em 0 0;
}

/* --- Citation --- */
.article-body blockquote {
  padding: 0.35em 0 0.35em 1.25em;
  border-left: 3px solid var(--ab-accent);
  color: #e5e7eb;
  font-size: 1.1em;
  font-style: italic;
}

.article-body blockquote p:last-child {
  margin-bottom: 0;
}

/* --- Code --- */
.article-body code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.875em;
  background: var(--ab-surface-2);
  border: 1px solid var(--ab-border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  color: var(--ab-strong);
}

.article-body pre {
  background: var(--ab-surface);
  border: 1px solid var(--ab-border);
  border-radius: 12px;
  padding: 1em 1.15em;
  overflow-x: auto;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.article-body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  white-space: pre;
  color: #e5e7eb;
}

/* --- Séparateur --- */
.article-body hr {
  height: 1px;
  border: 0;
  margin: 2.25em 0;
  background: linear-gradient(to right, transparent, var(--ab-border), transparent);
}

/* --- Encadrés --- */
.article-body .callout {
  --cl: var(--ab-accent);
  padding: 1em 1.15em;
  border: 1px solid color-mix(in srgb, var(--cl) 35%, transparent);
  border-left: 3px solid var(--cl);
  border-radius: 10px;
  background: color-mix(in srgb, var(--cl) 9%, var(--ab-surface));
}

.article-body .callout.is-tip {
  --cl: #34d399;
}

.article-body .callout.is-warn {
  --cl: #fbbf24;
}

.article-body .callout.is-danger {
  --cl: #f87171;
}

.article-body .callout > *:last-child {
  margin-bottom: 0;
}

.article-body .callout strong:first-child {
  color: var(--cl);
}

/* --- Images et vidéos --- */
.article-body figure {
  margin-left: 0;
  margin-right: 0;
}

.article-body figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--ab-border);
}

.article-body figure.media-sm {
  max-width: 340px;
}

.article-body figure.media-md {
  max-width: 620px;
}

.article-body figure.txt-center {
  margin-left: auto;
  margin-right: auto;
}

.article-body figure.txt-right {
  margin-left: auto;
}

.article-body figcaption {
  margin-top: 0.6em;
  font-size: 0.8125rem;
  color: var(--ab-muted);
  text-align: center;
}

.article-body .ab-embed {
  max-width: 100%;
}

.article-body .ab-embed iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 1px solid var(--ab-border);
  border-radius: 14px;
  background: #000;
}

/* --- Tableaux --- */
.article-body .ab-table-wrap {
  overflow-x: auto;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  border: 1px solid var(--ab-border);
  border-radius: 10px;
  overflow: hidden;
}

.article-body th,
.article-body td {
  padding: 0.6em 0.85em;
  border-bottom: 1px solid var(--ab-border);
  text-align: left;
  vertical-align: top;
}

.article-body th {
  background: var(--ab-surface-2);
  color: var(--ab-strong);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.article-body tbody tr:last-child td {
  border-bottom: 0;
}

.article-body tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

/* --- Téléphone --- */
@media (max-width: 640px) {
  .article-body {
    font-size: 1rem;
  }

  .article-body h2 {
    font-size: 1.5rem;
  }

  .article-body h3 {
    font-size: 1.25rem;
  }

  .article-body figure.media-sm,
  .article-body figure.media-md {
    max-width: 100%;
  }

  /* Tableau à partir de 4 colonnes : il défile au doigt plutôt que d'écraser le texte */
  .article-body table:has(th:nth-child(4)),
  .article-body table:has(td:nth-child(4)) {
    min-width: 520px;
  }
}
