:root {
  --booklet-page-width: min(42vw, 540px);
  --booklet-width: calc(var(--booklet-page-width) * 2);
  --booklet-height: calc(var(--booklet-page-width) * 1.4244);
}

.booklet-section {
  --page-width: var(--booklet-page-width);
  --book-width: var(--booklet-width);
  --book-height: var(--booklet-height);
  --booklet-ink: #1b1b1b;
  --booklet-muted: #706a60;
  --booklet-shadow: rgba(18, 16, 12, 0.28);

  color: var(--booklet-ink);
  display: grid;
  gap: 18px;
  padding: 26px 18px 22px;
}

.booklet-section,
.booklet-section * {
  box-sizing: border-box;
}

.booklet-section button {
  font: inherit;
}

.booklet-section__header {
  width: min(100%, var(--book-width));
  margin: 0 auto 4px;
  text-align: center;
}

.booklet-section__title {
  margin: 0;
  color: var(--booklet-ink);
  font-size: clamp(1.5rem, 2.2vw, 2.35rem);
  font-weight: 700;
  line-height: 1.16;
}

.booklet-section__description {
  width: min(100%, 760px);
  margin: 10px auto 0;
  color: var(--booklet-muted);
  font-size: 1rem;
  line-height: 1.6;
}

.booklet-section__description p {
  margin: 0;
}

.booklet-section__description p + p {
  margin-top: 0.75em;
}

.booklet-section .stage {
  display: grid;
  place-items: center;
  perspective: 2200px;
}

.booklet-section .book-shell {
  position: relative;
  width: var(--book-width);
  height: var(--book-height);
  display: grid;
  place-items: center;
  filter: drop-shadow(0 26px 34px var(--booklet-shadow));
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
}

.booklet-section .book-gutter {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 20px);
  width: 40px;
  z-index: 9999;
  background:
    linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.06) 30%, rgba(0, 0, 0, 0.22) 49%, rgba(255, 255, 255, 0.5) 51%, rgba(255, 255, 255, 0.18) 66%, transparent 100%),
    linear-gradient(90deg, transparent 0%, transparent calc(50% - 1px), rgba(34, 27, 19, 0.28) 50%, transparent calc(50% + 1px), transparent 100%);
  opacity: 0.88;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.booklet-section .book-shell.is-turning .book-gutter {
  opacity: 0;
}

.booklet-section .book {
  position: relative;
  width: var(--book-width);
  height: var(--book-height);
  touch-action: pan-y;
  border-radius: 6px;
  overflow: hidden;
  background: #f7f2e9;
}

.booklet-section .book .page {
  position: relative;
  background: #fff;
  overflow: hidden;
}

.booklet-section .book .page::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.booklet-section .book .page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.booklet-section .book .even::after {
  background:
    linear-gradient(90deg, transparent 82%, rgba(0, 0, 0, 0.11) 96%, rgba(0, 0, 0, 0.2)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.16), transparent 22%);
}

.booklet-section .book .odd::after {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.11) 4%, transparent 18%),
    linear-gradient(90deg, transparent 78%, rgba(255, 255, 255, 0.14));
}

.booklet-section .fallback-message {
  width: min(92vw, 720px);
  padding: 18px 20px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 12px 28px rgba(36, 28, 18, 0.16);
  color: #33291f;
  line-height: 1.45;
  text-align: center;
}

.booklet-section .controls {
  width: min(100%, 560px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 46px 46px minmax(128px, 1fr) 46px 46px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 12px 28px rgba(36, 28, 18, 0.16);
  backdrop-filter: blur(14px);
}

.booklet-section .icon-button {
  width: 46px;
  height: 42px;
  border: 1px solid rgba(40, 30, 18, 0.18);
  border-radius: 7px;
  color: #221c15;
  background: #fffaf1;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, opacity 160ms ease;
}

.booklet-section .icon-button:hover:not(:disabled) {
  background: #ffffff;
  transform: translateY(-1px);
}

.booklet-section .icon-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.booklet-section .page-status {
  min-width: 0;
  color: var(--booklet-muted);
  font-size: 0.95rem;
  text-align: center;
  white-space: nowrap;
}

@media (max-width: 760px) {
  :root {
    --booklet-page-width: min(46vw, 320px);
  }

  .booklet-section {
    padding: 16px 10px 14px;
    gap: 12px;
  }

  .booklet-section__header {
    margin-bottom: 0;
  }

  .booklet-section .controls {
    grid-template-columns: 42px 42px minmax(92px, 1fr) 42px 42px;
    gap: 7px;
    padding: 8px;
  }

  .booklet-section .icon-button {
    width: 42px;
    height: 40px;
  }

  .booklet-section .page-status {
    font-size: 0.84rem;
  }
}
