/* ═══════════════════════════════════════════════════════════════
   PoésIA — Design system v2
   Typographie : Cormorant Garamond · Playfair Display · DM Mono
   Palette : bleu-nuit #0E1B2E · or #C9A84C · crème #FAF8F5
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500;1,600&family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300&display=swap');

/* ─── VARIABLES ─────────────────────────────────────────────────────────── */
:root {
  --bg:              #FAF8F5;
  --text:            #1A1510;
  --heading:         #0E1B2E;
  --muted:           #7A7068;
  --border:          #E5E0D8;

  --sidebar-bg:      #0E1B2E;
  --sidebar-text:    rgba(200, 192, 176, 0.75);
  --sidebar-hover:   rgba(200, 192, 176, 0.95);
  --sidebar-active:  #C9A84C;
  --sidebar-border:  rgba(255, 255, 255, 0.07);
  --sidebar-w:       260px;

  --gold:            #C9A84C;
  --gold-light:      rgba(201, 168, 76, 0.10);
  --gold-border:     rgba(201, 168, 76, 0.4);

  --poem-bg:         #F3F0EA;
  --encadre-bg:      #F5F2EC;
  --prompt-bg:       #0E1B2E;
  --prompt-text:     #A8C8C8;
  --shadow-bg:       #FFFFFF;

  --font-body:       'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-display:    'Playfair Display', 'Cormorant Garamond', Georgia, serif;
  --font-mono:       'DM Mono', 'Courier New', Courier, monospace;

  --content-w:       680px;
  --content-pad:     2.5rem;
}

/* ─── RESET ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 19px;
  scroll-behavior: smooth;
}

/* ─── LAYOUT : SIDEBAR + MAIN ───────────────────────────────────────────── */
body {
  display: flex;
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── SIDEBAR ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding: 2rem 0 2rem;
  border-right: 1px solid var(--sidebar-border);
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-border) transparent;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 2px; }

.sidebar__brand {
  padding: 0 1.75rem 2rem;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.sidebar__brand-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.sidebar__title {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 400;
  font-style: italic;
  color: #FFFFFF;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-bottom: 0.4rem;
}

.sidebar__title .ia {
  color: var(--gold);
  font-style: normal;
}

.sidebar__byline {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 300;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sidebar-text);
}

.sidebar__nav {
  flex: 1;
  padding: 0 0.75rem;
}

.sidebar__nav-label {
  font-family: var(--font-mono);
  font-size: 0.54rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sidebar-text);
  opacity: 0.45;
  padding: 0 1rem 0.75rem;
  display: block;
}

.sidebar__chapter-list {
  list-style: none;
}

.sidebar__chapter-list a {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  padding: 0.48rem 1rem;
  text-decoration: none;
  color: var(--sidebar-text);
  transition: color 0.15s, background 0.15s;
  border-radius: 4px;
  line-height: 1.35;
}

.sidebar__chapter-list a:hover {
  color: var(--sidebar-hover);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar__chapter-list a.active {
  color: var(--gold);
  background: rgba(201, 168, 76, 0.08);
}

.sidebar__chapter-list a.active .chap-num { color: var(--gold); }

.chap-num {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 400;
  color: rgba(200, 192, 176, 0.3);
  flex-shrink: 0;
  letter-spacing: 0.03em;
  padding-top: 0.1em;
  min-width: 1.5rem;
  text-align: right;
  transition: color 0.15s;
}

.chap-title {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.35;
}

.sidebar__sep {
  height: 1px;
  background: var(--sidebar-border);
  margin: 0.75rem 1rem;
}

.sidebar__chapter-list .annexe a {
  font-style: italic;
  opacity: 0.65;
}

.sidebar__footer {
  padding: 1.5rem 1.75rem 0;
  border-top: 1px solid var(--sidebar-border);
  margin-top: 1rem;
  flex-shrink: 0;
}

.sidebar__footer a {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: var(--sidebar-text);
  text-decoration: none;
  opacity: 0.45;
  transition: opacity 0.15s;
  display: block;
  margin-bottom: 0.4rem;
}

.sidebar__footer a:hover { opacity: 0.8; }

/* ─── CONTENU PRINCIPAL ──────────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  max-width: calc(var(--content-w) + var(--content-pad) * 2);
  margin: 0 auto;
  width: 100%;
  padding: 0 var(--content-pad);
}

/* ─── EN-TÊTE DE CHAPITRE ────────────────────────────────────────────────── */
.chapter-header {
  padding: 4rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3.5rem;
}

.chapter-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1rem;
  display: block;
}

.chapter-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 400;
  font-style: italic;
  color: var(--heading);
  line-height: 1.2;
  margin-bottom: 1rem;
}

.chapter-header .subtitle {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--muted);
  line-height: 1.6;
}

/* ─── PROSE ─────────────────────────────────────────────────────────────── */
.prose {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text);
  padding-bottom: 4rem;
}

.prose p {
  margin-bottom: 1.5rem;
  hyphens: auto;
}

.prose p:last-child { margin-bottom: 0; }

.prose h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 400;
  font-style: italic;
  color: var(--heading);
  margin-top: 4rem;
  margin-bottom: 1.25rem;
  line-height: 1.3;
}

.prose h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  font-style: normal;
}

.prose a {
  color: var(--heading);
  text-decoration: underline;
  text-decoration-color: var(--gold-border);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}

.prose a:hover { text-decoration-color: var(--gold); }

.prose em { font-style: italic; }

.prose strong {
  font-weight: 600;
  color: var(--heading);
}

.prose hr {
  border: none;
  text-align: center;
  color: var(--muted);
  margin: 3.5rem 0;
  font-family: var(--font-body);
  font-size: 1.1rem;
  letter-spacing: 0.35em;
  opacity: 0.35;
}

.prose hr::after { content: '· · ·'; }

/* ─── POÈMES ────────────────────────────────────────────────────────────── */
.poem {
  background: var(--poem-bg);
  border-left: 2px solid var(--border);
  padding: 1.75rem 2rem;
  margin: 2.5rem 0;
  font-family: var(--font-body);
  font-style: italic;
  line-height: 2;
  font-size: 1rem;
}

.poem p { margin-bottom: 0.4rem; }
.poem p:last-child { margin-bottom: 0; }

.poem pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-style: normal;
  line-height: 1.8;
  color: var(--heading);
}

.poem-source {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  font-style: normal;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: block;
}

/* Poème-ombre */
.shadow-poem {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.75rem 2.25rem;
  margin: 2.5rem 0;
  font-family: var(--font-body);
  font-style: italic;
  line-height: 2;
  background: var(--shadow-bg);
}

.shadow-poem p { margin-bottom: 0.4rem; }
.shadow-poem p:last-child { margin-bottom: 0; }

.shadow-label {
  font-family: var(--font-mono);
  font-size: 0.57rem;
  font-weight: 400;
  font-style: normal;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  display: block;
}

/* ─── BLOC PROMPT ───────────────────────────────────────────────────────── */
.prompt-block {
  background: var(--prompt-bg);
  border-radius: 5px;
  padding: 1.75rem 2rem;
  margin: 2.5rem 0;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.05);
  /* Force les propriétés de base sur le conteneur pour ne pas
     hériter de .prose (Cormorant Garamond / couleur corps) */
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--prompt-text);
  font-weight: 400;
  font-style: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

.prompt-block::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold) 0%, transparent 60%);
}

.prompt-label {
  font-family: var(--font-mono);
  font-size: 0.57rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.8;
  margin-bottom: 1rem;
  display: block;
}

.prompt-block p,
.prompt-block ul,
.prompt-block ol {
  margin-bottom: 0.6rem;
}

.prompt-block p:last-child { margin-bottom: 0; }

.prompt-block pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  line-height: inherit;
}

.prompt-block strong {
  font-weight: 500;
  color: rgba(200, 230, 230, 0.85);
}

.prompt-block ul, .prompt-block ol { padding-left: 1.5rem; }
.prompt-block li { margin-bottom: 0.3rem; }

/* ─── ENCADRÉ NIVEAU 2 ──────────────────────────────────────────────────── */
details.encadre {
  background: var(--encadre-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 0 4px 4px 0;
  margin: 2.5rem 0;
  overflow: hidden;
}

details.encadre summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.5rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s;
}

details.encadre summary:hover {
  background: rgba(201, 168, 76, 0.05);
}

details.encadre summary::-webkit-details-marker { display: none; }
details.encadre summary::marker { display: none; }

details.encadre summary::before {
  content: '▸';
  font-size: 0.6rem;
  color: var(--gold);
  flex-shrink: 0;
  transition: transform 0.2s;
  display: inline-block;
  opacity: 0.7;
}

details.encadre[open] summary::before {
  transform: rotate(90deg);
}

.encadre__kicker {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  flex-shrink: 0;
  opacity: 0.8;
}

.encadre__title {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--heading);
  line-height: 1.35;
}

.encadre__body {
  padding: 1.25rem 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
}

.encadre__body p {
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 1rem;
}

.encadre__body p:last-child { margin-bottom: 0; }

/* Annuler l'héritage de .encadre__body p à l'intérieur d'un prompt-block */
.encadre__body .prompt-block,
.encadre__body .prompt-block p,
.encadre__body .prompt-block ul,
.encadre__body .prompt-block ol {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--prompt-text);
  font-weight: 400;
  font-style: normal;
}

.encadre__body .poem { font-size: 0.88rem; }
.encadre__body .shadow-poem { font-size: 0.88rem; }
.encadre__body strong { font-weight: 600; color: var(--heading); }
.encadre__body em { font-style: italic; }

/* ─── FORMULE ───────────────────────────────────────────────────────────── */
.formula {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-style: italic;
  color: var(--heading);
  text-align: center;
  padding: 1.5rem 2rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #FFFFFF;
  margin: 2.5rem 0;
  line-height: 1.4;
}

/* ─── FIGURE / IMAGE ────────────────────────────────────────────────────── */
.figure {
  margin: 3rem 0;
}

.figure img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}

.figure figcaption {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-top: 0.75rem;
  line-height: 1.5;
}

/* ─── PRÉAMBULE / ÉPIGRAPHE ─────────────────────────────────────────────── */
.preambule {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.8;
  padding: 0 0 0 1.5rem;
  border-left: 2px solid var(--border);
  margin: 2rem 0 3rem;
}

.preambule p { margin-bottom: 0.75rem; }
.preambule p:last-child { margin-bottom: 0; }

/* ─── LISTE AXES ────────────────────────────────────────────────────────── */
.axes-list {
  list-style: none;
  margin: 1.5rem 0;
  font-family: var(--font-body);
}

.axes-list li {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  line-height: 1.6;
}

.axes-list li:first-child { border-top: 1px solid var(--border); }
.axes-list strong { font-weight: 600; color: var(--heading); }

/* ─── NAVIGATION BAS DE PAGE ────────────────────────────────────────────── */
.page-nav {
  border-top: 1px solid var(--border);
  padding: 2rem var(--content-pad);
  max-width: calc(var(--content-w) + var(--content-pad) * 2);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 1rem;
}

.page-nav__link {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--heading);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  min-width: 150px;
  max-width: 46%;
  transition: border-color 0.15s, background 0.15s;
}

.page-nav__link:hover {
  border-color: var(--gold-border);
  background: var(--gold-light);
}

.page-nav__dir {
  color: var(--muted);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.page-nav__title {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-style: italic;
  color: var(--heading);
  line-height: 1.3;
}

.page-nav__link--prev { text-align: left; }
.page-nav__link--next { text-align: right; margin-left: auto; }
.page-nav__link--next .page-nav__dir { justify-content: flex-end; }

/* ─── PIED DE PAGE ──────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem var(--content-pad);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: var(--muted);
  opacity: 0.55;
  border-top: 1px solid var(--border);
}

.site-footer a { color: inherit; text-decoration: none; }

/* ─── MENU MOBILE ───────────────────────────────────────────────────────── */
.menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--sidebar-bg);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--sidebar-text);
  width: 40px;
  height: 40px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.menu-toggle:hover { background: rgba(255,255,255,0.06); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14, 27, 46, 0.55);
  z-index: 140;
}

.sidebar-overlay.open { display: block; }

/* ─── RESPONSIVE ────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  :root { --sidebar-w: 230px; }
}

@media (max-width: 720px) {
  :root {
    --content-pad: 1.5rem;
  }

  html { font-size: 18px; }

  body { display: block; }

  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    z-index: 150;
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.35);
  }

  .sidebar.open { transform: translateX(0); }

  .main-wrapper { margin-left: 0; }

  .menu-toggle { display: flex; }

  .chapter-header { padding-top: 4.5rem; }

  .page-nav {
    flex-direction: column;
  }

  .page-nav__link {
    max-width: 100%;
  }

  .page-nav__link--next { margin-left: 0; }
}
