/* Book showcase — mirrored cinematic composition */
body .books {
  --book-tabs-height:clamp(58px,10svh,78px);
  --book-nav-size:44px;
  position:relative;
  container-type:size;
  isolation: isolate;
  display: block;
  width: 100%;
  height: clamp(620px, 100dvh, 980px);
  min-height: 620px;
  padding: 0;
  overflow: hidden;
  background: #0b1219;
  color: #eee7da;
}

.books-art-stack,
.books-shade,
.books-art {
  position: absolute;
  inset: 0;
}

.books-art-stack { z-index: -3; background: #0b1219; }
.books-art {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  filter: saturate(.9) brightness(.92);
  transform: scale(1.025);
  transition: opacity 700ms cubic-bezier(.16,1,.3,1), transform 1100ms cubic-bezier(.16,1,.3,1);
}
.books-art.is-active { opacity: 1; transform: scale(1); }
.books-shade {
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(4,10,16,.03) 0%, rgba(5,12,20,.08) 27%, rgba(5,12,20,.28) 58%, rgba(5,10,16,.58) 100%),
    linear-gradient(0deg, rgba(4,9,14,.5) 0%, transparent 28%, rgba(4,9,14,.06) 72%, rgba(4,9,14,.18) 100%);
}
.books-shade::after {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 74% 44%, rgba(62,82,101,.13), transparent 38%);
  content: '';
}

.book-showcase {
  position: absolute;
  z-index: 2;
  inset:0 0 var(--book-tabs-height);
  display: flex;
  align-items: center;
  padding: clamp(38px,5vw,76px) 0;
}
.book-showcase-content {
  display: grid;
  grid-template-columns:minmax(320px,520px) max-content;
  width:min(1400px,80vw);
  height:70%;
  min-height:0;
  align-items:center;
  justify-content:end;
  gap:clamp(36px,4vw,50px);
  margin-left:auto;
  margin-right:clamp(120px,10vw,170px);
  transition:opacity 180ms ease-out;
}
.book-showcase-content.is-leaving {
  opacity:0;
}
.book-showcase-content.is-entering {
  opacity:0;
}

.book-copy { min-width:0;text-align:right; }
.book-copy time {
  display: block;
  margin-bottom: 12px;
  color: #b0aa9f;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.book-series {
  display:block;
  margin-bottom:7px;
  color:#d7b37a;
  font-size:12px;
  letter-spacing:.08em;
}
.book-copy .book-series { text-shadow:0 2px 12px rgba(0,0,0,.58); }
.book-copy h2 {
  max-width:11ch;
  margin:0 0 0 auto;
  color: #f0eadf;
  font: 500 clamp(42px, 4.8vw, 72px)/.98 var(--display, Georgia, serif);
  letter-spacing: -.025em;
  text-wrap: balance;
  text-shadow: 0 3px 24px rgba(0,0,0,.56);
}
.book-copy-divider {
  width: min(290px, 100%);
  height: 1px;
  margin:20px 0 18px auto;
  background:linear-gradient(90deg,rgba(208,167,103,.06),rgba(208,167,103,.82));
}
.book-copy p {
  max-width: 45ch;
  margin:0 0 0 auto;
  color:#d0cbc2;
  font-size: clamp(14px, 1.15vw, 17px);
  line-height: 1.68;
  text-wrap: pretty;
  text-shadow: 0 2px 14px rgba(0,0,0,.72);
}
.book-actions { display:flex;flex-wrap:wrap;justify-content:flex-end;gap:10px;margin-top:26px; }
.book-actions button {
  position:relative;
  isolation:isolate;
  flex:1 1 180px;
  width:min(230px,100%);
  max-width:230px;
  height:52px;
  min-width:0;
  min-height:0;
  padding:0 24px;
  background:linear-gradient(180deg,rgba(137,81,52,.36),rgba(73,37,24,.32)),url('/assets/ui/game-button-texture.webp') center/cover;
  color:#f4dfbd;
  border:0;
  border-radius:0;
  box-shadow:inset 0 1px rgba(255,221,156,.14),inset 0 -8px 18px rgba(38,17,10,.2);
  font:400 14px/1.2 Arial,sans-serif;
  letter-spacing:.015em;
  text-shadow:0 1px 3px rgba(33,15,8,.8);
  -webkit-mask:url('/assets/ui/game-button-shape.svg') center/100% 100% no-repeat;
  mask:url('/assets/ui/game-button-shape.svg') center/100% 100% no-repeat;
  transition:color 180ms ease-out,filter 180ms ease-out;
}
.book-actions button::before,
.book-actions button::after {
  position:absolute;
  z-index:3;
  inset:0;
  content:'';
  pointer-events:none;
  -webkit-mask:url('/assets/ui/game-button-frame.svg') center/100% 100% no-repeat;
  mask:url('/assets/ui/game-button-frame.svg') center/100% 100% no-repeat;
}
.book-actions button::before {
  background:linear-gradient(180deg,#fff0a4 0%,#e6a83d 32%,#9b5b20 66%,#ffd676 100%);
  filter:drop-shadow(0 0 4px rgba(235,166,48,.72));
  opacity:.92;
}
.book-actions button::after {
  background:linear-gradient(105deg,transparent 8%,rgba(255,219,122,.18) 30%,#fff8c9 49%,#ffc955 58%,transparent 88%);
  background-position:-70% 0;
  background-repeat:no-repeat;
  background-size:38% 100%;
  filter:drop-shadow(0 0 5px rgba(255,207,91,.75));
  animation:gameButtonFrameShimmer 3.4s linear infinite;
}
.book-actions button:hover {
  background:linear-gradient(180deg,rgba(157,93,58,.42),rgba(78,39,24,.25)),url('/assets/ui/game-button-texture.webp') center/cover;
  color:#fff0d3;
  filter:drop-shadow(0 0 9px rgba(232,165,54,.18));
}
.book-actions button:active { filter:brightness(.95); }
.book-actions button:focus-visible { outline:2px solid #e2b574;outline-offset:3px; }

.book-object-frame {
  display: grid;
  width: 100%;
  max-height: min(80dvh, 680px);
  place-items:center end;
  perspective:none;
}
.book-object {
  position:relative;
  display:block;
  width:min(100%,560px);
  transform:none;
}
.book-front {
  position:relative;
  z-index:2;
  isolation:isolate;
  padding:22px;
  background:transparent;
}
.book-front-panel {
  position:absolute;
  z-index:0;
  inset:0;
  width:100%;
  height:100%;
  overflow:visible;
  fill:#070b0f;
  pointer-events:none;
}
.book-front img {
  position:relative;
  z-index:1;
  display:block;
  width:100%;
  height:auto;
  max-height:min(70dvh,610px);
  object-fit:contain;
  clip-path:polygon(5% 0,95% 0,95% 3%,100% 7.33%,100% 92.67%,95% 97%,95% 100%,5% 100%,5% 97%,0 92.67%,0 7.33%,5% 3%);
}
.book-cover-ornament {
  position:absolute;
  z-index:3;
  inset:0;
  width:100%;
  height:100%;
  overflow:visible;
  color:#d7aa5e;
  pointer-events:none;
  filter:drop-shadow(0 0 2px rgba(215,170,94,.2));
}
.book-cover-ornament .ornament-frame { stroke-width:2.5;opacity:.82; }
.book-frame-emblem {
  position:absolute;
  z-index:5;
  left:50%;
  width:28px;
  height:28px;
  overflow:visible;
  color:#d7aa5e;
  filter:drop-shadow(0 0 2px rgba(215,170,94,.2));
  transform:translate(-50%,-50%);
  pointer-events:none;
}
.book-frame-emblem-top { top:0; }
.book-frame-emblem-bottom { top:100%; }
.book-frame-emblem .emblem-outer { fill:rgba(9,13,17,.92);stroke:currentColor;stroke-width:2; }
.book-frame-emblem .emblem-inner { fill:none;stroke:currentColor;stroke-width:.65;opacity:.9; }
.book-frame-emblem .emblem-center { fill:#e6bf76;stroke:none; }

.book-edge-nav {
  position: absolute;
  z-index:7;
  top:0;
  bottom:var(--book-tabs-height);
  width:clamp(48px,6vw,88px);
  padding: 0;
  background: transparent;
  border: 0;
  color: #dbb77d;
  cursor: pointer;
}
.book-edge-nav:hover { background: linear-gradient(90deg, rgba(205,159,94,.06), transparent); }
.book-edge-next { right: 0; }
.book-edge-previous { left: 0; }
.book-edge-next:hover { background: linear-gradient(-90deg, rgba(205,159,94,.06), transparent); }
.book-nav-glyph {
  position:absolute;
  top:50%;
  width:var(--book-nav-size);
  height:var(--book-nav-size);
  overflow:visible;
  fill:rgba(10,16,21,.52);
  stroke:currentColor;
  filter:drop-shadow(0 8px 15px rgba(0,0,0,.5));
  transform:translateY(-50%);
  transition:color 220ms ease-out,filter 220ms ease-out,transform 220ms cubic-bezier(.16,1,.3,1);
}
.book-edge-next .book-nav-glyph { right:clamp(10px,1.6vw,24px); }
.book-edge-previous .book-nav-glyph { left:clamp(10px,1.6vw,24px); }
.book-nav-diamond { stroke-width:1;opacity:.82; }
.book-nav-inner { stroke-width:.7;opacity:.3; }
.book-nav-mark { fill:none;stroke-width:1;opacity:.9; }
.book-edge-nav:hover .book-nav-glyph { color:#f0ca88;filter:drop-shadow(0 8px 15px rgba(0,0,0,.5)) drop-shadow(0 0 8px rgba(218,174,105,.3));transform:translateY(-50%) scale(1.045); }
.book-edge-nav:focus-visible { outline:1px solid rgba(226,181,116,.7);outline-offset:-5px; }

.book-tabs-shell {
  position: absolute;
  z-index: 5;
  right: 0;
  bottom: 0;
  left: 0;
  height:var(--book-tabs-height);
  display: flex;
  align-items: center;
  padding: 0 clamp(52px, 7vw, 120px);
  background: rgba(5,10,15,.68);
  border-top: 1px solid rgba(188,151,98,.32);
  backdrop-filter: blur(7px);
}
.book-tabs {
  display: flex;
  width: 100%;
  min-width: 0;
  justify-content: center;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.book-tabs::-webkit-scrollbar { display: none; }
.book-tabs button {
  position: relative;
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 clamp(20px,2.4vw,38px);
  background: transparent;
  color: #9d988f;
  border: 0;
  border-left: 1px solid rgba(190,151,96,.18);
  border-radius: 0;
  font: 400 13px/1.2 Arial,sans-serif;
  white-space: nowrap;
  scroll-snap-align: center;
  transition: color 220ms ease-out, background 220ms ease-out;
}
.book-tabs button:last-child { border-right: 1px solid rgba(190,151,96,.18); }
.book-tabs button span { margin-right: 10px; color: #716e68; font-variant-numeric: tabular-nums; }
.book-tabs button::after {
  position: absolute;
  right:8px;
  bottom:0;
  left:8px;
  height:9px;
  background:url('/assets/ui/header-nav-chevron.svg') center / 100% 100% no-repeat;
  filter:drop-shadow(0 0 3px rgba(215,169,95,.34));
  content: '';
  opacity: 0;
  transform: scaleX(.35);
  transition: opacity 220ms ease-out, transform 320ms cubic-bezier(.16,1,.3,1);
}
.book-tabs button:hover { color: #e3d9cb; background: rgba(255,255,255,.025); }
.book-tabs button.is-active { color: #f0d9b4; }
.book-tabs button.is-active span { color: #d9aa63; }
.book-tabs button.is-active::after { opacity: 1; transform: scaleX(1); }
.book-tabs button:focus-visible { outline: 1px solid #d8aa65; outline-offset: -3px; }

/* Details and the final fragment page share one composition. */
.book-dialog,
.book-reader-dialog.is-offer {
  width: min(1080px, calc(100vw - 32px));
  max-height: min(820px, calc(100dvh - 32px));
  padding: 0;
  overflow: auto;
  background: #171b1d;
  color: #eee7dc;
  border: 1px solid #65503b;
}
.book-dialog[open],
.book-reader-dialog.is-offer[open] { display: grid; grid-template-columns: minmax(270px,390px) minmax(0,1fr); align-items: center; }
.book-dialog .dialog-cover,
.book-reader-dialog.is-offer .dialog-cover { display: block; width: 100%; height: 100%; max-height: min(818px,calc(100dvh - 34px)); object-fit: cover; background: #0d1112; }
.book-dialog .dialog-book-copy,
.book-reader-dialog.is-offer .dialog-book-copy { align-self: center; padding: clamp(34px,5vw,66px); }
.book-dialog .dialog-book-copy h2,
.book-reader-dialog.is-offer .dialog-book-copy h2 { margin: 10px 0 22px; color: #f0e8dc; font: 500 clamp(38px,5vw,68px)/1 var(--display,Georgia,serif); text-wrap: balance; }
.book-dialog .dialog-book-copy p,
.book-reader-dialog.is-offer .dialog-book-copy p { max-width: 56ch; margin: 0; color: #c1bbb1; font-size: 16px; line-height: 1.65; }
.book-dialog .dialog-book-copy h3,
.book-reader-dialog.is-offer .dialog-book-copy h3 { margin: 30px 0 11px; color: #d7b28f; font-size: 12px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
.book-dialog .dialog-close,
.book-reader-dialog .dialog-close { z-index: 4; width: 42px; height: 42px; color: #eee7dc; background: rgba(12,16,17,.82); line-height: 1; }
.book-description p + p { margin-top: 12px; }
.reader-return { margin-top: 26px; background: transparent; color: #d9b37c; border-color: #765b42; }

.book-reader-dialog:not(.is-offer) {
  width: min(860px,calc(100vw - 28px));
  height: min(720px,calc(100dvh - 28px));
  max-height: 900px;
  padding: 0;
  overflow: hidden;
  background: #171a19;
  color: #e8e1d5;
  border: 1px solid #62503d;
}
.book-reader-dialog:not(.is-offer)[open] { display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
.reader-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; padding: 26px 34px 18px; border-bottom: 1px solid rgba(187,148,92,.3); }
.reader-heading span { color: #d7b985; font: 24px/1.1 var(--display,Georgia,serif); }
.reader-heading strong { color: #918a80; font-size: 10px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
.reader-page {
  min-height: 0;
  padding: clamp(32px,5vw,58px) clamp(30px,8vw,84px);
  overflow-y: auto;
  background: radial-gradient(circle at 50% 25%,rgba(65,61,50,.28),transparent 50%);
  color: #ddd6ca;
  font: clamp(17px,1.5vw,20px)/1.8 Georgia,serif;
  scrollbar-color: #735b40 transparent;
}
.reader-page p { max-width: 64ch; margin: 0 auto 1em; text-wrap: pretty; }
.reader-page h3 { max-width: 64ch; margin: 0 auto 1em; color: #eadfcf; font-size: 1.3em; }
.reader-controls { display: grid; grid-template-columns: 150px 1fr 190px; align-items: center; gap: 12px; min-height: 72px; padding: 12px 22px; background: #111514; border-top: 1px solid rgba(187,148,92,.3); }
.reader-controls span { color: #827b72; font-size: 11px; text-align: center; }
.reader-controls button { min-height: 42px; background: transparent; color: #dfd3c2; border-color: #65503b; }
.reader-controls .reader-next { background: #684128; border-color: #a5784c; }
.reader-controls button:disabled { visibility: hidden; }

@media (min-width:768px) {
  body .books {
    height:calc(100svh - 72px);
    min-height:0;
    max-height:calc(100svh - 72px);
  }
  .book-showcase { padding-block:clamp(14px,4.5svh,76px); }
  .book-copy time { margin-bottom:clamp(6px,1.6svh,12px); }
  .book-copy h2 { font-size:clamp(30px,min(4.4vw,8cqh),68px); }
  .book-copy-divider { margin-block:clamp(8px,2.2cqh,18px) clamp(8px,2cqh,16px); }
  .book-copy p { display:-webkit-box;overflow:hidden;font-size:clamp(12px,2cqh,16px);line-height:1.55;-webkit-box-orient:vertical;-webkit-line-clamp:5; }
  .book-actions { margin-top:clamp(10px,2.7cqh,22px); }
  .book-actions button { height:clamp(44px,7cqh,52px); }
  .book-object {
    display:block;
    width:auto;
    max-width:100%;
    height:min(620px,58cqh);
  }
  .book-front { min-width:0;height:100%; }
  .book-front img { width:auto;height:100%;max-width:100%;max-height:none;object-fit:contain; }
}

@media (max-width: 900px) {
  body .books { --book-tabs-height:66px;--book-nav-size:38px; }
  .book-showcase { bottom:var(--book-tabs-height);padding:42px 0 28px; }
  .book-showcase-content { grid-template-columns:minmax(0,1fr) minmax(170px,39vw);width:calc(100% - 164px);height:70%;min-height:0;justify-content:stretch;gap:clamp(32px,5vw,50px);margin-right:90px; }
  .book-object-frame { width:100%;place-items:center end; }
  .book-copy h2 { font-size: clamp(34px,6.4vw,52px); }
  .book-copy p { display: -webkit-box; overflow: hidden; font-size: 14px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 7; }
  .book-actions { margin-top: 20px; }
  .book-actions button { min-width: 0; }
  .book-tabs-shell { height:var(--book-tabs-height);padding:0 42px; }
  .book-tabs { justify-content: flex-start; }
  .book-tabs button { min-height: 42px; padding-inline: 22px; font-size: 12px; }
  .book-tabs button::after { bottom:0; }
  .book-edge-nav { width:44px; }
}

@media (min-width:768px) and (max-width:900px) {
  .book-showcase-content { grid-template-columns:minmax(0,520px) max-content;justify-content:end; }
}

@media (max-width:767px) {
  body .books { height:100dvh;min-height:0;max-height:100dvh; }
}

@media (max-width: 600px) {
  body .books { --book-tabs-height:60px;--book-nav-size:30px; }
  .books-shade { background:linear-gradient(90deg,rgba(4,10,16,.07),rgba(5,11,18,.34) 48%,rgba(4,9,15,.68)),linear-gradient(0deg,rgba(4,9,14,.52),transparent 42%,rgba(4,9,14,.14)); }
  .book-showcase { bottom:var(--book-tabs-height);padding:28px 0 20px; }
  .book-showcase-content { grid-template-columns:minmax(0,1fr) minmax(126px,40vw);width:calc(100% - 104px);height:68%;min-height:0;gap:clamp(12px,4vw,16px);margin-right:52px; }
  .book-copy time { margin-bottom:7px;font-size:8px; }
  .book-copy .book-series { margin-bottom:5px;font-size:10px;letter-spacing:.03em;white-space:nowrap; }
  .book-copy h2 { max-width:100%;font-size:clamp(17px,5.5vw,25px);line-height:1.02;overflow-wrap:normal;word-break:normal; }
  .book-copy-divider { margin: 12px 0; }
  .book-copy p { font-size: clamp(11px,3.2vw,13px); line-height: 1.45; -webkit-line-clamp: 6; }
  .book-actions { display:grid;justify-items:end;gap:7px;margin-top:15px; }
  .book-actions button { width:100%;max-width:none;height:44px;padding:0 10px;font-size:11px; }
  .book-object { width:90%;margin-left:auto;transform:none; }
  .book-front img { max-height:43dvh; }
  .book-tabs-shell { height:var(--book-tabs-height);padding:0 34px;backdrop-filter:none; }
  .book-tabs button { min-height: 38px; padding-inline: 17px; font-size: 10px; }
  .book-tabs button span { margin-right: 7px; }
  .book-tabs button::after { right:8px;bottom:0;left:8px; }
  .book-edge-nav { width:34px; }
  .book-dialog,
  .book-reader-dialog.is-offer { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
  .book-dialog[open],
  .book-reader-dialog.is-offer[open] { grid-template-columns: 110px minmax(0,1fr); align-items: start; padding: 52px 14px 18px; gap: 14px; }
  .book-dialog .dialog-cover,
  .book-reader-dialog.is-offer .dialog-cover { height: auto; max-height: 42dvh; object-fit: contain; }
  .book-dialog .dialog-book-copy,
  .book-reader-dialog.is-offer .dialog-book-copy { min-width: 0; padding: 0; }
  .book-dialog .dialog-book-copy h2,
  .book-reader-dialog.is-offer .dialog-book-copy h2 { margin: 6px 0 10px; font-size: clamp(24px,7.5vw,34px); overflow-wrap: anywhere; }
  .book-dialog .dialog-book-copy p,
  .book-reader-dialog.is-offer .dialog-book-copy p { display: -webkit-box; overflow: hidden; font-size: 12px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 8; }
  .book-dialog .dialog-book-copy h3,
  .book-reader-dialog.is-offer .dialog-book-copy h3 { margin: 14px 0 7px; font-size: 9px; }
  .book-reader-dialog:not(.is-offer) { width: calc(100vw - 10px); height: calc(100dvh - 10px); }
  .reader-heading { align-items: start; flex-direction: column; gap: 5px; padding: 20px 46px 14px 18px; }
  .reader-heading span { font-size: 20px; }
  .reader-page { padding: 26px 21px; font-size: 16px; line-height: 1.7; }
  .reader-controls { grid-template-columns: 74px 1fr 112px; gap: 6px; min-height: 64px; padding: 9px; }
  .reader-controls button { min-width: 0; padding: 8px 5px; font-size: 10px; }
  .reader-controls span { font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .books-art,
  .book-showcase-content,
  .book-actions button,
  .book-tabs button,
  .book-tabs button::after { transition: none; }
  .book-nav-glyph { transition:none; }
  .book-showcase-content.is-leaving,
  .book-showcase-content.is-entering { filter: none; transform: none; }
  .book-actions button::after { animation:none; }
}
