:root {
  color-scheme: dark;
  --paper: #f3ead9;
  --ink: #231b15;
  --gold: #d0a85d;
  --wine: #7d2f3e;
}

html[dir="rtl"] body {
  direction: rtl;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

html[dir="rtl"] .book-toolbar,
html[dir="rtl"] .book-hint,
html[dir="rtl"] .experience-header,
html[dir="rtl"] .experience-body {
  text-align: right;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: #fff8ec;
  background:
    radial-gradient(circle at 50% 28%, rgba(122, 91, 58, 0.42), transparent 34%),
    linear-gradient(145deg, #211914, #0e0b09 72%);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

button, a { font: inherit; }

.book-toolbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: auto auto minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 76px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255,255,255,.16);
  background: rgba(18, 14, 11, .92);
  backdrop-filter: blur(16px);
}

.book-logo {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.book-toolbar p, .book-toolbar h1 { margin: 0; }
.book-toolbar p { color: var(--gold); font-size: 9px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.book-toolbar h1 { font: 500 clamp(19px, 2.4vw, 30px)/1 Georgia, serif; }

.book-back, .book-toolbar button, #experience-close {
  border: 1px solid rgba(255,255,255,.24);
  padding: 7px 9px;
  color: #fff8ec;
  background: #261e18;
  text-decoration: none;
  font-size: 12px;
  cursor: pointer;
}

.book-toolbar-actions { display: flex; gap: 8px; align-items: center; }
#book-progress { min-width: 78px; color: #d6c6b1; font-size: 11px; text-align: center; }
.book-toolbar button:disabled { cursor: default; opacity: .34; }

.book-stage {
  position: relative;
  display: grid;
  place-items: center;
  height: calc(100vh - 76px);
  perspective: 2600px;
  perspective-origin: 50% 43%;
}

.book-hint {
  position: absolute;
  top: 10px;
  z-index: 2;
  margin: 0;
  color: #d8c9b5;
  font-size: 13px;
}

.book {
  position: relative;
  width: min(88vw, calc((100vh - 132px) * 1.42), 1260px);
  aspect-ratio: 1.42;
  top: 15px;
  transform: rotateX(7deg);
  transform-origin: top center;
  transition: transform .18s ease-out;
  transform-style: preserve-3d;
  filter: drop-shadow(0 34px 34px rgba(0,0,0,.55));
  touch-action: none;
  user-select: none;
}

.book.zoomed { transform: rotateX(7deg) scale(1.1); }

.book::after {
  content: "";
  position: absolute;
  inset: 4% -2% -5%;
  z-index: -4;
  border-radius: 50%;
  background: rgba(0,0,0,.46);
  filter: blur(28px);
  transform: translateZ(-35px);
}

.book-cover-base {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  border: 10px solid #4b211d;
  background: linear-gradient(135deg, #722f2e, #311816);
  box-shadow: inset 0 0 0 2px #b6854d, inset 0 0 40px rgba(0,0,0,.55);
  transform: translateZ(-14px);
}
.book-cover-left { left: 0; border-radius: 18px 4px 4px 18px; }
.book-cover-right { right: 0; border-radius: 4px 18px 18px 4px; }

.book-spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 11px);
  z-index: 15;
  width: 22px;
  background: linear-gradient(90deg, rgba(45,25,19,.8), #b99260 48%, rgba(45,25,19,.8));
  box-shadow: 0 0 18px rgba(0,0,0,.7);
  transform: translateZ(6px);
  pointer-events: none;
}

.sheet {
  position: absolute;
  top: 2.1%;
  right: 1.2%;
  width: 48.8%;
  height: 95.8%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 1.05s cubic-bezier(.2,.72,.16,1);
}

.sheet.turned { transform: rotateY(-180deg); }

.page {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 2px 10px 10px 2px;
  background-color: var(--paper);
  background-position: center;
  background-size: 100% 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  box-shadow: inset 0 0 30px rgba(90,63,37,.18), 2px 1px 5px rgba(0,0,0,.26);
  cursor: pointer;
}

.page-front {
  transform: rotateY(0deg) translateZ(.6px);
}

.page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(71,45,24,.17), transparent 9%, transparent 88%, rgba(97,65,34,.08));
  mix-blend-mode: multiply;
}

.page-back {
  transform: rotateY(180deg) translateZ(.6px);
  border-radius: 10px 2px 2px 10px;
}

.page-hotspot {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1.4px solid rgba(255,248,223,.82);
  border-radius: 50%;
  color: #21170e;
  background: rgba(208,168,93,.72);
  box-shadow: 0 0 0 5px rgba(208,168,93,.13), 0 0 13px rgba(255,224,158,.68);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  opacity: .78;
  transform: translate(-50%, -50%);
  animation: hotspot-pulse 2.2s ease-in-out infinite;
}

@keyframes hotspot-pulse {
  50% { box-shadow: 0 0 0 8px rgba(208,168,93,.06), 0 0 18px rgba(255,224,158,.76); }
}

.book-experience {
  width: min(1080px, 94vw);
  height: min(760px, 88vh);
  border: 1px solid rgba(255,255,255,.25);
  padding: 0;
  color: #fff8ec;
  background: #17120f;
  box-shadow: 0 28px 90px rgba(0,0,0,.74);
}
.book-experience::backdrop { background: rgba(5,4,3,.84); backdrop-filter: blur(9px); }
.experience-header { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 15px 18px; border-bottom: 1px solid rgba(255,255,255,.15); }
.experience-header p, .experience-header h2 { margin: 0; }
.experience-header p { color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.experience-header h2 { margin-top: 4px; font: 500 30px/1 Georgia, serif; }
.experience-body { height: calc(100% - 76px); }
.experience-body iframe { width: 100%; height: 100%; border: 0; background: #111; }
.experience-audio { display: grid; place-items: center; height: 100%; padding: 30px; background: radial-gradient(circle, #4b3426, #17120f 68%); }
.experience-audio audio { width: min(680px, 90%); }
.experience-video { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: 12px; height: 100%; padding: 18px; background: #090807; }
.experience-video video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.experience-video p { margin: 0; color: #d8c9b5; text-align: center; }
.experience-video-controls { display: flex; justify-content: center; gap: 9px; }
.experience-video-controls button { border: 1px solid rgba(255,255,255,.28); padding: 9px 14px; color: #fff8ec; background: #263f52; cursor: pointer; }
.experience-world {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  height: 100%;
  padding: 36px;
  text-align: center;
  background: radial-gradient(circle at 50% 38%, #5d4030, #17120f 70%);
}
.experience-world p { max-width: 620px; margin: 0; font: 500 clamp(24px, 4vw, 42px)/1.25 Georgia, serif; }
.experience-world a { border: 1px solid #e7c477; padding: 14px 20px; color: #19120d; background: var(--gold); font-weight: 800; text-decoration: none; }
.experience-world small { color: #d8c9b5; }

@media (max-width: 760px) {
  body { overflow: auto; }
  .book-toolbar { grid-template-columns: auto 1fr; }
  .book-toolbar-actions { grid-column: 1 / -1; justify-content: center; }
  .book-stage {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: calc(100vh - 126px);
    height: auto;
    padding: 16px 2vw 40px;
    overflow: auto;
  }
  .book {
    flex: 0 0 auto;
    width: 96vw;
    aspect-ratio: 1.42;
    top: 0;
    transform: none;
    transform-origin: top center;
  }
  .book.zoomed {
    width: 96vw;
    margin-bottom: 16vh;
    transform: scale(1.16);
  }
  .book-cover-left, .book-spine { display: block; }
  .book-cover-right { left: auto; width: 50%; border-radius: 4px 12px 12px 4px; }
  .sheet { right: 1.2%; width: 48.8%; }
  .book-hint { display: none; }
  .page-hotspot {
    width: 34px;
    height: 34px;
    border-width: 2px;
    font-size: 12px;
    opacity: .95;
    box-shadow: 0 0 0 5px rgba(208,168,93,.2), 0 0 16px rgba(255,224,158,.9);
  }
  #book-zoom { border-color: var(--gold); }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .book { width: min(88vw, calc((100vh - 130px) * 1.42), 1180px); }
}
