/* ═══════════════════════════════════════════════════════════════════════════════
   BOOK 3D MOCKUP v2 — Premium CSS-based 3D book effect
   True 3D depth with spine, page edges, lighting, and hover interactions.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Container: sets perspective ── */
.book-3d {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  perspective: 800px;
  position: relative;
}

/* ── Inner book: the 3D-rotated wrapper ── */
.book-3d__inner {
  position: relative;
  transform-style: preserve-3d;
  transform: rotateY(-20deg) rotateX(2deg);
  transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1);
  border-radius: 3px 8px 8px 3px;
}

/* ── Cover: front face with the product image ── */
.book-3d__cover {
  position: relative;
  overflow: hidden;
  border-radius: 2px 6px 6px 2px;
  z-index: 2;
  backface-visibility: hidden;
}

.book-3d__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2px 6px 6px 2px;
}

/* ── Spine: TRUE 3D left edge with depth ── */
.book-3d__spine {
  position: absolute;
  top: 0;
  left: -1px;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  border-radius: 2px 6px 6px 2px;
  /* Rich gradient simulating spine lighting */
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.7) 0%,
    rgba(0, 0, 0, 0.4) 2.5%,
    rgba(0, 0, 0, 0.18) 5%,
    rgba(255, 255, 255, 0.04) 8%,
    transparent 16%,
    transparent 84%,
    rgba(0, 0, 0, 0.03) 100%
  );
}

/* Spine highlight edge — simulates light catching the raised edge */
.book-3d__spine::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.15) 0%,
    rgba(255, 255, 255, 0.06) 30%,
    rgba(255, 255, 255, 0.02) 60%,
    rgba(0, 0, 0, 0.2) 100%
  );
  border-radius: 2px 0 0 2px;
}

/* Inner spine crease line */
.book-3d__spine::after {
  content: '';
  position: absolute;
  top: 2%;
  left: 4px;
  width: 1px;
  height: 96%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 20%,
    rgba(255, 255, 255, 0.03) 80%,
    transparent 100%
  );
}

/* ── Shine: multi-layer light reflection across the cover ── */
.book-3d__shine {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border-radius: 2px 6px 6px 2px;
  /* Primary diagonal light sweep */
  background:
    linear-gradient(
      125deg,
      rgba(255, 255, 255, 0.18) 0%,
      rgba(255, 255, 255, 0.06) 15%,
      transparent 40%,
      transparent 65%,
      rgba(255, 255, 255, 0.03) 85%,
      rgba(255, 255, 255, 0.08) 100%
    );
  opacity: 0.85;
  transition: opacity 0.4s ease, background 0.4s ease;
}

/* ── Pages: right-side page edges with paper texture ── */
.book-3d__inner::after {
  content: '';
  position: absolute;
  top: 3px;
  right: -6px;
  width: 7px;
  bottom: 3px;
  z-index: 1;
  transform: rotateY(15deg);
  transform-origin: left center;
  /* Dark paper stripe texture */
  background:
    repeating-linear-gradient(
      180deg,
      #3a3832 0px,
      #3a3832 1px,
      #332f2b 1px,
      #332f2b 2px,
      #3d3935 2px,
      #3d3935 3px
    );
  border-radius: 0 2px 2px 0;
  box-shadow:
    2px 0 6px rgba(0, 0, 0, 0.35),
    1px 0 2px rgba(0, 0, 0, 0.2);
}

/* ── Bottom page edges ── */
.book-3d__inner::before {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 6px;
  right: 2px;
  height: 6px;
  z-index: 0;
  /* Dark bottom page stripe texture */
  background:
    repeating-linear-gradient(
      90deg,
      #35322d 0px,
      #35322d 1px,
      #2d2b27 1px,
      #2d2b27 2px,
      #38352f 2px,
      #38352f 3px
    );
  border-radius: 0 0 3px 3px;
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ── Shadow underneath: multi-layer realistic shadow ── */
.book-3d__shadow {
  position: absolute;
  bottom: -12px;
  left: 8%;
  right: 8%;
  height: 16px;
  z-index: -1;
  /* Contact shadow + ambient */
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(0, 0, 0, 0.5) 0%,
    rgba(0, 0, 0, 0.2) 35%,
    rgba(0, 0, 0, 0.05) 60%,
    transparent 80%
  );
  filter: blur(6px);
  transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   HOVER EFFECTS — Book opens toward viewer with teal ambient glow
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Card-level hover: rotate book towards viewer */
.book-3d--hover:hover .book-3d__inner,
.card:hover .book-3d__inner,
.p-card:hover .book-3d__inner,
.bs-item:hover .book-3d__inner,
.combo-card:hover .book-3d__inner {
  transform: rotateY(-6deg) rotateX(1deg);
}

/* Enhanced shine on hover — light shifts */
.book-3d--hover:hover .book-3d__shine,
.card:hover .book-3d__shine,
.p-card:hover .book-3d__shine,
.bs-item:hover .book-3d__shine {
  opacity: 1;
  background:
    linear-gradient(
      115deg,
      rgba(255, 255, 255, 0.25) 0%,
      rgba(255, 255, 255, 0.08) 20%,
      transparent 45%,
      transparent 70%,
      rgba(0, 212, 212, 0.06) 90%,
      rgba(0, 212, 212, 0.1) 100%
    );
}

/* Shadow expands on hover */
.book-3d--hover:hover .book-3d__shadow,
.card:hover .book-3d__shadow,
.p-card:hover .book-3d__shadow {
  bottom: -16px;
  left: 4%;
  right: 4%;
  height: 20px;
  filter: blur(8px);
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(0, 212, 212, 0.15) 0%,
    rgba(0, 0, 0, 0.35) 25%,
    rgba(0, 0, 0, 0.12) 50%,
    transparent 80%
  );
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SIZE VARIANTS
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── XS: tiny thumbnails (combo list, cart mini) ── */
.book-3d--xs .book-3d__inner {
  transform: rotateY(-14deg);
}
.book-3d--xs .book-3d__cover {
  width: 24px;
  height: 32px;
}
.book-3d--xs .book-3d__inner::after {
  width: 3px;
  right: -2px;
  top: 2px;
  bottom: 2px;
}
.book-3d--xs .book-3d__inner::before {
  height: 2px;
  bottom: -1px;
  left: 3px;
}
.book-3d--xs .book-3d__spine::before {
  width: 2px;
}
.book-3d--xs .book-3d__spine::after {
  display: none;
}
.book-3d--xs .book-3d__shadow {
  display: none;
}
.book-3d--xs .book-3d__inner {
  box-shadow:
    -3px 1px 6px rgba(0, 0, 0, 0.5),
    0 4px 10px -2px rgba(0, 0, 0, 0.45);
}

/* ── SM: bestseller covers, cart items, combo books ── */
.book-3d--sm .book-3d__cover {
  width: 42px;
  height: 58px;
}
.book-3d--sm .book-3d__inner {
  transform: rotateY(-16deg);
  box-shadow:
    -5px 2px 10px rgba(0, 0, 0, 0.5),
    0 8px 20px -3px rgba(0, 0, 0, 0.5),
    0 0 15px rgba(0, 212, 212, 0.04);
}
.book-3d--sm .book-3d__inner::after {
  width: 4px;
  right: -3px;
  top: 2px;
  bottom: 2px;
}
.book-3d--sm .book-3d__inner::before {
  height: 4px;
  bottom: -2px;
  left: 4px;
}
.book-3d--sm .book-3d__shadow {
  display: none;
}

/* ── MD: product cards (default) ── */
.book-3d--md .book-3d__cover {
  width: 130px;
  height: 173px;
}
.book-3d--md {
  padding: 14px 10px 18px;
}
.book-3d--md .book-3d__inner {
  box-shadow:
    -8px 3px 14px rgba(0, 0, 0, 0.55),
    0 14px 32px -5px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(0, 212, 212, 0.06),
    /* Subtle teal rim glow */
    inset 0 0 0 0.5px rgba(0, 212, 212, 0.08);
}

/* ── CAT: category page product cards ── */
.book-3d--cat .book-3d__cover {
  width: 110px;
  height: 147px;
}
.book-3d--cat {
  padding: 12px 8px 16px;
}
.book-3d--cat .book-3d__inner {
  box-shadow:
    -7px 3px 12px rgba(0, 0, 0, 0.5),
    0 12px 28px -4px rgba(0, 0, 0, 0.48),
    0 0 24px rgba(0, 212, 212, 0.05);
}

/* ── LG: featured section, product detail ── */
.book-3d--lg .book-3d__cover {
  width: 190px;
  height: 253px;
}
.book-3d--lg .book-3d__inner {
  box-shadow:
    -10px 5px 22px rgba(0, 0, 0, 0.6),
    0 18px 48px -6px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(0, 212, 212, 0.1),
    0 0 120px rgba(0, 212, 212, 0.04);
}
.book-3d--lg .book-3d__inner::after {
  width: 9px;
  right: -7px;
  top: 4px;
  bottom: 4px;
}
.book-3d--lg .book-3d__inner::before {
  height: 8px;
  bottom: -5px;
  left: 8px;
}
.book-3d--lg .book-3d__shadow {
  bottom: -16px;
  height: 22px;
  left: 6%;
  right: 6%;
  filter: blur(8px);
}
.book-3d--lg {
  padding: 20px 16px 28px;
}

/* ── XL: product detail hero ── */
.book-3d--xl .book-3d__cover {
  width: 240px;
  height: 320px;
}
.book-3d--xl .book-3d__inner {
  box-shadow:
    -12px 6px 28px rgba(0, 0, 0, 0.6),
    0 24px 56px -8px rgba(0, 0, 0, 0.55),
    0 0 80px rgba(0, 212, 212, 0.12),
    0 0 160px rgba(0, 212, 212, 0.05);
}
.book-3d--xl .book-3d__inner::after {
  width: 11px;
  right: -9px;
  top: 5px;
  bottom: 5px;
}
.book-3d--xl .book-3d__inner::before {
  height: 10px;
  bottom: -6px;
  left: 10px;
}
.book-3d--xl .book-3d__shadow {
  bottom: -20px;
  height: 26px;
  left: 5%;
  right: 5%;
  filter: blur(10px);
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(0, 212, 212, 0.08) 0%,
    rgba(0, 0, 0, 0.45) 15%,
    rgba(0, 0, 0, 0.15) 45%,
    transparent 75%
  );
}
.book-3d--xl {
  padding: 24px 20px 34px;
}

/* ── COMBO: special size for combo section books ── */
.book-3d--combo .book-3d__cover {
  width: 64px;
  height: 86px;
}
.book-3d--combo .book-3d__inner {
  transform: rotateY(-14deg);
  box-shadow:
    -5px 2px 12px rgba(0, 0, 0, 0.55),
    0 10px 24px -3px rgba(0, 0, 0, 0.5);
}
.book-3d--combo .book-3d__inner::after {
  width: 5px;
  right: -4px;
  top: 3px;
  bottom: 3px;
}
.book-3d--combo .book-3d__inner::before {
  height: 4px;
  bottom: -2px;
  left: 5px;
}
.book-3d--combo .book-3d__shadow {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   INTEGRATION OVERRIDES
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Card thumb: use book-3d as the thumbnail content */
.card-thumb .book-3d,
.p-thumb .book-3d {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Featured section override */
.feat-cover .book-3d {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Bestseller cover override */
.bs-cover.book-3d-wrap {
  background: transparent !important;
  border: none !important;
  overflow: visible;
}

/* Cart thumb override */
.u-thumb .book-3d,
.r-thumb .book-3d {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Combo book override — make book-3d work inside combo positions */
.combo-book .book-3d {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.combo-book .book-3d__cover {
  width: 100% !important;
  height: 100% !important;
}
.combo-book .book-3d__inner {
  transform: rotateY(-10deg);
}
.combo-book .book-3d__shadow {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .book-3d--md .book-3d__cover {
    width: 110px;
    height: 147px;
  }
  .book-3d--lg .book-3d__cover {
    width: 150px;
    height: 200px;
  }
  .book-3d--xl .book-3d__cover {
    width: 180px;
    height: 240px;
  }
}

@media (max-width: 480px) {
  .book-3d--md .book-3d__cover {
    width: 90px;
    height: 120px;
  }
  .book-3d--lg .book-3d__cover {
    width: 120px;
    height: 160px;
  }
  .book-3d--xl .book-3d__cover {
    width: 150px;
    height: 200px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ANIMATION: Gentle float for featured/hero books
   ═══════════════════════════════════════════════════════════════════════════════ */

@keyframes book3dFloat {
  0%, 100% {
    transform: translateY(0) rotateZ(0deg);
  }
  50% {
    transform: translateY(-8px) rotateZ(0.5deg);
  }
}

.book-3d--float {
  animation: book3dFloat 4s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TEAL AMBIENT GLOW — Subtle glow for dark theme integration
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Featured/XL books get a subtle ambient teal glow around them */
.book-3d--lg::after,
.book-3d--xl::after {
  content: '';
  position: absolute;
  inset: -20px;
  z-index: -2;
  background: radial-gradient(
    ellipse at 50% 50%,
    rgba(0, 212, 212, 0.06) 0%,
    transparent 65%
  );
  pointer-events: none;
  transition: opacity 0.4s ease;
  opacity: 0.7;
}

.card:hover .book-3d--md::after,
.p-card:hover .book-3d--cat::after {
  content: '';
  position: absolute;
  inset: -12px;
  z-index: -2;
  background: radial-gradient(
    ellipse at 50% 60%,
    rgba(0, 212, 212, 0.08) 0%,
    transparent 60%
  );
  pointer-events: none;
  opacity: 1;
}
