:root {
  --ink: #2b241b;
  --inkSoft: rgba(43, 36, 27, 0.72);
  --paper: #efe5cf;
  --paper2: #e7d9ba;
  --paperEdge: #d0c1a2;
  --cover: #5a3f2c;
  --cover2: #4b3323;
  --shadow: rgba(0, 0, 0, 0.28);

  --bookW: min(980px, 92vw);
  --bookH: min(640px, 72vh);
  --radius: 14px;

  --typeScale: 1.35;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-size: calc(16px * var(--typeScale));
  /* Countertop photo background (images/countertop.png) + subtle lighting + vignette */
  background-color: #24160f;
  background-image:
    radial-gradient(1400px 980px at 50% 52%, rgba(0, 0, 0, 0) 46%, rgba(0, 0, 0, 0.62) 100%),
    radial-gradient(1100px 700px at 28% 8%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 58%),
    linear-gradient(180deg, rgba(18, 11, 7, 0.10) 0%, rgba(18, 11, 7, 0.35) 100%),
    url("images/countertop.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
  display: grid;
  place-items: center;
  padding: 22px;
  font-family: "IM Fell English", Georgia, "Times New Roman", Times, serif;
}

.stage {
  width: min(1100px, 100%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 10px 12px;
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
}

.brand__title {
  font-family: "IM Fell English SC", "IM Fell English", Georgia, serif;
  letter-spacing: 0.02em;
  font-size: calc(22px * var(--typeScale));
}

.brand__subtitle {
  font-size: calc(13px * var(--typeScale));
  color: rgba(255, 255, 255, 0.78);
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.95);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pager {
  min-width: 120px;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: calc(14px * var(--typeScale));
}

.bookWrap {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 8px 0 0;
}

.bookWrap::before {
  content: "";
  position: absolute;
  top: 14px;
  width: var(--bookW);
  height: var(--bookH);
  border-radius: var(--radius);
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0) 70%);
  filter: blur(14px);
  transform: translateY(10px) scale(0.98);
  opacity: 0.80;
  pointer-events: none;
  z-index: 0;
}

.book {
  width: var(--bookW);
  height: var(--bookH);
  position: relative;
  perspective: 1800px;
  z-index: 1;
  outline: none;
}

.book:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
}

/* A single physical sheet with a front & back. */
.page {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: left center;
  transition: transform 650ms cubic-bezier(0.2, 0.75, 0.15, 1);
  border-radius: var(--radius);
  will-change: transform;
}

.page.is-flipped {
  transform: rotateY(-180deg);
}

.page__face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  overflow: hidden;
  box-shadow:
    0 10px 22px var(--shadow),
    inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

/* Paper texture: gradients + subtle speckle */
.page__paper {
  background:
    radial-gradient(900px 500px at 20% 10%, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0) 60%),
    radial-gradient(800px 520px at 80% 30%, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0) 55%),
    linear-gradient(180deg, var(--paper), var(--paper2));
}

.page__paper::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 10% 10%, rgba(0, 0, 0, 0.035) 0 1px, transparent 1px),
    radial-gradient(circle at 40% 70%, rgba(0, 0, 0, 0.03) 0 1px, transparent 1px),
    radial-gradient(circle at 80% 30%, rgba(0, 0, 0, 0.03) 0 1px, transparent 1px);
  background-size: 120px 120px;
  mix-blend-mode: multiply;
  opacity: 0.85;
  pointer-events: none;
}

.page__paper::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow:
    inset 28px 0 32px rgba(0, 0, 0, 0.06),
    inset -18px 0 26px rgba(0, 0, 0, 0.035);
  pointer-events: none;
}

.page__cover {
  background:
    radial-gradient(1200px 800px at 25% 20%, rgba(255, 255, 255, 0.20), rgba(255, 255, 255, 0) 60%),
    radial-gradient(1400px 980px at 50% 50%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.55) 100%),
    url("images/leather-cover.png");
  background-size: auto, auto, cover;
  background-position: center, center, center;
  background-repeat: no-repeat;
  color: #120b07;
}

.page__cover::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.10);
  pointer-events: none;
}

.page__back {
  transform: rotateY(180deg);
}

/* Layout within a page face */
.sheet {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.sheet__header {
  padding: 18px 22px 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.10);
}

.sheet__title {
  font-family: "IM Fell English SC", "IM Fell English", Georgia, serif;
  font-size: calc(22px * var(--typeScale));
  letter-spacing: 0.02em;
}

.sheet__meta {
  font-size: calc(13px * var(--typeScale));
  color: var(--inkSoft);
}

.sheet__body {
  padding: 16px 22px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;
  max-height: calc(var(--bookH) - 160px);
  overflow: hidden;
}

.sheet__footer {
  padding: 12px 22px 18px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--inkSoft);
  font-size: calc(13px * var(--typeScale));
}

.catalogNote {
  font-style: italic;
  line-height: 1.45;
}

.inkLink {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.inkLink:hover {
  opacity: 0.85;
}

.items {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100%;
  padding-right: 8px;
}

.items::-webkit-scrollbar {
  width: 6px;
}

.items::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.items::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.20);
  border-radius: 3px;
}

.items::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.30);
}

.media {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.10);
  background: rgba(255, 255, 255, 0.18);
  /* Allow full image visibility in browser full view */
  max-height: clamp(270px, calc(var(--bookH) * 0.62), 500px);
  margin-top: 5px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.bulletList {
  margin: 8px 0 0;
  padding-left: 18px;
}

.bulletList li {
  margin: 4px 0;
}

.item {
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.22);
}

.item__name {
  font-family: "IM Fell English SC", "IM Fell English", Georgia, serif;
  letter-spacing: 0.01em;
  font-size: calc(16px * var(--typeScale));
}

.item__desc {
  margin-top: 4px;
  font-size: calc(14px * var(--typeScale));
  line-height: 1.4;
  color: var(--ink);
}

.item__price {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: calc(13px * var(--typeScale));
  color: var(--inkSoft);
}

.item__price strong {
  color: var(--ink);
}

.cover {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
}

.cover__frame {
  width: min(520px, 92%);
  padding: 26px 22px;
  border-radius: 16px;
  border: none;
  background: transparent;
  box-shadow: none;
}

.cover__kicker {
  font-size: calc(14px * var(--typeScale));
  color: rgba(18, 11, 7, 0.80);
  letter-spacing: 0.04em;
}

.cover__title {
  margin-top: 10px;
  font-family: "IM Fell English SC", "IM Fell English", Georgia, serif;
  font-size: calc(34px * var(--typeScale));
  letter-spacing: 0.03em;
}

.cover__rule {
  display: none;
}

.cover__blurb {
  margin: 0;
  font-size: calc(16px * var(--typeScale));
  line-height: 1.55;
  color: rgba(18, 11, 7, 0.86);
}

.cover__stamp {
  margin-top: 18px;
  display: inline-block;
  padding: 8px 12px;
  border: 1px dashed rgba(18, 11, 7, 0.55);
  border-radius: 999px;
  font-size: calc(13px * var(--typeScale));
  color: rgba(18, 11, 7, 0.82);
}

.edgeHints {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: var(--bookW);
  height: var(--bookH);
  z-index: 2;
}

.edgeHints__left,
.edgeHints__right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.74);
}

.edgeHints__left { left: -16px; }
.edgeHints__right { right: -16px; }

.help {
  color: rgba(255, 255, 255, 0.78);
  font-size: calc(13px * var(--typeScale));
}

.footer {
  margin-top: 8px;
  text-align: center;
  padding: 10px 12px 0;
  color: rgba(255, 255, 255, 0.70);
  font-size: calc(13px * var(--typeScale));
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .page {
    transition: none;
  }
}

@media (max-width: 820px) {
  :root {
    --bookH: min(620px, 70vh);
  }

  .sheet__body {
    grid-template-columns: 1fr;
  }
}
