/* ============================================================
   EMILIE — LEGAL LUXE — couche v=002 (12/10 quest)
   Drop caps · Romains · Coda · Sommaire · Grain · Pull-quote
   ============================================================ */

/* ---------- Tokens micro-typo ---------- */
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
html, body {
  font-feature-settings: 'liga' 1, 'dlig' 1, 'kern' 1, 'calt' 1, 'onum' 1, 'pnum' 1;
}
:root {
  --grain-noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.23  0 0 0 0 0.18  0 0 0 0 0.15  0 0 0 0.45 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------- Grain papier sur tout le body ---------- */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.042;
  mix-blend-mode: multiply;
  background-image: var(--grain-noise);
}
@media (max-width: 720px) { body::before { display: none; } }

/* ---------- Scroll progress bar dorée ---------- */
.scroll-progress {
  position: fixed; top: 0; left: 0; height: 2px;
  width: var(--scroll-pct, 0%);
  background: linear-gradient(90deg, var(--lumiere-doree), var(--terre-sacree));
  z-index: 9999;
  opacity: 0.55;
  transition: width 60ms linear, opacity 200ms;
  pointer-events: none;
}

/* ---------- Bandeau édition (haut conteneur) ---------- */
.edition-mark {
  position: absolute;
  top: 14px; right: 18px;
  font-family: 'Manrope', sans-serif;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gris-discret);
  opacity: 0.75;
}
.edition-mark::before { content: "❋"; color: var(--lumiere-doree); margin-right: 6px; }
@media (max-width: 720px) { .edition-mark { position: static; margin-bottom: 10px; opacity: 0.6; } }

/* ---------- Drop cap Cormorant ---------- */
.has-dropcap p:first-of-type::first-letter,
p.dropcap::first-letter {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-style: italic;
  float: left;
  font-size: 4.2em;
  line-height: 0.88;
  margin: 0.08em 0.12em 0 -0.04em;
  color: var(--terre-sacree-dark);
  background: linear-gradient(135deg, var(--terre-sacree) 0%, var(--lumiere-doree) 70%, var(--terre-sacree-dark) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 1px 0 rgba(58, 46, 38, 0.04);
}

/* ---------- Numérotation romaine + filet doré ---------- */
h2 .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  height: 1.6em;
  padding: 0 0.55em;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(212, 175, 106, 0.16), rgba(193, 122, 90, 0.10));
  border: 1px solid var(--bordure-gold);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 500;
  font-size: 0.78em;
  color: var(--terre-sacree-dark);
  letter-spacing: 0.03em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ---------- Pull-quote ---------- */
.pull-quote {
  position: relative;
  margin: 48px auto;
  max-width: 680px;
  padding: 28px 32px 24px;
  text-align: center;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 1.55rem;
  line-height: 1.42;
  color: var(--terre-sacree-dark);
  letter-spacing: 0.005em;
}
.pull-quote::before, .pull-quote::after {
  content: "❋";
  display: block;
  color: var(--lumiere-doree);
  font-size: 0.8rem;
  letter-spacing: 0;
  opacity: 0.85;
}
.pull-quote::before { margin-bottom: 14px; }
.pull-quote::after { margin-top: 14px; }
.pull-quote em { color: var(--foret-profonde-dark); font-style: normal; font-weight: 500; }

/* ---------- Sommaire flottant sticky desktop ---------- */
.toc-floating {
  display: none;
}
@media (min-width: 1280px) {
  .toc-floating {
    display: block;
    position: fixed;
    top: 110px;
    left: calc(50% - 700px);
    width: 200px;
    font-family: 'Manrope', sans-serif;
    font-size: 12px;
    line-height: 1.5;
    color: var(--texte-doux);
    padding: 18px 16px 18px 18px;
    border-left: 1px solid var(--bordure-gold);
    z-index: 50;
    pointer-events: auto;
  }
  .toc-floating .toc-title {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 14px;
    color: var(--foret-profonde-dark);
    margin-bottom: 10px;
    letter-spacing: 0.04em;
  }
  .toc-floating ol { list-style: none; margin: 0; padding: 0; counter-reset: tocn; }
  .toc-floating li {
    counter-increment: tocn;
    margin-bottom: 4px;
    padding-left: 18px;
    position: relative;
  }
  .toc-floating li::before {
    content: counter(tocn);
    position: absolute;
    left: 0; top: 0;
    color: var(--lumiere-doree);
    font-size: 10px;
    letter-spacing: 0.04em;
  }
  .toc-floating a {
    color: var(--texte-doux);
    text-decoration: none;
    font-size: 11.5px;
    line-height: 1.45;
    transition: color 250ms;
    display: inline-block;
  }
  .toc-floating a:hover { color: var(--terre-sacree); }
  .toc-floating a.is-active { color: var(--terre-sacree-dark); font-weight: 600; }
}

/* ---------- Coda footer ❋ identique accueil ---------- */
.legal-coda {
  margin: 56px auto 0;
  max-width: 580px;
  padding: 40px 24px 8px;
  text-align: center;
  position: relative;
  border-top: 1px solid var(--bordure-gold);
}
.legal-coda::before {
  content: "❋";
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: #FDFBF6;
  padding: 0 14px;
  color: var(--lumiere-doree);
  font-size: 18px;
}
.legal-coda-quote {
  font-family: 'Caveat', cursive, 'Cormorant Garamond', serif;
  font-size: 1.6rem;
  line-height: 1.3;
  color: var(--terre-sacree-dark);
  margin-bottom: 8px;
}
.legal-coda-sign {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--gris-discret);
  letter-spacing: 0.06em;
}

/* ---------- Sceau signature SVG en filigrane ---------- */
.legal-seal {
  margin: 36px auto 0;
  display: block;
  width: 88px;
  height: auto;
  opacity: 0.18;
  filter: sepia(0.4) hue-rotate(-10deg);
  pointer-events: none;
}

/* ---------- Encadrés enrichis (texture nervures subtile) ---------- */
.warn, .info, .notice {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.warn::after, .info::after, .notice::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url('../img/textures/texture-veins.webp');
  background-size: cover;
  background-position: center;
  opacity: 0.035;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: -1;
}

/* ---------- Justification + hyphenation française ---------- */
.container p {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  hyphenate-limit-chars: 6 3 3;
  text-wrap: pretty;
}
.container h1, .container h2, .container h3, .container .subtitle, .pull-quote, .legal-coda-quote {
  text-wrap: balance;
}
.container li { text-wrap: pretty; }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 12px;
  background: var(--foret-profonde-dark);
  color: var(--souffle-ivoire);
  padding: 10px 18px;
  border-radius: 4px;
  text-decoration: none;
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  z-index: 9999;
}
.skip-link:focus { left: 12px; }

/* ---------- Focus rings dorés cohérents ---------- */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--lumiere-doree);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ---------- Apparition au scroll (intersection observer) ---------- */
.fade-in {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s cubic-bezier(.16,1,.3,1), transform 0.7s cubic-bezier(.16,1,.3,1);
  will-change: opacity, transform;
}
.fade-in.is-visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .fade-in { opacity: 1; transform: none; transition: none; }
}

/* ---------- Print stylesheet ---------- */
@media print {
  body::before, .scroll-progress, .toc-floating, .back, .legal-nav { display: none !important; }
  body { background: white; padding: 0; }
  .container {
    box-shadow: none;
    border: none;
    max-width: 100%;
    padding: 0;
    background: white;
  }
  h1, h2, h3 { color: #000; -webkit-text-fill-color: #000; background: none; }
  h2 .num { background: none; border: 1px solid #999; color: #000; }
  a { color: #000; text-decoration: underline; }
  .warn, .info, .notice { border: 1px solid #999; background: white; }
  .warn::after, .info::after, .notice::after { display: none; }
  .legal-coda-quote { color: #555; }
}

/* ---------- Mobile : sommaire en bas, drop cap réduit ---------- */
@media (max-width: 720px) {
  .has-dropcap p:first-of-type::first-letter,
  p.dropcap::first-letter { font-size: 3.4em; }
  .pull-quote { font-size: 1.2rem; padding: 20px 18px; margin: 32px auto; }
  .legal-coda-quote { font-size: 1.3rem; }
}

/* ---------- FIX mobile : pas de justify, juste hyphens ---------- */
.subtitle { text-align: left !important; hyphens: manual !important; }
@media (max-width: 720px) {
  .container p { text-align: left; hyphens: auto; }
  .toc-floating { display: none; }
  .edition-mark { display: block; text-align: center; opacity: 0.55; margin-bottom: 14px; }
  .legal-coda { padding: 32px 12px 8px; max-width: 100%; }
  .legal-coda-quote { font-size: 1.25rem; }
}
