/* The master thesis as a book. A4 pages in the original layout, set by scripts/build_thesis.mjs;
   without JS they stand one below the other, with book.js they turn like a book. */
:root { --ink: #101010; --muted: #6a6a63; --soft-line: #cfcfca; --paper: #ffffff; --desk: #efefeb; }
html, body { margin: 0; }
body { background: var(--desk); color: var(--ink); font-family: Arial, Helvetica, sans-serif; }
a { color: var(--ink); }
a:focus-visible, button:focus-visible, .book:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 30; background: var(--paper); padding: 10px 14px; }
.skip-link:focus { top: 12px; }

.book-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  min-height: 52px; padding: 0 20px; box-sizing: border-box;
  background: var(--paper); border-top: 2px solid var(--ink); border-bottom: 1px solid var(--soft-line);
  font-size: 12px; letter-spacing: .08em;
}
.book-head span { color: var(--muted); }
.book-head a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.book-note { text-align: center; font-size: 13px; padding: 0 16px 40px; }

/* without JS: every page, one below the other */
.spread { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 24px 0 48px; }
.page { box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 12px 32px rgba(0, 0, 0, .07); flex: none; }
@media (max-width: 860px) { html:not(.book-on) .page { zoom: .8; } }
@media (max-width: 640px) { html:not(.book-on) .page { zoom: .6; } }
@media (max-width: 480px) { html:not(.book-on) .page { zoom: .46; } }

/* with JS: a spread, or one page on narrow screens */
.book-on body { overflow: hidden; }
.book-on .book { position: fixed; inset: 52px 0 72px; outline: none; }
.book-on .stage { position: absolute; inset: 0; overflow: hidden; }
.book-on .spread {
  position: absolute; left: 50%; top: 50%; display: block; padding: 0; gap: 0;
  width: 1190.56pt; height: 841.89pt;
  transform: translate(-50%, -50%) scale(var(--s, 1)); transform-origin: 50% 50%;
  perspective: 2600px;
}
.book-on .spread.is-single { width: 595.28pt; }
.book-on .spread > .page { position: absolute; top: 0; display: none; }
.book-on .spread > .page.at-left { display: block; left: 0; box-shadow: inset -16px 0 20px -16px rgba(0, 0, 0, .16), 0 12px 32px rgba(0, 0, 0, .08); }
.book-on .spread > .page.at-right { display: block; left: 595.28pt; box-shadow: inset 16px 0 20px -16px rgba(0, 0, 0, .16), 0 12px 32px rgba(0, 0, 0, .08); }
.book-on .spread > .page.at-one { display: block; left: 0; }
.book-on .spread > .page { cursor: pointer; user-select: none; -webkit-user-select: none; }

.leaf {
  position: absolute; top: 0; z-index: 5; width: 595.28pt; height: 841.89pt;
  transform-style: preserve-3d;
  transition: transform .95s cubic-bezier(.42, .06, .22, 1), opacity .95s ease-in;
  pointer-events: none;
}
.leaf .face { position: absolute; inset: 0; overflow: hidden; background: var(--paper); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.leaf .face.back { transform: rotateY(180deg); }
.leaf .face > .page { position: absolute; left: 0; top: 0; display: block; box-shadow: none; }
.leaf .face::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.leaf.from-right { left: 595.28pt; transform-origin: 0 50%; }
.leaf.from-right.turn { transform: rotateY(-180deg); }
.leaf.from-right .face:not(.back)::after { background: linear-gradient(to right, rgba(0, 0, 0, .10), transparent 30%); }
.leaf.from-left { left: 0; transform-origin: 100% 50%; }
.leaf.from-left.turn { transform: rotateY(180deg); }
.leaf.from-left .face:not(.back)::after { background: linear-gradient(to left, rgba(0, 0, 0, .10), transparent 30%); }
.leaf.from-one { left: 0; transform-origin: 0 50%; }
.leaf.from-one.turn { transform: rotateY(-180deg); opacity: 0; }
.leaf.from-one.reverse { transform: rotateY(-180deg); opacity: 0; }
.leaf.from-one.reverse.turn { transform: none; opacity: 1; }

.book-controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: 72px;
  display: flex; justify-content: center; align-items: center; gap: 20px;
  background: var(--paper); border-top: 1px solid var(--soft-line);
}
.book-controls[hidden] { display: none; }
.book-controls .turn {
  width: 48px; height: 44px; border: 1px solid var(--ink); border-radius: 0; background: var(--paper); color: var(--ink);
  font: 18px Arial, Helvetica, sans-serif; cursor: pointer;
}
.book-controls .turn:disabled { opacity: .25; cursor: default; }
.book-controls .count { min-width: 104px; text-align: center; font-size: 12px; letter-spacing: .2em; color: var(--muted); }
@media (hover: hover) { .book-controls .turn:not(:disabled):hover { background: var(--ink); color: var(--paper); } }
@media (prefers-reduced-motion: reduce) { .leaf { transition: none; } }
