/* ==========================================================================
   danmei.fr — feuille de style unique
   Direction : porcelaine céladon, encre de Chine, sceau cinabre.
   Display : EB Garamond (variable, auto-hébergée, sous-ensemble latin)
   Texte   : pile système Charter/Georgia (0 octet)
   Hanzi   : Noto Serif SC, sous-ensemble de 86 glyphes (46 Ko)
   ========================================================================== */

@font-face {
  font-family: "EB Garamond";
  src: url("/fonts/eb-garamond-vf.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Serif SC Subset";
  src: url("/fonts/noto-serif-sc-subset.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+4E00-9FFF;
}

:root {
  /* Glaçure céladon, encre, cinabre, or vieilli */
  --porcelaine: #EEF0E9;
  --porcelaine-2: #E5E8DD;
  --brume: #D3D8C8;
  --encre: #23282B;
  --encre-2: #4C5458;
  --cinabre: #9E3123;
  --cinabre-vif: #B23A2E;
  --jade: #45604F;
  --or: #8A6C3C;
  --blanc-sceau: #EEF0E9;

  --serif-affiche: "EB Garamond", "Iowan Old Style", Georgia, serif;
  --serif-texte: "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hanzi: "Noto Serif SC Subset", "Noto Serif SC", "Songti SC", "SimSun", serif;

  --mesure: 66ch;
  --large: 70rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --porcelaine: #15181A;
    --porcelaine-2: #1D2124;
    --brume: #31373B;
    --encre: #E7E6DC;
    --encre-2: #A6ABA0;
    --cinabre: #D4553F;
    --cinabre-vif: #C74A36;
    --jade: #7FA98F;
    --or: #B99055;
    --blanc-sceau: #EDEBE0;
  }
}

/* --- Base ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--porcelaine);
  color: var(--encre);
  font-family: var(--serif-texte);
  font-size: 1.125rem;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.zh { font-family: var(--hanzi); font-weight: 600; font-style: normal; }

h1, h2, h3 {
  font-family: var(--serif-affiche);
  font-weight: 640;
  line-height: 1.14;
  letter-spacing: .002em;
  color: var(--encre);
  text-wrap: balance;
  margin: 0 0 .55em;
}
h1 { font-size: clamp(2.3rem, 5.4vw, 3.4rem); }
h2 { font-size: clamp(1.7rem, 3.4vw, 2.25rem); margin-top: 2.6em; }
h3 { font-size: clamp(1.25rem, 2.2vw, 1.5rem); margin-top: 2em; font-weight: 600; }

p, ul, ol, dl { margin: 0 0 1.15em; }
ul, ol { padding-left: 1.3em; }
li { margin-bottom: .4em; }

a {
  color: var(--cinabre);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  text-decoration-color: color-mix(in srgb, var(--cinabre) 45%, transparent);
  transition: text-decoration-color .15s ease;
}
a:hover { text-decoration-color: var(--cinabre); }
a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--cinabre);
  outline-offset: 3px;
  border-radius: 2px;
}

strong { font-weight: 700; }
em, cite { font-style: italic; }
hr { border: 0; border-top: 1px solid var(--brume); margin: 3rem 0; }
::selection { background: color-mix(in srgb, var(--cinabre-vif) 22%, var(--porcelaine)); }

/* --- Structure --------------------------------------------------------- */
.conteneur { max-width: var(--large); margin-inline: auto; padding-inline: clamp(1.1rem, 4vw, 2.5rem); }
.prose { max-width: var(--mesure); }
.prose > h2, .prose > h3 { max-width: none; }

.saut { padding-block: clamp(2.4rem, 6vw, 4.5rem); }

/* Lien d'évitement */
.evitement {
  position: absolute; left: -9999px; top: 0;
  background: var(--encre); color: var(--porcelaine);
  padding: .6rem 1rem; z-index: 100; font-family: var(--sans);
}
.evitement:focus { left: .5rem; top: .5rem; }

/* --- En-tête & navigation ---------------------------------------------- */
.entete {
  border-bottom: 1px solid var(--brume);
  background: var(--porcelaine);
}
.entete-int {
  display: flex; flex-wrap: wrap; align-items: center; gap: .9rem 1.6rem;
  padding-block: 1rem;
}
.marque {
  display: flex; align-items: center; gap: .7rem;
  text-decoration: none; color: var(--encre);
  font-family: var(--serif-affiche); font-weight: 640; font-size: 1.5rem;
}
.marque img { width: 2.4rem; height: 2.4rem; display: block; }
.marque small {
  display: block; font-family: var(--sans); font-size: .66rem;
  font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  color: var(--encre-2);
}
.nav-principale { margin-left: auto; }
.nav-principale ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: .1rem .3rem;
  font-family: var(--sans); font-size: .92rem; font-weight: 500;
}
.nav-principale a {
  display: block; padding: .45rem .7rem; border-radius: 4px;
  color: var(--encre); text-decoration: none;
}
.nav-principale a:hover { background: var(--porcelaine-2); color: var(--cinabre); }
.nav-principale a[aria-current="page"] {
  color: var(--cinabre);
  box-shadow: inset 0 -2px 0 var(--cinabre);
  border-radius: 4px 4px 0 0;
}

/* --- Fil d'Ariane ------------------------------------------------------- */
.fil-ariane {
  font-family: var(--sans); font-size: .84rem; color: var(--encre-2);
  padding-top: 1.4rem;
}
.fil-ariane ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.fil-ariane li { margin: 0; }
.fil-ariane li + li::before { content: "›"; margin-right: .35rem; color: var(--brume); }
.fil-ariane a { color: var(--encre-2); }

/* --- Héros « entrée de dictionnaire » ----------------------------------- */
.heros { padding-block: clamp(2.2rem, 6vw, 4.2rem) clamp(1.6rem, 4vw, 2.6rem); }
.entree-dico { max-width: 46rem; }
.entree-dico .phonetique {
  font-family: var(--sans); font-size: 1rem; color: var(--encre-2);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .8rem;
  margin-top: .2rem;
}
.entree-dico .phonetique .zh { font-size: 1.5rem; color: var(--cinabre); }
.entree-dico .nature { font-style: italic; }
.heros-flex { display: flex; gap: clamp(1.5rem, 5vw, 4rem); align-items: flex-start; }
.heros-sceau { flex-shrink: 0; width: clamp(84px, 12vw, 132px); margin-top: .8rem; }
.heros-sceau img { width: 100%; height: auto; display: block; filter: drop-shadow(0 2px 8px rgba(35,40,43,.12)); }
@media (max-width: 620px) { .heros-sceau { display: none; } }

/* --- Œil de section ------------------------------------------------------ */
.oeil {
  font-family: var(--sans); font-size: .74rem; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--or);
  display: flex; align-items: center; gap: .6rem; margin-bottom: .9rem;
}
.oeil .zh { font-size: 1.05rem; letter-spacing: 0; text-transform: none; }
.oeil::after { content: ""; height: 1px; flex: 0 0 3.2rem; background: var(--or); opacity: .5; }

/* --- Bloc « En bref » (réponse directe) ---------------------------------- */
.en-bref {
  border-left: 3px solid var(--cinabre-vif);
  background: var(--porcelaine-2);
  padding: 1.15rem 1.4rem 1.15rem 1.3rem;
  border-radius: 0 4px 4px 0;
  max-width: var(--mesure);
  margin: 1.4rem 0 2.2rem;
}
.en-bref > p:last-child { margin-bottom: 0; }
.en-bref .etiquette {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--sans); font-size: .72rem; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--cinabre);
  margin-bottom: .5rem;
}
.en-bref .etiquette::before {
  content: ""; width: .55rem; height: .55rem; border-radius: 2px;
  background: var(--cinabre-vif); display: inline-block;
}

/* --- Tableaux ------------------------------------------------------------ */
.defilement-x { overflow-x: auto; margin-block: 1.6rem 2.2rem; }
table {
  border-collapse: collapse; width: 100%;
  font-size: .97rem; line-height: 1.5;
}
caption {
  caption-side: top; text-align: left; padding-bottom: .6rem;
  font-family: var(--sans); font-size: .84rem; color: var(--encre-2);
}
th, td { padding: .65rem .8rem; vertical-align: top; text-align: left; }
thead th {
  font-family: var(--sans); font-size: .8rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--encre-2);
  border-bottom: 2px solid var(--encre);
}
tbody tr { border-bottom: 1px solid var(--brume); }
tbody tr:hover { background: color-mix(in srgb, var(--porcelaine-2) 60%, transparent); }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { padding-right: 0; }

/* --- Chronologie ---------------------------------------------------------- */
.chronologie { list-style: none; margin: 2rem 0; padding: 0; max-width: var(--mesure); }
.chronologie li {
  position: relative; padding: 0 0 1.7rem 5.4rem; margin: 0;
  border-left: 1px solid var(--brume); margin-left: 3.4rem;
}
.chronologie li:last-child { padding-bottom: .4rem; }
.chronologie .an {
  position: absolute; left: -3.55rem; top: -.28rem; width: 6.4rem;
  text-align: right;
  font-family: var(--serif-affiche); font-weight: 640; font-size: 1.32rem;
  color: var(--or);
  background: var(--porcelaine);
  padding-right: 1.15rem;
}
.chronologie li::before {
  content: ""; position: absolute; left: -4.5px; top: .42rem;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cinabre-vif); outline: 3px solid var(--porcelaine);
}
.chronologie h3 { margin: 0 0 .25em; font-size: 1.18rem; }
.chronologie p { margin: 0; font-size: 1.02rem; color: var(--encre-2); }
@media (max-width: 560px) {
  .chronologie li { margin-left: 0; padding-left: 1.4rem; }
  .chronologie .an { position: static; display: block; text-align: left; padding: 0 0 .15rem; width: auto; }
  .chronologie li::before { top: 2.5rem; }
}

/* --- Glossaire -------------------------------------------------------------- */
.glossaire dt {
  font-family: var(--serif-affiche); font-weight: 640; font-size: 1.4rem;
  margin-top: 2.1rem; scroll-margin-top: 2rem;
}
.glossaire dt .zh { color: var(--cinabre); font-size: 1.25rem; margin-left: .4rem; }
.glossaire dt .pinyin { font-family: var(--serif-texte); font-style: italic; font-weight: 400; font-size: 1.05rem; color: var(--encre-2); margin-left: .4rem; }
.glossaire dd { margin: .45rem 0 0; max-width: var(--mesure); }
.glossaire dd + dt { border-top: 1px solid var(--brume); padding-top: 1.6rem; }

/* --- Cartes & grilles --------------------------------------------------------- */
.grille {
  display: grid; gap: 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr));
  margin-block: 1.8rem 2.4rem;
}
.carte {
  background: var(--porcelaine-2);
  border: 1px solid var(--brume);
  border-radius: 6px;
  padding: 1.3rem 1.4rem;
}
.carte h3 { margin-top: 0; font-size: 1.22rem; }
.carte p { font-size: .99rem; margin-bottom: .6rem; }
.carte p:last-child { margin-bottom: 0; }
.carte .zh-titre { color: var(--cinabre); font-size: .95rem; }
.carte-lien { font-family: var(--sans); font-size: .88rem; font-weight: 600; }

/* --- FAQ ------------------------------------------------------------------ */
.faq h2 { font-size: 1.45rem; margin-top: 2.4rem; }
.faq h2::before { content: "問"; font-family: var(--hanzi); color: var(--or); margin-right: .6rem; font-size: 1.15rem; }

/* --- Encadré 口口 (censure) -------------------------------------------------- */
.motif-censure {
  font-family: var(--hanzi); color: var(--brume);
  letter-spacing: .3em; user-select: none;
}

/* --- Renvoi / note ------------------------------------------------------------ */
.renvoi {
  font-family: var(--sans); font-size: .9rem; font-weight: 600;
  display: inline-block; margin-top: .3rem;
}
.note {
  font-size: .92rem; color: var(--encre-2);
  border-top: 1px solid var(--brume); padding-top: .8rem; margin-top: 2.5rem;
  max-width: var(--mesure);
}

/* --- Sources -------------------------------------------------------------- */
.sources { font-size: .95rem; }
.sources li { margin-bottom: .55em; }

/* --- Pied de page ------------------------------------------------------------- */
.pied {
  margin-top: clamp(3rem, 8vw, 5.5rem);
  border-top: 1px solid var(--brume);
  background: var(--porcelaine-2);
  font-family: var(--sans); font-size: .9rem;
}
.pied-int {
  display: grid; gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr));
  padding-block: 2.6rem 2rem;
}
.pied h2 {
  font-family: var(--sans); font-size: .74rem; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--encre-2);
  margin: 0 0 .8rem;
}
.pied ul { list-style: none; margin: 0; padding: 0; }
.pied li { margin-bottom: .45em; }
.pied a { color: var(--encre); text-decoration: none; }
.pied a:hover { color: var(--cinabre); text-decoration: underline; }
.pied .mention {
  grid-column: 1 / -1; border-top: 1px solid var(--brume);
  padding-block: 1.2rem .4rem; color: var(--encre-2); font-size: .84rem;
  display: flex; flex-wrap: wrap; gap: .6rem 1.6rem; align-items: center;
}
.pied .mention img { width: 1.5rem; height: 1.5rem; }

/* --- Impression ------------------------------------------------------------ */
@media print {
  .entete, .pied, .fil-ariane, .evitement { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a { color: #000; text-decoration: none; }
  .en-bref { border: 1px solid #000; }
}
