/* Le livre de mots : un carnet relié, ouvert à plat.
   Couverture en cuir (débord + coutures), deux pages de papier crème avec
   ombre de reliure, signets en ruban sur la tranche, vignettes pixel art. */

.panel.book-panel {
  width: min(calc(96vw - 140px), 1000px); margin-right: 130px; max-height: none; height: min(88vh, 660px);
  background: none; border: none; box-shadow: none; overflow: visible;
}

.book { position: relative; width: 100%; height: 100%; padding: 18px 22px 22px; }
.book > .ribbons { z-index: -1; }

/* couverture : cuir brun, grain, coutures dorées, ombre portée */
.book-cover {
  position: absolute; inset: 0; border-radius: 14px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 210, 160, 0.10), transparent 60%),
    repeating-radial-gradient(circle at 17% 31%, rgba(0, 0, 0, 0.06) 0 1px, transparent 1px 3px),
    linear-gradient(135deg, #6b3a24 0%, #4e2716 55%, #3a1c10 100%);
  box-shadow:
    inset 0 0 0 3px #2a120a, inset 0 0 0 7px rgba(240, 192, 74, 0.0),
    inset 0 2px 0 9px rgba(255, 220, 170, 0.06),
    0 30px 70px rgba(0, 0, 0, 0.7), 0 6px 0 #241008;
}
.book-cover::after {          /* surpiqûre dorée */
  content: ""; position: absolute; inset: 9px; border-radius: 9px;
  border: 2px dashed rgba(232, 184, 92, 0.45);
  pointer-events: none;
}

/* les deux pages */
.spread {
  position: relative; z-index: 1; height: 100%;
  display: grid; grid-template-columns: 1fr 26px 1fr;
  filter: drop-shadow(0 3px 0 #d8c8a4) drop-shadow(0 6px 0 #c8b48c);   /* épaisseur des feuilles */
  perspective: 1600px;
}
.page {
  position: relative; display: flex; flex-direction: column; min-height: 0;
  padding: 26px 30px 34px;
  color: #3a2a1c;
  background:
    repeating-linear-gradient(to bottom, transparent 0 31px, rgba(120, 150, 190, 0.18) 31px 32px),
    radial-gradient(ellipse at 50% 40%, #fbf4e2 0%, #f3e6c8 70%, #e8d6b0 100%);
}
.page-left { border-radius: 10px 0 0 10px; box-shadow: inset -26px 0 30px -18px rgba(90, 60, 30, 0.45); }
.page-right { border-radius: 0 10px 10px 0; box-shadow: inset 26px 0 30px -18px rgba(90, 60, 30, 0.45); }
.page-left::before {          /* marge rouge des cahiers */
  content: ""; position: absolute; top: 0; bottom: 0; left: 18px; width: 1px; background: rgba(200, 80, 70, 0.35);
}
.gutter {
  background: linear-gradient(to right, #c9b48a, #f3e6c8 30%, #f3e6c8 70%, #c9b48a);
  box-shadow: inset 0 0 12px rgba(80, 50, 20, 0.35);
}

/* animation de page tournée */
.spread.turn-next .page-right, .spread.turn-prev .page-left { animation: page-in 0.38s ease-out both; }
.spread.turn-next .page-left, .spread.turn-prev .page-right { animation: page-fade 0.38s ease-out both; }
.spread.turn-next .page-right { transform-origin: left center; }
.spread.turn-prev .page-left { transform-origin: right center; --flip: -1; }
@keyframes page-in {
  0% { transform: rotateY(calc(var(--flip, 1) * -78deg)); filter: brightness(0.75); }
  100% { transform: none; filter: none; }
}
@keyframes page-fade { 0% { opacity: 0.4; } 100% { opacity: 1; } }

/* titre de chapitre */
.chapter { margin: 0 0 12px 6px; }
.chapter-num { font-family: var(--serif); font-style: italic; font-size: 0.85em; color: #8a5a2c; letter-spacing: 0.08em; }
.chapter-title {
  margin: 0.1em 0 0.25em; font-family: var(--pixel); font-size: 1.7em; font-weight: normal;
  color: #2e1f14; word-spacing: 0.3em;
}
.chapter-sub { display: flex; align-items: center; gap: 0.7em; font-family: var(--serif); font-size: 0.82em; color: #6a5038; }
.chapter-bar { flex: 1; max-width: 180px; height: 7px; border-radius: 4px; background: rgba(90, 60, 30, 0.18); overflow: hidden; }
.chapter-bar i { display: block; height: 100%; background: linear-gradient(90deg, #c9852f, #e8b85c); }
.stamp {
  position: absolute; top: 22px; right: 22px; transform: rotate(8deg);
  padding: 0.25em 0.6em; border: 3px double #b8372e; border-radius: 6px;
  color: #b8372e; font-family: var(--pixel); font-size: 0.9em; opacity: 0.85; word-spacing: 0.3em;
}

/* les entrées : vignette + mot appris + traduction */
.entries {
  flex: 1; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; align-content: start;
  padding: 2px 4px 4px 8px;
}
.entries::-webkit-scrollbar { width: 6px; }
.entries::-webkit-scrollbar-thumb { background: rgba(120, 80, 40, 0.3); border-radius: 3px; }
.entry {
  position: relative; display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 4px 6px; border: none; border-radius: 6px; background: none; text-align: left;
  font: inherit; color: inherit; cursor: default;
}
.entry.got { cursor: pointer; }
.entry.got:hover { background: rgba(232, 184, 92, 0.18); }
.entry-pic {
  flex: none; width: 68px; height: 68px; display: grid; place-items: center;
  border-radius: 6px; background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 0 0 2px rgba(120, 85, 50, 0.25);
}
.entry.got .entry-pic { transform: rotate(-2deg); box-shadow: inset 0 0 0 2px rgba(120, 85, 50, 0.35), 2px 3px 0 rgba(90, 60, 30, 0.15); }
.entry:nth-child(even).got .entry-pic { transform: rotate(2deg); }
.entry-pic canvas.pix { image-rendering: pixelated; width: 64px; height: 64px; }
.entry-words { display: flex; flex-direction: column; min-width: 0; }
.entry-target {
  font-family: var(--pixel); font-weight: normal; font-size: 1.32em; color: #23170e; word-spacing: 0.3em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-decoration: underline; text-decoration-color: var(--ink, transparent); text-decoration-thickness: 3px; text-underline-offset: 3px;
}
.entry-native { font-family: var(--serif); font-size: 0.95em; color: #7a5e44; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry.missing .entry-target { color: rgba(90, 65, 40, 0.4); letter-spacing: 0.1em; }
.entry-say { position: absolute; right: 8px; top: 6px; color: #b8772e; font-size: 0.9em; opacity: 0; transition: opacity 0.15s; }
.entry.got:hover .entry-say { opacity: 1; }
.entry-num { position: absolute; left: -2px; top: 2px; font-family: var(--serif); font-size: 0.62em; color: rgba(120, 85, 50, 0.55); }

.folio { margin-top: 8px; text-align: center; font-family: var(--serif); font-style: italic; font-size: 0.8em; color: #9a7a58; }

/* signets en ruban sur la tranche droite */
.ribbons { position: absolute; right: -138px; top: 54px; z-index: 0; display: flex; flex-direction: column; gap: 8px; }
.ribbon {
  position: relative; display: flex; flex-direction: column; align-items: flex-end;
  width: 150px; padding: 7px 26px 7px 12px; white-space: nowrap; border: none; cursor: pointer;
  background: color-mix(in srgb, var(--accent) 80%, #2a1a10);
  clip-path: polygon(0 0, 100% 0, 88% 50%, 100% 100%, 0 100%);
  color: #fff8e8; font-family: var(--pixel); font-size: 0.78em; text-align: right; word-spacing: 0.25em;
  transform: translateX(-34px); transition: transform 0.15s; filter: brightness(0.82);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}
.ribbon:hover { transform: translateX(-24px); filter: none; }
.ribbon.on { transform: translateX(-10px); background: var(--accent); filter: none; }
.ribbon-count { font-size: 0.85em; opacity: 0.85; }

/* flèches, fermeture, aide */
.turn {
  position: absolute; top: 50%; z-index: 3; transform: translateY(-50%);
  width: 34px; height: 54px; border: none; border-radius: 8px; cursor: pointer;
  background: rgba(42, 18, 10, 0.75); color: #f0c04a; font-size: 1em;
}
.turn:hover { background: rgba(70, 30, 16, 0.95); }
.turn-l { left: -12px; }
.turn-r { right: -12px; }
.book-close { position: absolute; top: -12px; right: 18px; z-index: 3; border: none; background: none; cursor: pointer; }
.book-close kbd { background: #f0c04a; color: #2a1a10; border-radius: 6px; padding: 0.2em 0.55em; font-family: var(--pixel); box-shadow: 0 3px 0 #8a5a1c; }
.book-hint { position: absolute; left: 0; right: 0; bottom: -26px; text-align: center; font-family: var(--pixel); font-size: 0.78em; color: rgba(240, 230, 210, 0.75); word-spacing: 0.3em; }

@media (max-width: 760px) {
  .spread { grid-template-columns: 1fr; }
  .gutter, .page-right .folio { display: none; }
  .page-left, .page-right { border-radius: 10px; }
  .ribbons { display: none; }
}

/* chapitres longs (nombres : 23 mots) : entrées plus serrées pour tout faire tenir */
.spread.dense .entries { gap: 4px 12px; }
.spread.dense .entry-pic { width: 52px; height: 52px; }
.spread.dense .entry-pic canvas.pix { width: 48px; height: 48px; }
.spread.dense .entry-target { font-size: 1.12em; }
.spread.dense .entry-native { font-size: 0.85em; }
