/* Polices auto-hébergées (pas de dépendance Google Fonts — contourne les bloqueurs) */
@font-face {
  font-family: 'Ma Shan Zheng';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/MaShanZheng.ttf') format('truetype');
}
@font-face {
  font-family: 'Zhi Mang Xing';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/ZhiMangXing.ttf') format('truetype');
}
@font-face {
  font-family: 'Noto Serif SC';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/NotoSerifSC-Regular.ttf') format('truetype');
}
@font-face {
  font-family: 'Noto Serif SC';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/NotoSerifSC-Bold.ttf') format('truetype');
}

@font-face {
  font-family: 'Noto Serif Devanagari';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/NotoSerifDevanagari-Regular.woff2') format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF;
}

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

:root {
  --bg: #1a1814;
  --surface: #22201c;
  --surface2: #2a2720;
  --border: #3a3730;
  --accent: #c8a96e;
  --accent-dim: #8a7248;
  --text: #e8e0d0;
  --text-muted: #8a8278;
  --radius: 12px;
  --font: 'Georgia', 'Times New Roman', 'Noto Serif SC', 'Noto Serif Devanagari', serif;
  --font-ui: system-ui, -apple-system, 'Noto Serif SC', 'Noto Serif Devanagari', sans-serif;
  --nav-h: 60px;
  /* Largeur du panneau de chat : s'élargit avec l'écran, mais reste bornée pour
     ne pas écraser le texte de la page sur un portable. */
  --ai-w: clamp(420px, 34vw, 560px);
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

/* ── NAV ────────────────────────────────────── */



.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.nav-links a {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  letter-spacing: 0.02em;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--surface);
}

.nav-links a.active {
  color: var(--accent);
}

.nav-lang {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.nav-lang button {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  transition: color 0.15s;
}

.nav-lang button:hover,
.nav-lang button.active {
  color: var(--accent);
}

.nav-lang .sep {
  color: var(--border);
  font-size: 12px;
}

/* hamburger — mobile */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  margin-left: auto;
  padding: 4px;
}

/* ── PAGE LAYOUT ────────────────────────────── */

.page {
  padding-top: var(--nav-h);
  min-height: 100vh;
  min-height: 100dvh;
  transition: padding-right 0.3s ease;
}

.page.ai-open {
  padding-right: var(--ai-w);
}

.page-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 24px 80px;
}

/* ── TEXT PAGE ──────────────────────────────── */

.text-header {
  margin-bottom: 40px;
}

.text-meta {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.text-title {
  font-size: 28px;
  font-weight: normal;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.text-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  font-style: italic;
}

.text-divider {
  width: 40px;
  height: 1px;
  background: var(--accent-dim);
  margin: 28px 0;
  opacity: 0.4;
}

.text-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 40px;
}

.text-summary h2 {
  font-size: 12px;
  font-family: var(--font-ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-dim);
  margin-bottom: 12px;
}

.text-summary p {
  font-size: 14px;
  line-height: 1.85;
  color: var(--text-muted);
}

.text-summary p + p {
  margin-top: 10px;
}

.text-body {
  font-size: 16px;
  line-height: 1.95;
  color: var(--text);
}

.text-body p {
  margin-bottom: 1.4em;
}

.text-body h3 {
  font-size: 14px;
  font-family: var(--font-ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-dim);
  margin: 2em 0 0.8em;
}

.text-body blockquote {
  border-left: 2px solid var(--accent-dim);
  padding-left: 20px;
  margin: 1.5em 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Chinese / Japanese original text */
.text-body p.zh,
.text-body p.jp {
  font-family: "Ma Shan Zheng", "LXGW WenKai", "STKaiti", "KaiTi", "FZKai-Z03", "BiauKai", serif;
  font-size: 18px;
  line-height: 2;
}

.text-note {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-style: italic;
  text-align: center;
  margin: 2em 0;
}
.text-provenance {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-style: italic;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 2em;
  opacity: 0.7;
}
.text-provenance a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.site-license {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 2em;
  opacity: 0.6;
  text-align: center;
}
.site-license a {
  color: var(--accent-dim);
  text-decoration: none;
}
.site-license a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.translation-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 28px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-muted);
}

.translation-banner .tb-icon {
  font-size: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.translation-banner strong {
  color: var(--text);
  font-weight: 500;
}

/* chapter nav */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 13px;
}

.chapter-nav a {
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}

.chapter-nav a:hover { color: var(--accent); }

/* ── AI PANEL ────────────────────────────────── */

.ai-panel {
  position: fixed;
  top: var(--nav-h);
  right: 0;
  width: var(--ai-w);
  height: calc(100vh - var(--nav-h));
  height: calc(100dvh - var(--nav-h));
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.ai-panel.open {
  transform: translateX(0);
}

.ai-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ai-panel-header h2 {
  font-size: 14px;
  font-weight: normal;
  color: var(--accent);
  font-family: var(--font-ui);
  letter-spacing: 0.05em;
}

.ai-panel-context {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-style: italic;
  margin-top: 2px;
}
.ai-model-label {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  opacity: 0.55;
  margin-top: 1px;
  letter-spacing: 0.03em;
}

.ai-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.ai-close:hover { color: var(--text); }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.ai-messages::-webkit-scrollbar { width: 3px; }
.ai-messages::-webkit-scrollbar-thumb { background: var(--border); }

.ai-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-message.user { align-self: flex-end; align-items: flex-end; }
.ai-message.bot  { align-self: flex-start; align-items: flex-start; }

.ai-bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
  /* Les bulles plafonnaient à 300px, soit moins que la largeur du panneau :
     elles laissaient une bande vide à droite et tassaient le texte. */
  max-width: 88%;
}

.ai-message.user .ai-bubble {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom-right-radius: 4px;
}

.ai-message.bot .ai-bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-bubble strong { color: var(--accent); }
.ai-bubble em { color: var(--text-muted); font-style: italic; }
.ai-bubble p { margin-bottom: 8px; }
.ai-bubble p:last-child { margin-bottom: 0; }

.ai-meta {
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 2px;
}

.ai-typing .ai-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
}

.ai-dot {
  width: 5px; height: 5px;
  background: var(--accent-dim);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.ai-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

.ai-welcome {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  line-height: 1.7;
  text-align: center;
  padding: 20px 8px;
}

.ai-input-area {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  transition: border-color 0.15s;
}

.ai-input-row:focus-within { border-color: var(--accent-dim); }

.ai-input-row textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  min-height: 22px;
  max-height: 120px;
  overflow-y: auto;
}

.ai-input-row textarea::placeholder { color: var(--text-muted); }

.ai-send {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent-dim);
  padding: 2px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  flex-shrink: 0;
}

.ai-send:hover:not(:disabled) { color: var(--accent); }
.ai-send:disabled { opacity: 0.3; cursor: default; }

/* ── AI FLOAT BUTTON ─────────────────────────── */

.ai-float {
  position: fixed;
  bottom: 28px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  border-radius: 24px;
  padding: 10px 18px;
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s;
  z-index: 80;
}

.ai-float:hover {
  background: var(--surface2);
  border-color: var(--accent);
}

.ai-float.hidden { display: none; }

/* ── STATIC PAGE ─────────────────────────────── */

.static-hero {
  text-align: center;
  padding: 48px 0 40px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.static-hero 

@keyframes breathe {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(1.03); }
}

.static-hero h1 {
  font-size: 26px;
  font-weight: normal;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 12px;
}

.static-hero p {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.8;
}

.static-body {
  font-size: 15px;
  line-height: 1.9;
  color: var(--text);
}

.static-body h2 {
  font-size: 17px;
  font-weight: normal;
  color: var(--accent);
  margin: 2em 0 0.8em;
  letter-spacing: 0.05em;
}

.static-body p {
  margin-bottom: 1.2em;
  color: var(--text-muted);
}

.static-body p strong {
  color: var(--text);
}

.static-body a, .lineage-note a, .lineage-name a, .text-meta a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--text-muted);
}

.static-body a:hover, .lineage-note a:hover, .lineage-name a:hover, .text-meta a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── INDEX LISTS ─────────────────────────────── */

.works-section {
  margin-top: 48px;
}

.works-section-title {
  font-size: 13px;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 0;
}

.works-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.work-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  text-decoration: none;
  display: block;
  transition: border-color 0.15s;
}

.work-card:hover { border-color: var(--accent-dim); }

.work-card h2 {
  font-size: 17px;
  font-weight: normal;
  color: var(--accent);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

.work-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}

.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
}

.chapter-link {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.15s;
}

.chapter-link:hover { border-color: var(--accent-dim); }

/* Fascicule pas encore publié */
.chapter-pending {
  opacity: 0.55;
  cursor: default;
}
.chapter-pending:hover { border-color: var(--border); }
.chapter-soon {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-dim);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  margin-left: 6px;
  white-space: nowrap;
}

.chapter-num {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  flex-shrink: 0;
  min-width: 28px;
}

.chapter-name {
  font-size: 15px;
  color: var(--text);
}

.chapter.jp {
  font-family: "Ma Shan Zheng", "LXGW WenKai", "STKaiti", "KaiTi", "FZKai-Z03", "BiauKai", serif;
  font-size: 18px;
  line-height: 2;
}

/* ── MOBILE ──────────────────────────────────── */

@media (max-width: 680px) {
  :root { --nav-h: 56px; }
  .nav-links { display: none; }
  .nav-links.open { display: flex; flex-direction: column; position: absolute; top: var(--nav-h); left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--border); padding: 12px 16px; gap: 4px; }
  .nav-toggle { display: flex; }
  /* Logo compact : évite qu'il déborde sur le contenu (barre de 48px) */
  .nav-logo-img { height: 52px; }
  /* Libère de la place dans la barre sur écran étroit */
  .nav-construction { display: none; }
  .ai-panel { width: 100vw; }
  .page.ai-open { padding-right: 0; }
  :root { --ai-w: 100vw; }
  /* Panneau IA : empêche le zoom iOS (seuil 16px) et cible tactile 44px */
  .ai-input-row textarea { font-size: 16px; min-height: 26px; }
  .ai-send { min-width: 44px; min-height: 44px; padding: 0; justify-content: center; }
  .ai-input-area { padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .ai-float { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); right: 16px; }
  .ai-bubble { font-size: 15px; }
}

@media (max-width: 420px) {
  .site-nav { padding: 0 12px; gap: 8px; }
  .page-content { padding-left: 16px; padding-right: 16px; }
  .text-body, .text-summary { padding-left: 0; padding-right: 0; }
}

.construction-bar a {
  color: #1a1814;
  text-decoration: underline;
}

.construction-badge:hover {
  opacity: 1;
}
/* ── Nav logo row (above nav bar) ──────────────────── */
.nav-logo-row {
  text-align: center;
  padding: 12px 0 8px;
  background: var(--bg);
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  min-height: 48px;
}
/* ── Custom language dropdown ──────────────────────── */
.lang-dropdown {
  position: relative;
  display: inline-block;
}
.lang-current {
  font-family: var(--font-ui);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: border-color .2s;
}
.lang-current:hover { border-color: var(--accent); }
.lang-flag { font-size: 16px; line-height: 1; }
.lang-arrow { font-size: 10px; color: var(--text-muted); transition: transform .2s; }
.lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  min-width: 120px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.lang-menu.open { display: block; }
.lang-option {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 10px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.lang-option:hover { background: var(--surface); }
.lang-option.active { background: var(--surface); color: var(--accent); }
.lang-option .lang-flag { font-size: 16px; }
.nav-lang { display: flex; align-items: center; gap: 8px; }

/* ── Nav logo ──────────────────────────────────────── */

/* ── Nav logo ──────────────────────────────────────── */



/* ── Nav logo ──────────────────────────────────────── */










/* ── Nav logo ──────────────────────────────────────── */


/* ── Flag images ───────────────────────────────────── */
.lang-flag-img {
  width: 20px;
  height: 13px;
  vertical-align: middle;
}

/* ── Under construction in nav ─────────────────────── */
.nav-construction {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
  white-space: nowrap;
  margin-left: 8px;
  padding: 2px 8px;
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  background: rgba(200, 169, 110, 0.08);
  align-self: center;
}

/* ── Under construction badge ──────────────────────── */
.construction-badge-small {
  position: fixed;
  bottom: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: help;
  opacity: 0.35;
  z-index: 999;
  transition: opacity 0.2s;
}
.construction-badge-small:hover {
  opacity: 0.8;
}


/* ── Nav logo ──────────────────────────────────────── */













.site-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
  height: 48px;
  overflow: visible;
}
.nav-logo {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  height: 100%;
  flex-shrink: 0;
  align-self: flex-start;
  overflow: visible;
}

.nav-logo-img {
  height: 120px;
  width: auto;
  display: block;
}

.sutra-line .jp {
  font-family: "Ma Shan Zheng", "STKaiti", "KaiTi", "FZKai-Z03", serif;
  font-size: 17px;
  line-height: 2;
}

.chinese-kaiti {
  font-family: "Ma Shan Zheng", "LXGW WenKai", "STKaiti", "KaiTi", "FZKai-Z03", "BiauKai", serif;
}
