/* Bibliothèque — pages de lecture, design « Temple nocturne » (DESIGN.md v2).
   La home a sa propre feuille (temple.css) ; ici, le même monde en mode lecture. */

:root {
  --nuit: #0c0e14;
  --laque: #141722;
  --laque-2: #191d2b;
  --soie: #ede5d3;
  --cendre: #a89e8a;
  --or: #d2a24b;
  --or-sombre: #8a6b32;
  --cinabre: #d03a24;
  --cinabre-sombre: #7e1f12;
  --filet: rgba(210, 162, 75, 0.22);
  --display: "Marcellus", "Spectral", serif;
  --lecture: "Spectral", Georgia, serif;
  --zh: "Noto Serif SC", serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--nuit);
  color: var(--soie);
  font-family: var(--lecture);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

[lang="zh"] { font-family: var(--zh); }

a { color: var(--soie); text-decoration-color: var(--or-sombre); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--or); }

nav a:focus-visible,
button:focus-visible,
input:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--or);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus {
  left: 0.5rem;
  top: 0.5rem;
  background: var(--cinabre);
  color: var(--soie);
  padding: 0.5rem 1rem;
  z-index: 10;
}

/* ---------- header ---------- */

.cloth {
  min-height: 3.5rem;
  padding: 1.1rem clamp(1rem, 4vw, 3rem);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
  border-bottom: 1px solid var(--filet);
}
.wordmark {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
  font-family: var(--display);
  letter-spacing: 0.04em;
  font-size: 1.05rem;
}
.wordmark .mark {
  font-family: var(--zh);
  color: var(--cinabre);
  border: 1px solid var(--cinabre-sombre);
  padding: 0.1rem 0.3rem;
  font-size: 0.9rem;
  line-height: 1.3;
}
header nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.15rem; }
header nav a {
  font-family: var(--display);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--cendre);
  padding: 0.2rem 0;
}
header nav a[aria-current="page"] { color: var(--soie); }
header nav a.act { color: var(--cinabre); }
@media (hover: hover) and (pointer: fine) {
  header nav a:hover { color: var(--soie); }
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(55% 42% at 50% 0%, rgba(210, 162, 75, 0.07), transparent 70%);
  pointer-events: none;
}

main {
  padding: 2.4rem clamp(1rem, 4vw, 3rem) 4.5rem;
  max-width: 76rem;
  margin-inline: auto;
}

/* ---------- titres et prose ---------- */

h1, h2 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.14;
}
h1 { font-size: clamp(1.9rem, 4.2vw, 2.85rem); margin: 0 0 0.85rem; max-width: 20ch; }
h2 { font-size: 1.35rem; margin: 0 0 0.85rem; color: var(--soie); }

.lede { font-size: 1.1rem; color: var(--cendre); max-width: 58ch; margin: 0 0 0.2rem; }
.lede strong { color: var(--soie); font-weight: 500; }

.kicker {
  font-family: var(--display);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--or);
  margin: 0 0 0.6rem;
  font-size: 0.74rem;
}
.kicker [lang="zh"] { letter-spacing: 0.12em; }

.crumbs {
  font-family: var(--display);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cendre);
  margin: 0 0 1.4rem;
}
.crumbs a { color: var(--or); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* Colonne de lecture centrée ; les listes et grilles s'étalent. */
.prose {
  display: grid;
  grid-template-columns: 1fr min(65ch, 100%) 1fr;
}
.prose > * { grid-column: 2; }
.prose > .roll, .prose > .feed, .prose > .grid60 { grid-column: 1 / -1; }
.prose > dl:not(.faq) { grid-column: 1 / -1; }
.prose h2 { margin-top: 2.2rem; }
.prose code {
  background: var(--laque-2);
  border: 1px solid var(--filet);
  border-radius: 2px;
  padding: 0.05em 0.35em;
  font-size: 0.9em;
}

/* ---------- tables, notes, faq ---------- */

.sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
  margin: 1.1rem 0 1.4rem;
  background: var(--laque);
}
.sheet th, .sheet td {
  border: 1px solid var(--filet);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
.sheet th {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--or);
  background: var(--laque-2);
}
.sheet td[lang="zh"] { font-family: var(--zh); }

.note, .hint {
  font-size: 0.92rem;
  color: var(--cendre);
}

.faq { margin: 1.2rem 0 0; }
.faq dt { font-weight: 500; margin-top: 1.1rem; color: var(--soie); }
.faq dd { margin: 0.35rem 0 0; color: var(--cendre); }
.faq dd a { color: var(--soie); }

/* glossaire : définitions en deux colonnes sur grand écran */
.prose > dl:not(.faq) { margin: 1.4rem 0 0; }
.prose > dl:not(.faq) dt {
  font-family: var(--display);
  font-size: 1.02rem;
  color: var(--soie);
  break-after: avoid;
  margin-top: 1.1rem;
}
.prose > dl:not(.faq) dd {
  margin: 0.3rem 0 0;
  color: var(--cendre);
  break-inside: avoid;
}
@media (min-width: 60rem) {
  .prose > dl:not(.faq) { columns: 2; column-gap: 3.5rem; }
}

.byline {
  font-family: var(--display);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--or);
  margin: 0 0 1.2rem;
}

/* ---------- listes de liens (fil, roll) ---------- */

.feed, .roll {
  list-style: none;
  padding: 0;
  margin: 1.6rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 0.7rem;
}
.feed { grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.feed li, .roll li { max-width: none; }
.feed a, .roll a {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  height: 100%;
  text-decoration: none;
  color: inherit;
  background: var(--laque);
  border: 1px solid var(--filet);
  border-radius: 3px;
  padding: 1.05rem 1.15rem;
  transition: border-color 0.2s ease, transform 0.15s ease;
}
.feed a:hover, .roll a:hover { border-color: var(--or); transform: translateY(-2px); }
.roll a [lang="zh"] {
  color: var(--or);
  font-size: 1.9rem;
  line-height: 1.1;
}
.roll a strong {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.08rem;
  letter-spacing: 0.05em;
}
.roll a > span:last-child {
  color: var(--cendre);
  font-size: 0.9rem;
}
.feed time {
  font-family: var(--display);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--or);
}
.feed span, .roll span { color: var(--cendre); font-size: 0.92rem; }
.fil h2 { margin-top: 0; }

.cta-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.8rem; }

/* ---------- formulaires ---------- */

.instrument {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.6rem;
  max-width: 22rem;
}
.instrument.row {
  max-width: none;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 0.7rem;
}
.instrument .field { display: grid; gap: 0.35rem; }

label, footer, dt {
  font-size: 0.92rem;
}
.instrument label {
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--or);
}

input[type="date"], input[type="email"], input[type="password"] {
  font: inherit;
  padding: 0.62rem 0.75rem;
  border: 1px solid rgba(210, 162, 75, 0.35);
  border-radius: 2px;
  background: var(--laque);
  color: var(--soie);
  width: 100%;
  color-scheme: dark;
}

button {
  font-family: var(--display);
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--cinabre-sombre);
  background: var(--cinabre);
  color: var(--soie);
  padding: 0.7rem 1.1rem;
  cursor: pointer;
  border-radius: 2px;
  transition: transform 150ms cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}
button:hover { background: #e2482f; }
button:active { transform: scale(0.97); }
button.ghost {
  background: transparent;
  color: var(--soie);
  border: 1px solid var(--filet);
}
button.ghost:hover { border-color: var(--or); background: transparent; }

.result {
  display: block;
  margin-top: 1.1rem;
  padding: 1rem 1.1rem;
  background: var(--laque);
  border: 1px solid var(--filet);
  border-radius: 3px;
}
.result[hidden] { display: none; }
.result strong { font-size: 1.5rem; color: var(--or); }
.result strong[lang="zh"] { color: var(--cinabre); }
.result a { color: var(--soie); }

/* ---------- grille des 60 (pages de lecture) ---------- */

.grid60 {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 3px;
  margin: 1.1rem 0;
}
.cell {
  aspect-ratio: 1;
  font: inherit;
  border: 1px solid transparent;
  border-radius: 2px;
  background: var(--laque-2);
  color: var(--cendre);
  font-family: var(--zh);
  font-size: clamp(0.62rem, 1.05vw, 0.88rem);
  padding: 0.15rem 0 0.35rem;
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
  letter-spacing: 0;
  text-transform: none;
  transition: none;
}
.cell [lang="zh"] { color: var(--soie); }
.cell .n {
  position: absolute;
  left: 0.18rem;
  bottom: 0.08rem;
  font-family: var(--display);
  font-size: 0.48rem;
  color: var(--or-sombre);
  line-height: 1;
}
.cell:hover { border-color: var(--or-sombre); background: var(--laque-2); }
.cell[aria-current="true"],
.cell.is-on {
  background: var(--cinabre-sombre);
  border-color: var(--cinabre);
  color: var(--soie);
}
.cell.is-on .n,
.cell[aria-current="true"] .n { color: var(--soie); }

/* ---------- footer ---------- */

footer {
  padding: 1.6rem clamp(1rem, 5vw, 4rem) 2.2rem;
  color: var(--cendre);
  border-top: 1px solid var(--filet);
  font-size: 0.92rem;
}
footer a { color: inherit; }
footer a:hover { color: var(--soie); }

/* ---------- responsive & motion ---------- */

@media (max-width: 800px) {
  .cloth { justify-content: center; text-align: center; }
  h1 { max-width: none; }
  .instrument.row { grid-template-columns: 1fr; }
  .grid60 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

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

/* ============================================================
   Gabarit v2 « bandes » — pages repensées pleine largeur.
   L'en-tête porte l'œuvre ou un filigrane ; le contenu vit en
   bandes centrées 76rem, comme la home.
   ============================================================ */

main.large { padding: 0; max-width: none; }

.tete {
  position: relative;
  padding: clamp(2.6rem, 9vh, 5.5rem) clamp(1rem, 4vw, 3rem) clamp(2rem, 6vh, 3.5rem);
  overflow: hidden;
  isolation: isolate;
}
.tete .fond { position: absolute; inset: 0; z-index: -2; }
.tete .fond img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; }
.tete .fond::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, rgba(12, 14, 20, 0.94), rgba(12, 14, 20, 0.62) 52%, rgba(12, 14, 20, 0.3)),
    linear-gradient(to top, var(--nuit), transparent 45%);
}
.tete .filigrane {
  position: absolute;
  right: clamp(0rem, 5vw, 5rem);
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--zh);
  font-size: clamp(9rem, 24vw, 19rem);
  color: rgba(210, 162, 75, 0.09);
  line-height: 1;
  z-index: -1;
  user-select: none;
  pointer-events: none;
}
.tete-inner { max-width: 76rem; margin-inline: auto; }
.tete .crumbs { margin-bottom: 1.6rem; }
.tete h1 { max-width: 22ch; font-size: clamp(2.1rem, 5vw, 3.4rem); margin: 0.3rem 0 0.9rem; }
.tete .lede { font-size: 1.15rem; max-width: 50ch; margin: 0; }

.b {
  padding: clamp(2.4rem, 6vh, 4.2rem) clamp(1rem, 4vw, 3rem);
  border-top: 1px solid var(--filet);
}
.b-inner { max-width: 76rem; margin-inline: auto; }
.b h2 { font-size: clamp(1.5rem, 3.4vw, 2.05rem); margin: 0 0 0.6rem; }
.b .b-lede { color: var(--cendre); max-width: 46rem; margin: 0 0 1.6rem; }
.b .prose { margin-top: 0.4rem; }

/* cartes génériques (équivalent bibliothèque des grilles de la home) */
.cartes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 0.7rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.cartes.larges { grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr)); }
.carte, .cartes a {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  height: 100%;
  background: var(--laque);
  border: 1px solid var(--filet);
  border-radius: 3px;
  padding: 1.05rem 1.2rem;
  text-decoration: none;
  color: inherit;
}
.cartes a { transition: border-color 0.2s ease, transform 0.15s ease; }
.cartes a:hover { border-color: var(--teinte, var(--or)); transform: translateY(-2px); }
.carte .zh, .cartes .zh { font-family: var(--zh); font-size: 1.9rem; line-height: 1.1; color: var(--teinte, var(--or)); }
.carte .nom, .cartes .nom { font-family: var(--display); font-size: 1.08rem; letter-spacing: 0.05em; }
.carte .detail, .cartes .detail { color: var(--cendre); font-size: 0.9rem; }
.carte .valeur { font-size: 1.35rem; font-family: var(--display); color: var(--soie); }
.carte.accent { border-color: rgba(208, 58, 36, 0.5); }
.carte.accent .zh { color: var(--cinabre); }

/* étiquette d'année en cours */
.badge-annee {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--display);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--or);
  border: 1px solid var(--filet);
  border-radius: 2px;
  padding: 0.4rem 0.8rem;
  margin: 0 0 1.1rem;
}
.badge-annee [lang="zh"] { color: var(--cinabre); font-size: 1rem; letter-spacing: 0; }

/* bande finale : calcul + inscription */
.cta-fin { text-align: center; }
.cta-fin .suite {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
  margin: 1.4rem 0 0;
}
.cta-fin .suite a {
  font-family: var(--display);
  font-size: 0.84rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.7rem 1.2rem;
  border-radius: 2px;
  border: 1px solid var(--filet);
  color: var(--soie);
}
.cta-fin .suite a.acte { background: var(--cinabre); border-color: var(--cinabre-sombre); }
.cta-fin .suite a.acte:hover { background: #e2482f; }
.cta-fin .suite a:not(.acte):hover { border-color: var(--or); }
.cta-fin form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 1.6rem;
}
.cta-fin input[type="email"] { max-width: min(20rem, 80vw); }
.cta-fin .statut { min-height: 1.3em; margin: 0.6rem 0 0; font-size: 0.9rem; color: var(--cendre); }
.cta-fin .statut.est-succes { color: #5aa878; }
.cta-fin .statut.est-erreur { color: #e0562f; }

@media (max-width: 40rem) {
  .tete .filigrane { display: none; }
}

/* ============================================================
   Page-outil /calculer/ — l'outil d'abord, le résultat en preuve.
   ============================================================ */

.outil {
  background: var(--laque);
  border: 1px solid var(--filet);
  border-radius: 4px;
  padding: clamp(1.2rem, 3vw, 2rem);
  max-width: 34rem;
}
.outil .instrument { max-width: none; margin: 0; }
.outil .instrument.row { grid-template-columns: 1fr auto; align-items: end; }
.outil .erreur { color: #e0562f; font-size: 0.9rem; margin: 0.5rem 0 0; min-height: 1.2em; }
.outil .gage {
  margin: 0.9rem 0 0;
  font-size: 0.9rem;
  color: var(--cendre);
}
.outil .gage strong { color: var(--or); font-weight: 400; }

.calcul-resultat {
  margin-top: 1.4rem;
  border-top: 1px solid var(--filet);
  padding-top: 1.3rem;
}
.calcul-resultat[hidden] { display: none; }
.calcul-titre {
  font-family: var(--display);
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  margin: 0 0 0.6rem;
  color: var(--teinte, var(--or));
}
.calcul-titre strong { font-weight: 400; }
.calcul-sceau {
  font-family: var(--zh);
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  color: var(--cinabre);
  margin: 0 0 1rem;
  line-height: 1;
}
.calcul-detail { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.45rem; }
.calcul-detail li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  border-bottom: 1px solid rgba(210, 162, 75, 0.12);
  padding-bottom: 0.45rem;
}
.calcul-detail li > span:first-child {
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--or);
  flex: 0 0 12rem;
}
.calcul-detail strong { font-weight: 500; }
.calcul-detail li > span:last-child:not(:first-child) { color: var(--cendre); font-size: 0.92rem; }
.calcul-alerte {
  border-left: 2px solid var(--cinabre);
  background: rgba(208, 58, 36, 0.07);
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  font-size: 0.95rem;
}
.calcul-suites { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.2rem 0 0; }
.calcul-suites a {
  font-family: var(--display);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.65rem 1.1rem;
  border-radius: 2px;
  border: 1px solid var(--filet);
  color: var(--soie);
}
.calcul-suites a.acte { background: var(--cinabre); border-color: var(--cinabre-sombre); }
.calcul-suites a.acte:hover { background: #e2482f; }
.calcul-suites a:not(.acte):hover { border-color: var(--or); }

@media (max-width: 34rem) {
  .calcul-detail li > span:first-child { flex-basis: 100%; }
}

/* Dans une bande, la prose suit le titre : même origine à gauche,
   pas de recentrage qui creuse un vide sous le h2. */
.b .prose {
  display: block;
  max-width: 68ch;
}
.b .prose > .roll,
.b .prose > .feed,
.b .prose > dl:not(.faq) { max-width: none; }

/* ---------- bloc de partage (pages de combinaison) ---------- */

.partage-carte {
  display: block;
  width: 100%;
  max-width: 40rem;
  height: auto;
  border: 1px solid var(--filet);
  border-radius: 4px;
  margin: 1.4rem 0 1.2rem;
}
.partage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 0;
}
.partage-actions a,
.partage-actions button {
  font-family: var(--display);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.65rem 1.1rem;
  border-radius: 2px;
  border: 1px solid var(--filet);
  background: transparent;
  color: var(--soie);
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.partage-actions a:hover,
.partage-actions button:hover { border-color: var(--or); background: transparent; }
.partage-actions [data-share-natif] {
  background: var(--cinabre);
  border-color: var(--cinabre-sombre);
}
.partage-actions [data-share-natif]:hover { background: #e2482f; border-color: var(--cinabre); }
.partage-actions [data-share-natif][hidden] { display: none; }
.partage-statut { min-height: 1.3em; margin: 0.7rem 0 0; font-size: 0.9rem; color: var(--or); }
