/* "ليش معالي" open book (see book.js). Purple boards, cream paper with grain, mint ribbon, taped photos. */
.bk-host { height: auto !important; display: block !important; }
.bk-host > :not(.bk) { display: none !important; }

.bk { --cover: rgb(53, 13, 88); --paper: rgb(250, 248, 242); --ink: rgb(22, 22, 22);
  --mint: rgb(94, 234, 212); --purple: rgb(137, 11, 248);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .2 0 0 0 0 .1 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  position: relative; width: 100%; height: calc(var(--segs) * 95vh + 100vh); direction: ltr; }
.bk-stage { position: sticky; top: 84px; height: calc(100vh - 100px); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; }

/* Book */
.bk-book { position: relative; width: min(1180px, 94vw); aspect-ratio: 2 / 1.12; max-height: calc(100vh - 130px);
  background: var(--cover); border-radius: 28px; perspective: 2800px;
  box-shadow: 0 30px 60px rgba(53, 13, 88, .28), inset 0 0 0 3px rgba(255, 255, 255, .06); }
.bk-half, .bk-leaf { position: absolute; top: 16px; bottom: 16px; width: calc(50% - 16px); }
.bk-half--left, .bk-leaf { left: 16px; }
.bk-half--right { right: 16px; }
.bk-half { z-index: 2; }
.bk-leaf { transform-origin: right center; transform-style: preserve-3d; will-change: transform; }
.bk-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.bk-face--back { transform: rotateY(180deg); }

/* Shading while a page turns, and the shadow it casts */
.bk-shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; border-radius: inherit;
  background: linear-gradient(to left, rgba(53, 13, 88, .5), rgba(53, 13, 88, .08) 45%, rgba(255, 255, 255, .25) 80%, transparent); }
.bk-face--back .bk-shade { background: linear-gradient(to right, rgba(53, 13, 88, .5), rgba(53, 13, 88, .08) 45%, rgba(255, 255, 255, .25) 80%, transparent); }
.bk-cast { position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 5; }
.bk-half--right .bk-cast { background: linear-gradient(to right, rgba(53, 13, 88, .35), transparent 40%); }
.bk-half--left .bk-cast { background: linear-gradient(to left, rgba(53, 13, 88, .35), transparent 40%); }

/* Paper */
.bk-page { position: absolute; inset: 0; overflow: hidden; direction: rtl; display: flex; flex-direction: column; background-color: var(--paper); }
.bk-half--left .bk-page, .bk-leaf .bk-face--front .bk-page { border-radius: 14px 4px 4px 14px;
  background-image: linear-gradient(to left, rgba(53, 13, 88, .17), rgba(53, 13, 88, 0) 9%), var(--grain); }
.bk-half--right .bk-page, .bk-face--back .bk-page { border-radius: 4px 14px 14px 4px;
  background-image: linear-gradient(to right, rgba(53, 13, 88, .17), rgba(53, 13, 88, 0) 9%), var(--grain); }
.bk-leaf .bk-face { border-radius: 14px 4px 4px 14px; }
.bk-leaf .bk-face--back { border-radius: 4px 14px 14px 4px; }
.bk-spine { position: absolute; top: 8px; bottom: 8px; left: 50%; width: 8px; transform: translateX(-50%); z-index: 80;
  background: linear-gradient(to right, rgba(0, 0, 0, .3), rgba(255, 255, 255, .12), rgba(0, 0, 0, .3)); border-radius: 4px; pointer-events: none; }
.bk-edges { display: none; }
/* page block: a real photo of book page edges (gen_book_edges_photo.py) along each page's outer side */
.bk-half::before { content: ""; position: absolute; z-index: -1; top: 6px; bottom: 6px; width: 11px; pointer-events: none;
  background: linear-gradient(rgba(53, 13, 88, .14), rgba(53, 13, 88, 0) 6%, rgba(53, 13, 88, 0) 94%, rgba(53, 13, 88, .14)),
    var(--edge-img) center / 100% 100% no-repeat;
  box-shadow: var(--edge-line) 0 0 0 rgba(53, 13, 88, .45); }
.bk-half--left::before { --edge-img: url(/maali/book-edges-left.png); --edge-line: -1px; left: -10px; border-radius: 6px 0 0 6px; }
.bk-half--right::before { --edge-img: url(/maali/book-edges-right.png); --edge-line: 1px; right: -10px; border-radius: 0 6px 6px 0; }

/* Text page */
.bk-page--text { padding: clamp(46px, 5.4vw, 84px) clamp(28px, 4.4vw, 70px) clamp(26px, 3vw, 46px); gap: clamp(10px, 1.2vw, 18px); }
.bk-ribbon { position: absolute; top: -2px; right: clamp(22px, 3vw, 48px); width: 46px; padding: 14px 0 22px; text-align: center;
  background: var(--mint); color: var(--ink); font: 400 24px/1 Lalezar, sans-serif;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%); box-shadow: 0 4px 0 rgba(0, 0, 0, .05); }
.bk-kicker { margin: 0; font: 600 14px/1.4 "Readex Pro", sans-serif; color: var(--purple); }
.bk-title { margin: 0; font: 400 clamp(32px, 3.6vw, 58px)/1.15 Lalezar, sans-serif; color: var(--cover); }
.bk-points { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 12px;
  font: 400 clamp(15px, 1.35vw, 20px)/1.5 "Readex Pro", sans-serif; color: var(--ink); }
.bk-points li { display: flex; gap: 10px; align-items: baseline; transition: opacity .5s ease, transform .5s ease;
  transition-delay: calc(var(--k) * 90ms); }
.bk-points li::before { content: "✱"; color: var(--purple); }
.bk-stage .bk-page--text:not(.is-active) .bk-points li { opacity: .35; transform: translateX(-6px); }
.bk-cta { margin-top: auto; align-self: flex-start; display: inline-flex; align-items: center; gap: 12px;
  padding: 12px 22px; border-radius: 14px; background: var(--mint); color: var(--ink); text-decoration: none;
  border: 2px solid var(--ink); border-bottom-width: 5px; font: 700 17px/1 "Readex Pro", sans-serif; transition: transform .2s ease; }
.bk-cta:hover { transform: translateY(-2px); }
.bk-cta i { font-style: normal; font-size: 20px; }
.bk-folio { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center;
  font: 600 13px/1 "Readex Pro", sans-serif; color: rgba(53, 13, 88, .45); }

/* Image page: photo taped to the paper with a sticker on it */
.bk-page--image { padding: clamp(30px, 3.6vw, 56px); justify-content: center; }
.bk-photo { position: relative; margin: 0; flex: 1; min-height: 0; background: #fff; padding: 12px 12px 34px; border-radius: 6px;
  box-shadow: 0 14px 30px rgba(53, 13, 88, .16), 0 2px 4px rgba(53, 13, 88, .08); }
.bk-photo > img:first-child { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 3px; }
.bk-tape { position: absolute; width: 108px; height: 30px; opacity: .85; mix-blend-mode: multiply;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .25) 0 6px, transparent 6px 12px), var(--mint); }
.bk-tape--a { top: -12px; right: 14%; transform: rotate(4deg); }
.bk-tape--b { bottom: 10px; left: -22px; transform: rotate(-38deg); background-color: rgb(201, 168, 255); }
.bk-photo--1 .bk-tape--a { background-color: rgb(201, 168, 255); right: auto; left: 16%; transform: rotate(-5deg); }
.bk-photo--1 .bk-tape--b { background-color: var(--mint); left: auto; right: -20px; transform: rotate(36deg); }
.bk-sticker { position: absolute; width: clamp(80px, 8vw, 120px); bottom: -22px; right: -18px; transform: rotate(8deg);
  filter: drop-shadow(0 6px 10px rgba(53, 13, 88, .2)); }
.bk-photo--1 .bk-sticker { right: auto; left: -18px; transform: rotate(-8deg); }

/* Phones and reduced motion: single pages, no page turning */
.bk-list { display: none; }
@media (max-width: 820px), (prefers-reduced-motion: reduce) {
  .bk { height: auto; }
  .bk-stage { display: none; }
  .bk-list { display: grid; gap: 22px; direction: rtl; }
  .bk-sheet { background: var(--cover); border-radius: 24px; padding: 12px; display: grid; gap: 10px; }
  .bk-sheet .bk-page { position: relative; inset: auto; border-radius: 14px !important; background-image: var(--grain); }
  .bk-sheet .bk-page--image { aspect-ratio: 4 / 3; padding: 22px 18px 26px; }
  .bk-sheet .bk-page--text { padding: 70px 24px 30px; }
  .bk-sheet .bk-folio { display: none; }
}
