/* ===== Blog — identité v2 =====
 * Mêmes tokens que le reste du site (voir legal.css) : pastel, verre,
 * Geist + Pixelify Sans. Fichier autonome (chaque page du site a sa propre
 * feuille de style, convention déjà suivie par recuperer.css/legal.css).
 */

:root {
  --shell:  #fff5f0;
  --teal:   #7bc6c9;
  --teal-ink: #2e7377;
  --aqua:   #a5e1df;
  --coral:  #ffb199;
  --coral-deep: #ef8f6e;
  --peach:  #ffcdb2;
  --ink:    #26393c;
  --muted:  #5d7275;
  --line:   rgba(38, 57, 60, 0.16);
  --sans:    "Geist", -apple-system, "Helvetica Neue", sans-serif;
  --display: "Pixelify Sans", "Geist", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(58% 46% at 14% 6%, rgba(165, 225, 223, 0.5), transparent 70%),
    radial-gradient(50% 42% at 88% 30%, rgba(255, 205, 178, 0.45), transparent 72%),
    var(--shell);
  background-attachment: fixed;
  min-height: 100vh;
}

/* --- fond vidéo en boucle (page liste uniquement, cf. blog.php) --- */
.blog-bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}
.blog-bg-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  /* Voile volontairement léger : la vidéo doit rester bien visible. La
     lisibilité du texte est assurée par le verre dépoli des cartes et de la
     barre haute, pas par ce voile. */
  background: linear-gradient(180deg, rgba(255, 245, 240, 0.18), rgba(255, 245, 240, 0.32));
}
/* Sur un article, on lit un long texte : le voile est plus dense pour que la
   vidéo reste une ambiance et non une gêne. */
.blog-bg-overlay.is-soft {
  background: linear-gradient(180deg, rgba(255, 245, 240, 0.5), rgba(255, 245, 240, 0.68));
}
@media (prefers-reduced-motion: reduce) {
  .blog-bg-video { display: none; }
}

/* Chiffres dans un titre en fonte « pixel » : Pixelify Sans les rend quasi
   illisibles à grande taille (« 250 g », « 404 »…). blog_fix_digits() les
   isole dans un <span class="num"> qu'on repasse en fonte texte. */
.num {
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: 0;
}

/* --- barre haute (verre) --- */
.topbar {
  position: sticky;
  top: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1100px, calc(100% - 32px));
  margin: 14px auto 0;
  padding: 12px 22px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  box-shadow: 0 12px 32px rgba(123, 198, 201, 0.16);
}
.brand {
  font-family: var(--display);
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-back {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.3s ease;
}
.topbar-back:hover { color: var(--coral-deep); }

/* --- sélecteur de langue : liens réels (pas un switch JS, cf. blog.php) --- */
.blog-langswitch { display: inline-flex; gap: 2px; }
.blog-lang-btn {
  font-size: 1.05rem;
  line-height: 1;
  padding: 4px 5px;
  text-decoration: none;
  border-radius: 999px;
  opacity: 0.5;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.blog-lang-btn:hover { opacity: 1; transform: translateY(-1px); }
.blog-lang-btn.is-active { opacity: 1; }

/* --- contenu --- */
.blog-main {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(40px, 7vh, 80px) 0 70px;
}
.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--teal-ink);
  margin: 0 0 1rem;
  text-align: center;
}
.blog-main > h1 {
  font-family: var(--display);
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0;
  font-weight: 600;
  font-size: clamp(2rem, 4.6vw, 3.2rem);
  line-height: 1.1;
  margin: 0 0 2.4rem;
  text-align: center;
}
.muted { color: var(--muted); font-size: 0.9rem; text-align: center; }
.sub {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--teal-ink);
  margin: 0 0 0.8rem;
}

/* --- étagère : les articles en tranches, comme des dos de livres ---
 * Accordéon horizontal : chaque article est une tranche verticale portant son
 * titre à la verticale ; celle qu'on survole s'élargit et révèle son résumé.
 * L'ouverture repose sur flex-grow (transition fluide), pas sur width.
 * La première tranche est ouverte par défaut (.is-open) pour que la page ne
 * paraisse jamais fermée à l'arrivée ; dès qu'on survole l'étagère, c'est le
 * survol qui décide (voir .blog-shelf:hover .shelf-item.is-open plus bas).
 */
.blog-shelf {
  display: flex;
  gap: clamp(8px, 1vw, 14px);
  height: clamp(380px, 58vh, 560px);
}
.shelf-item {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background-color: var(--aqua);
  background-size: cover;
  background-position: center;
  text-decoration: none;
  color: #fff;
  box-shadow: 0 14px 36px rgba(38, 57, 60, 0.18);
  transition: flex-grow 0.55s cubic-bezier(0.22, 0.61, 0.36, 1),
              box-shadow 0.35s ease, border-color 0.35s ease;
}
/* voile sombre en bas : garantit la lisibilité du texte quelle que soit la photo */
.shelf-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(38, 57, 60, 0.05) 30%, rgba(38, 57, 60, 0.78));
  transition: background 0.35s ease;
}
.shelf-item.is-open,
.shelf-item:hover,
.shelf-item:focus-visible {
  flex-grow: 5.5;
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 26px 60px rgba(38, 57, 60, 0.3);
}
/* Le survol reprend la main sur l'ouverture par défaut. :has() plutôt que
   .blog-shelf:hover — sinon survoler le simple espace entre deux tranches
   refermerait tout, ce qui donne une impression de bug. */
.blog-shelf:has(.shelf-item:hover) .shelf-item.is-open:not(:hover) { flex-grow: 1; }
.shelf-item:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* titre vertical (tranche fermée) — libellé COURT, cf. blog_short_title() */
.shelf-spine {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  writing-mode: vertical-rl;
  rotate: 180deg;
  z-index: 1;
  max-height: calc(100% - 52px);
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--display);
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 14px rgba(38, 57, 60, 0.6);
  opacity: 1;
  transition: opacity 0.3s ease;
}
.shelf-item.is-open .shelf-spine,
.shelf-item:hover .shelf-spine,
.shelf-item:focus-visible .shelf-spine { opacity: 0; }
.blog-shelf:has(.shelf-item:hover) .shelf-item.is-open:not(:hover) .shelf-spine { opacity: 1; }

/* contenu horizontal (tranche ouverte) */
.shelf-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: clamp(18px, 2.2vw, 30px);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease 0.12s, transform 0.4s ease 0.12s;
  pointer-events: none;
}
.shelf-item.is-open .shelf-panel,
.shelf-item:hover .shelf-panel,
.shelf-item:focus-visible .shelf-panel { opacity: 1; transform: none; }
.blog-shelf:has(.shelf-item:hover) .shelf-item.is-open:not(:hover) .shelf-panel {
  opacity: 0;
  transform: translateY(10px);
}
.shelf-panel-title {
  font-weight: 800;
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
  line-height: 1.25;
  text-shadow: 0 2px 14px rgba(38, 57, 60, 0.5);
}
.shelf-panel-desc {
  font-size: 0.9rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.9);
  max-width: 46ch;
}
.shelf-panel-cta {
  align-self: flex-start;
  margin-top: 0.3rem;
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* --- mobile : MÊME accordéon, pivoté à la verticale, piloté au TAP ---
 * L'ouverture reste pilotée par flex-grow, mais sur l'axe vertical : les
 * tranches fermées deviennent des bandeaux fins empilés, et l'ouverte s'étire
 * en un grand pavé qui montre sa couverture au milieu de l'écran.
 * Pas de :hover au doigt → l'ouverture passe par .is-open, que le script de
 * blog.php déplace au tap (voir « accordéon tactile » dans blog.php).
 */
@media (max-width: 760px) {
  .blog-shelf {
    flex-direction: column;
    height: clamp(520px, 78vh, 760px);
    gap: 10px;
  }
  /* la tranche ouverte prend l'essentiel de la hauteur, les autres restent fines */
  .shelf-item { flex: 1 1 0; }
  .shelf-item.is-open { flex-grow: 6; }
  /* au doigt, :hover se « colle » après un tap : on le neutralise ici pour que
     seul .is-open décide, sinon deux tranches paraissent ouvertes à la fois */
  .shelf-item:hover { flex-grow: 1; }
  .shelf-item.is-open:hover { flex-grow: 6; }

  /* titre du dos : horizontal sur mobile (la tranche est un bandeau large) */
  .shelf-spine {
    writing-mode: horizontal-tb;
    rotate: none;
    left: 20px;
    right: 20px;
    bottom: 14px;
    transform: none;
    max-height: none;
    font-size: 1.05rem;
  }
  .shelf-item:hover .shelf-spine { opacity: 1; }
  .shelf-item.is-open .shelf-spine,
  .shelf-item.is-open:hover .shelf-spine { opacity: 0; }

  .shelf-item:hover .shelf-panel { opacity: 0; transform: translateY(10px); }
  .shelf-item.is-open .shelf-panel,
  .shelf-item.is-open:hover .shelf-panel { opacity: 1; transform: none; }
}

/* --- article --- */
.blog-article {
  padding: clamp(1.6rem, 4vw, 3rem);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  /* Plus opaque que les cartes de la liste : le fond vidéo défile derrière et
     du texte long doit rester parfaitement lisible par-dessus. */
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: 0 22px 54px rgba(38, 57, 60, 0.14);
}
.blog-cover {
  aspect-ratio: 21 / 9;
  background-color: var(--aqua);
  background-size: cover;
  background-position: center;
  border-radius: 18px;
  margin: -0.4rem -0.4rem 1.8rem;
}
.blog-article h1 {
  font-family: var(--display);
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0;
  font-weight: 600;
  font-size: clamp(1.7rem, 3.8vw, 2.6rem);
  line-height: 1.15;
  margin: 0 0 1.8rem;
  text-align: center;
}

/* --- corps rendu depuis le Markdown (voir lib/blog.php::md_to_html) --- */
.blog-prose { font-size: 1.02rem; line-height: 1.75; color: #3c5154; max-width: 68ch; margin: 0 auto; }
.blog-prose h2 {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--ink);
  margin: 2.2rem 0 0.8rem;
}
.blog-prose h3 { font-family: var(--sans); font-weight: 700; font-size: 1.1rem; color: var(--ink); margin: 1.8rem 0 0.6rem; }
.blog-prose p { margin: 0.9rem 0; }
.blog-prose strong { color: var(--ink); }
.blog-prose a { color: var(--coral-deep); text-decoration: none; }
.blog-prose a:hover { text-decoration: underline; }
.blog-prose ul, .blog-prose ol { padding-left: 1.3rem; margin: 0.9rem 0; }
.blog-prose li { margin: 0.35rem 0; }
.blog-prose blockquote {
  margin: 1.4rem 0;
  padding: 0.2rem 0 0.2rem 1.1rem;
  border-left: 3px solid var(--coral);
  color: var(--teal-ink);
  font-style: italic;
}
.blog-prose img {
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  margin: 1.2rem 0;
  display: block;
}

/* --- navigation de série (précédent/suivant) --- */
.blog-series-nav {
  margin-top: 2.4rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
  text-align: center;
}
.blog-chip {
  display: inline-block;
  margin: 4px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.25s ease, color 0.25s ease;
}
.blog-chip:hover { border-color: var(--coral); color: var(--coral-deep); }

/* --- 404 --- */
.blog-404 { text-align: center; padding: 10vh 0; }
.blog-404 h1 { font-family: var(--display); font-size: 4rem; margin: 0; color: var(--coral-deep); }
.blog-404 a { color: var(--teal-ink); }

/* --- pied de page --- */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto 22px;
  padding: 16px 26px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.8rem;
  color: var(--muted);
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--coral-deep); }

@media (max-width: 560px) {
  .topbar { justify-content: flex-end; }
  .topbar .brand { display: none; }
  .footer { border-radius: 24px; justify-content: center; text-align: center; }
}
