:root {
  color: #17181b;
  background: #f2eee4;
  font: .875rem/1.4 "Space Mono", monospace;
  --rule: #17181b30;
  --rust: #c24e2c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  overscroll-behavior: none;
}
.reader-header, .reader-footer {
  display: grid;
  align-items: center;
  gap: clamp(6px, 2vw, 24px);
  padding: 8px clamp(8px, 3vw, 36px);
  min-width: 0;
}
.reader-header {
  grid-template-columns: auto minmax(0, 24rem) auto;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
}
.reader-footer {
  grid-template-columns: 1fr minmax(0, auto) 1fr;
  border-top: 1px solid var(--rule);
}
.reader-footer button:last-child { justify-self: end; }
.reader-footer button:first-child { justify-self: start; }
a { color: inherit; text-decoration: none; }
a:hover, .wordmark span { color: var(--rust); }
.wordmark { font: 1.7rem/1 Anton, Impact, sans-serif; }
button, select { font: inherit; color: inherit; }
select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: #e9e2d2;
  padding-inline: 6px;
  text-overflow: ellipsis;
}
button {
  min-height: 36px;
  padding: 4px clamp(6px, 2vw, 16px);
  border: 1px solid #17181b;
  border-radius: 2px;
  background: #17181b;
  color: #f2eee4;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--rust); border-color: var(--rust); }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid #3e6e68; outline-offset: 2px; }
#position { margin: 0; text-align: center; }
#stage { min-width: 0; min-height: 0; display: grid; place-items: center; overflow: clip; }
#book {
  position: relative;
  isolation: isolate;
  overflow: clip;
  background: #e9e2d2;
  box-shadow: 0 10px 36px #17181b24;
}
.sheet {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fbf8f1;
}
.sheet iframe {
  position: absolute;
  display: block;
  inset: 0;
  border: 0;
  transform-origin: top left;
}
.sheet.turning { z-index: 2; pointer-events: none; background: transparent; }
.sheet.turning .paper-front { clip-path: var(--front, none); }
.paper-front { position: absolute; inset: 0; }
.paper-back, .paper-shadow { position: absolute; pointer-events: none; }
.paper-back {
  inset: 0;
  clip-path: polygon(0 0,0 0,0 0);
  background: linear-gradient(to var(--shade-direction, right), #d6c9af, #faf4e7 55%, #e5d9c2);
  box-shadow: inset 0 0 35px #86765d36;
}
.paper-shadow {
  z-index: 1;
  width: 70px;
  height: 145%;
  bottom: 0;
  left: -35px;
  transform-origin: 50% 100%;
  background: linear-gradient(90deg, transparent, #342a1e 49%, transparent);
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.fallback { position: fixed; inset: 30% 10% auto; }
@media (max-width: 480px), (max-height: 450px) {
  :root { font-size: .75rem; }
  .reader-header, .reader-footer { padding-block: 4px; }
  button, select { min-height: 32px; }
}
