/* ─── Pages secondaires DX-5 — DA « L'Énigme » ───
   Mêmes tokens que la bibliothèque. Header partagé, composants de contenu. */

:root {
  --bg: #070b14;
  --surface: #0c1322;
  --surface-2: #101a2e;
  --line: rgba(140, 170, 220, 0.14);
  --ink: #e9eef7;
  --ash: #8da0bf;
  --blue: #4cc2ff;
  --gold: #e8c76a;
  --red: #ff4d4d;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  --serif: 'Times New Roman', Times, Georgia, serif; /* clin d'œil à l'écrivain */
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background:
    radial-gradient(900px 480px at 78% -8%, rgba(76, 194, 255, 0.07), transparent 60%),
    radial-gradient(700px 420px at 12% 14%, rgba(232, 199, 106, 0.045), transparent 65%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
}

.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; }
.ash  { color: var(--ash); }
.gold { color: var(--gold); }
.red  { color: var(--red); }

/* ── header partagé ── */
.top {
  position: fixed; top: 10px; left: 10px; right: 10px; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 18px;
  background: rgba(10, 15, 26, 0.78);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 12px;
  flex-wrap: wrap;
}
html[data-theme="light"] .top { background: rgba(255, 255, 255, 0.82); }
.wordmark { font-weight: 700; white-space: nowrap; color: inherit; text-decoration: none; }
.wordmark:hover { color: var(--blue); }
.top-nav { display: flex; gap: 20px; flex-wrap: wrap; }
.nav-link { color: var(--ash); text-decoration: none; white-space: nowrap; transition: color 0.2s; }
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--gold); }
.nav-cta {
  background: #d8231f; color: #fff;   /* ÉCOUTER toujours rouge (y compris bibliothèque) */
  text-decoration: none; white-space: nowrap;
  padding: 8px 14px; border-radius: 8px; font-weight: 700;
  transition: filter 0.2s;
}
.nav-cta:hover { filter: brightness(1.08); }

/* ── layout ── */
main { max-width: 880px; margin: 0 auto; padding: 150px 22px 60px; }
.page-head { margin-bottom: 44px; }
.kicker { color: var(--gold); margin-bottom: 14px; display: block; }
h1 { font-size: clamp(34px, 6vw, 62px); line-height: 1.04; font-weight: 800; letter-spacing: -0.02em; }
h1 em { font-style: normal; color: var(--blue); }
.lead { margin-top: 18px; color: var(--ash); max-width: 58ch; }
h2 { font-size: clamp(22px, 3.4vw, 32px); font-weight: 750; letter-spacing: -0.01em; margin: 56px 0 18px; }
.prose p { margin-bottom: 14px; max-width: 64ch; }
a { color: var(--blue); }

/* ── pastilles d'état (placeholders) ── */
.notice {
  display: inline-block; vertical-align: 2px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em;
  color: var(--gold); border: 1px solid var(--gold);
  border-radius: 12px; padding: 2px 9px; white-space: normal;
}
.notice.red-n { color: var(--red); border-color: var(--red); }
.banner {
  border: 1px solid var(--gold); border-radius: 10px;
  background: rgba(232, 199, 106, 0.06);
  padding: 12px 16px; margin-bottom: 36px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--gold);
}

/* ── dossier / timeline ── */
.pieces { list-style: none; border-top: 1px solid var(--line); }
.piece {
  display: grid; grid-template-columns: 120px 1fr; gap: 18px;
  padding: 20px 4px; border-bottom: 1px solid var(--line);
}
.piece .when { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; color: var(--gold); padding-top: 4px; }
.piece h3 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.piece p { color: var(--ash); font-size: 14.5px; max-width: 58ch; }

/* ── pays / signaux ── */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 99px;
  background: var(--surface); padding: 7px 14px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; color: var(--ash);
}
.chip i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--blue);
  animation: pulse 2.6s infinite;
}
.chip.lead-chip { border-color: var(--gold); color: var(--gold); }
.chip.lead-chip i { background: var(--gold); }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ── cartes ── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  border: 1px solid var(--line); border-radius: 12px;
  background: linear-gradient(165deg, var(--surface), var(--surface-2));
  padding: 20px;
}
.card h3 { font-size: 17px; margin-bottom: 6px; }
.card .mono { display: block; margin-bottom: 10px; }
.card p { color: var(--ash); font-size: 14px; }
.card.big { grid-column: 1 / -1; }

/* ── fragment manuscrit (écrits) ── */
.fragment {
  border-left: 2px solid var(--gold);
  padding: 6px 0 6px 22px; margin: 26px 0;
  font-family: var(--serif); font-style: italic;
  font-size: 19px; line-height: 1.75; color: var(--ink);
  max-width: 56ch;
}
.fragment footer { font-family: var(--mono); font-style: normal; font-size: 10px; letter-spacing: 0.14em; color: var(--ash); margin-top: 10px; }

/* ── formulaires ── */
form { display: grid; gap: 14px; max-width: 560px; }
.frow { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
label { display: grid; gap: 6px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--ash); }
input, textarea, select {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 13px; font: 15px/1.4 inherit; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn {
  display: inline-block; cursor: pointer; border: 0;
  background: var(--gold); color: #1a1915;
  font: 700 13px/1 var(--mono); letter-spacing: 0.1em;
  padding: 14px 22px; border-radius: 9px; text-decoration: none;
  transition: filter 0.2s;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--blue); color: var(--blue); filter: none; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.form-note { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--ash); max-width: 56ch; }
.ok-msg { color: var(--gold); font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; }

/* ── footer partagé ── */
.foot {
  border-top: 1px solid var(--line);
  margin-top: 80px; padding: 36px 0 10px;
  display: grid; gap: 14px;
}
.foot-links { display: flex; flex-wrap: wrap; gap: 16px 22px; }
.foot-links a { color: var(--ash); text-decoration: none; }
.foot-links a:hover { color: var(--ink); }

/* ── divers ── */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.hidden { display: none !important; }

@media (max-width: 680px) {
  main { padding-top: 170px; }
  .piece { grid-template-columns: 1fr; gap: 4px; }
  .frow { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .chip i { animation: none; opacity: 0.8; }
}

/* ── sous-menu PLUS ▾ ── */
.nav-sub { position: relative; display: inline-flex; }
.nav-more { background: none; border: 0; cursor: pointer; font: inherit; }
.nav-menu {
  position: absolute; top: calc(100% + 14px); right: -6px;
  min-width: 185px; display: flex; flex-direction: column; gap: 2px; padding: 10px;
  background: rgba(12, 17, 28, 0.96);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 12px; z-index: 90;
}
html[data-theme="light"] .nav-menu { background: rgba(255, 255, 255, 0.98); }
.nav-menu a { padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--ash); white-space: nowrap; }
.nav-menu a:hover { background: rgba(76, 194, 255, 0.1); color: var(--gold); }
.nav-menu[hidden] { display: none; } /* l' attribut hidden doit gagner sur display:flex */

/* ── immersion : scène de fond, entrée de page, révélations ── */
#signal-bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

@media (prefers-reduced-motion: no-preference) {
  main { animation: pagein 0.55s cubic-bezier(0.19, 1, 0.22, 1) both; }
  @keyframes pagein { from { opacity: 0; transform: translateY(14px); } }
}

html.js .rv {
  opacity: 0; transform: translateY(30px) scale(0.985);
  transition: opacity 0.8s cubic-bezier(0.19, 1, 0.22, 1), transform 0.8s cubic-bezier(0.19, 1, 0.22, 1);
}
html.js .rv.in { opacity: 1; transform: none; }


/* ── header compact : une seule rangée partout ── */
.nav-menu .m-only { display: none; }
@media (max-width: 920px) {
  /* tablette : la rangée unique doit tenir à 768 px */
  .top { gap: 12px; }
  .top-nav { gap: 14px; }
}
@media (max-width: 800px) {
  /* téléphone et petite tablette : la navigation se verse dans PLUS ▾ —
     seuls les liens directs se masquent ; .nav-sub (qui porte le bouton
     PLUS ▾ lui-même) doit rester visible, sinon plus aucun moyen de
     l'ouvrir (bug constaté sur toutes les pages intérieures, pas
     seulement l'espace fans). */
  .top-nav > a.nav-link { display: none; }
  .nav-menu .m-only { display: block; }
}

@media (max-width: 380px) {
  /* wordmark + PLUS + CTA doivent tenir sur UNE rangée à 320 px */
  .top { padding: 10px 12px; gap: 10px; }
  .wordmark { font-size: 15px; }
  .nav-cta { padding: 7px 10px; }
}


/* ══════════ PALETTE NOIR & ROUGE — pages is-pg (demande client) ══════════
   La bibliothèque (is-bib) conserve sa charte « Énigme » bleu/or. */
html.is-pg {
  --bg: #0a0708;
  --surface: #160f10;
  --surface-2: #1e1415;
  --line: rgba(216, 35, 31, 0.18);
  --ink: #f4efef;
  --ash: #9a8d8e;
  --blue: #e23b36;     /* « matière » / liens → rouge */
  --gold: #d8231f;     /* « signal rare » → rouge (noir & rouge) */
  --red: #ff5a4f;      /* alerte, rouge vif distinct */
}
html.is-pg body {
  background:
    radial-gradient(900px 480px at 78% -8%, rgba(216, 35, 31, 0.10), transparent 60%),
    radial-gradient(700px 420px at 12% 14%, rgba(216, 35, 31, 0.05), transparent 65%),
    var(--bg);
}

/* ── Mode clair (bascule) : mêmes accents noir & rouge, surface claire ── */
html.is-pg[data-theme="light"] {
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #ece9e3;
  --line: rgba(26, 25, 21, 0.14);
  --ink: #1a1915;
  --ash: #6b6f76;
  --blue: #c81e1a;
  --gold: #a9780a;
  --red: #b9261f;
}
html.is-pg[data-theme="light"] body {
  background:
    radial-gradient(900px 480px at 78% -8%, rgba(216, 35, 31, 0.05), transparent 60%),
    radial-gradient(700px 420px at 12% 14%, rgba(232, 199, 106, 0.10), transparent 65%),
    var(--bg);
}

/* logo officiel dans l'entête partagé */
.wordmark { display: inline-flex; align-items: center; }
.wordmark .brand-logo { height: 34px; width: auto; display: block; border-radius: 0; }
@media (max-width: 760px) { .wordmark .brand-logo { height: 30px; } }

/* ── logo mieux détaché : halo sombre + léger fondu dans le coin de l'entête ── */
.wordmark .brand-logo { filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.85)); }
.top { position: fixed; }
.top::before {
  content: ""; position: absolute; left: 0; top: 0; width: 220px; height: 100%;
  background: radial-gradient(130px 90px at 36px 50%, rgba(0, 0, 0, 0.55), transparent 72%);
  border-radius: 12px 0 0 12px; pointer-events: none; z-index: -1;
}
/* clair : halo sombre devenu inutile (le logo porte déjà son propre contour) */
html[data-theme="light"] .top::before { display: none; }
