:root {
  --red: #ee2e2e;
  --navy: #1b2150;
  --shadow: rgba(27, 33, 80, 0.16);
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
@supports (height: 100dvh) {
  html,
  body {
    height: 100dvh;
  }
}
body {
  display: flex;
  flex-direction: column;
  background: radial-gradient(
    120% 100% at 50% 20%,
    #ffffff 0%,
    #f5f2ef 55%,
    #eae5df 100%
  );
  font-family: "Trebuchet MS", "Helvetica Neue", Helvetica, Arial, sans-serif;
  overflow: hidden;
}
/* faint ring motifs in backdrop */
body > svg.bg-ring {
  position: fixed;
  right: -12%;
  top: -16%;
  width: 46vw;
  max-width: 680px;
  opacity: 0.07;
  pointer-events: none;
}
body > svg.bg-ring2 {
  position: fixed;
  left: -14%;
  bottom: -18%;
  width: 38vw;
  max-width: 560px;
  opacity: 0.05;
  pointer-events: none;
}

/* ---------- HEADER ---------- */
header {
  text-align: center;
  padding: 20px 16px 8px;
  flex: none;
}
header .kicker {
  font-size: 9px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--navy);
  opacity: 0.7;
}
header h1 {
  margin-top: 6px;
  font-size: clamp(15px, 2.6vw, 22px);
  font-weight: 300;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--navy);
}
header h1 b {
  color: var(--red);
  font-weight: 800;
}

/* ---------- VIEWER ---------- */
main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
  padding: 14px 0;
}
.book-wrap {
  perspective: 3000px;
  transition: transform 1.1s cubic-bezier(0.4, 0.05, 0.2, 1);
}
.book {
  position: relative;
  transform-style: preserve-3d;
  cursor: pointer;
}
.book::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 50%;
  height: 100%;
  background: #fff;
  border-radius: 4px 0 0 4px;
  box-shadow: 0 24px 60px var(--shadow);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.book.opened::before {
  opacity: 1;
}
.book::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  width: 50%;
  height: 100%;
  border-radius: 0 4px 4px 0;
  box-shadow: 0 20px 50px var(--shadow);
  transition: opacity 0.6s ease;
  pointer-events: none;
  z-index: 0;
}
.book.finished::after {
  opacity: 0;
}

.sheet {
  position: absolute;
  left: 50%;
  top: 0;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(0.45, 0.05, 0.15, 1);
}
.sheet.flipped {
  transform: rotateY(-180deg);
}
.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background-color: #fff;
  background-size: cover;
  background-position: center;
}
.face.front {
  transform: translateZ(0.6px);
  border-radius: 0 4px 4px 0;
}
.face.back {
  transform: rotateY(180deg) translateZ(0.6px);
  border-radius: 4px 0 0 4px;
}
.face.front::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.1),
    rgba(0, 0, 0, 0) 12%
  );
}
.face.back::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(
    to left,
    rgba(0, 0, 0, 0.1),
    rgba(0, 0, 0, 0) 12%
  );
}

/* side arrows */
.arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #d4cfc8;
  background: #ffffffd9;
  color: var(--navy);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    opacity 0.3s;
  backdrop-filter: blur(3px);
  z-index: 5;
}
.arrow:hover {
  background: #fff;
}
.arrow:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.arrow.left {
  left: max(10px, 3vw);
}
.arrow.right {
  right: max(10px, 3vw);
}
.arrow[disabled] {
  opacity: 0.25;
  cursor: default;
}

/* ---------- FOOTER BAR ---------- */
footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 16px 18px;
}
.counter {
  font-size: 12px;
  color: var(--navy);
  letter-spacing: 0.08em;
  min-width: 84px;
  text-align: center;
}
footer button {
  border: 1px solid #d4cfc8;
  background: #fff;
  color: var(--navy);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}
footer button:hover {
  background: #f5f2ef;
}
footer button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
footer .credit {
  position: fixed;
  right: 14px;
  bottom: 12px;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #a39c93;
}

body:fullscreen {
  background: #f5f2ef;
}

/* ---------- ZOOM LIGHTBOX ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 22, 40, 0.96);
  display: none;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.lightbox.open {
  display: flex;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox .close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 51;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.lightbox .lb-hint {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  letter-spacing: 0.08em;
}

@media (prefers-reduced-motion: reduce) {
  .sheet {
    transition: transform 0.2s linear;
  }
}
@media (max-width: 720px), (orientation: portrait) {
  .arrow {
    width: 34px;
    height: 34px;
    font-size: 14px;
    background: #ffffffb3;
  }
  .arrow.left {
    left: 6px;
  }
  .arrow.right {
    right: 6px;
  }
  header {
    padding: 12px 12px 4px;
  }
  header h1 {
    letter-spacing: 0.1em;
  }
  main {
    padding: 8px 0;
  }
  footer {
    gap: 10px;
    padding: 8px 12px 14px;
    flex-wrap: wrap;
  }
  footer .credit {
    position: static;
    width: 100%;
    text-align: center;
  }
  body > svg.bg-ring {
    width: 70vw;
    right: -30%;
  }
  body > svg.bg-ring2 {
    display: none;
  }
}