@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&display=swap");

:root {
  --ui-font: "Montserrat", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --charcoal: #2E2E2E;
  --gold: #CBA135;

  html,
  body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
  }

  #flipbook-container {
    position: fixed;
    inset: 0;
  }

  --stage-table: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/highlights/tabletop.webp");
  --stage-parquet: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/highlights/parquet.webp");
  --stage-kitchen: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/highlights/marble-kitchen.webp");
  --stage-basement: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/highlights/ginnys-basement-carpet.webp");
  --stage-lawn: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/highlights/lawn.webp");
  --stage-cancun: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/highlights/cancun-waters.webp");

  --book-frame: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/highlights/smith-book-frame.webp");
}

body,
button,
input {
  font-family: var(--ui-font);
}

/* ----------------------------
   Stage
---------------------------- */
#flipbook-stage {
  position: relative;
  inset: 0;
  width: 100vw;
  height: 100vh;
  padding: 15px 15px 120px;
  box-sizing: border-box;
  background: var(--stage-img, var(--stage-table)) center / cover no-repeat;
  display: flex;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden;
}

/* Dim tabletop ONLY in cover-only (start + end) */
#flipbook-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
  /* “semi-transparent tabletop” look: slightly frosted/dim */
  background: rgba(255, 255, 255, 0.28);
}

body.is-cover-only #flipbook-stage::after {
  opacity: 1;
}

body.is-reading #flipbook-stage::after {
  opacity: 0;
}

/* ----------------------------
   Stage menu
---------------------------- */
.stagemenu {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--charcoal) 35%, transparent);
}

.stagemenu.is-open {
  display: block;
}

.stagemenu button {
  display: block;
  width: 100%;
  text-align: left;
}

/* ----------------------------
   Wrap + Frame
---------------------------- */
#flipbook-wrap {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  cursor: default;
  touch-action: none;
  position: relative;
  z-index: 2;
  transition: cursor 0.05s linear, opacity 0.75s ease;
  opacity: 0;
}

body.is-reading #flipbook-wrap {
  display: flex !important;
  opacity: 1;
}

#flipbook-wrap {
  --cursor-open: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/flipbook-ui-icons/grab-open-gold.png?v=2");
  --cursor-closed: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/flipbook-ui-icons/grab-closed-gold.png?v=2");
}

#flipbook-wrap::before {
  content: "";
  position: absolute;
  inset: -18%;
  background: var(--book-frame) center / contain no-repeat;
  pointer-events: none;
  z-index: 0;
}

#flipbook-stage.is-resting #flipbar {
  display: none;
}

#flipbook-stage.is-resting #flipbook {
  opacity: 0;
  pointer-events: none;
}

#flipbook-stage.is-resting #flipbook-wrap {
  display: none !important;
  opacity: 0 !important;
}

body.is-cover-only #flipbook-wrap {
  display: none !important;
  opacity: 0 !important;
}

body.is-cover-only #flipbook-wrap::before {
  display: none !important;
  /* kill book frame */
}

/* ----------------------------
   Start screen
---------------------------- */
#startScreen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

#startBtn {
  width: min(780px, 92vw);
  aspect-ratio: 4000 / 3778;
  border: 0;
  height: auto;
  cursor: pointer;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.35));
  background-color: transparent;
  background: transparent;
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
}

body.is-reading #startScreen {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.75s ease;
}

/* ----------------------------
   Flipbook container
---------------------------- */
#flipbook {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  transform-origin: center center;
}

/* Panning cursors */
#flipbook-wrap.can-pan,
#flipbook-wrap.can-pan * {
  cursor: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/flipbook-ui-icons/grab-open-gold.png?v=4") 16 16, grab;
}

#flipbook-wrap.is-dragging,
#flipbook-wrap.is-dragging * {
  cursor: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/flipbook-ui-icons/grab-closed-gold.png?v=4") 16 16, grabbing;
}

/* Covers: ensure the cover art fills the page area cleanly */
.page.page-cover .page-image {
  background-size: contain;
}

/* ----------------------------
   Flipbar
---------------------------- */
.flipbar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--charcoal) 72%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  z-index: 99;
}

#flipbook-wrap,
#tiles {
  position: relative;
  z-index: 2;
}

.ibtn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font: 20px/1 var(--ui-font);
}

.ibtn:hover {
  background: rgba(255, 255, 255, 0.10);
}

.ibtn:active {
  transform: translateY(1px);
}

.ibtn img {
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
}

.ibtn.is-disabled {
  opacity: 0.35;
  filter: grayscale(1);
  cursor: not-allowed;
  pointer-events: none;
}

.sep {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 4px;
}

.pageJump {
  font-family: var(--ui-font);
  font-size: 16px;
  font-weight: 600;
  width: 140px;
  min-width: 140px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--gold);
  text-align: center;
  outline: none;
}

.pageIndicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pageTotal {
  height: 38px;
  display: inline-flex;
  align-items: center;
  font: 18px/1 var(--ui-font);
  font-weight: 700;
  color: color-mix(in srgb, var(--gold) 70%, white);
  padding-right: 4px;
  user-select: none;
}

.pageJump::placeholder {
  color: color-mix(in srgb, var(--gold) 55%, transparent);
}

/* Flipbar entrance animation */
#flipbar.is-entering {
  animation: flipbarIn 900ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
  animation-delay: 180ms;
}

@keyframes flipbarIn {
  0% {
    opacity: 0;
    transform: translate(-50%, 18px) scale(0.98);
    filter: blur(2px);
  }

  60% {
    opacity: 1;
    transform: translate(-50%, -6px) scale(1);
    filter: blur(0px);
  }

  80% {
    opacity: 1;
    transform: translate(-50%, 2px) scale(1);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, 0px) scale(1);
  }
}

/* ----------------------------
   More menu
---------------------------- */
.moremenu {
  position: absolute;
  bottom: 54px;
  right: 12px;
  display: none;
  min-width: 200px;
  background: rgba(20, 20, 20, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.moremenu.is-open {
  display: block;
}

.moremenu button {
  width: 100%;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.92);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font: 14px/1.2 var(--ui-font);
}

.moremenu button:hover {
  background: rgba(255, 255, 255, 0.07);
}

.moremenu img {
  width: 16px;
  height: 16px;
}

/* ----------------------------
   Tiles
---------------------------- */
.tiles {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  display: none;
  z-index: 120;
  overflow: auto;
  padding: 14px;
}

.tiles.is-open {
  display: block;
}

.tiles-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.tiles-close {
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  cursor: pointer;
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: block;
  margin: 18px auto;
  z-index: 5;
}

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.tile {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.tile img {
  width: 100%;
  display: block;
}

.tile .n {
  padding: 8px 10px;
  font-size: 12px;
  opacity: 0.75;
  display: flex;
  justify-content: space-between;
}

.flipbar,
.moremenu,
.tiles {
  user-select: none;
}

/* ----------------------------
   Page sizing + image
---------------------------- */
.page,
.page .page-content,
.page .page-image {
  width: 100%;
  height: 100%;
}

.page .page-content {
  display: block;
}

.page .page-image {
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

/* ----------------------------
   Ghost spacer pages — fully inert
---------------------------- */
.page.page-ghost {
  opacity: 0 !important;
  visibility: hidden !important;
  box-shadow: none !important;
  filter: none !important;

  background: transparent !important;
  border: 0 !important;

  /* kill geometry */
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;

  /* kill interaction */
  pointer-events: none !important;
}

/* nuke all inner rendering */
.page.page-ghost *,
.page.page-ghost::before,
.page.page-ghost::after {
  display: none !important;
}

body.is-end-state #startHint {
  display: none !important;
  opacity: 0 !important;
  animation: none !important;
}

/* ----------------------------
   Start hint GIF overlay
---------------------------- */
#startHint {
  position: absolute;
  z-index: 9999;
  pointer-events: none;

  inset: auto;
  right: 30%;
  bottom: 14%;
  transform: translateX(-30%)translateY(6px);

  width: 180px;
  height: 180px;
  display: none;
  opacity: 0;

  background-image: url("https://pub-be03f9c6fce44f8cbc3ec20dcaa3b337.r2.dev/flipbook-ui-icons/click-me-to-start.gif");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 160px auto;

  transition: opacity 0.45s ease, transform 0.45s ease;
  transition-delay: 0s;
}

body:not(.is-end-state) #flipbook-stage.is-resting #startHint {
  display: block;
  opacity: 1;
  transform: translateY(0);
  animation: hintBob 2.2s ease-in-out infinite;
  transition-delay: 0.18s;
}

@keyframes hintBob {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

/* ----------------------------
   Optional: cover icon button style
---------------------------- */
.ibtn.cover-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background-size: 70% 70%;
  background-repeat: no-repeat;
  background-position: center;
}

/* ----------------------------
   PDF Download Modal
---------------------------- */
.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  font-family: var(--ui-font, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif);
}

.pdf-modal.is-open {
  display: block;
}

.pdf-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.pdf-modal__panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 28px));
  border-radius: 18px;
  background: rgba(20, 20, 20, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.pdf-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pdf-modal__title {
  font-size: 18px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
}

.pdf-modal__subtitle {
  margin-top: 2px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.70);
}

.pdf-modal__x {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 18px;
  line-height: 1;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 10px;
}

.pdf-modal__x:hover {
  background: rgba(255, 255, 255, 0.08);
}

.pdf-modal__body {
  padding: 14px 16px 16px 16px;
  display: grid;
  gap: 12px;
}

.pdf-option {
  width: 100%;
  text-align: left;
  border-radius: 14px;
  padding: 12px 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.pdf-option:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.pdf-option__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.pdf-option__name {
  font-weight: 700;
  font-size: 14px;
}

.pdf-option__size {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.70);
  white-space: nowrap;
}

.pdf-option__desc {
  margin-top: 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
}

.pdf-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.80);
  background: var(--gold, #CBA135);
}

.pdf-pill--big {
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.pdf-modal__hint {
  margin-top: 2px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
}