/* Mise en page de l'export PDF des fiches de grammaire (fiches.html).
   Reprend le style du PDF « Fiches de Grammaire » : Raleway, rouge #c0002a, gris doux. */

:root { --fiche-red: #c0002a; }

@page {
  size: A4;
  margin: 16mm 16mm 18mm;
  @bottom-right {
    content: counter(page);
    font-family: "Raleway", sans-serif;
    font-size: 9pt;
    color: #9a9a9a;
  }
}
@page cover {
  margin: 0;
  @bottom-right { content: none; }
}

.fiches-export {
  margin: 0;
  background: #e9ebef;
  color: #1a1a1a;
  font-family: "Raleway", "Noto Sans JP", "Yu Gothic", sans-serif;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.fiches-export [lang="ja"] { font-family: "Noto Sans JP", "Yu Gothic", sans-serif; }

/* ---------- Barre d'aide (écran) ---------- */
.export-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid #e3e3e3;
}
.export-bar .back-link { margin: 0; }
.export-hint { flex: 1; margin: 0; color: var(--muted); font-size: 0.9rem; }
.export-bar .btn-primary:disabled { opacity: 0.5; cursor: wait; }

.cover, .toc, .level-block { box-sizing: border-box; background: #fff; }

/* À l'écran seulement, les pages sont montrées comme des feuilles A4 centrées.
   (En impression, un « justify-items: center » réduirait chaque page à la largeur de son contenu.) */
@media screen {
  #fiches { display: grid; justify-items: center; gap: 24px; padding: 24px 12px 48px; }
  .cover, .toc, .level-block { width: 210mm; max-width: 100%; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); }
  .toc, .level-block { padding: 16mm; }
}

/* ---------- Page de garde ---------- */
.cover {
  page: cover;
  position: relative;
  height: 297mm;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #fff 55%, #fbeef1 100%);
}
/* Centré verticalement par calcul (hauteur = 1 × font-size). */
.cover-watermark {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% - 44mm);
  text-align: center;
  color: #fbf0f2;
  font-size: 88mm;
  font-weight: 300;
  line-height: 1;
  white-space: nowrap;
}
.cover-content { position: relative; text-align: center; }
.cover-jp { font-family: "Noto Sans JP", sans-serif; font-size: 26pt; font-weight: 400; letter-spacing: 0.05em; }
.cover h1 { margin: 10px 0 6px; font-size: 30pt; font-weight: 800; letter-spacing: -0.01em; }
.cover-sub { margin: 0; color: var(--fiche-red); font-size: 12pt; letter-spacing: 0.25em; }
.cover hr { width: 50px; margin: 22px auto; border: none; border-top: 2px solid var(--fiche-red); }
.cover-meta { margin: 0; color: #9a9a9a; font-size: 9pt; font-weight: 300; }

/* ---------- Sommaire ---------- */
.toc { break-before: page; }
.toc-title {
  margin: 0 0 22px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--fiche-red);
  font-size: 18pt;
  font-weight: 800;
}
.toc-level { margin: 22px 0 8px; color: var(--fiche-red); font-size: 11pt; font-weight: 800; }
.toc-type { margin: 12px 0 4px 12px; color: #444; font-size: 9.5pt; font-weight: 700; }
.toc-list { margin: 0 0 0 26px; padding: 0; list-style: none; }
.toc-list li { break-inside: avoid; }
.toc-list a {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2.5px 0;
  color: inherit;
  text-decoration: none;
  font-size: 9pt;
}
.toc-name { font-weight: 700; flex-shrink: 0; max-width: 55%; }
.toc-sub { flex-shrink: 1; min-width: 0; overflow: hidden; color: #9a9a9a; font-size: 7.5pt; white-space: nowrap; text-overflow: ellipsis; }
.toc-dots { flex: 1; min-width: 12px; border-bottom: 1px dotted #c8c8c8; transform: translateY(-3px); }
.toc-num { color: #9a9a9a; font-size: 8pt; }

/* ---------- Fiches ---------- */
.level-block { break-before: page; }
.level-badge {
  display: inline-block;
  margin-bottom: 18px;
  padding: 4px 12px;
  border-radius: 6px;
  background: var(--fiche-red);
  color: #fff;
  font-size: 10pt;
  font-weight: 800;
}
.cat-title {
  margin: 18px 0 14px;
  padding-left: 10px;
  border-left: 3px solid var(--fiche-red);
  color: #444;
  font-size: 10pt;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  break-after: avoid;
}

.fiche {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  padding: 14px 0 18px;
  border-bottom: 1px solid #ececec;
}
.fiche-num {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border-radius: 50%;
  background: #f0f0f0;
  color: #888;
  font-size: 7pt;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.fiche-title { margin: 0; font-size: 11.5pt; font-weight: 800; break-after: avoid; }
.fiche-sub { margin: 3px 0 0; color: #888; font-size: 8.5pt; break-after: avoid; }
.fiche-content { margin-top: 10px; color: #333; font-size: 9.5pt; line-height: 1.6; }
.fiche-content:empty { display: none; }
.fiche-content img { max-width: 100%; height: auto; break-inside: avoid; }
.fiche-content li,
.fiche-content p { break-inside: avoid; }

.fiche-examples { margin-top: 12px; font-size: 9.5pt; }
.fiche-examples-title {
  margin: 0 0 6px;
  color: var(--fiche-red);
  font-size: 8pt;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  break-after: avoid;
}
.fiche-examples ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.fiche-examples li {
  display: grid;
  gap: 1px;
  padding-left: 10px;
  border-left: 2px solid #e2e2e2;
  break-inside: avoid;
}
.fiche-example-ja { color: #1a1a1a; font-size: 10pt; }
.fiche-example-fr { color: #777; }

/* ---------- Fiches de Kanji (kanji-fiches.html) ---------- */
.cover-filters { margin-top: 6px; }
.kanji-level-count { margin-left: 8px; color: #9a9a9a; font-size: 9pt; font-weight: 600; }

.kanji-fiche {
  padding: 14px 0 16px;
  border-bottom: 1px solid #ececec;
  break-inside: avoid;
}
.kanji-fiche-main { display: grid; grid-template-columns: 22mm 1fr; gap: 14px; align-items: center; }
.kanji-fiche-char {
  display: grid;
  place-items: center;
  height: 22mm;
  border: 1.5px solid #f0c7cf;
  border-radius: 8px;
  background: #fdf5f7;
  color: #1a1a1a;
  font-size: 40pt;
  font-weight: 400;
  line-height: 1;
}
.kanji-fiche-body { min-width: 0; }
.kanji-fiche-readings { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; margin-top: 6px; font-size: 9.5pt; }
.kanji-fiche-label {
  min-width: 26px;
  color: var(--fiche-red);
  font-size: 7.5pt;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.kanji-fiche-reading { padding: 1px 7px; border-radius: 4px; background: #f3f3f3; color: #333; }
.kanji-fiche-strokes { display: grid; gap: 6px; margin-top: 12px; }
.kanji-fiche-strokes img { display: block; max-width: 100%; max-height: 60mm; border-radius: 6px; }

/* ---------- Impression ---------- */
@media print {
  .export-bar { display: none; }
  .fiches-export { background: #fff; }
}
