/* Sandro's Virtual Publishing House — HTML/CSS/JS version of the 2004 Flash site */
:root { --bg: #d4d0c8; --paper: #f1e6dc; --ink: #5f0101; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  display: flex; flex-direction: column; align-items: safe center; justify-content: safe center;
  overflow-x: hidden;
}

/* ---------- stage: a fixed 960×580 canvas, scaled to the window by site.js ---------- */
.stage-wrap { position: relative; width: 960px; height: 580px; flex: none; }
.stage {
  position: absolute; left: 0; top: 0; width: 960px; height: 580px;
  transform-origin: 0 0; perspective: 2200px; overflow: hidden;
}
.bookbg { position: absolute; left: 0; top: 0; display: block; user-select: none; -webkit-user-drag: none; }

/* pieces placed with the original coordinates */
.stage .t, .stage .g, .stage .b, .stage .e { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.t span { position: absolute; white-space: pre; line-height: 1; }
.g { display: block; max-width: none; user-select: none; -webkit-user-drag: none; }
.e { line-height: 1.22; }
.e p { margin: 0; }
.e a { color: inherit; text-decoration: none; }
.e a:hover { text-decoration: underline; }

/* buttons: "up" and "over" layers swap on hover, the hit area is the only clickable part */
.b { display: block; width: 0; height: 0; pointer-events: none; text-decoration: none; outline: none; }
.b .hit { position: absolute; pointer-events: auto; cursor: pointer; }
.b .ov { visibility: hidden; }
.b:hover .ov, .b:focus-visible .ov, .tabs .b[aria-current] .ov { visibility: visible; }
.b:hover .up, .b:focus-visible .up, .tabs .b[aria-current] .up { visibility: hidden; }
.b:focus-visible .hit { outline: 2px dashed var(--ink); outline-offset: 2px; }

/* tabs (paper bookmarks) rise a little on hover */
.tabs .b > :not(.hit) { transition: translate .18s ease-out; }
.tabs .b:hover > :not(.hit), .tabs .b:focus-visible > :not(.hit) { translate: 0 -5px; }

/* ---------- pages ---------- */
/* the page layer covers the whole stage, so it must let clicks through to the tabs underneath */
.page { position: absolute; inset: 0; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s .25s; }
.page.on { opacity: 1; visibility: visible; transition: opacity .35s ease; }
.page.on > .t, .page.on > .e { pointer-events: auto; }

/* turning sheet */
.flip {
  position: absolute; top: 135px; height: 435px; width: 432px; left: 481px;
  transform-origin: 0 50%; transform-style: preserve-3d; visibility: hidden; pointer-events: none;
}
.flip i {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, #e3d3c3 0, var(--paper) 22%, #f6eee6 100%);
  box-shadow: 0 0 18px rgba(60, 30, 10, .25);
}
.flip.back { left: 49px; transform-origin: 100% 50%; }
.flip.back i { background: linear-gradient(270deg, #e3d3c3 0, var(--paper) 22%, #f6eee6 100%); }
.flip.run { visibility: visible; animation: turn-fwd .7s cubic-bezier(.45, .05, .35, 1) both; }
.flip.back.run { animation-name: turn-back; }
@keyframes turn-fwd { from { transform: rotateY(0); } to { transform: rotateY(-180deg); } }
@keyframes turn-back { from { transform: rotateY(0); } to { transform: rotateY(180deg); } }

/* ---------- loader: seven letters fade in one by one while the percentage counts up ---------- */
.loader { position: absolute; left: 475.05px; top: 406.1px; width: 0; height: 0; visibility: hidden; pointer-events: none; }
.loader.show { visibility: visible; }
.loader.inbook { left: 480.1px; top: 350.05px; }
.loader .g { opacity: 0; }
.loader .pct { position: absolute; left: -15px; top: 51px; white-space: nowrap; font: 900 14px "Arial Black", Arial, sans-serif; color: #000033; }
.stage.loading > :not(.loader) { visibility: hidden; }
.stage.ready > .bookbg, .stage.ready > .tabs { animation: appear .5s ease both; }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

/* e-book playing inside the open book (placed over the two pages by site.js) */
.bookplayer { position: absolute; background: #e4dfd1; overflow: hidden; }
.bookplayer[hidden] { display: none; }
.bookplayer > * { width: 100%; height: 100%; display: block; }

/* ---------- language links ---------- */
.langs { flex: none; display: flex; gap: 22px; padding: 10px 16px 14px; font-size: 13px; }
.langs a { color: #6b5a48; text-decoration: none; }
.langs a:hover { color: var(--ink); text-decoration: underline; }
.langs a[aria-current] { color: var(--ink); font-weight: bold; }

/* ---------- e-book / game player ---------- */
.player {
  border: 0; padding: 0; background: #000033; overflow: visible;
  width: min(864px, 96vw); max-width: none; max-height: none;
  box-shadow: 0 12px 60px rgba(0, 0, 0, .55);
}
.player::backdrop { background: rgba(40, 28, 18, .72); }
.player-box { width: 100%; aspect-ratio: 864 / 434; display: block; }
.player-box > * { width: 100%; height: 100%; display: block; }
.player-close {
  position: absolute; right: -6px; top: -40px; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: var(--paper); color: var(--ink); font: bold 22px/1 Arial, sans-serif; cursor: pointer;
}
.player-close:hover { background: #fff; }

/* ---------- start page ---------- */
.start { text-align: center; padding: 24px 16px; }
.start h1 { font-size: 15px; font-weight: normal; letter-spacing: .04em; color: #6b5a48; margin: 0 0 28px; }
.start ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; }
.start a {
  display: block; padding: 22px 30px; min-width: 190px; background: var(--paper); color: var(--ink);
  text-decoration: none; font-size: 20px; box-shadow: 0 2px 10px rgba(60, 30, 10, .25);
  transition: transform .18s ease-out, box-shadow .18s;
}
.start li:nth-child(1) a { transform: rotate(-2deg); }
.start li:nth-child(2) a { transform: rotate(1.5deg); }
.start li:nth-child(3) a { transform: rotate(-1deg); }
.start a:hover, .start a:focus-visible { transform: translateY(-5px) rotate(0); box-shadow: 0 8px 18px rgba(60, 30, 10, .3); }
.start small { display: block; font-size: 12px; color: #6b5a48; margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  .flip.run { animation-duration: .01s; }
  .tabs .b > :not(.hit) { transition: none; }
}
