/* PDF flipbook for the Digital Product Book resource page. Loaded only on that
   page via the master template's extra_head block. Uses the site design tokens
   defined on :root in styles.css. */

.flipbook {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}

.flipbook__stage {
  position: relative;
  width: 100%;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px clamp(8px, 3vw, 40px);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(45, 181, 218, .12), transparent 60%),
    linear-gradient(180deg, #eaf4fa, #dfeef6);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Centre gutter shadow so the spread reads like a bound book. The explicit
   width gives StPageFlip's stretch mode a box to measure against. */
.flipbook__book {
  position: relative;
  width: 100%;
  max-width: 100%;
}

.flipbook__book::after {
  content: "";
  position: absolute;
  inset: 0;
  left: 50%;
  width: 40px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(13, 49, 72, .18), transparent);
  pointer-events: none;
  z-index: 3;
}

.flipbook .page {
  background: var(--white);
}

.flipbook .page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
}

/* Loading state */
.flipbook__loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--cobalt);
  font-weight: 500;
}

.flipbook__loader p {
  margin: 0;
  color: var(--muted);
}

.flipbook__spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(0, 114, 188, .18);
  border-top-color: var(--cobalt);
  animation: flipbook-spin .8s linear infinite;
}

@keyframes flipbook-spin {
  to { transform: rotate(360deg); }
}

.flipbook.is-ready .flipbook__loader {
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
}

.flipbook.is-error .flipbook__spinner {
  display: none;
}

/* Controls */
.flipbook__controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.flipbook__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--cobalt);
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
}

.flipbook__btn:hover {
  background: var(--cobalt);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(0, 114, 188, .28);
}

.flipbook__btn:disabled {
  opacity: .4;
  cursor: default;
  transform: none;
  box-shadow: none;
  background: var(--white);
  color: var(--grey);
}

.flipbook__btn--ghost {
  background: transparent;
}

.flipbook__page {
  min-width: 74px;
  text-align: center;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .01em;
}

/* Fullscreen */
.flipbook:fullscreen,
.flipbook:-webkit-full-screen {
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #0b2233, #06131d);
}

.flipbook:fullscreen .flipbook__stage {
  flex: 1;
  width: 100%;
}

.flipbook:fullscreen .flipbook__page {
  color: var(--white);
}

@media (max-width: 640px) {
  .flipbook__stage {
    min-height: 320px;
    padding: 18px 8px;
  }
}
