/* =====================================================================
   Blog — Maxime Bonnet, webmaster freelance à Nancy
   ---------------------------------------------------------------------
   Complément de style.css : on n'y redéfinit RIEN, on réutilise ses
   variables (--red, --ink, --line, --radius, --shadow-*, --container…),
   ses polices (Poppins / Open Sans) et ses composants (.container,
   .section, .btn, .breadcrumb, .cta-band).
   ===================================================================== */

:root {
  /* Écart vertical entre le bloc d'en-tête d'un article et ce qui suit.
     ~40 px en mobile, ~60 px en grand écran. Une seule variable : les
     deux respirations (en-tête → image, image → corps) restent égales. */
  --article-gap: clamp(40px, 4.2vw, 60px);

  /* Distance entre une image et sa légende, partout dans le blog. */
  --figure-caption-gap: 12px;

  /* Largeur de lecture confortable pour le corps d'un article. */
  --article-measure: 760px;
}

/* =====================================================================
   1. Bandeau d'aperçu privé (brouillon / article programmé)
   ===================================================================== */

.blog-preview-bar {
  background: var(--red-deep);
  color: #fff;
  font-size: .9rem;
}
.blog-preview-bar__inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 22px;
}
.blog-preview-bar strong { color: #fff; font-family: "Poppins", sans-serif; }
.blog-preview-bar span { color: rgba(255, 255, 255, .88); }
.blog-preview-bar__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ffd7d7;
  flex: none;
}
.blog-preview-bar__link {
  margin-left: auto;
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
}
.blog-preview-bar__link:hover { color: #ffd7d7; }

/* =====================================================================
   2. Liste des articles
   ===================================================================== */

/* ---------- Filtres par catégorie ---------- */
.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 clamp(28px, 4vw, 44px);
}
.blog-filters__chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-2);
  font-size: .9rem;
  font-weight: 500;
  transition: border-color .2s ease, background .2s ease, color .2s ease;
}
.blog-filters__chip span {
  font-size: .78rem;
  color: var(--muted);
  background: var(--bg-alt);
  border-radius: 999px;
  padding: 1px 7px;
}
.blog-filters__chip:hover { border-color: var(--red); color: var(--red-dark); }
.blog-filters__chip.is-active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.blog-filters__chip.is-active span { background: rgba(255, 255, 255, .22); color: #fff; }

/* ---------- Grille ---------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 26px;
}

/* ---------- Vignette d'article ---------- */
.post-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.post-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
  border-color: #f0d6d6;
}

/* Vignette en 16:9 — aspect-ratio évite le saut de mise en page pendant
   le chargement, sans avoir à connaître les dimensions réelles. */
.post-card__media {
  display: block;
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg-alt);
  overflow: hidden;
}
.post-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.post-card:hover .post-card__media img { transform: scale(1.05); }
.post-card__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Poppins", sans-serif;
  font-size: 2.6rem;
  font-weight: 800;
  color: #fff;
  background: var(--grad);
  opacity: .9;
}

.post-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 22px 22px 24px;
}
.post-card__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.post-card__cat {
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--red);
  background: var(--red-soft);
  border-radius: 999px;
  padding: 4px 10px;
}
.post-card__dot { opacity: .6; }

.post-card__title {
  font-size: 1.16rem;
  line-height: 1.32;
  margin: 0 0 10px;
}
.post-card__title a { color: var(--ink); }
.post-card__title a:hover { color: var(--red-dark); }

.post-card__excerpt {
  color: var(--muted);
  font-size: .95rem;
  flex: 1;
  margin-bottom: 16px;
}
.post-card__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: .92rem;
  color: var(--red-dark);
}
.post-card__link svg { transition: transform .2s ease; }
.post-card:hover .post-card__link svg { transform: translateX(4px); }

/* ---------- Aucun article ---------- */
.blog-empty {
  max-width: 620px;
  margin-inline: auto;
  text-align: center;
  padding: clamp(28px, 5vw, 56px) 0;
}
.blog-empty h1, .blog-empty h2 { margin-bottom: .5em; }

/* ---------- Pagination ---------- */
.blog-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: clamp(36px, 5vw, 56px);
}
.blog-pagination__page,
.blog-pagination__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink-2);
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: .92rem;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.blog-pagination__page:hover,
.blog-pagination__nav:hover { border-color: var(--red); color: var(--red-dark); }
.blog-pagination__page.is-active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* =====================================================================
   3. Article
   ===================================================================== */

/* ---------- Bloc d'en-tête ----------
   PIÈGE ÉVITÉ : sans précaution, le padding bas de cet en-tête
   s'additionne à l'espacement du bloc suivant et on obtient plus de
   200 px de vide entre la ligne « date · temps de lecture » et l'image
   d'ouverture. D'où : padding-bas à ZÉRO ici, et un espacement unique
   porté par .article__block ci-dessous. */
.article__head {
  padding: clamp(34px, 4.6vw, 54px) 0 0;
}
.article__head-inner {
  max-width: var(--article-measure);
}

/* L'espacement vertical est un PADDING, pas une marge : une marge se
   serait fusionnée avec celle de l'en-tête (fusion des marges verticales)
   et l'écart réel serait devenu imprévisible. */
.article__block {
  padding-top: var(--article-gap);
}

.article__cat {
  display: inline-block;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: .74rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--red);
  background: var(--red-soft);
  border-radius: 999px;
  padding: 5px 13px;
  margin-bottom: 16px;
}
.article__cat:hover { background: var(--red); color: #fff; }

.article__title {
  font-size: clamp(1.85rem, 4vw, 2.7rem);
  margin-bottom: .35em;
}
.article__lead {
  font-size: 1.14rem;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 1.1em;
  max-width: 62ch;
}
.article__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  font-size: .9rem;
  color: var(--muted);
  margin: 0;
}
.article__meta-dot { opacity: .6; }

/* ---------- Image d'ouverture ----------
   PIÈGE ÉVITÉ : le cadre arrondi (border-radius + overflow + ombre) porte
   sur l'IMAGE, pas sur la <figure>. Sur la figure, une légende éventuelle
   se retrouverait enfermée dans la vignette, collée au bord bas. */
.article__cover {
  margin: 0;
}
.article__cover img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ---------- Corps de l'article ----------
   Aucune classe .reveal ici, volontairement : elle laisserait le texte à
   opacité 0 jusqu'à l'exécution du script, et la page paraîtrait vide au
   chargement. Une animation n'a rien à faire sur le contenu principal. */
.article__body {
  max-width: var(--article-measure);
  font-size: 1.06rem;
  line-height: 1.78;
  color: var(--ink-2);
}
.article__body > *:first-child { margin-top: 0; }
.article__body > *:last-child  { margin-bottom: 0; }

.article__body h2 {
  font-size: clamp(1.4rem, 2.6vw, 1.85rem);
  margin: 1.9em 0 .6em;
  scroll-margin-top: 100px;
}
.article__body h3 {
  font-size: clamp(1.15rem, 2vw, 1.32rem);
  margin: 1.6em 0 .5em;
  scroll-margin-top: 100px;
}
.article__body h4 {
  font-size: 1.05rem;
  margin: 1.4em 0 .45em;
  scroll-margin-top: 100px;
}
.article__body p { margin: 0 0 1.15em; }

.article__body a {
  color: var(--red-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(210, 63, 63, .4);
}
.article__body a:hover {
  color: var(--red-deep);
  text-decoration-color: currentColor;
}

.article__list { margin: 0 0 1.3em; padding-left: 1.35em; }
.article__list li { margin-bottom: .5em; }
.article__list li::marker { color: var(--red); font-weight: 600; }
.article__list--num li::marker { font-family: "Poppins", sans-serif; }

.article__quote {
  margin: 1.8em 0;
  padding: 4px 0 4px 22px;
  border-left: 3px solid var(--red);
  color: var(--ink);
  font-size: 1.08rem;
  font-style: italic;
}
.article__quote p:last-child { margin-bottom: 0; }

.article__body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 6px;
}
.article__code {
  margin: 1.6em 0;
  padding: 18px 20px;
  background: #1f1f1f;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: .9rem;
  line-height: 1.6;
}
.article__code code {
  background: none;
  border: 0;
  padding: 0;
  color: #f2f2f2;
  font-size: inherit;
}

.article__rule {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 2.2em 0;
}

.article__body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: .96rem;
}
.article__body th, .article__body td {
  border: 1px solid var(--line);
  padding: 10px 13px;
  text-align: left;
}
.article__body th { background: var(--bg-alt); color: var(--ink); font-family: "Poppins", sans-serif; }

/* ---------- Images dans le corps ----------
   Règle générale : une image isolée respire dans le texte. */
.article__body img {
  margin: 28px 0;
  border-radius: var(--radius);
}

/* PIÈGE ÉVITÉ : la règle ci-dessus écarterait chaque image de SA PROPRE
   légende. On la neutralise à l'intérieur des figures — le sélecteur est
   volontairement plus précis (.article__body figure.article__figure img,
   soit trois classes contre une) pour l'emporter à coup sûr, sans dépendre
   de l'ordre de déclaration.
   Le cadre arrondi porte ici encore sur l'IMAGE, jamais sur la figure :
   c'est ce qui garde la légende à l'extérieur de la vignette. */
.article__figure {
  margin: 2em 0;
}
.article__body figure.article__figure img {
  margin: 0 0 var(--figure-caption-gap);
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.article__body figure.article__figure figcaption {
  margin: 0;
  font-size: .88rem;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* =====================================================================
   4. Responsive
   ===================================================================== */

@media (max-width: 980px) {
  .post-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .post-grid { grid-template-columns: 1fr; }

  .article__body { font-size: 1.02rem; }
  .article__cover img { border-radius: var(--radius); }

  .blog-preview-bar__link { margin-left: 0; }
  .blog-pagination__page,
  .blog-pagination__nav { min-width: 38px; height: 38px; padding: 0 11px; font-size: .86rem; }
}

/* Le site respecte prefers-reduced-motion : on fait de même. */
@media (prefers-reduced-motion: reduce) {
  .post-card,
  .post-card__media img,
  .post-card__link svg { transition: none; }
  .post-card:hover { transform: none; }
  .post-card:hover .post-card__media img { transform: none; }
}
