/* =======================================================
   EPUB — Le format du livre numérique
   Feuille de style éditoriale
   ======================================================= */

:root {
  --cream: #faf6ef;
  --paper: #ede4d3;
  --paper-dark: #d9ccb2;
  --ink: #1a1613;
  --ink-soft: #3a322c;
  --ink-mute: #6b615a;
  --accent: #7a2e24;
  --accent-light: #a14a3f;
  --accent-soft: #c9a79e;
  --gold: #b8935a;
  --rule: #c9bfae;
  --shadow: rgba(26, 22, 19, 0.08);

  --font-display: "Playfair Display", "Cormorant Garamond", Georgia, serif;
  --font-body: "Lora", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  --max: 1180px;
  --max-text: 680px;
  --max-wide: 1360px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* =======================================================
   Typographie
   ======================================================= */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  margin: 2.2em 0 0.6em;
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); margin-top: 0; }
h2 { font-size: clamp(1.8rem, 3.2vw, 2.6rem); }
h3 { font-size: clamp(1.35rem, 2.2vw, 1.75rem); }
h4 { font-size: 1.2rem; font-style: italic; font-weight: 600; }

p { margin: 0 0 1.2em; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
  transition: all 0.2s ease;
}
a:hover {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

strong { color: var(--ink); font-weight: 700; }
em { font-style: italic; }

blockquote {
  margin: 2em 0;
  padding: 1em 1.8em;
  border-left: 3px solid var(--accent);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
  background: rgba(201, 167, 158, 0.12);
}
blockquote cite {
  display: block;
  margin-top: 0.8em;
  font-size: 0.9rem;
  font-style: normal;
  color: var(--ink-mute);
}
blockquote cite::before { content: "— "; }

hr.ornament {
  border: none;
  text-align: center;
  margin: 3em 0;
  overflow: visible;
  height: 1em;
}
hr.ornament::before {
  content: "❦";
  color: var(--gold);
  font-size: 1.4rem;
  background: var(--cream);
  padding: 0 1em;
  position: relative;
  top: -0.5em;
}
hr.ornament::after {
  content: "";
  display: block;
  border-top: 1px solid var(--rule);
  margin-top: -0.5em;
}

/* =======================================================
   Layout global
   ======================================================= */

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.container--narrow { max-width: var(--max-text); }
.container--wide   { max-width: var(--max-wide); }

/* =======================================================
   Header / Navigation
   ======================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 246, 239, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.site-header__inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--ink);
  border: none;
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.brand__dot { color: var(--accent); }
.brand:hover { color: var(--accent); }

.nav {
  display: flex;
  gap: 1.6rem;
  flex-wrap: wrap;
  align-items: center;
}
.nav a {
  color: var(--ink-soft);
  font-size: 0.92rem;
  border: none;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}
.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--accent);
}
.nav a[aria-current="page"] {
  border-bottom: 1px solid var(--accent);
  padding-bottom: 2px;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--rule);
  padding: 0.4rem 0.7rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
  border-radius: 3px;
}

@media (max-width: 900px) {
  .nav-toggle { display: inline-block; }
  .nav {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 0.8rem;
    padding: 1rem 0;
    border-top: 1px solid var(--rule);
    margin-top: 0.5rem;
  }
  .nav.is-open { display: flex; }
  .site-header__inner { flex-wrap: wrap; }
}

/* =======================================================
   Hero (accueil)
   ======================================================= */

.hero {
  padding: 6rem 1.5rem 5rem;
  text-align: center;
  background:
    radial-gradient(ellipse at top, rgba(184, 147, 90, 0.08), transparent 60%),
    linear-gradient(180deg, var(--cream) 0%, var(--paper) 100%);
  border-bottom: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
}
.hero__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 1.5rem;
}
.hero__title {
  font-size: clamp(2.8rem, 8vw, 6.5rem);
  line-height: 0.95;
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
}
.hero__title em {
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}
.hero__subtitle {
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-style: italic;
  color: var(--ink-mute);
  max-width: 640px;
  margin: 0 auto 2.5rem;
  font-weight: 400;
}
.hero__cta {
  display: inline-flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  display: inline-block;
  padding: 0.85rem 1.8rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--cream);
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
}
.btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--cream);
}
.btn--ghost {
  background: transparent;
  color: var(--ink);
}
.btn--ghost:hover {
  background: var(--ink);
  color: var(--cream);
}

/* =======================================================
   Page header (sous-pages)
   ======================================================= */

.page-header {
  padding: 4rem 1.5rem 2.5rem;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--cream) 0%, rgba(237, 228, 211, 0.4) 100%);
}
.page-header__inner {
  max-width: var(--max);
  margin: 0 auto;
}
.page-header__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.72rem;
  color: var(--accent);
  margin-bottom: 1rem;
}
.page-header__title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin: 0 0 0.5rem;
}
.page-header__lede {
  font-size: 1.2rem;
  font-style: italic;
  color: var(--ink-mute);
  max-width: var(--max-text);
  margin: 0;
}

.byline {
  margin-top: 1.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  align-items: center;
  font-size: 0.86rem;
  color: var(--ink-mute);
  font-family: var(--font-body);
  max-width: var(--max-text);
}
.byline__author { color: var(--ink-soft); }
.byline__author a {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--rule);
}
.byline__author a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.byline__sep {
  color: var(--rule);
  user-select: none;
}
.byline time {
  font-style: italic;
}
.byline__updated {
  color: var(--ink-mute);
  font-style: italic;
}

/* =======================================================
   Corps d'article
   ======================================================= */

.prose {
  max-width: 920px;
  margin: 3rem auto;
  padding: 0 1.5rem;
}
.prose--wide { max-width: 1100px; }

.prose h2 {
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
}
.prose h2:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.prose ul, .prose ol {
  margin: 1em 0 1.5em;
  padding-left: 1.4em;
  clear: left;
}
.prose li { margin-bottom: 0.4em; }

.prose > p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 4.4em;
  float: left;
  line-height: 0.85;
  margin: 0.08em 0.08em 0 0;
  color: var(--accent);
  font-weight: 700;
}

/* =======================================================
   Callouts & encadrés
   ======================================================= */

.callout {
  margin: 2em 0;
  padding: 1.4em 1.6em;
  background: var(--paper);
  border-left: 4px solid var(--gold);
  border-radius: 2px;
}
.callout--note   { border-color: var(--gold); }
.callout--info   { border-color: #5a7a8a; background: #eaf0f3; }
.callout--warn   { border-color: #c49422; background: #f7eed4; }
.callout--danger { border-color: var(--accent); background: #f4e3df; }
.callout__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 0.4em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5em;
}
.callout p:last-child { margin-bottom: 0; }

/* =======================================================
   Code
   ======================================================= */

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.88em;
}
p code, li code, td code {
  background: var(--paper);
  padding: 0.12em 0.4em;
  border-radius: 3px;
  color: var(--accent);
  border: 1px solid var(--paper-dark);
}
pre {
  background: #1f1a16;
  color: #ede4d3;
  padding: 1.3em 1.5em;
  overflow-x: auto;
  border-radius: 4px;
  margin: 1.6em 0;
  font-size: 0.85rem;
  line-height: 1.6;
  box-shadow: 0 4px 20px var(--shadow);
}
pre code { color: inherit; background: none; border: none; padding: 0; }

/* coloration syntaxique légère */
.tok-comment  { color: #7a7060; font-style: italic; }
.tok-tag      { color: #e39f76; }
.tok-attr     { color: #b8935a; }
.tok-string   { color: #c9a79e; }
.tok-keyword  { color: #d68a6e; font-weight: 600; }
.tok-punct    { color: #9a8c7c; }
.tok-value    { color: #d3c9a3; }

pre .filename {
  display: block;
  margin: -1.3em -1.5em 1em;
  padding: 0.5em 1.5em;
  background: #2b241e;
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid #3a322c;
}

/* =======================================================
   Tableaux
   ======================================================= */

.table-wrap { overflow-x: auto; margin: 2em 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}
th, td {
  padding: 0.8em 1em;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
thead th {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  background: rgba(201, 167, 158, 0.08);
}
tbody tr:hover { background: rgba(201, 167, 158, 0.08); }

/* =======================================================
   Cartes / grilles
   ======================================================= */

.grid {
  display: grid;
  gap: 1.8rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin: 2.5rem 0;
}

.card {
  padding: 1.8rem;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 3px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 24px var(--shadow);
  transform: translateY(-2px);
}
.card__num {
  font-family: var(--font-display);
  font-size: 2.2rem;
  color: var(--accent);
  font-style: italic;
  font-weight: 400;
  line-height: 1;
  margin-bottom: 0.4rem;
  opacity: 0.7;
}
.card__title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0 0 0.6rem;
  color: var(--ink);
}
.card__text {
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 0 0 1rem;
}
.card__link {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  border: none;
}
.card__link::after { content: " →"; transition: margin 0.2s; }
.card:hover .card__link::after { margin-left: 0.3em; }

/* Index / Table of Contents on homepage */
.toc-grid {
  display: grid;
  gap: 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  counter-reset: chapter;
}
.toc-item {
  display: flex;
  gap: 1.2rem;
  align-items: baseline;
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--rule);
  border-top: none;
  text-decoration: none;
  color: var(--ink);
  border-left: none;
  border-right: none;
}
.toc-item:hover { color: var(--accent); }
.toc-item__num {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--gold);
  font-size: 1.6rem;
  min-width: 2.5rem;
  font-weight: 400;
}
.toc-item__body { flex: 1; }
.toc-item__title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 0.2rem;
  font-weight: 700;
}
.toc-item__desc {
  font-size: 0.92rem;
  color: var(--ink-mute);
  margin: 0;
}

/* =======================================================
   Tableaux comparatifs (liseuses)
   ======================================================= */

.ereader-grid {
  display: grid;
  gap: 1.8rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  margin: 3rem 0;
}
.ereader {
  background: var(--cream);
  border: 1px solid var(--rule);
  padding: 1.8rem;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
}
.ereader__brand {
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 0.3rem;
}
.ereader__name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 1rem;
  color: var(--accent);
}
.ereader__badge {
  display: inline-block;
  padding: 0.2em 0.7em;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--paper);
  color: var(--ink-soft);
  margin-bottom: 1rem;
  border-radius: 2px;
}
.ereader__badge--warn { background: #f4e3df; color: var(--accent); }
.ereader__badge--ok   { background: #e1ecd7; color: #4a6b2a; }

.ereader__specs {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}
.ereader__specs li {
  padding: 0.45em 0;
  border-bottom: 1px dotted var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.ereader__specs li:last-child { border-bottom: none; }
.ereader__specs strong {
  color: var(--ink-mute);
  font-weight: 400;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.ereader__specs span { text-align: right; font-weight: 600; }

.ereader__pros-cons {
  font-size: 0.9rem;
  margin-top: auto;
}
.ereader__pros,
.ereader__cons {
  margin: 0.5rem 0;
  padding-left: 1.2rem;
}
.ereader__pros li::marker { color: #4a6b2a; }
.ereader__cons li::marker { color: var(--accent); }

/* =======================================================
   Diagramme fichier EPUB
   ======================================================= */

.file-tree {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  background: var(--paper);
  padding: 1.8rem 2rem;
  border-radius: 3px;
  border: 1px solid var(--paper-dark);
  line-height: 2;
  margin: 2em 0;
  overflow-x: auto;
}
.file-tree .f-dir { color: var(--accent); font-weight: 700; }
.file-tree .f-file { color: var(--ink-soft); }
.file-tree .f-comment { color: var(--ink-mute); font-style: italic; }

/* =======================================================
   Footer
   ======================================================= */

.site-footer {
  margin-top: 6rem;
  padding: 3rem 1.5rem;
  padding-bottom: max(3rem, calc(2rem + env(safe-area-inset-bottom)));
  background: var(--ink);
  color: var(--paper);
  font-size: 0.92rem;
}
.site-footer__inner {
  max-width: var(--max);
  margin: 0 auto;
  display: grid;
  gap: 2rem;
  grid-template-columns: 2fr 1fr 1fr;
}
@media (max-width: 700px) {
  .site-footer__inner { grid-template-columns: 1fr 1fr; }
  .site-footer__inner > div:first-child { grid-column: 1 / -1; }
}
.site-footer h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--gold);
  margin: 0 0 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.site-footer a {
  color: var(--paper);
  border-bottom-color: transparent;
}
.site-footer a:hover {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 0.4rem; }
.site-footer__colophon {
  max-width: var(--max);
  margin: 2.5rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(237, 228, 211, 0.15);
  font-size: 0.82rem;
  color: var(--ink-mute);
  text-align: center;
}

/* =======================================================
   Navigation précédent / suivant
   ======================================================= */

.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--max-text);
  margin: 4rem auto 2rem;
  padding: 2rem 1.5rem 0;
  border-top: 1px solid var(--rule);
  flex-wrap: wrap;
}
.page-nav a {
  border: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-width: 48%;
}
.page-nav__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-mute);
}
.page-nav__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
}
.page-nav a:hover .page-nav__title { color: var(--accent); }
.page-nav__prev { text-align: left; }
.page-nav__next { text-align: right; margin-left: auto; }
.page-nav__prev .page-nav__label::before { content: "← "; }
.page-nav__next .page-nav__label::after  { content: " →"; }

/* =======================================================
   Progression de lecture
   ======================================================= */

.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 200;
  transition: width 0.1s ease-out;
}

/* =======================================================
   Pull quote
   ======================================================= */

.pullquote {
  margin: 3rem -2rem;
  padding: 2rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-style: italic;
  color: var(--accent);
  line-height: 1.35;
  position: relative;
}
.pullquote::before,
.pullquote::after {
  content: "";
  display: block;
  width: 80px;
  height: 1px;
  background: var(--gold);
  margin: 1rem auto;
}

@media (max-width: 720px) {
  .pullquote { margin: 2.5rem 0; font-size: 1.35rem; }
}

/* =======================================================
   Chiffres / timeline
   ======================================================= */

.timeline {
  list-style: none;
  padding: 0;
  margin: 3rem 0;
  border-left: 2px solid var(--gold);
}
.timeline li {
  position: relative;
  padding: 0 0 2rem 2rem;
  margin: 0;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 0.4em;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  border: 3px solid var(--cream);
  box-shadow: 0 0 0 2px var(--gold);
}
.timeline__year {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  font-size: 1.3rem;
  display: block;
  margin-bottom: 0.2em;
}
.timeline__desc { color: var(--ink-soft); }

/* =======================================================
   Accessibilité / focus
   ======================================================= */

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* =======================================================
   Small utilities
   ======================================================= */

.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.small { font-size: 0.88rem; color: var(--ink-mute); }
.lead { font-size: 1.2rem; color: var(--ink-soft); }
