:root {
  --black: #080706;
  --ink: #17120e;
  --cream: #e9dfce;
  --gold: #c69a58;
  --hot: #e83c87;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 15%, rgba(138, 97, 55, .18), transparent 42rem),
    linear-gradient(180deg, #15100c 0, var(--black) 44rem);
  color: var(--cream);
  font-family: Arial, Helvetica, sans-serif;
}

a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.site-header {
  width: min(1180px, calc(100% - 32px));
  min-height: 74px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(198, 154, 88, .5);
}

.wordmark {
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 2.6vw, 2rem);
  font-style: italic;
  font-weight: 700;
  letter-spacing: -.04em;
  text-decoration: none;
}

.issue { text-align: right; line-height: 1.2; }
.issue strong { display: block; color: var(--hot); font-size: .84rem; letter-spacing: .18em; }
.issue span { color: #b9ad9d; font-size: .72rem; letter-spacing: .12em; }

main { padding: clamp(18px, 3vw, 38px) 16px 20px; }
.reader { width: min(1180px, 100%); margin: 0 auto; }

.reader-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(74vh, 760px);
  padding: 8px 48px;
  perspective: 2200px;
}

.book {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: min(100%, calc((74vh - 20px) * 1.54545));
  max-height: 760px;
  aspect-ratio: 1224 / 792;
  filter: drop-shadow(0 20px 26px rgba(0, 0, 0, .58));
  transform-style: preserve-3d;
}

.book.single { width: min(52%, calc((74vh - 20px) * .77273)); aspect-ratio: 612 / 792; }

.page {
  display: block;
  width: 50%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  user-select: none;
  -webkit-user-drag: none;
}

.single .page { width: 100%; }
.page-left { transform-origin: right center; }
.page-right { transform-origin: left center; }
.page-left:not([src]), .page-right:not([src]) { display: none; }
.page-left { box-shadow: inset -12px 0 20px -18px rgba(0,0,0,.8); }
.page-right { box-shadow: inset 12px 0 20px -18px rgba(0,0,0,.8); }

.page-turn {
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.42), rgba(255,255,255,.08), rgba(0,0,0,.22));
  opacity: 0;
  transform-origin: left center;
}

.book.turning-forward .page-turn { animation: turn-forward .44s ease-in-out; }
.book.turning-back .page-turn { left: 0; right: auto; transform-origin: right center; animation: turn-back .44s ease-in-out; }

@keyframes turn-forward {
  0% { opacity: 0; transform: rotateY(0); }
  45% { opacity: .78; }
  100% { opacity: 0; transform: rotateY(-178deg); }
}
@keyframes turn-back {
  0% { opacity: 0; transform: rotateY(0); }
  45% { opacity: .78; }
  100% { opacity: 0; transform: rotateY(178deg); }
}

.page-zone {
  position: absolute;
  z-index: 4;
  top: 7%;
  bottom: 7%;
  width: 14%;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.page-zone-left { left: 0; cursor: w-resize; }
.page-zone-right { right: 0; cursor: e-resize; }
.page-zone:focus-visible { outline: 2px solid var(--hot); outline-offset: -4px; }

.loading {
  position: absolute;
  color: var(--gold);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .18em;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
}

.controls button, .controls a {
  border: 1px solid rgba(198, 154, 88, .5);
  background: #100d0a;
  color: var(--cream);
  min-height: 42px;
  padding: 0 15px;
  font: 700 .73rem/1 Arial, Helvetica, sans-serif;
  letter-spacing: .1em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.controls button:hover, .controls a:hover { border-color: var(--hot); color: #fff; }
.controls button:disabled { opacity: .32; cursor: default; }
#pageStatus { min-width: 116px; text-align: center; color: var(--gold); font-size: .75rem; letter-spacing: .12em; }
.control-divider { width: 1px; height: 28px; background: rgba(198, 154, 88, .35); }
.reader-help { text-align: center; color: #887e72; font-size: .75rem; letter-spacing: .04em; }

footer {
  width: min(1180px, calc(100% - 32px));
  margin: 10px auto 0;
  padding: 24px 0 34px;
  border-top: 1px solid rgba(198, 154, 88, .28);
  display: flex;
  justify-content: space-between;
  color: #80766b;
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .14em;
}
footer a { text-decoration: none; color: var(--gold); }
.noscript { margin: 20px; text-align: center; }

body.fullscreen .site-header,
body.fullscreen footer,
body.fullscreen .reader-help { display: none; }
body.fullscreen main { padding: 0; }
body.fullscreen .reader { width: 100%; }
body.fullscreen .reader-stage { height: calc(100vh - 60px); max-height: none; }
body.fullscreen .book { max-height: calc(100vh - 80px); }

@media (max-width: 720px) {
  .site-header { min-height: 62px; }
  main { padding: 12px 8px 18px; }
  .reader-stage { min-height: 68vh; padding: 4px 22px; }
  .book, .book.single { width: min(100%, calc((68vh - 12px) * .77273)); aspect-ratio: 612 / 792; }
  .page { width: 100%; }
  .page-left { display: none !important; }
  .page-zone { width: 22%; }
  .controls { gap: 7px; }
  .controls button, .controls a { min-height: 40px; padding: 0 10px; font-size: .66rem; }
  .control-divider { display: none; }
  #pageStatus { order: -1; width: 100%; min-height: 18px; }
  .reader-help { display: none; }
  footer { padding-bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .book.turning-forward .page-turn,
  .book.turning-back .page-turn { animation: none; }
}
