/* ── case book overlay — fullscreen page-turn book ─────────── */
.cbo {
  position: fixed; inset: 0; z-index: 4000; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .45s ease;
  user-select: none; -webkit-user-select: none;
}
.cbo.open { opacity: 1; pointer-events: auto; }
.cbo__veil {
  position: absolute; inset: 0;
  background: rgba(10, 18, 12, .58);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
}
.cbo__stage {
  position: relative; perspective: 2600px; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  transform: translateY(10vh) scale(.55) rotateX(24deg); opacity: 0;
  transition: transform .75s cubic-bezier(.26, .9, .3, 1.02), opacity .5s ease;
}
.cbo.open .cbo__stage { transform: none; opacity: 1; }
.cbo__close {
  position: absolute; top: max(1rem, env(safe-area-inset-top)); right: max(1rem, env(safe-area-inset-right));
  z-index: 2; width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  isolation: isolate; overflow: hidden; background: transparent;
  color: #f1fff4; font-size: 1.3rem; line-height: 1;
  box-shadow: 0 4px 4px rgba(0,0,0,.25), 0 0 12px rgba(0,0,0,.12), 0 0 24px rgba(255,255,255,.08);
  transition: transform .2s ease;
}
.cbo__close::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; z-index: -2;
  -webkit-backdrop-filter: blur(4.5px) saturate(1.55) brightness(1.04);
  backdrop-filter: blur(4.5px) saturate(1.55) brightness(1.04);
}
.cbo__close::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; z-index: -1; pointer-events: none;
  background: rgba(255, 255, 255, .1);
  box-shadow: inset 2px 2px 2px 0 rgba(255,255,255,.35), inset -2px -2px 2px 0 rgba(255,255,255,.35);
}
.cbo__close:hover { transform: scale(1.08) rotate(90deg); }

/* the book itself */
.cbbook {
  position: relative; transform-style: preserve-3d;
  transition: transform .95s cubic-bezier(.45, .05, .28, 1);
  touch-action: pan-y; cursor: grab;
}
.cbbook.grabbing { cursor: grabbing; }
.cbbook::before {
  content: ""; position: absolute; left: 2%; right: 2%; bottom: -5.5%; height: 9%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(0, 0, 0, .5), transparent 72%);
  filter: blur(6px); z-index: 0; pointer-events: none;
}
.cbstack {
  position: absolute; top: .35%; height: 99.3%; width: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(to right, #fbfaf5 0 1.6px, #dedcd2 1.6px 2.6px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  transition: width .95s cubic-bezier(.45, .05, .28, 1), opacity .4s;
}
.cbstack--l { left: 0; transform: translateX(-100%); border-radius: 3px 0 0 3px; }
.cbstack--r { right: 0; transform: translateX(100%); border-radius: 0 3px 3px 0; }
.cbleaf {
  position: absolute; left: 50%; top: 0; width: 50%; height: 100%;
  transform-origin: left center; transform-style: preserve-3d;
  transition: transform .95s cubic-bezier(.45, .05, .28, 1);
  z-index: 10;
}
.cbleaf.turned { transform: rotateY(-180deg); }
.cbleaf.dragging { transition: none; }
.cbface {
  position: absolute; inset: 0; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: #f7f7f3;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.cbface--back { transform: rotateY(180deg); }
.cbface canvas { display: block; width: 100%; height: 100%; pointer-events: none; }
.cbface::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.cbface--front::after {
  background: linear-gradient(to right, rgba(20, 25, 18, .17), rgba(20, 25, 18, .045) 6%, transparent 11%),
              linear-gradient(to left, rgba(20, 25, 18, .08), transparent 3%);
}
.cbface--back::after {
  background: linear-gradient(to left, rgba(20, 25, 18, .17), rgba(20, 25, 18, .045) 6%, transparent 11%),
              linear-gradient(to right, rgba(20, 25, 18, .08), transparent 3%);
}
.cbshade {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  transition: opacity .5s ease;
}
.cbface--front .cbshade { background: linear-gradient(to left, rgba(0, 0, 0, .45), rgba(0, 0, 0, .07) 55%, transparent); }
.cbface--back .cbshade { background: linear-gradient(to right, rgba(0, 0, 0, .45), rgba(0, 0, 0, .07) 55%, transparent); }

/* mobile single page */
.cbsingle { position: relative; overflow: visible; perspective: 1500px; touch-action: pan-y; }
.cbsingle .cbpage {
  position: absolute; inset: 0; background: #f7f7f3; overflow: hidden;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
  transition: transform .45s cubic-bezier(.4, .1, .3, 1), opacity .45s;
  transform-origin: left center;
}
.cbsingle .cbpage.nodrift { transition: none; }
.cbsingle .cbpage canvas { display: block; width: 100%; height: 100%; pointer-events: none; }
.cbsingle .cbpage.out-l { transform: rotateY(-26deg) translateX(-16%); opacity: 0; }
.cbsingle .cbpage.out-r { transform: rotateY(14deg) translateX(13%); opacity: 0; }

/* controls — arrows retired (drag, tap and side-clicks turn the pages);
   the buttons stay in the DOM as hidden fallbacks for the key handlers */
.cbo__nav { display: none !important; }
.cbo__ctrls { display: flex; align-items: center; justify-content: center; gap: 1.1rem; margin-top: .9rem; }
.cbo__nav {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  position: relative; isolation: isolate; overflow: hidden; background: transparent;
  color: #f1fff4; font-size: 1.25rem; line-height: 1;
  box-shadow: 0 4px 4px rgba(0,0,0,.25), 0 0 12px rgba(0,0,0,.12), 0 0 24px rgba(255,255,255,.08);
  transition: transform .2s ease, opacity .3s;
}
.cbo__nav::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; z-index: -2;
  -webkit-backdrop-filter: blur(4.5px) saturate(1.55) brightness(1.04);
  backdrop-filter: blur(4.5px) saturate(1.55) brightness(1.04);
}
.cbo__nav::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; z-index: -1; pointer-events: none;
  background: rgba(255, 255, 255, .1);
  box-shadow: inset 2px 2px 2px 0 rgba(255,255,255,.35), inset -2px -2px 2px 0 rgba(255,255,255,.35);
}
.cbo__nav:hover { transform: scale(1.08); }
.cbo__nav:active { transform: scale(.95); }
.cbo__nav[disabled] { opacity: .35; cursor: default; transform: none; }
.cbo__count { font-size: .85rem; font-weight: 600; color: rgba(241, 255, 244, .85); min-width: 8.5rem; text-align: center; letter-spacing: .04em; }
