/* كتالوج الألوان — كتاب بيتقلّب بتأثير ثلاثي الأبعاد */
.cbook { max-width: 1000px; margin: 0 auto; }
.cbook__stage { perspective: 2400px; padding: 28px 0 46px; outline: none; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.book {
  --pw: min(400px, 42vw);
  --ph: calc(var(--pw) * 1.3518);
  --n: 3;
  position: relative; direction: ltr;
  width: calc(var(--pw) * 2); height: var(--ph);
  margin: 0 auto; transform-style: preserve-3d;
  transform: translateX(calc(var(--pw) / 2)) rotateX(6deg);
  transition: transform 1.1s var(--ease);
}
.book[data-cur="1"], .book[data-cur="2"] { transform: translateX(0) rotateX(4deg); }
.book[data-cur="3"] { transform: translateX(calc(var(--pw) / -2)) rotateX(6deg); }
.book::after { /* ظل الكتاب */
  content: ""; position: absolute; left: 4%; right: 4%; bottom: -34px; height: 36px; z-index: -1;
  background: radial-gradient(ellipse at center, rgba(7, 38, 59, .38), transparent 70%); filter: blur(6px);
  transform: translateZ(-40px);
}
.sheet {
  position: absolute; top: 0; left: 0; width: var(--pw); height: 100%;
  transform-origin: right center; transform-style: preserve-3d;
  transform: rotateY(0deg) translateZ(calc((var(--n) - var(--i)) * 1px));
  transition: transform 1.15s var(--ease);
}
.sheet.is-flipped { transform: rotateY(180deg) translateZ(calc(var(--i) * -1px)); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  overflow: hidden; background: #fff; direction: rtl;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.face--back { transform: rotateY(180deg); }
.face::after { /* ظل منطقة الكعب */
  content: ""; position: absolute; top: 0; bottom: 0; width: 18%; pointer-events: none;
}
.face--front::after { right: 0; background: linear-gradient(to left, rgba(0, 0, 0, .22), transparent); }
.face--back::after { left: 0; background: linear-gradient(to right, rgba(0, 0, 0, .22), transparent); }
.face--front { border-radius: 6px 0 0 6px; }
.face--back { border-radius: 0 6px 6px 0; }
.face img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.face__zoom {
  position: absolute; bottom: 12px; z-index: 2; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: rgba(13, 58, 88, .78); cursor: zoom-in;
  opacity: .55; transition: opacity .25s, transform .25s; backdrop-filter: blur(4px);
}
.face--front .face__zoom { left: 12px; }
.face--back .face__zoom { right: 12px; }
.face:hover .face__zoom, .face__zoom:focus-visible { opacity: 1; transform: scale(1.08); }

/* الغلاف الأمامي والخلفي */
.cover {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; text-align: center;
  padding: 9% 8% 8%; color: #fff;
  background: radial-gradient(120% 80% at 80% 0%, var(--navy-soft), var(--navy) 55%, var(--navy-deep));
}
.cover::before { content: ""; position: absolute; inset: 14px; border: 1.5px solid rgba(207, 169, 143, .55); border-radius: 4px; pointer-events: none; }
.cover__logo { background: var(--cream); border-radius: 12px; padding: 12px 18px; width: 82%; box-shadow: 0 10px 26px rgba(0, 0, 0, .25); position: relative; z-index: 1; }
.cover__logo img { width: 100%; height: auto; object-fit: contain; }
.cover__threads { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cover__threads path { fill: none; stroke-linecap: round; stroke-dasharray: 520; stroke-dashoffset: 520; animation: thread 6s var(--ease) infinite alternate; }
.cover__threads path:nth-child(1) { stroke: #cfa98f; stroke-width: 2.4; }
.cover__threads path:nth-child(2) { stroke: #74523f; stroke-width: 2.4; animation-delay: .6s; }
.cover__threads path:nth-child(3) { stroke: #fff; stroke-width: 1.6; opacity: .7; animation-delay: 1.2s; }
.cover__threads path:nth-child(4) { stroke: #1b5a85; stroke-width: 2.4; animation-delay: 1.8s; }
@keyframes thread { to { stroke-dashoffset: 0; } }
.cover__mid { position: relative; z-index: 1; }
.cover h3 { color: #fff; margin: 0 0 6px; font-size: clamp(1.4rem, 3.3vw, 2.3rem); font-weight: 800; letter-spacing: .5px; }
.cover p { margin: 0; color: var(--tan); font-size: clamp(.78rem, 1.5vw, 1rem); }
.cover__hint { position: relative; z-index: 1; font-size: clamp(.7rem, 1.3vw, .9rem); opacity: .85; display: inline-flex; gap: 8px; align-items: center; }
.cover__hint i { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(-6px); } }
.cover--back .cover__mid { line-height: 2; font-size: clamp(.78rem, 1.5vw, 1rem); }
.cover--back .cover__mid strong { display: block; color: var(--tan); font-size: clamp(.95rem, 2vw, 1.3rem); margin-bottom: 4px; }
.cover--back a { color: #fff; direction: ltr; unicode-bidi: embed; }

/* التحكم */
.cbook__ui { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 4px; }
.cbtn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer; font: inherit; font-weight: 700;
  padding: 10px 22px; border-radius: 999px; color: #fff; background: var(--navy); box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), background .25s, opacity .25s;
}
.cbtn:hover:not(:disabled) { background: var(--brown); transform: translateY(-2px); }
.cbtn:disabled { opacity: .35; cursor: default; }
.cbook__count { min-width: 150px; text-align: center; color: var(--navy); font-weight: 700; }
.cbook__thumbs { display: flex; justify-content: center; gap: 14px; margin-top: 26px; flex-wrap: wrap; }
.cthumb { border: 2px solid transparent; padding: 0; background: #fff; border-radius: 8px; overflow: hidden; width: 76px; cursor: pointer; box-shadow: var(--shadow-sm); transition: transform .3s var(--ease), border-color .3s; }
.cthumb img { display: block; width: 100%; height: auto; aspect-ratio: 1262 / 1706; object-fit: cover; }
.cthumb:hover { transform: translateY(-5px); }
.cthumb.is-on { border-color: var(--brown); }

/* كتاب الصفحة الواحدة — للموبايل الطولي */
.book--single { display: none; }
.book--single, .book.book--single[data-cur] { --pw: min(86vw, 370px); --n: 6; width: var(--pw); transform: rotateX(3deg); }
.book--single .face { border-radius: 8px; }
.book--single .face--front::after { width: 14%; }
.face--paper { background: linear-gradient(to right, #ece6da, #f7f3ea 30%, #f1ecdf); }
.face--paper::after { display: none; }
.book--single .face__zoom { left: auto; right: auto; inset-inline-start: 12px; }
@media (max-width: 760px) {
  .book--double { display: none; }
  .book--single { display: block; }
  .cbook__stage { overflow: hidden; padding: 22px 0 44px; }
  .cbook__thumbs { gap: 10px; margin-top: 18px; }
  .cthumb { width: 56px; }
  .cbtn { padding: 12px 18px; min-height: 46px; }
  .cbook__count { min-width: 110px; font-size: .95rem; }
}
@media (prefers-reduced-motion: reduce) {
  .book, .sheet { transition: none !important; }
  .cover__threads path { animation: none; stroke-dashoffset: 0; }
  .cover__hint i { animation: none; }
}

/* زرار تحميل الـ PDF */
.cdl { display: flex; justify-content: center; margin: -8px 0 6px; }
.cdl .btn { min-height: 50px; gap: 10px; }
.cdl small { opacity: .75; font-weight: 500; }
