:root {
  --bg-start: #f6efe5;
  --bg-end: #d8c0a4;
  --text: #2d2018;
  --page-radius: 18px;
  --button-size: 54px;
  --dock-radius: 999px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.55), transparent 34%),
    linear-gradient(160deg, var(--bg-start), var(--bg-end));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 100%);
  background-size: 34px 34px;
  opacity: 0.22;
}

.page-shell {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding:
    max(10px, env(safe-area-inset-top))
    10px
    calc(96px + env(safe-area-inset-bottom))
    8px;
}

.book-app {
  position: relative;
  width: min(100%, 760px);
}

.book-socials {
  position: fixed;
  right: calc(10px + env(safe-area-inset-right));
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 25;
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 12px 28px rgba(49, 28, 11, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.44);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.social-link {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: rgba(48, 30, 18, 0.88);
  background: rgba(255, 255, 255, 0.24);
  text-decoration: none;
  transition: transform 0.18s ease, background-color 0.18s ease, opacity 0.18s ease;
  opacity: 0.82;
}

.social-link svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.social-link:active {
  transform: scale(0.96);
}

.social-link:hover {
  opacity: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.book-stage {
  position: relative;
  display: flex;
  justify-content: center;
}

.book-frame {
  position: relative;
  width: min(calc(100vw - 16px), calc((100svh - 110px) * 0.7045), 680px);
  max-width: 100%;
  height: min(calc((100vw - 16px) / 0.7045), calc(100svh - 110px), 980px);
  aspect-ratio: 0.7;
  overflow: hidden;
  border-radius: calc(var(--page-radius) + 2px);
  touch-action: pan-y pinch-zoom;
  user-select: none;
}

.book-pages {
  position: absolute;
  inset: 0;
}

.book-pages::before {
  content: "";
  position: absolute;
  inset: 18px 14px 8px;
  border-radius: 22px;
  background: rgba(70, 39, 13, 0.18);
  filter: blur(30px);
  z-index: 0;
}

.book-slide {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: translate3d(42px, 0, 0) scale(0.985);
  transition:
    opacity 0.45s ease,
    transform 0.45s cubic-bezier(0.22, 0.8, 0.2, 1);
  pointer-events: none;
  z-index: 1;
}

.book-slide.is-active {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  pointer-events: auto;
  z-index: 3;
}

.book-slide.is-before {
  transform: translate3d(-42px, 0, 0) scale(0.985);
  z-index: 2;
}

.book-slide.is-after {
  transform: translate3d(42px, 0, 0) scale(0.985);
  z-index: 2;
}

.slide-card {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
  display: grid;
  place-items: center;
  border-radius: var(--page-radius);
  background: transparent;
}

.slide-card::before {
  content: "";
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 2.5%;
  height: 12%;
  border-radius: 999px;
  background: radial-gradient(ellipse at center, rgba(53, 28, 12, 0.34), rgba(53, 28, 12, 0));
  filter: blur(18px);
  z-index: 0;
}

.slide-card::after {
  content: "";
  position: absolute;
  inset: 6px;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.03));
  opacity: 0.55;
  z-index: 0;
}

.slide-card img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: transparent;
  position: relative;
  z-index: 1;
  border-radius: calc(var(--page-radius) - 2px);
  box-shadow:
    0 24px 44px rgba(41, 20, 7, 0.2),
    0 6px 18px rgba(41, 20, 7, 0.1);
}

.slide-card picture {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.book-controls {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--dock-radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.34);
  box-shadow:
    0 18px 40px rgba(49, 28, 11, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  transform: translateX(-50%);
}

.nav-button {
  appearance: none;
  border: 0;
  width: var(--button-size);
  height: var(--button-size);
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.22));
  color: #4f321f;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 10px 18px rgba(77, 43, 20, 0.12);
  transition: transform 0.18s ease, opacity 0.18s ease, background-color 0.18s ease;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.nav-button:disabled {
  opacity: 0.38;
  cursor: default;
  transform: none;
}

.nav-button:not(:disabled):active {
  transform: scale(0.96);
}

.book-dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px;
}

.book-dot {
  appearance: none;
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(83, 51, 29, 0.22);
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.book-dot.is-active {
  background: rgba(79, 50, 31, 0.82);
  transform: scale(1.14);
}

.book-fallback {
  display: grid;
  gap: 14px;
}

.book-fallback img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 18px;
  box-shadow: 0 12px 24px rgba(58, 31, 12, 0.18);
}

@media (hover: hover) {
  .nav-button:not(:disabled):hover,
  .book-dot:hover {
    transform: translateY(-1px);
  }
}

@media (max-width: 900px) {
  .book-app {
    width: 100%;
  }

  .book-frame {
    width: min(calc(100vw - 16px), calc((100svh - 104px) * 0.7045), 640px);
    height: min(calc((100vw - 16px) / 0.7045), calc(100svh - 104px), 900px);
  }

  .book-pages::before {
    inset: 14px 10px 8px;
    filter: blur(24px);
  }
}

@media (max-width: 560px) {
  :root {
    --page-radius: 14px;
    --button-size: 46px;
  }

  .page-shell {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .book-frame {
    width: min(calc(100vw - 12px), calc((100svh - 92px) * 0.7045));
    height: min(calc((100vw - 12px) / 0.7045), calc(100svh - 92px));
    max-height: calc(100svh - 92px);
  }

  .book-slide {
    transform: translate3d(18px, 0, 0) scale(0.994);
  }

  .book-slide.is-before {
    transform: translate3d(-18px, 0, 0) scale(0.994);
  }

  .book-slide.is-after {
    transform: translate3d(18px, 0, 0) scale(0.994);
  }

  .book-controls {
    width: calc(100vw - 14px);
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .book-socials {
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    gap: 6px;
    padding: 6px;
  }

  .social-link {
    width: 30px;
    height: 30px;
  }

  .social-link svg {
    width: 17px;
    height: 17px;
  }

  .slide-card::before {
    left: 10%;
    right: 10%;
    bottom: 3%;
    height: 10%;
    filter: blur(14px);
  }

  .slide-card img {
    box-shadow:
      0 18px 32px rgba(41, 20, 7, 0.18),
      0 4px 12px rgba(41, 20, 7, 0.08);
  }

  .book-dots {
    gap: 7px;
  }

  .book-dot {
    width: 9px;
    height: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .book-slide,
  .nav-button,
  .book-dot {
    transition: none;
  }
}
