/* =========================
   BASE
   ========================= */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #050505;
  color: #3a2b1b;
  font-family: "Cinzel", serif;
}

.history-page {
  width: 100%;
  padding: 36px 20px 50px;
}

/* =========================
   BOOK WRAPPER
   ========================= */

.book-wrapper {
  position: relative;
  width: min(100%, 1520px);
  margin: 0 auto;
}

.book-img {
  width: 100%;
  display: block;
}

/* =========================
   PAGE OVERLAYS
   ========================= */

.page {
  position: absolute;
  top: 14.6%;
  height: 64.2%;
  width: 30.5%;
  padding: 20px 20px;
}

.page.left {
  left: 17.8%;
}

.page.right {
  right: 17.2%;
}

/* =========================
   LEFT PAGE IMAGE
   ========================= */

.visual-page {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-frame {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}

/* Soft alpha-style edge blend into the paper */
.image-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    linear-gradient(to top, rgba(231, 210, 163, 0.25) 0%, rgba(231, 210, 163, 0) 12%),
    linear-gradient(to bottom, rgba(231, 210, 163, 0.22) 0%, rgba(231, 210, 163, 0) 12%),
    linear-gradient(to left, rgba(231, 210, 163, 0.24) 0%, rgba(231, 210, 163, 0) 10%),
    linear-gradient(to right, rgba(231, 210, 163, 0.24) 0%, rgba(231, 210, 163, 0) 10%);
}

#chapter-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
  opacity: 1;
  transition: opacity 0.45s ease;
  filter: saturate(0.98) contrast(1.02) brightness(0.98);
  position: relative;
  z-index: 1;

  -webkit-mask-image: radial-gradient(
      ellipse at center,
      rgba(0, 0, 0, 1) 78%,
      rgba(0, 0, 0, 0.88) 86%,
      rgba(0, 0, 0, 0.35) 94%,
      rgba(0, 0, 0, 0) 100%
    );
  mask-image: radial-gradient(
      ellipse at center,
      rgba(0, 0, 0, 1) 78%,
      rgba(0, 0, 0, 0.88) 86%,
      rgba(0, 0, 0, 0.35) 94%,
      rgba(0, 0, 0, 0) 100%
    );
}

/* =========================
   RIGHT PAGE TEXT
   ========================= */

.text-page {
  overflow-y: auto;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: rgba(80, 60, 30, 0.35) transparent;
}

.text-page::-webkit-scrollbar {
  width: 6px;
}

.text-page::-webkit-scrollbar-track {
  background: transparent;
}

.text-page::-webkit-scrollbar-thumb {
  background: rgba(80, 60, 30, 0.35);
  border-radius: 999px;
}

.page-inner {
  max-width: 92%;
  margin: 0 auto;
  padding-top: 2px;
  text-shadow:
    0 0 1px rgba(0, 0, 0, 0.20),
    0 1px 0 rgba(255, 255, 255, 0.12);
}

.page-inner h2 {
  margin: 0 0 16px;
  font-size: clamp(18px, 1.45vw, 28px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #2a1d10;
  border-bottom: 1px solid rgba(60, 40, 20, 0.28);
  padding-bottom: 10px;
}

.page-inner p {
  margin: 0 0 14px;
  font-size: clamp(13px, 0.95vw, 18px);
  line-height: 1.72;
  letter-spacing: 0.02em;
  text-align: justify;
}

.page-inner p:first-of-type::first-letter {
  float: left;
  font-size: 2.5em;
  line-height: 0.95;
  margin-right: 8px;
  font-weight: 600;
  color: #2a1d10;
}

.page-inner hr {
  border: none;
  height: 1px;
  margin: 18px 0;
  background: linear-gradient(
    to right,
    transparent,
    rgba(80, 60, 30, 0.45),
    transparent
  );
}

/* =========================
   CONTROLS
   ========================= */

.chapter-controls {
  width: min(100%, 760px);
  margin: 22px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #e8d5af;
}

.chapter-controls button {
  appearance: none;
  border: 1px solid rgba(232, 213, 175, 0.25);
  background: rgba(34, 21, 10, 0.95);
  color: #f0dfba;
  padding: 10px 18px;
  font-family: "Cinzel", serif;
  font-size: 14px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.chapter-controls button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(52, 31, 15, 0.98);
}

.chapter-controls button:disabled {
  opacity: 0.45;
  cursor: default;
}

.chapter-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 180px;
}

.chapter-kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.7;
}

#chapter-label {
  margin-top: 2px;
  font-size: 18px;
  letter-spacing: 0.04em;
}

/* =========================
   MOBILE
   ========================= */

@media (max-width: 980px) {
  .book-wrapper {
    width: min(100%, 760px);
  }

  .book-img {
    display: none;
  }

  .page {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    padding: 18px;
    margin: 0 auto 18px;
    background: rgba(236, 220, 184, 0.92);
    border-radius: 10px;
  }

  .visual-page {
    min-height: 320px;
  }

  .image-frame::after {
    background:
      linear-gradient(to top, rgba(236, 220, 184, 0.88) 0%, rgba(236, 220, 184, 0) 10%),
      linear-gradient(to bottom, rgba(236, 220, 184, 0.82) 0%, rgba(236, 220, 184, 0) 10%),
      linear-gradient(to left, rgba(236, 220, 184, 0.84) 0%, rgba(236, 220, 184, 0) 10%),
      linear-gradient(to right, rgba(236, 220, 184, 0.84) 0%, rgba(236, 220, 184, 0) 10%);
  }

  #chapter-image {
    -webkit-mask-image: radial-gradient(
      ellipse at center,
      rgba(0, 0, 0, 1) 72%,
      rgba(0, 0, 0, 0.82) 84%,
      rgba(0, 0, 0, 0) 100%
    );
    mask-image: radial-gradient(
      ellipse at center,
      rgba(0, 0, 0, 1) 72%,
      rgba(0, 0, 0, 0.82) 84%,
      rgba(0, 0, 0, 0) 100%
    );
  }

  .text-page {
    max-height: none;
    overflow: visible;
  }

  .chapter-controls {
    flex-wrap: wrap;
    gap: 12px;
  }
}
