/* Styles du lecteur web statique pour roman graphique / BD.
 * Mode album : page de bande dessinee, cases aux formats natifs, bulles en surimpression.
 * Mode webtoon : une colonne, image puis texte, sans recadrage.
 */
:root {
  --bg-color: #141312;
  --paper: #f4ecdf;
  --paper-edge: #c9b99f;
  --ink: #1c1a17;
  --text-color: #f3ede2;
  --accent-gold: #c99738;
  --accent-red: #8b2500;
  --border-color: rgba(201, 151, 56, 0.32);
  --bubble-bg: #fffdf6;
  --caption-bg: #fbf3e2;
  --panel-bg: #1e1c19;
}

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

html {
  background: var(--bg-color);
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1.6;
  min-height: 100vh;
}

.site-header {
  border-bottom: 1px solid var(--border-color);
  padding: 1.2rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background-color: rgba(20, 19, 18, 0.96);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.site-header h1 {
  font-size: 1.35rem;
  color: var(--accent-gold);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-nav a {
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.95rem;
  opacity: 0.8;
  transition: opacity 0.2s, color 0.2s;
}

.site-nav a:hover {
  opacity: 1;
  color: var(--accent-gold);
}

.mode-toggle {
  appearance: none;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-color);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.mode-toggle:hover,
.mode-toggle:focus-visible {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  background-color: rgba(201, 151, 56, 0.08);
}

.app-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

.credits-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

.credits-page section {
  margin-bottom: 2rem;
}

.credits-page h2 {
  color: var(--accent-gold);
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.credits-page p {
  margin-bottom: 0.7rem;
  opacity: 0.9;
}

.credits-page code {
  color: var(--accent-gold);
  font-size: 0.9em;
}

.credits-page a {
  color: var(--accent-gold);
}

.credits-page a:hover {
  color: var(--text-color);
}

.book-intro {
  text-align: center;
  margin-bottom: 3.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}

.book-intro h2 {
  font-size: clamp(2rem, 4vw, 2.9rem);
  color: var(--accent-gold);
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.book-author {
  font-style: italic;
  font-size: 1.05rem;
  opacity: 0.85;
}

.book-note {
  margin-top: 0.9rem;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.55;
}

.comic-page {
  max-width: 920px;
  margin: 0 auto 4.5rem;
}

.page-title {
  font-size: 1.45rem;
  color: var(--accent-gold);
  margin-bottom: 1.1rem;
  padding-left: 0.65rem;
  border-left: 4px solid var(--accent-gold);
  letter-spacing: 0.02em;
}

.page-sheet {
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.45), transparent 55%),
    radial-gradient(circle at 80% 90%, rgba(120, 90, 50, 0.08), transparent 60%);
  border: 1px solid var(--paper-edge);
  padding: 20px;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.35) inset,
    0 24px 60px rgba(0, 0, 0, 0.5);
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.comic-panel {
  position: relative;
  container-type: inline-size;
  background-color: #0f0e0d;
  border: 2px solid var(--ink);
  min-width: 0;
}

.panel--large,
.panel--banner {
  grid-column: span 2;
}

.panel-frame {
  position: relative;
  width: 100%;
  overflow: visible;
}

.panel--large .panel-frame {
  aspect-ratio: 1344 / 576;
}

.panel--banner .panel-frame {
  aspect-ratio: 1536 / 512;
}

.panel--portrait .panel-frame {
  aspect-ratio: 768 / 1024;
}

.panel-frame img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.panel-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.panel-caption {
  position: absolute;
  width: var(--caption-w, 52%);
  max-width: calc(100% - 6%);
  padding: 0.42em 0.6em;
  background: var(--caption-bg);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
  font-size: clamp(0.62rem, 2.45cqw, 0.95rem);
  font-style: italic;
  line-height: 1.34;
  hyphens: auto;
  text-wrap: pretty;
}

.pos-tl {
  top: 3%;
  left: 3%;
}

.pos-tr {
  top: 3%;
  right: 3%;
}

.pos-bl {
  bottom: 3%;
  left: 3%;
}

.pos-br {
  bottom: 3%;
  right: 3%;
}

.speech-bubble {
  position: absolute;
  left: var(--bx, 50%);
  top: var(--by, 20%);
  width: var(--bw, 40%);
  max-width: calc(100% - 6%);
  transform: translate(-50%, -50%);
  padding: 0.5em 0.68em;
  background: var(--bubble-bg);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.3);
  font-size: clamp(0.62rem, 2.45cqw, 0.95rem);
  line-height: 1.32;
  hyphens: auto;
  text-wrap: pretty;
}

.bubble-speaker {
  display: block;
  color: var(--accent-red);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1.2;
  margin-bottom: 0.15em;
  text-transform: uppercase;
}

.bubble-text {
  display: block;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--bubble-bg);
  transform: rotate(45deg);
}

.tail-bl::after {
  bottom: -8px;
  left: 18px;
  border-bottom: 1.5px solid var(--ink);
  border-left: 1.5px solid var(--ink);
}

.tail-br::after {
  bottom: -8px;
  right: 18px;
  border-bottom: 1.5px solid var(--ink);
  border-right: 1.5px solid var(--ink);
}

.tail-tl::after {
  top: -8px;
  left: 18px;
  border-top: 1.5px solid var(--ink);
  border-left: 1.5px solid var(--ink);
}

.tail-tr::after {
  top: -8px;
  right: 18px;
  border-top: 1.5px solid var(--ink);
  border-right: 1.5px solid var(--ink);
}

/* Mode webtoon : lecture lineaire, texte sous l'image, aucun recadrage. */
body[data-mode="webtoon"] .app-shell {
  max-width: 760px;
  padding: 2rem 1.25rem 4rem;
}

body[data-mode="webtoon"] .book-intro {
  margin-bottom: 2.5rem;
}

body[data-mode="webtoon"] .comic-page {
  max-width: 720px;
  margin-bottom: 3rem;
}

body[data-mode="webtoon"] .page-sheet {
  background: transparent;
  border: 0;
  padding: 0;
  box-shadow: none;
}

body[data-mode="webtoon"] .panel-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

body[data-mode="webtoon"] .panel--large,
body[data-mode="webtoon"] .panel--banner {
  grid-column: auto;
}

body[data-mode="webtoon"] .comic-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

body[data-mode="webtoon"] .panel-frame {
  aspect-ratio: auto;
}

body[data-mode="webtoon"] .panel-frame img {
  height: auto;
}

body[data-mode="webtoon"] .panel-overlay {
  position: static;
  padding: 0.9rem 1rem 1.1rem;
  pointer-events: auto;
}

body[data-mode="webtoon"] .panel-caption,
body[data-mode="webtoon"] .speech-bubble {
  position: static;
  width: auto;
  max-width: none;
  transform: none;
  margin: 0 0 0.7rem;
  box-shadow: none;
  font-size: 0.95rem;
  line-height: 1.45;
}

body[data-mode="webtoon"] .panel-caption:last-child,
body[data-mode="webtoon"] .speech-bubble:last-child {
  margin-bottom: 0;
}

body[data-mode="webtoon"] .speech-bubble {
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
}

body[data-mode="webtoon"] .speech-bubble::after {
  display: none;
}

body[data-mode="webtoon"] .bubble-speaker {
  font-size: 0.72rem;
}

body[data-mode="webtoon"] .page-title {
  font-size: 1.2rem;
  margin-bottom: 0.9rem;
}

@media (max-width: 760px) {
  .site-header {
    padding: 0.9rem 1rem;
    flex-wrap: wrap;
  }

  .site-header h1 {
    font-size: 1.1rem;
  }

  .app-shell {
    padding: 1.75rem 1rem 3rem;
  }

  .book-intro {
    margin-bottom: 2.5rem;
  }

  .page-sheet {
    padding: 10px;
  }

  .panel-grid {
    gap: 8px;
  }

  .comic-page {
    margin-bottom: 3rem;
  }
}

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

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .site-header,
  .book-intro,
  .mode-toggle {
    display: none;
  }

  .app-shell {
    max-width: none;
    padding: 0;
  }

  .comic-page {
    max-width: none;
    margin: 0;
    page-break-after: always;
  }

  .page-sheet {
    border: 0;
    box-shadow: none;
  }
}
