.jchd-bookblock {
  --bb-accent: #3f7ff0;
  --bb-surface: #fff;
  --bb-surface-soft: #f3f7ff;
  --bb-text: #172238;
  --bb-muted: #66748a;
  --bb-border: rgba(23, 34, 56, .14);
  --bb-shadow: 0 18px 46px rgba(26, 46, 78, .1);
  width: 100%;
  color: var(--bb-text);
}

[data-theme="dark"] .jchd-bookblock,
[data-theme-preference="dark"] .jchd-bookblock,
.theme-dark .jchd-bookblock,
body.dark-mode .jchd-bookblock {
  --bb-surface: #171c27;
  --bb-surface-soft: #111827;
  --bb-text: #f5f7fb;
  --bb-muted: #aab4c5;
  --bb-border: rgba(151, 173, 207, .22);
  --bb-shadow: 0 20px 48px rgba(0, 0, 0, .3);
}

.jchd-bookblock__heading {
  position: relative;
  margin: 0 0 1.25rem;
  padding-left: 1.15rem;
  color: var(--bb-text);
  font-weight: 750;
  line-height: 1.15;
}

.jchd-bookblock__heading::before {
  position: absolute;
  inset: .08em auto .08em 0;
  width: 4px;
  border-radius: 999px;
  background: var(--bb-accent);
  content: "";
}

.jchd-bookblock__viewport {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--bb-border);
  border-radius: 22px;
  background: var(--bb-surface);
  box-shadow: var(--bb-shadow);
  perspective: 1800px;
  transform-style: preserve-3d;
  isolation: isolate;
}

.jchd-bookblock__page {
  display: grid;
  min-height: var(--bookblock-page-height, 390px);
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, .95fr);
  backface-visibility: hidden;
}

.jchd-bookblock__page[hidden] { display: none !important; }

.jchd-bookblock__page.is-revealing {
  animation: jchd-bookblock-reveal 1.30s cubic-bezier(.22, .72, .18, 1) both;
}

.jchd-bookblock__turn-sheet {
  position: absolute;
  z-index: 4;
  inset: 0;
  width: 100%;
  min-height: var(--bookblock-page-height, 390px);
  background: var(--bb-surface);
  pointer-events: none;
  transform: rotateY(0deg) translateZ(1px);
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform, filter, opacity;
}

.jchd-bookblock__turn-sheet::after {
  position: absolute;
  z-index: 6;
  inset: 0;
  background: linear-gradient(90deg, rgba(9, 20, 39, .02), rgba(9, 20, 39, .32));
  content: "";
  opacity: 0;
  pointer-events: none;
}

.jchd-bookblock__turn-sheet.is-turning-next {
  transform-origin: 0 50%;
}

.jchd-bookblock__turn-sheet.is-turning-prev {
  transform-origin: 100% 50%;
}

.jchd-bookblock__turn-sheet.is-turning-next.is-turning {
  animation: jchd-bookblock-turn-next 1.30s cubic-bezier(.42, .08, .22, 1) forwards;
}

.jchd-bookblock__turn-sheet.is-turning-prev.is-turning {
  animation: jchd-bookblock-turn-prev 1.30s cubic-bezier(.42, .08, .22, 1) forwards;
}

.jchd-bookblock__turn-sheet.is-turning::after {
  animation: jchd-bookblock-page-shadow 1.30s ease-in-out forwards;
}

.jchd-bookblock__content {
  display: flex;
  padding: clamp(1.5rem, 4vw, 3.5rem);
  flex-direction: column;
  justify-content: center;
}

.jchd-bookblock__eyebrow {
  margin-bottom: .8rem;
  color: var(--bb-accent);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.jchd-bookblock__title {
  margin: 0 0 1rem;
  color: var(--bb-text);
  font-size: clamp(1.65rem, 3vw, 2.65rem);
  font-weight: 760;
  line-height: 1.12;
}

.jchd-bookblock__intro,
.jchd-bookblock__body {
  color: var(--bb-muted);
  font-size: clamp(1rem, 1.4vw, 1.12rem);
  line-height: 1.7;
}

.jchd-bookblock__intro > :first-child,
.jchd-bookblock__body > :first-child { margin-top: 0; }
.jchd-bookblock__intro > :last-child,
.jchd-bookblock__body > :last-child { margin-bottom: 0; }

.jchd-bookblock__button { align-self: flex-start; margin-top: 1.4rem; }

.jchd-bookblock__visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  background: var(--bb-surface-soft);
}

.jchd-bookblock__visual img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  object-fit: contain !important;
  object-position: center center !important;
}

.jchd-bookblock__visual figcaption {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  padding: .8rem 1rem;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 12px;
  background: rgba(10, 24, 45, .78);
  color: #fff;
  backdrop-filter: blur(10px);
  flex-direction: column;
  gap: .2rem;
}

.jchd-bookblock__visual figcaption span { color: rgba(255, 255, 255, .78); font-size: .9rem; }

.jchd-bookblock__navigation {
  display: flex;
  margin-top: 1rem;
  align-items: center;
  justify-content: flex-end;
  gap: .75rem;
}

.jchd-bookblock__nav {
  display: grid;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--bb-border);
  border-radius: 50%;
  background: var(--bb-surface);
  color: var(--bb-accent);
  box-shadow: 0 8px 22px rgba(26, 46, 78, .1);
  cursor: pointer;
  place-items: center;
  transition: transform .2s ease, background-color .2s ease, color .2s ease;
}

.jchd-bookblock__nav:hover { background: var(--bb-accent); color: #fff; transform: translateY(-2px); }
.jchd-bookblock__nav:focus-visible { outline: 3px solid var(--bb-accent); outline-offset: 3px; }
.jchd-bookblock__status { min-width: 3.5rem; color: var(--bb-muted); text-align: center; font-variant-numeric: tabular-nums; }

@keyframes jchd-bookblock-reveal {
  0%, 34% { opacity: .72; transform: scale(.995); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes jchd-bookblock-turn-next {
  0% { opacity: 1; transform: rotateY(0deg) translateZ(1px); filter: brightness(1); }
  55% { opacity: 1; filter: brightness(.82); }
  100% { opacity: 0; transform: rotateY(-112deg) translateZ(1px); filter: brightness(.68); }
}

@keyframes jchd-bookblock-turn-prev {
  0% { opacity: 1; transform: rotateY(0deg) translateZ(1px); filter: brightness(1); }
  55% { opacity: 1; filter: brightness(.82); }
  100% { opacity: 0; transform: rotateY(112deg) translateZ(1px); filter: brightness(.68); }
}

@keyframes jchd-bookblock-page-shadow {
  0%, 100% { opacity: 0; }
  45%, 70% { opacity: 1; }
}

@media (max-width: 800px) {
  .jchd-bookblock__page { min-height: var(--bookblock-page-height, 0px); grid-template-columns: 1fr; }
  .jchd-bookblock__content { padding: 1.4rem; }
  .jchd-bookblock__visual { min-height: 240px; order: -1; aspect-ratio: 16 / 9; }
  .jchd-bookblock__viewport { border-radius: 17px; }
  .jchd-bookblock__navigation { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .jchd-bookblock__page.is-revealing { animation-duration: .42s; }
  .jchd-bookblock__turn-sheet.is-turning-next.is-turning,
  .jchd-bookblock__turn-sheet.is-turning-prev.is-turning,
  .jchd-bookblock__turn-sheet.is-turning::after { animation-duration: .42s; }
  .jchd-bookblock__nav { transition: none; }
}
