/* ============================================================
   Storybook Flipbook - minimal neutral styling
   Designed to blend into any WordPress theme when iframed.
   ============================================================ */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height for mobile browsers */
  display: flex;
  flex-direction: column;
  overflow: hidden; /* prevent page scroll - everything must fit */
  background: radial-gradient(ellipse at 50% 30%, #2a2438 0%, #17141f 70%); /* dark halloween night */
  color: #d8d2e0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

/* ----- Title ----- */
.site-header {
  text-align: center;
  padding: 0.75rem 1rem 0.25rem;
  flex-shrink: 0;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ----- Flipbook stage ----- */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.5rem;
  overflow: hidden;
}

/* js/flipbook.js sizes this box to fit the screen before init
   (StPageFlip "stretch" mode sizes the book from its width).
   These values are only a pre-JS fallback. */
.book-wrap {
  width: min(96vw, 1150px);
  height: min(72vh, 780px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#book { margin: 0 auto; }

/* Audio unlock overlay - covers the book until first tap/click.
   Browsers block audio autoplay, so this prompts the reader to interact.
   Sized by JS to match the book exactly. */
.book-wrap { position: relative; }

.audio-overlay {
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(23, 20, 31, 0.85);
  border-radius: 4px;
  cursor: pointer;
  z-index: 9999;
  transition: opacity 0.3s ease;
  pointer-events: auto;
}

.audio-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Text is positioned by JS (left %) so it sits over the visible page:
   75% on the front cover (right half), 25% on the back cover (left half),
   50% on two-page spreads. */
.audio-overlay-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 42%;
  text-align: center;
  font-size: 1.1rem;
  color: #d8d2e0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Soft shadow around the book (StPageFlip adds .stf__parent to #book) */
.stf__parent {
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.55);
  border-radius: 4px;
}

/* ----- Pages ----- */
.page {
  background: #fff;
  overflow: hidden;
}

.page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;       /* let StPageFlip handle the drag, not the image */
  -webkit-user-drag: none;
  user-select: none;
}

/* Shown if the CDN library fails to load */
.load-error {
  padding: 2rem;
  text-align: center;
  color: #9a92ad;
}

/* ----- Controls ----- */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem 0.75rem;
  flex-shrink: 0;
}

/* "Rotate your phone" hint - only on narrow portrait phones.
   The book always uses two-page view so spreads never split;
   on a portrait phone that just means the book is smaller. */
.rotate-hint {
  display: none;
  flex-basis: 100%;
  margin: 0 0 0.25rem;
  order: -1; /* sit above the buttons */
  text-align: center;
  font-size: 0.8rem;
  color: #9a92ad;
}

@media (max-width: 520px) and (orientation: portrait) {
  .rotate-hint { display: block; }
}

.ctl {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #453d5c;
  background: #241f33;
  color: #d8d2e0;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation; /* prevent double-tap zoom on buttons */
  transition: background 0.15s ease, transform 0.1s ease;
}

.ctl:hover { background: #322a47; }
.ctl:active { transform: scale(0.94); }
.ctl:focus-visible {
  outline: 2px solid #7a6f9e;
  outline-offset: 2px;
}

.page-indicator {
  min-width: 4.5em;
  text-align: center;
  font-size: 0.9rem;
  color: #9a92ad;
  font-variant-numeric: tabular-nums;
}
