/* =========================================================
   public/css/10_global.css
   MMX — GLOBAL — "Maison éditoriale" (cohérent nav/footer)
   - Light : parchemin uniforme + grain doux (anti-banding)
   - Dark  : cosmos + starfield universel
   - Typo  : Cormorant Garamond (titres) + Inter (corps)
   ========================================================= */


/* =========================================================
   STICKY FOOTER (conservé, ne pas modifier)
   ========================================================= */

body.app-body{
  min-height: 100vh;
  display: flex;
  flex-direction: column;

  background: var(--app-bg);
  color: var(--text-main);

  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main.app-main{ flex: 1 0 auto; }
footer.app-footer{ flex-shrink: 0; }

html{ background: var(--app-bg); }


/* =========================================================
   MAIN CONTAINER
   ========================================================= */
.app-main.container{
  max-width: 1100px;
  padding-bottom: 4rem;
}

@media (max-width: 767.98px){
  .app-main.container{ padding-top: 1.5rem; }
}


/* =========================================================
   TYPOGRAPHIE — alignée sur nav/footer (Cormorant + Inter)
   ========================================================= */

/* Titres principaux — Cormorant Garamond italique éditorial */
.app-main h1,
.app-main h2{
  font-family: 'Cormorant Garamond', Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.15;
  color: var(--heading, var(--text-main));
}

.app-main h1{
  font-size: clamp(2.1rem, 4vw, 3.2rem);
  font-style: italic;
  margin-bottom: 1.4rem;
}

.app-main h2{
  font-size: clamp(1.6rem, 2.8vw, 2.2rem);
  margin-top: 2.4rem;
  margin-bottom: 1rem;
}

/* H3 hybride : serif romain (pas italique), tonalité section */
.app-main h3{
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.3rem, 2.2vw, 1.65rem);
  letter-spacing: 0;
  line-height: 1.3;
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
  color: var(--heading, var(--text-main));
}

/* H4-H6 : sans-serif (rôle "label de section") */
.app-main h4,
.app-main h5,
.app-main h6{
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--heading, var(--text-main));
}

.app-main h4{ font-size: 1.15rem; }
.app-main h5{ font-size: 1rem; letter-spacing: .04em; }
.app-main h6{
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 500;
}

/* Paragraphes */
p{
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 1rem;
}

.app-main p{
  font-size: 1rem;
}

/* Lead paragraph (premier paragraphe sous H1) — italique discret */
.app-main h1 + p,
.app-main p.lead{
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.18rem;
  font-style: italic;
  line-height: 1.55;
  font-weight: 400;
  color: var(--text-main);
  opacity: .92;
}

/* Texte secondaire */
.text-muted,
small{
  color: var(--text-muted) !important;
  font-family: 'Inter', system-ui, sans-serif;
}


/* =========================================================
   LIENS — éditoriaux (soulignement or au hover)
   ========================================================= */
.app-main a:not(.btn){
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: color .2s ease, border-color .25s ease;
}

.app-main a:not(.btn):hover{
  color: var(--link-hover);
  text-decoration: none;
  border-bottom-color: var(--mmx-gold, #B8924D);
}


/* =========================================================
   UTILITAIRES GLOBAUX
   ========================================================= */
.page-title{
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: clamp(2.1rem, 4vw, 3.2rem);
  font-weight: 500;
  margin-bottom: 1.5rem;
  line-height: 1.1;
}


/* =========================================================
   LIGHT — Fond parchemin UNIFORME + grain ultrafin
   (anti-banding : zéro radial-gradient sur app-bg)
   ========================================================= */
html[data-theme="light"] body.app-body{
  background: var(--app-bg);   /* couleur unie #f3ebd6 (cf. tokens) */
  color: var(--text-main);
}

/* Grain doux — ZÉRO mix-blend-mode (cause de banding amplifié) */
html[data-theme="light"] body.app-body::before{
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 220px 220px;
}

/* Le contenu doit rester au-dessus du grain */
html[data-theme="light"] body.app-body > *{
  position: relative;
  z-index: 1;
}

html[data-theme="light"] .app-main a:not(.btn){
  color: var(--link);
  border-bottom: 1px solid transparent;
}

html[data-theme="light"] .app-main a:not(.btn):hover{
  color: var(--accent-strong);
  border-bottom-color: var(--mmx-gold, #B8924D);
}
/* Texte secondaire light */
html[data-theme="light"] .text-muted,
html[data-theme="light"] small,
html[data-theme="light"] .form-text{
  color: var(--text-soft) !important;
}

/* Cards et panneaux light — bordure or ultrafine */
html[data-theme="light"] .card{
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-strong);
  border-radius: var(--radius-lg);
}

html[data-theme="light"] .card:hover{
  border-color: rgba(184, 146, 77, 0.30);
  transition: border-color .25s ease;
}

/* Panneau structurant — papier ivoire avec filet or top */
html[data-theme="light"] .mmx-panel{
  background: var(--surface);
  box-shadow: 0 6px 22px rgba(17,24,39,0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  position: relative;
}

html[data-theme="light"] .mmx-panel::before{
  content: "";
  position: absolute;
  top: 0;
  left: 2rem;
  right: 2rem;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--mmx-gold, #B8924D) 50%,
    transparent 100%
  );
  opacity: .4;
}

/* Neutralise toute alternance section parasite */
html[data-theme="light"] section:nth-of-type(even),
html[data-theme="light"] section:nth-of-type(odd){
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
}


/* =========================================================
   DARK — Cosmos profond + starfield universel
   ========================================================= */
html[data-theme="dark"] body.app-body,
html:not([data-theme="light"]) body.app-body{
  background:
    radial-gradient(circle at 50% 50%,
      #080d1f 0%,
      #040714 40%,
      #020408 100%);
  color: var(--text-main);
}

html[data-theme="dark"] html,
html[data-theme="dark"]{
  background:
    radial-gradient(circle at 50% 50%,
      #080d1f 0%,
      #040714 40%,
      #020408 100%);
}


/* =========================================================
   STARFIELD — couche DOM injectée par PHP (conservé intact)
   ========================================================= */
body.app-body:has(#mmxStarfield){
  background: transparent !important;
  position: relative;
  overflow-x: hidden;
  isolation: isolate;
}

body.app-body:has(#mmxStarfield) > *:not(#mmxStarfield){
  position: relative;
  z-index: 3;
}

#mmxStarfield{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  transform: translateZ(0);
  --mmxDriftX: 0px;
  --mmxDriftY: 0px;
}

#mmxStarfield .mmx-stars,
#mmxStarfield .mmx-objects{
  position: absolute;
  inset: 0;
}
#mmxStarfield .mmx-stars{ z-index: 1; }
#mmxStarfield .mmx-objects{ z-index: 2; }

#mmxStarfield .mmx-stars{
  inset: -40px;
  will-change: transform;
  transform: translate3d(0,0,0);
  animation: mmxStarsDrift 240s linear infinite;
}

@keyframes mmxStarsDrift{
  from{ transform: translate3d(0,0,0); }
  to  { transform: translate3d(var(--mmxDriftX), var(--mmxDriftY), 0); }
}

#mmxStarfield .mmx-star{
  position: absolute;
  width: var(--sz, 1.2px);
  height: var(--sz, 1.2px);
  border-radius: 999px;
  background: rgba(255,255,255, var(--op, .5));
  transform: translateZ(0);
}

#mmxStarfield .mmx-star.tw{
  animation: mmxTwinkle var(--twDur, 6s) ease-in-out infinite;
}

@keyframes mmxTwinkle{
  0%, 100% { opacity: var(--op, .5); transform: scale(1); }
  50%      { opacity: calc(var(--op, .5) * 0.55); transform: scale(1.12); }
}


/* =========================================================
   STARFIELD — Light : OFF
   ========================================================= */
html[data-theme="light"] body.app-body:has(#mmxStarfield){
  background: var(--app-bg) !important;
}

html[data-theme="light"] #mmxStarfield{
  display: none !important;
}


/* =========================================================
   STARFIELD — Dark : fond + dither + blooms (conservé)
   ========================================================= */
html[data-theme="dark"] body.app-body:has(#mmxStarfield),
html:not([data-theme="light"]) body.app-body:has(#mmxStarfield){
  background:
    radial-gradient(circle at 50% 50%, #080d1f 0%, #040714 40%, #020408 100%) !important;
}

html[data-theme="dark"] #mmxStarfield,
html:not([data-theme="light"]) #mmxStarfield{
  background:
    radial-gradient(circle at 50% 50%, #080d1f 0%, #040714 40%, #020408 100%) !important;
}

/* Dither anti-banding sur le starfield dark */
html[data-theme="dark"] #mmxStarfield::before,
html:not([data-theme="light"]) #mmxStarfield::before{
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 140px 140px;
  opacity: 0.08;
  mix-blend-mode: overlay;
  transform: translateZ(0);
}

/* Blooms lumineux + vignette (3 zones) */
html[data-theme="dark"] #mmxStarfield::after,
html:not([data-theme="light"]) #mmxStarfield::after{
  content: "";
  position: absolute;
  inset: -10%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1200px 800px at 50% 45%,
      rgba(0,0,0,0.00) 0%,
      rgba(0,0,0,0.20) 58%,
      rgba(0,0,0,0.42) 100%),
    radial-gradient(900px 620px at 16% 42%,
      rgba(110,190,255,0.16) 0%,
      rgba(110,190,255,0.10) 22%,
      rgba(110,190,255,0.00) 62%),
    radial-gradient(1050px 720px at 72% 18%,
      rgba(140,205,255,0.14) 0%,
      rgba(140,205,255,0.08) 24%,
      rgba(140,205,255,0.00) 66%),
    radial-gradient(980px 720px at 78% 74%,
      rgba(120,185,255,0.13) 0%,
      rgba(120,185,255,0.07) 26%,
      rgba(120,185,255,0.00) 68%);
  mix-blend-mode: screen;
  opacity: 1;
  filter: blur(0.45px) saturate(1.12) contrast(1.04);
  transform: translateZ(0);
}

/* Layers étoiles/objets restent au-dessus des pseudos */
html[data-theme="dark"] #mmxStarfield .mmx-stars,
html:not([data-theme="light"]) #mmxStarfield .mmx-stars{
  position: absolute !important;
  inset: -40px !important;
  z-index: 1 !important;
}

html[data-theme="dark"] #mmxStarfield .mmx-objects,
html:not([data-theme="light"]) #mmxStarfield .mmx-objects{
  position: absolute !important;
  inset: 0 !important;
  z-index: 2 !important;
}


/* =========================================================
   SATELLITE PREMIUM (conservé intact)
   ========================================================= */
#mmxStarfield .mmx-satellite{
  width: var(--ssz, 18px);
  height: calc(var(--ssz, 18px) * 0.60);
  border-radius: 999px;
  opacity: 0;
  z-index: 4;
  mix-blend-mode: screen;

  background:
    radial-gradient(10px 8px at 35% 35%, rgba(255,255,255,0.55), transparent 70%),
    linear-gradient(180deg, rgba(255,255,255,0.78), rgba(255,255,255,0.18)),
    linear-gradient(90deg, rgba(255,255,255,0.25), rgba(255,255,255,0.06)),
    linear-gradient(90deg, transparent 46%, rgba(255,255,255,0.18) 47%, rgba(255,255,255,0.18) 53%, transparent 54%);

  box-shadow:
    0 0 10px rgba(255,255,255,0.10),
    0 0 22px rgba(120,190,255,0.10);

  border: 1px solid rgba(255,255,255,0.14);
  position: absolute;
  transform: translate3d(0,0,0) rotate(var(--srot, 18deg));
  animation: mmxSatelliteFly var(--sdur, 5200ms) ease-in-out forwards;
  will-change: transform, opacity;
}

#mmxStarfield .mmx-satellite::before,
#mmxStarfield .mmx-satellite::after{
  content: "";
  position: absolute;
  top: 50%;
  width: 62%;
  height: 78%;
  transform: translateY(-50%);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(25,40,70,0.95), rgba(10,18,40,0.95)),
    repeating-linear-gradient(90deg,
      rgba(110,190,255,0.20) 0 2px,
      rgba(0,0,0,0.00) 2px 6px);
  border: 1px solid rgba(120,190,255,0.22);
  box-shadow:
    0 0 10px rgba(120,190,255,0.10),
    inset 0 0 0 1px rgba(255,255,255,0.06);
  opacity: .95;
}

#mmxStarfield .mmx-satellite::before{ left: -78%; }
#mmxStarfield .mmx-satellite::after{ right: -78%; }


/* =========================================================
   SHOOTING STARS (conservées)
   ========================================================= */
#mmxStarfield .mmx-shooting-star{
  position: absolute;
  width: var(--tail, 180px);
  height: 2px;
  background: linear-gradient(90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,.35) 40%,
    rgba(255,255,255,1) 100%);
  border-radius: 2px;
  filter: blur(.3px) drop-shadow(0 0 6px rgba(170,210,255,.65));
  transform: rotate(var(--rot, 28deg));
  animation: mmxShoot var(--dur, 1100ms) cubic-bezier(.2,.65,.2,1) forwards;
  z-index: 3;
}

@keyframes mmxShoot{
  0%   { opacity: 0; transform: rotate(var(--rot, 28deg)) translate3d(0,0,0); }
  10%  { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--rot, 28deg)) translate3d(var(--tx, 1100px), var(--ty, 700px), 0); }
}


/* =========================================================
   ALERT FLASH — global (conservé, ajusté)
   ========================================================= */
.alert{
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  font-family: 'Inter', system-ui, sans-serif;
}

html[data-theme="light"] .alert-success{
  background: rgba(21, 128, 61, 0.08);
  color: #14532d;
  border-color: rgba(21, 128, 61, 0.25);
}

html[data-theme="light"] .alert-danger{
  background: rgba(185, 28, 28, 0.08);
  color: #7f1d1d;
  border-color: rgba(185, 28, 28, 0.25);
}

html[data-theme="light"] .alert-info{
  background: rgba(30, 58, 138, 0.08);
  color: var(--accent-strong);
  border-color: rgba(30, 58, 138, 0.20);
}


/* =========================================================
   ACCESSIBILITÉ — reduce motion
   ========================================================= */
@media (prefers-reduced-motion: reduce){
  #mmxStarfield .mmx-stars,
  #mmxStarfield .mmx-star.tw,
  #mmxStarfield .mmx-shooting-star,
  #mmxStarfield .mmx-satellite{
    animation: none !important;
  }
}