/* =====================================================================
   LE LIVRE DE LA LIBERTÉ — feuille de style commune à toutes les pages
   ---------------------------------------------------------------------
   Charte « moderne » : bordeaux du logo Morale de l'Histoire,
   Young Serif pour les titres, Inter pour le texte.
   Young Serif n'existe qu'en romain (pas d'italique ni de gras) :
   les textes « en italique » sont donc composés en romain ou en Inter.

   Organisation :
     1. Variables (couleurs, polices, dimensions)
     2. Base commune
     3. Composants communs (surtitre, pastille, bouton, barre du haut,
        couverture 3D, pieds de page)
     4. Page d'accueil       → body.page-home
     5. Mentions légales     → body.page-legal
     6. Page de confirmation → body.page-merci
   ===================================================================== */

/* ---------- 1. Variables ---------- */
:root {
  --bg: #FBF9F6;          /* blanc cassé chaud */
  --surface: #FFFFFF;
  --tint: #F4ECE8;        /* bordeaux très dilué */
  --ink: #16120F;
  --muted: #5F5852;
  --rule: #E8E1DB;
  --accent: #771D1C;      /* bordeaux du logo Morale de l'Histoire */
  --accent-dark: #5A1414;
  --on-accent: #F8F3EF;
  --display: "Young Serif", Georgia, "Times New Roman", serif;
  --text: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --container: 1120px;
  --measure: 640px;
  --radius: 14px;
  color-scheme: light;
}

/* ---------- 2. Base commune ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

.wrap { width: 100%; max-width: calc(var(--container) + 48px); margin: 0 auto; padding: 0 24px; }
@media (max-width: 400px) { .wrap { padding: 0 18px; } }

a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-dark); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip { position: absolute; left: 16px; top: -100px; background: var(--ink); color: var(--bg); padding: 10px 14px; z-index: 10; border-radius: 8px; }
.skip:focus { top: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.08; margin: 0; letter-spacing: -0.015em; font-synthesis: none; }

::selection { background: #EBD3CE; color: var(--ink); }

@media (prefers-reduced-motion: no-preference) {
  @keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
}

/* ---------- 3. Composants communs ---------- */

/* Surtitre */
.kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin: 0;
}
.kicker::before { content: ""; width: 18px; height: 2px; background: currentColor; border-radius: 2px; }

/* Pastilles */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--tint); color: var(--accent);
  font-size: 0.82rem; font-weight: 500; margin: 0;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* Boutons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 14px 26px;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--text); font-size: 1rem; font-weight: 600;
  text-decoration: none; border: 1px solid transparent; border-radius: 999px; cursor: pointer;
  box-shadow: 0 6px 20px -8px rgba(119,29,28,0.55);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.button:hover { background: var(--accent-dark); color: var(--on-accent); }
@media (prefers-reduced-motion: no-preference) { .button:hover { transform: translateY(-1px); } }
.button .arrow { transition: transform 0.15s ease; }
.button:hover .arrow { transform: translateY(2px); }
.button svg { width: 16px; height: 16px; flex: none; }
.button-ghost { background: var(--surface); color: var(--ink); border-color: var(--rule); box-shadow: none; }
.button-ghost:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }

/* Barre du haut */
.topbar { padding: 18px 0; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-family: var(--display); font-size: 1.2rem; color: var(--ink); text-decoration: none; line-height: 1.1; }
.topbar-cta {
  font-size: 0.9rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  padding: 10px 16px; min-height: 44px; display: inline-flex; align-items: center;
  border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); color: var(--ink);
}
.topbar-cta:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 420px) { .brand { font-size: 1.02rem; } .topbar-cta { padding: 8px 12px; font-size: 0.85rem; } }

/* Boutons de partage du header (accueil) */
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-share { display: flex; align-items: center; gap: 6px; }
.share-icon {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0;
  background: transparent; color: var(--ink); border: 1px solid transparent; border-radius: 50%;
  cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.share-icon:hover { color: var(--accent); border-color: var(--rule); background: var(--surface); }
.share-icon svg { width: 18px; height: 18px; display: block; }
.share-native { display: none; }
/* Sur petit écran : un seul bouton « Partager » à la place des quatre icônes */
@media (max-width: 720px) {
  .topbar-share .share-icon:not(.share-native) { display: none; }
  .share-native { display: inline-grid; width: 44px; height: 44px; border-color: var(--rule); background: var(--surface); }
  .topbar-right { gap: 8px; }
}
.share-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: #F8F3EF; font-size: 0.92rem; line-height: 1.45; text-align: center;
  box-shadow: 0 12px 30px -12px rgba(0,0,0,0.5);
}

/* Couverture 3D (CSS pur) — la taille se règle avec --w */
.book-scene { --w: clamp(160px, 46vw, 240px); --t: calc(var(--w) * 0.13); position: relative; width: var(--w); perspective: 1400px; }
.book-scene::after {
  content: ""; position: absolute; left: 4%; right: -6%; bottom: -16px; height: 24px;
  background: radial-gradient(ellipse at center, rgba(22,18,15,0.32), rgba(22,18,15,0) 70%);
  filter: blur(5px); z-index: -1;
}
.book { position: relative; width: 100%; aspect-ratio: 2 / 3; transform-style: preserve-3d; transform: rotateY(-26deg) rotateX(3deg); }
@media (prefers-reduced-motion: no-preference) {
  .book { transition: transform 0.6s ease; }
  .book-scene:hover .book { transform: rotateY(-14deg) rotateX(2deg); }
}
.book > div { position: absolute; }
.book-front {
  inset: 0; transform: translateZ(calc(var(--t) / 2)); border-radius: 2px 4px 4px 2px;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.28) 0, rgba(0,0,0,0) 7%, rgba(255,255,255,0.05) 9%, rgba(0,0,0,0) 12%),
    linear-gradient(160deg, #8C2A28 0%, #771D1C 45%, #561313 100%);
  padding: 12% 11% 10% 14%; display: flex;
}
.book-frame { flex: 1; display: flex; flex-direction: column; align-items: flex-start; text-align: left; color: var(--on-accent); }
.cover-art { width: 100%; height: auto; margin: 0 0 auto; display: block; }
.cover-title { font-family: var(--display); font-size: calc(var(--w) * 0.12); line-height: 1.08; letter-spacing: -0.01em; color: var(--on-accent); margin: 0 0 9%; }
.cover-author {
  font-family: var(--text); font-weight: 500; font-size: calc(var(--w) * 0.045); letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(248,243,239,0.85); margin: 0; padding-top: 7%; border-top: 1px solid rgba(248,243,239,0.45); align-self: stretch;
}
.book-back { inset: 0; transform: rotateY(180deg) translateZ(calc(var(--t) / 2)); background: #561313; }
.book-pages {
  top: 1.5%; bottom: 1.5%; width: calc(var(--t) - 4px); left: calc(100% - var(--t) / 2 - 2px);
  transform: rotateY(90deg) translateZ(-2px);
  background: repeating-linear-gradient(90deg, #F6F2EC 0 2px, #E3DBD1 2px 3px);
}
.book-spine { top: 0; bottom: 0; width: var(--t); left: calc(var(--t) / -2); transform: rotateY(-90deg); background: #4E1212; }

/* Pieds de page */
footer { background: var(--ink); color: #CFC7BF; font-size: 0.92rem; }
footer a { color: #F8F3EF; }
footer p { margin: 0; }

/* Pied de page complet (accueil) */
.footer-full { padding: 56px 0 40px; }
.footer-top { display: grid; gap: 28px; padding-bottom: 32px; border-bottom: 1px solid rgba(255,255,255,0.12); }
@media (min-width: 800px) { .footer-top { grid-template-columns: 1fr auto; align-items: center; } }
.footer-brand { font-family: var(--display); font-size: 1.6rem; color: #F8F3EF; line-height: 1.1; }
.footer-brand span { display: block; }
.footer-brand span:last-child { font-family: var(--text); font-size: 0.92rem; color: #CFC7BF; margin-top: 6px; }
.footer-social { display: flex; flex-wrap: wrap; gap: 12px; }
.footer-social a {
  display: inline-flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px 8px 8px;
  border: 1px solid rgba(255,255,255,0.16); border-radius: 999px; text-decoration: none; font-weight: 500;
}
.footer-social a:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.32); color: #FFFFFF; }
.footer-social .logo { width: 36px; height: 36px; border-radius: 50%; flex: none; display: block; }
.footer-social .logo-x { background: #F8F3EF; color: var(--ink); display: grid; place-items: center; }
.footer-social .logo-x svg { width: 16px; height: 16px; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; padding-top: 24px; }

/* Pied de page simple (mentions légales, confirmation) */
.footer-simple { padding: 28px 0; }
.footer-simple .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; }


/* =====================================================================
   4. PAGE D'ACCUEIL — body.page-home
   ===================================================================== */
.page-home section { padding: clamp(64px, 12vw, 112px) 0; }
.page-home .section-head h2 { font-size: clamp(1.9rem, 7vw, 2.9rem); line-height: 1.12; margin: 14px 0 0; }

/* Hero */
.page-home .hero { padding: clamp(32px, 7vw, 72px) 0 clamp(56px, 10vw, 104px); }
.hero-grid { display: grid; gap: 48px; align-items: center; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.15fr 0.85fr; gap: 64px; } }
@media (prefers-reduced-motion: no-preference) {
  .hero-text, .hero-visual { animation: rise 0.8s cubic-bezier(.2,.7,.2,1) both; }
  .hero-visual { animation-delay: 0.12s; }
}
.hero h1 { font-size: clamp(2.5rem, 10.5vw, 4.6rem); line-height: 1.08; margin: 22px 0 20px; }
.subtitle { font-family: var(--text); font-size: clamp(1.15rem, 3.8vw, 1.35rem); line-height: 1.5; color: var(--muted); max-width: 26ch; margin: 0; }
.author { margin: 22px 0 0; font-size: 0.95rem; font-weight: 500; color: var(--ink); }
.author::before { content: "par "; font-weight: 400; color: var(--muted); }
.hook { font-size: clamp(1.1rem, 3.6vw, 1.2rem); line-height: 1.6; max-width: 34ch; margin: 28px 0 32px; padding-left: 16px; border-left: 2px solid var(--accent); }
.hero-visual {
  position: relative; border-radius: 24px;
  background: radial-gradient(120% 90% at 70% 20%, #FFFFFF 0%, var(--tint) 70%);
  padding: clamp(40px, 9vw, 64px) 24px clamp(48px, 10vw, 72px);
  display: flex; justify-content: center;
}

/* Promesse */
.promise { border-top: 1px solid var(--rule); }
.promise-grid { display: grid; gap: 28px; }
@media (min-width: 900px) { .promise-grid { grid-template-columns: 0.9fr 1.1fr; gap: 64px; } }
.prose { max-width: var(--measure); }
.prose p { margin: 0 0 1.2em; }
.prose p:first-child { font-size: 1.2rem; line-height: 1.6; }
.prose p:last-child { margin-bottom: 0; }

/* Sommaire */
.contents { background: var(--surface); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.contents .section-head { margin-bottom: 40px; }
.toc { list-style: none; margin: 0; padding: 0; counter-reset: chap; display: grid; gap: 0 48px; }
@media (min-width: 800px) { .toc { grid-template-columns: 1fr 1fr; } }
.toc li { counter-increment: chap; display: grid; grid-template-columns: 3rem 1fr; gap: 0 14px; padding: 22px 0; border-top: 1px solid var(--rule); }
.toc li::before {
  content: counter(chap, decimal-leading-zero);
  font-family: var(--display); font-size: 1.7rem; line-height: 1; color: var(--accent); font-variant-numeric: lining-nums;
}
.toc .who { font-family: var(--display); font-size: 1.4rem; line-height: 1.15; }
.toc .when { display: inline-block; margin: 8px 0; padding: 2px 10px; border-radius: 999px; background: var(--tint); color: var(--accent); font-size: 0.78rem; font-weight: 500; }
.toc .what { margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.epilogue {
  margin: 36px 0 0; padding: 22px 24px; border-radius: var(--radius);
  background: var(--tint); font-family: var(--display); font-size: 1.25rem; line-height: 1.35; text-align: center;
}

/* Inscription : bande bordeaux pleine largeur */
.signup-band { background: var(--accent); color: var(--on-accent); }
.signup-grid { display: grid; gap: 32px; align-items: center; }
@media (min-width: 900px) { .signup-grid { grid-template-columns: 0.9fr 1.1fr; gap: 64px; } }
.signup-band .kicker { color: #F1D9D4; }
.signup-band h2 { font-size: clamp(1.9rem, 7vw, 2.8rem); line-height: 1.12; margin: 14px 0 16px; color: var(--on-accent); }
.signup-band .lead { margin: 0; color: rgba(248,243,239,0.88); max-width: 40ch; }
.signup-card { background: var(--surface); color: var(--ink); border-radius: 20px; padding: clamp(20px, 5vw, 32px); box-shadow: 0 24px 60px -30px rgba(0,0,0,0.5); }
.kit-embed { min-height: 120px; }
.consent { font-size: 0.88rem; line-height: 1.55; color: var(--muted); margin: 18px 0 0; }

/* Actualité */
.news .section-head { text-align: center; margin-bottom: 32px; }
.news .kicker { justify-content: center; }
.excerpt-embed { max-width: 550px; margin: 0 auto; }
.excerpt-embed .twitter-tweet { margin-left: auto !important; margin-right: auto !important; }
.excerpt-embed iframe { display: block; max-width: 100%; margin-left: auto !important; margin-right: auto !important; }
.excerpt-embed + .excerpt-embed { margin-top: 28px; }
/* Rendus de secours des posts (avant chargement des scripts X et Substack) */
.excerpt-embed blockquote.twitter-tweet,
.embed-substack .substack-post-embed {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 22px 24px; margin: 0; font-size: 1.05rem;
}
.excerpt-embed blockquote.twitter-tweet p,
.embed-substack .substack-post-embed p { margin: 0 0 12px; white-space: pre-line; }
.embed-substack .substack-post-embed p:nth-of-type(2) { color: var(--muted); font-size: 0.95rem; }

/* Cartes « Lire Morale de l'Histoire » / « Suivre l'écriture sur X » */
.follow-head { text-align: center; margin: 56px 0 0; }
.follow { display: grid; gap: 16px; max-width: 860px; margin: 20px auto 0; }
@media (min-width: 720px) { .follow { grid-template-columns: 1fr 1fr; } }
.follow-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 18px;
  padding: 24px; text-decoration: none; color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.follow-card:hover { border-color: var(--accent); color: var(--ink); box-shadow: 0 14px 34px -22px rgba(119,29,28,0.5); }
.follow-card .head { display: flex; align-items: center; gap: 14px; }
.follow-card .logo { width: 44px; height: 44px; border-radius: 50%; flex: none; display: block; }
.follow-card .logo-x { background: var(--ink); color: #F8F3EF; display: grid; place-items: center; }
.follow-card .logo-x svg { width: 18px; height: 18px; }
.follow-card h3 { font-size: 1.25rem; line-height: 1.2; }
.follow-card p { margin: 0; color: var(--muted); font-size: 0.98rem; }
.follow-card .more { margin-top: auto; padding-top: 6px; color: var(--accent); font-weight: 600; font-size: 0.95rem; }
.follow-card:hover .more { text-decoration: underline; text-underline-offset: 3px; }


/* Partage de la page */
.share-block { text-align: center; margin: 64px auto 0; max-width: 620px; }
.share-block .kicker { justify-content: center; }
.share-intro { margin: 10px 0 18px; color: var(--muted); }
.share-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.share-btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 18px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: 999px;
  font-family: var(--text); font-size: 0.95rem; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }
.share-btn svg { width: 18px; height: 18px; flex: none; }
.share-status { min-height: 1.4em; margin: 12px 0 0; font-size: 0.9rem; color: var(--accent); }
@media (max-width: 400px) { .share-btn { padding: 10px 14px; } }


/* =====================================================================
   5. MENTIONS LÉGALES — body.page-legal
   ===================================================================== */
.page-legal { font-size: 1rem; }
.page-legal main { padding: clamp(32px, 7vw, 64px) 0 clamp(56px, 10vw, 96px); }
.page-legal .narrow { max-width: 760px; }
.page-legal h1 { font-size: clamp(2rem, 8vw, 3rem); line-height: 1.12; margin: 14px 0 12px; }
.page-legal .lead { color: var(--muted); margin: 0 0 40px; }
.page-legal .card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 18px;
  padding: clamp(20px, 5vw, 32px); margin: 0 0 20px;
}
.page-legal .card h2 { font-size: 1.5rem; margin: 0 0 14px; }
.page-legal .card p { margin: 0 0 0.8em; }
.page-legal .card p:last-child { margin-bottom: 0; }
.page-legal .card ul { margin: 0; padding-left: 1.2em; }
.page-legal .card li + li { margin-top: 4px; }
.page-legal dl { margin: 0; display: grid; gap: 14px; }
@media (min-width: 640px) { .page-legal dl { grid-template-columns: 200px 1fr; gap: 14px 24px; } }
.page-legal dt { font-weight: 600; font-size: 0.92rem; color: var(--muted); }
.page-legal dd { margin: 0; }


/* =====================================================================
   6. PAGE DE CONFIRMATION — body.page-merci
   ===================================================================== */
.page-merci { min-height: 100vh; display: flex; flex-direction: column; }
.page-merci main { flex: 1; padding: clamp(24px, 6vw, 56px) 0 clamp(56px, 10vw, 96px); }
.page-merci h1 { font-size: clamp(2.2rem, 9vw, 3.6rem); line-height: 1.1; margin: 14px 0 18px; }

.panel {
  display: grid; gap: 40px; align-items: center;
  background: radial-gradient(120% 90% at 80% 10%, #FFFFFF 0%, var(--tint) 75%);
  border-radius: 24px; padding: clamp(32px, 7vw, 64px) clamp(22px, 6vw, 64px);
}
@media (min-width: 860px) { .panel { grid-template-columns: 1.3fr 0.7fr; gap: 56px; } }
@media (prefers-reduced-motion: no-preference) { .panel { animation: rise 0.7s cubic-bezier(.2,.7,.2,1) both; } }

.check {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; margin: 0 0 22px;
  box-shadow: 0 10px 24px -10px rgba(119,29,28,0.6);
}
.check svg { width: 26px; height: 26px; }
.page-merci .lead { font-size: clamp(1.1rem, 3.6vw, 1.25rem); line-height: 1.6; margin: 0 0 14px; max-width: 38ch; }
.page-merci .note { color: var(--muted); margin: 0 0 30px; max-width: 44ch; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.page-merci .button { padding: 14px 24px; }

.page-merci .book-scene { --w: clamp(140px, 40vw, 200px); margin: 0 auto; }

.next { margin-top: clamp(40px, 8vw, 64px); }
.next h2 { font-size: clamp(1.6rem, 6vw, 2.1rem); margin: 12px 0 24px; }
.cards { display: grid; gap: 16px; }
@media (min-width: 760px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.page-merci .card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 18px;
  padding: 24px; display: flex; flex-direction: column; gap: 10px;
}
.page-merci .card .num { font-family: var(--display); font-size: 1.5rem; line-height: 1; color: var(--accent); font-variant-numeric: lining-nums; }
.page-merci .card h3 { font-size: 1.25rem; line-height: 1.2; }
.page-merci .card p { margin: 0; color: var(--muted); font-size: 0.98rem; }
.page-merci .card a.more { margin-top: auto; padding-top: 6px; font-weight: 600; font-size: 0.95rem; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.page-merci .card .logo { width: 28px; height: 28px; border-radius: 50%; flex: none; }
