/* Petit livre de Maison Verte (livre.js) */
.book {
  --paper: #fdf8ea; --cover: var(--green-dark); --fold: #eadcb8;
  /* Patine : bords du papier très légèrement dorés */
  --aged: radial-gradient(ellipse at 50% 50%, transparent 62%, rgba(170, 125, 55, .10) 100%);
  width: min(980px, 100%); margin: 0 auto;
}

.bk-3d { position: relative; aspect-ratio: 980 / 690; perspective: 2400px; cursor: pointer; }
/* Couverture qui dépasse autour des pages */
.bk-3d::before {
  content: ""; position: absolute; inset: -14px -16px -18px; border-radius: 22px;
  background: var(--scales), var(--cover); box-shadow: 0 24px 50px rgba(47, 58, 42, .28);
}
/* Reliure au centre */
.bk-3d::after {
  content: ""; position: absolute; top: -14px; bottom: -18px; left: 50%; width: 22px; transform: translateX(-50%);
  background: linear-gradient(90deg, #2f5720, #4e8a35 50%, #2f5720); border-radius: 6px; z-index: 0;
}
/* Trait de couture au creux de la reliure, par-dessus les pages */
.bk-3d .bk-seam {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; transform: translateX(-50%); z-index: 60; pointer-events: none;
  background: linear-gradient(rgba(50, 35, 15, .45), rgba(50, 35, 15, .25) 50%, rgba(50, 35, 15, .45));
}

.bk-base, .bk-leaf { position: absolute; top: 0; width: 50%; height: 100%; z-index: 1; }
.bk-base-left { left: 0; }
.bk-base-right, .bk-leaf { left: 50%; }
.bk-leaf { transform-origin: left center; transform-style: preserve-3d; transition: transform 1.1s cubic-bezier(.645, .045, .355, 1); }
.bk-leaf.flipped { transform: rotateY(-180deg); }
.bk-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.bk-back { transform: rotateY(180deg); }
/* La face cachée ne doit pas capter la souris */
.bk-leaf.flipped .bk-front, .bk-leaf:not(.flipped) .bk-back { pointer-events: none; }

/* Pages */
.bk-page { position: relative; height: 100%; background: var(--paper); overflow: hidden; }
.bk-left {
  display: grid; place-items: center; align-content: center; gap: .6rem; padding: 6%;
  border-radius: 14px 4px 4px 14px;
  /* Pli de la reliure : ombre qui se creuse vers le centre du livre */
  background: linear-gradient(90deg, transparent 72%, rgba(90, 65, 30, .08) 86%, rgba(70, 50, 20, .22) 96%, rgba(50, 35, 15, .38)),
              var(--aged),
              radial-gradient(ellipse 42% 40% at 50% 46%, var(--pink) 0 98%, transparent 100%), var(--paper);
}
/* Petit logo en haut de chaque page de gauche */
.bk-left::before {
  content: ""; position: absolute; top: 5%; left: 6%; width: 46px; aspect-ratio: 1;
  background: url(img/logo.png) center / contain no-repeat; border-radius: 50%; opacity: .9;
}
.bk-left img { width: 72%; aspect-ratio: 300/335; object-fit: cover; border-radius: 48% 52% 30% 30% / 34% 34% 22% 22%; }
.bk-caption { margin: 0; font-family: "Caveat", cursive; font-size: clamp(1.2rem, 2.4vw, 1.7rem); color: var(--green-dark); }
.bk-right {
  display: flex; flex-direction: column; justify-content: center; padding: 8% 8% 6% 9%;
  border-radius: 4px 14px 14px 4px;
  background: linear-gradient(270deg, transparent 72%, rgba(90, 65, 30, .08) 86%, rgba(70, 50, 20, .22) 96%, rgba(50, 35, 15, .38)),
              var(--aged), var(--paper);
}
/* Coins du haut légèrement cornés */
.bk-left::after, .bk-right::after {
  content: ""; position: absolute; top: 0; width: 26px; height: 26px; pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(60, 45, 20, .18));
}
.bk-left::after { left: 0; background: linear-gradient(135deg, var(--cover) 50%, var(--fold) 50%); border-bottom-right-radius: 5px; }
.bk-right::after { right: 0; background: linear-gradient(225deg, var(--cover) 50%, var(--fold) 50%); border-bottom-left-radius: 5px; }
/* Épaisseur des pages sur les bords extérieurs */
.bk-base-left .bk-page { box-shadow: -2px 1px 0 #f3ead3, -4px 2px 0 #e4d7b6, -6px 3px 0 #f3ead3, -8px 4px 0 #ddd0ad; }
.bk-base-right .bk-page { box-shadow: 2px 1px 0 #f3ead3, 4px 2px 0 #e4d7b6, 6px 3px 0 #f3ead3, 8px 4px 0 #ddd0ad; }
.bk-right h3 { font-size: clamp(1.15rem, 2vw, 1.5rem); margin-bottom: .3em; }
.bk-right h3::after {
  content: ""; display: block; width: 84px; height: 11px; margin-top: .4em; background-color: var(--spine);
  -webkit-mask: var(--spines) repeat-x left bottom / 21px 11px; mask: var(--spines) repeat-x left bottom / 21px 11px;
}
.bk-right p { margin: 0; color: var(--ink); font-size: .86rem; line-height: 1.5; }
.bk-text { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.bk-text p + p { margin-top: .5em; }
.bk-right .bk-num { position: absolute; top: 5%; right: 8%; font-size: .8rem; font-weight: 700; color: var(--spine); letter-spacing: .1em; }

/* Coin de page : on le survole pour tourner */
.bk-corner { position: absolute; bottom: 0; width: 90px; height: 90px; z-index: 2; }
.bk-corner::before {
  content: ""; position: absolute; bottom: 0; width: 34px; height: 34px; transition: width .3s, height .3s;
  box-shadow: -3px -3px 8px rgba(47, 58, 42, .12);
}
.bk-corner-next { right: 0; }
.bk-corner-next::before { right: 0; background: linear-gradient(315deg, var(--cream) 50%, #efe6cc 50%); border-radius: 0 0 14px 0; }
.bk-corner-prev { left: 0; }
.bk-corner-prev::before { left: 0; background: linear-gradient(45deg, var(--cream) 50%, #efe6cc 50%); border-radius: 0 0 0 14px; box-shadow: 3px -3px 8px rgba(47, 58, 42, .12); }
.bk-corner:hover::before, .bk-3d:hover .bk-corner-next::before { width: 48px; height: 48px; }
.bk-leaf:last-of-type .bk-front .bk-corner-next::after,
.bk-leaf:first-of-type .bk-front .bk-corner-next::after {
  content: "Survolez-moi"; position: absolute; right: 54px; bottom: 12px; white-space: nowrap;
  font-family: "Caveat", cursive; font-size: 1.15rem; color: var(--spine);
}
.bk-leaf:last-of-type .bk-front .bk-corner-next::after { content: none; }

/* Navigation */
.bk-nav { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 2.4rem; }
.bk-nav > button {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--green); color: #fff;
  font-size: 1.2rem; cursor: pointer; transition: background .15s, opacity .15s;
}
.bk-nav > button:hover { background: var(--green-dark); }
.bk-nav > button:disabled { opacity: .3; cursor: default; }
.bk-dots { display: flex; gap: .5rem; }
.bk-dots button { width: 12px; height: 12px; padding: 0; border-radius: 50%; border: 2px solid var(--green); background: transparent; cursor: pointer; }
.bk-dots button.on { background: var(--green); }

/* Mobile : pages à faire défiler, image au-dessus du texte */
.bk-flat, .bk-hint-mob { display: none; }
@media (max-width: 1100px) {
  .bk-hint-desk { display: none; }
  .bk-hint-mob { display: inline; }
  .bk-3d { display: none; }
  .bk-flat { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; gap: 0; }
  .bk-flat::-webkit-scrollbar { display: none; }
  .bk-card { flex: 0 0 100%; scroll-snap-align: start; padding: 0 4px; --cover: var(--bg, var(--cream)); }
  .bk-card .bk-right { background-image: var(--aged); }
  .bk-card .bk-left { background-image: var(--aged), radial-gradient(ellipse 42% 40% at 50% 46%, var(--pink) 0 98%, transparent 100%); }
  .bk-card .bk-right::after { display: none; }
  .bk-card .bk-page { height: auto; border-radius: 0; }
  .bk-card .bk-left { border-radius: 18px 18px 0 0; padding: 1.4rem 1rem .6rem; }
  .bk-card .bk-left img { width: 55%; }
  .bk-card .bk-right { border-radius: 0 0 18px 18px; padding: 1rem 1.4rem 1.6rem; }
  .bk-card .bk-right p { font-size: 1rem; }
  .bk-card .bk-num { position: static; margin-bottom: .4rem; }
  .bk-nav { margin-top: 1.2rem; }
}
@media (prefers-reduced-motion: reduce) { .bk-leaf { transition: none; } }
