/**
 * Composants du gabarit Article.
 * Chargé uniquement sur les articles.
 */

/* ==========================================================================
   BARRE DE LECTURE + SOUS-EN-TÊTE COLLANT
   ========================================================================== */

.nc-lecture {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 3px;
  background: var(--surface-raise);
}

.nc-lecture__jauge {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width var(--t-fast) linear;
}

.nc-sousentete {
  position: sticky;
  top: 3px;
  z-index: 19;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 10px var(--sp-4);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mute);
}

/* ==========================================================================
   GRILLE — 232px / contenu / 236px
   ========================================================================== */

.nc-article {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 260px;
  gap: 56px;
  align-items: start;
  padding-block: var(--sp-6) var(--sp-12);
  padding-inline: var(--sp-4);
  max-width: var(--page);
  margin-inline: auto;
}

.nc-article__flanc {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}

.nc-article__corps { min-width: 0; }

@media (max-width: 900px) {
  .nc-article {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-4);
    max-width: 100%;
  }

  .nc-article__flanc {
    position: static;
    order: 2;
  }

  .nc-article__corps { order: 1; }
}

/* ==========================================================================
   SOMMAIRE
   ========================================================================== */

.nc-sommaire__titre,
.nc-progression__titre {
  margin: 0 0 var(--sp-1);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.nc-sommaire__liste {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nc-sommaire__lien {
  display: flex;
  gap: 9px;
  padding: 6px 10px;
  border-left: 2px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-soft);
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}

.nc-sommaire__lien:hover { background: var(--surface-raise); }

.nc-sommaire__lien.est-actif {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--accent-ink);
}

.nc-sommaire__num {
  flex: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-mute);
}

.nc-sommaire__item--n3 .nc-sommaire__lien { padding-left: 26px; font-weight: 500; }
.nc-sommaire__item--n3 .nc-sommaire__num { display: none; }

/* ==========================================================================
   PROGRESSION
   ========================================================================== */

.nc-progression {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: 12px;
  border-radius: 9px;
  background: var(--surface);
  border: var(--ring);
}

.nc-progression__barre {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-raise);
  overflow: hidden;
}

.nc-progression__jauge {
  display: block;
  height: 100%;
  background: var(--success);
  transition: width var(--t-base) var(--ease);
}

.nc-progression__compte {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--success);
}

.nc-progression__note {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-mute);
}

.nc-progression__reset {
  align-self: start;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-decoration: underline;
}

/* Case posée devant chaque h2 du corps */
.nc-etape {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  flex: none;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  vertical-align: middle;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}

.nc-etape[aria-pressed="true"] {
  background: var(--success);
  border-color: var(--success);
}

.nc-etape[aria-pressed="true"]::after {
  content: "✓";
  display: block;
  color: var(--surface);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
}

/* ==========================================================================
   FIL D'ARIANE ET MÉTA
   ========================================================================== */

.nc-fil {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mute);
}

.nc-fil a { color: inherit; text-decoration: none; }
.nc-fil a:hover { color: var(--accent); }
.nc-fil__cat { color: var(--cat-color, var(--text-soft)); font-weight: 700; }

.nc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1);
  margin-block: var(--sp-2);
}

.nc-meta__item {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-mute);
}

.nc-pastille {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: var(--r-full);
  background: var(--surface-raise);
  color: var(--text-soft);
  font-family: var(--font-title);
  font-size: 12.5px;
  font-weight: 600;
}

.nc-pastille--cat {
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 12%, transparent);
  color: color-mix(in srgb, var(--cat-color, var(--accent)) 78%, var(--text));
}

.nc-pastille__point {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--cat-color, var(--accent));
}

.nc-pastille--revise {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  color: color-mix(in srgb, var(--success) 80%, var(--text));
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

/* ==========================================================================
   ENCADRÉS
   ========================================================================== */

.nc-encadre {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-block: var(--sp-4);
  padding: 18px 20px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: var(--ring);
  border-left: 3px solid var(--encadre-teinte, var(--info));
}

.nc-encadre__titre {
  margin: 0;
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--encadre-teinte, var(--info));
}

.nc-encadre__liste {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 6px var(--sp-3);
}

.nc-encadre__liste li {
  display: flex;
  gap: 9px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-soft);
}

.nc-encadre__liste li::before {
  content: "□";
  flex: none;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--encadre-teinte, var(--info));
}

.nc-encadre--prerequis { --encadre-teinte: var(--info); }
.nc-encadre--avertissement { --encadre-teinte: var(--warning); }
.nc-encadre--danger { --encadre-teinte: var(--error); }

/* ==========================================================================
   BLOCS DE CODE
   Toujours sombres, y compris en mode clair : un terminal est sombre.
   ========================================================================== */

.nc-code {
  margin-block: var(--sp-4);
  border-radius: 9px;
  overflow: hidden;
  background: #211D1A;
  border: 1px solid #37302A;
}

.nc-code__entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 9px 14px;
  background: #2A251F;
  border-bottom: 1px solid #37302A;
}

.nc-code__langage {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #A79C91;
}

.nc-code__copier {
  padding: 3px 9px;
  border: none;
  border-radius: 5px;
  background: #37302A;
  color: #A79C91;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}

.nc-code__copier:hover { background: #4A423B; color: #F2EDE6; }
.nc-code__copier.est-copie { background: #2B2013; color: #FB8B3C; }

.nc-code__corps {
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: #E4DCD3;
  counter-reset: nc-ligne;
  tab-size: 2;
}

.nc-code__ligne {
  display: block;
  white-space: pre;
  padding-left: 34px;
  text-indent: -34px;
}

.nc-code__ligne::before {
  content: attr(data-ligne);
  display: inline-block;
  width: 22px;
  margin-right: 12px;
  text-align: right;
  color: #9C9187;
  text-indent: 0;
  user-select: none;
}

/* Le textarea sert uniquement de source au presse-papiers */
.nc-code__source {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Code en ligne dans le corps du texte */
.nc-article__corps :not(pre) > code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-raise);
  font-size: 0.88em;
}

/* ==========================================================================
   FIGURES
   ========================================================================== */

.nc-figure {
  margin-block: var(--sp-4);
  margin-inline: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.nc-figure__zoom {
  display: block;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: var(--ring);
  cursor: zoom-in;
}

/* Jamais d'agrandissement : un bouton de 300px reste à 300px.
   C'est width:100% qui rendait les petites images baveuses. */
.nc-figure img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
}

/* Une image plus étroite que la colonne est centrée plutôt que
   collée à gauche. */
.nc-figure__zoom,
.nc-figure--liee > a {
  display: inline-block;
  max-width: 100%;
}

.nc-figure { align-items: flex-start; }

/* Image déjà liée : pas de curseur de zoom, le lien va ailleurs. */
.nc-figure--liee > a { cursor: pointer; border: none; }
.nc-figure--liee img { border-radius: var(--r-sm); }

.nc-figure__legende {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-mute);
}

.nc-loupe {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: rgb(25 22 20 / 0.9);
  cursor: zoom-out;
}

.nc-loupe img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--r-sm);
}

.nc-loupe__fermer {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  padding: 6px 12px;
  border: 1px solid #4A423B;
  border-radius: var(--r-sm);
  background: #211D1A;
  color: #F2EDE6;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ==========================================================================
   CORPS DE L'ARTICLE
   ========================================================================== */

.nc-article__corps > h1,
.nc-article__corps .entry-content > h2,
.nc-article__corps .entry-content > h3 {
  margin-top: var(--sp-6);
  scroll-margin-top: 90px;
}

.nc-article__corps .entry-content > h2 {
  display: flex;
  align-items: center;
}

.nc-article__corps .entry-content > p {
  max-width: var(--measure);
}

/* ==========================================================================
   CORRECTIFS DE MISE À L'ÉCHELLE
   ========================================================================== */

/* Le titre d'article se cale sur la colonne, pas sur la fenêtre.
   Un clamp() en vw gonfle à 64px dans une colonne de 680px. */
.nc-article__corps > h1 {
  margin: var(--sp-2) 0 0;
  font-size: clamp(1.875rem, 1.2rem + 1.6vw, 3.25rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
  max-width: 24ch;
}

/* Chapô : la phrase de résumé technique, pas un titre bis. */
.nc-chapo {
  margin: var(--sp-2) 0 0;
  max-width: 52ch;
  font-size: 1.3125rem;
  line-height: 1.55;
  color: var(--text-soft);
}

/* ==========================================================================
   COLONNE « DANS LA MÊME RUBRIQUE »
   ========================================================================== */

.nc-rubrique__titre {
  margin: 0 0 var(--sp-1);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.nc-rubrique__liste {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nc-rubrique__item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-block: 11px;
  border-bottom: 1px solid var(--border);
}

.nc-rubrique__item:last-child { border-bottom: none; }

.nc-rubrique__cat {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--cat-color, var(--text-mute));
}

.nc-rubrique__lien {
  font-family: var(--font-title);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  text-decoration: none;
}

.nc-rubrique__lien:hover { color: var(--accent); }

.nc-rubrique__duree {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-mute);
}

/* Sommaire : trois niveaux au lieu de deux */
.nc-sommaire__item--n4 .nc-sommaire__lien {
  padding-left: 38px;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text-mute);
}

.nc-sommaire__item--n4 .nc-sommaire__num { display: none; }

/* Sous 1320px, la colonne de droite disparaît plutôt que d'écraser
   le contenu. Le sommaire reste, c'est lui qui sert à naviguer. */
@media (max-width: 1320px) {
  .nc-article {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 40px;
    max-width: min(1080px, 95vw);
  }

  .nc-article__flanc:last-child { display: none; }
}

/* ==========================================================================
   TITRES INTERNES HÉRITÉS
   Les articles de 2018 utilisent <h1> pour leurs sections. En attendant
   la correction en base, on les rend à la bonne échelle visuelle.
   Le sommaire, lui, les traite déjà comme un premier niveau.
   ========================================================================== */

.nc-article__corps :is(.entry-content, .wp-block-post-content) h1 {
  font-size: var(--step-h2);
  letter-spacing: -0.035em;
}

.nc-article__corps :is(.entry-content, .wp-block-post-content) h2 {
  font-size: var(--step-h3);
  letter-spacing: -0.03em;
}

/* ==========================================================================
   COMMENTAIRES
   Pas de bloc avatar dans le gabarit : Gravatar est une requête vers un
   tiers, ce qui contredirait la promesse affichée dans le pied de page.
   ========================================================================== */

.wp-block-comments {
  margin-top: var(--sp-8);
}

.wp-block-comments-title {
  margin: 0 0 var(--sp-4);
  font-size: var(--step-h3);
  letter-spacing: -0.03em;
}

.wp-block-comment-template {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.wp-block-comment-template li {
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface);
  border: var(--ring);
}

/* Une réponse est décalée et perd son cadre : c'est le fil qui compte,
   pas la répétition de la boîte. */
.wp-block-comment-template li .wp-block-comment-template {
  margin-top: var(--sp-3);
  padding-left: var(--sp-3);
  border-left: 2px solid var(--border);
}

.wp-block-comment-template li .wp-block-comment-template li {
  padding: 0 0 var(--sp-2);
  background: none;
  border: none;
  border-radius: 0;
}

.wp-block-comment-author-name {
  font-family: var(--font-title);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.wp-block-comment-author-name a { color: var(--text); text-decoration: none; }
.wp-block-comment-author-name a:hover { color: var(--accent); }

.wp-block-comment-date {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mute);
}

.wp-block-comment-date a { color: inherit; text-decoration: none; }

.wp-block-comment-content {
  margin-block: var(--sp-2);
  font-size: 1rem;
  line-height: 1.65;
}

.wp-block-comment-content p:last-child { margin-bottom: 0; }

.wp-block-comment-reply-link a {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
}

.wp-block-comment-reply-link a:hover { text-decoration: underline; }

.wp-block-comments-pagination {
  margin-top: var(--sp-4);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* --- Formulaire de commentaire --- */

.wp-block-post-comments-form {
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

.wp-block-post-comments-form .comment-reply-title {
  margin: 0 0 var(--sp-2);
  font-family: var(--font-title);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.wp-block-post-comments-form :is(input[type="text"], input[type="email"], input[type="url"], textarea) {
  width: 100%;
  max-width: 42ch;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color var(--t-fast) var(--ease);
}

.wp-block-post-comments-form textarea {
  max-width: none;
  min-height: 150px;
  resize: vertical;
}

.wp-block-post-comments-form :is(input, textarea):focus {
  border-color: var(--accent);
  outline: none;
}

.wp-block-post-comments-form label {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-title);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-soft);
}

.wp-block-post-comments-form :is(.comment-form-comment, .comment-form-author, .comment-form-email, .comment-form-url) {
  margin-bottom: var(--sp-3);
}

.wp-block-post-comments-form .comment-form-cookies-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: var(--sp-3);
  font-size: 0.875rem;
  color: var(--text-soft);
}

.wp-block-post-comments-form .comment-form-cookies-consent input { width: auto; margin-top: 3px; }
.wp-block-post-comments-form .comment-form-cookies-consent label { margin: 0; font-weight: 400; }

.wp-block-post-comments-form .comment-notes,
.wp-block-post-comments-form .logged-in-as {
  margin-bottom: var(--sp-3);
  font-size: 0.875rem;
  color: var(--text-mute);
}

.wp-block-post-comments-form .submit {
  padding: 11px 22px;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--accent);
  color: #FFFDFA;
  cursor: pointer;
  font-family: var(--font-title);
  font-size: 0.9375rem;
  font-weight: 600;
}

.wp-block-post-comments-form .submit:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
