/* WebGL book on the home page (html.book-gl) + the classic/3D switch. Tokens come from app/base.css. */

/* the canvas fills the whole viewport; header, pager and footer float over it */
.gl-stage { display: none; position: fixed; inset: 0; z-index: 1; touch-action: none; user-select: none; -webkit-user-select: none; opacity: 0; transition: opacity .6s; }
.book-gl .gl-stage { display: block; }
.book-gl.ready .gl-stage { opacity: 1; }
#gl { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
#gl.dragging { cursor: grabbing !important; }
.book-gl .scene { display: none; }

/* translucent chrome over the canvas */
.book-gl .site-head {
  background: linear-gradient(var(--gl-head-a), var(--gl-head-b));
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--gl-head-br);
}
.book-gl .book-foot { background: var(--gl-foot); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.book-gl .pager { pointer-events: none; }
.book-gl .pager > * { pointer-events: auto; }

/* classic / 3D switch: under the header, top right */
.book-switch { position: fixed; z-index: 12; top: 68px; right: max(16px, env(safe-area-inset-right)); height: 32px; font-size: 11px; }
.book-switch[hidden] { display: none; }
.book-switch:hover { border-color: var(--acc); color: var(--acc); }
html:not(.ready):not(.boot-error) .book-switch { opacity: 0; }
.book-switch { transition: opacity .4s; }

@media (max-width: 640px) {
  .book-switch { top: 64px; right: 10px; height: 30px; padding: 0 10px; font-size: 10px; letter-spacing: .06em; }
}

/* gentle vignette + warm light pool behind the book (colours are tokens: a dark theme overrides them) */
:root { --gl-vig: rgba(60, 66, 40, .22); --gl-pool: rgba(255, 238, 205, .55); --gl-head-a: rgba(248, 246, 239, .78); --gl-head-b: rgba(248, 246, 239, .5); --gl-head-br: rgba(22, 36, 26, .06); --gl-foot: rgba(244, 241, 232, .6); }
[data-theme="dark"] { --gl-vig: rgba(2, 5, 3, .62); --gl-pool: rgba(92, 128, 70, .42); --gl-head-a: rgba(14, 21, 17, .82); --gl-head-b: rgba(14, 21, 17, .55); --gl-head-br: rgba(239, 233, 220, .07); --gl-foot: rgba(14, 21, 17, .66); }
.gl-stage::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(58% 50% at 50% 46%, var(--gl-pool), transparent 72%); }
.gl-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 100% at 50% 46%, transparent 58%, var(--gl-vig) 100%); }
