/* Two scenes. Scene one: a Three.js meadow seen from above with a white-marble grimoire resting on it (CSS 3D).
   Scene two: the reader, a flat two-column page with page-turn transitions, a glass menu, the crystal and two views. */
:root {
  --grass-deep: #0e2d0b;
  --gold-hi: #f0d78a;
  --gold: #c49a30;
  --gold-lo: #8a6212;
  --ink: #3a2d12;
  --display: 'Caesar Dressing', 'Marcellus', Georgia, serif;
  --text: 'Afacad Flux', 'Iowan Old Style', Georgia, serif;
  --rune: 'Noto Sans Phoenician', sans-serif;
  --T: 34px;
  --Tc: 14px;
  --P: 520px;
  --H: 600px;
  --fs: 14px;
  --s: 1;
  --sc: 1; --sf: 1; --so: 1;
  --flip: 1.35s;
  --ease: cubic-bezier(.62, .03, .2, 1);
  --grain: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .6 0 0 0 0 .6 0 0 0 0 .62 0 0 0 .12 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --motif: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cg fill='none' stroke='%23c49a30' stroke-width='1.3' stroke-linecap='round'%3E%3Cpath d='M30 4c6 0 10 4 10 9s-4 7-7 7-5-2-5-4 2-3 3-3M30 4c-6 0-10 4-10 9s4 7 7 7 5-2 5-4-2-3-3-3'/%3E%3Cpath d='M30 56c6 0 10-4 10-9s-4-7-7-7-5 2-5 4 2 3 3 3M30 56c-6 0-10-4-10-9s4-7 7-7 5 2 5 4-2 3-3 3'/%3E%3Cpath d='M4 30c0-6 4-10 9-10s7 4 7 7-2 5-4 5-3-2-3-3M56 30c0-6-4-10-9-10s-7 4-7 7 2 5 4 5 3-2 3-3'/%3E%3Cpath d='M4 30c0 6 4 10 9 10s7-4 7-7-2-5-4-5-3 2-3 3M56 30c0 6-4 10-9 10s-7-4-7-7 2-5 4-5 3 2 3 3'/%3E%3Cpath d='M30 24l4 6-4 6-4-6z'/%3E%3Cpath d='M0 0q8 8 0 16M60 0q-8 8 0 16M0 60q8-8 0-16M60 60q-8-8 0-16'/%3E%3C/g%3E%3Cg fill='%23c49a30'%3E%3Ccircle cx='30' cy='30' r='1.6'/%3E%3Ccircle cx='30' cy='2' r='1.1'/%3E%3Ccircle cx='30' cy='58' r='1.1'/%3E%3Ccircle cx='2' cy='30' r='1.1'/%3E%3Ccircle cx='58' cy='30' r='1.1'/%3E%3C/g%3E%3C/svg%3E");
  --motif-small: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cg fill='none' stroke='%23b98a24' stroke-width='1' stroke-linecap='round'%3E%3Cpath d='M12 2c3 0 5 2 5 4s-2 3-3 3-2-1-2-2M12 2c-3 0-5 2-5 4s2 3 3 3 2-1 2-2'/%3E%3Cpath d='M12 22c3 0 5-2 5-4s-2-3-3-3-2 1-2 2M12 22c-3 0-5-2-5-4s2-3 3-3 2 1 2 2'/%3E%3Cpath d='M2 12c0-3 2-5 4-5s3 2 3 3-1 2-2 2M22 12c0-3-2-5-4-5s-3 2-3 3 1 2 2 2M2 12c0 3 2 5 4 5s3-2 3-3-1-2-2-2M22 12c0 3-2 5-4 5s-3-2-3-3 1-2 2-2'/%3E%3C/g%3E%3Ccircle cx='12' cy='12' r='1' fill='%23b98a24'/%3E%3C/svg%3E");
}
html, body { height: 100%; }
body { margin: 0; background: #0a1a07; color: var(--ink); overflow: hidden; font-family: var(--text); font-weight: 400; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* ---------- marble: four vein textures, each page picks one and an offset, so no two pages match ---------- */
.m0 { --marble: url(../assets/marble-0.webp); } .m1 { --marble: url(../assets/marble-1.webp); } .m2 { --marble: url(../assets/marble-2.webp); } .m3 { --marble: url(../assets/marble-3.webp); }
.o0 { --mpos: 0 0; --msize: 560px; } .o1 { --mpos: 40% 70%; --msize: 680px; } .o2 { --mpos: 75% 20%; --msize: 620px; } .o3 { --mpos: 15% 85%; --msize: 740px; }
.marble, .page, .face, .rear {
  --marble: url(../assets/marble-0.webp); --mpos: 0 0; --msize: 600px;
  background:
    radial-gradient(55% 38% at 24% 18%, rgba(255, 255, 255, .7), transparent 70%),
    radial-gradient(48% 34% at 76% 62%, rgba(255, 255, 255, .45), transparent 70%),
    var(--marble) var(--mpos) / var(--msize) var(--msize) repeat,
    var(--grain),
    linear-gradient(160deg, rgba(255, 255, 255, .965), rgba(247, 247, 251, .94));
}

/* ======================================================= scene one ======================================================= */
#landing { position: fixed; inset: 0; z-index: 1; transition: opacity .5s ease; }
#landing.leaving { opacity: 0; }
#grass { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
body.nogl #landing { background: repeating-linear-gradient(100deg, #1f5a14 0 6px, #2c7a1c 6px 12px, #3c9024 12px 18px); }
.light { position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(70% 50% at 78% 0%, rgba(255, 250, 220, .5), transparent 66%), radial-gradient(90% 40% at 50% 0%, rgba(240, 255, 230, .45), transparent 70%), radial-gradient(120% 90% at 50% 120%, rgba(6, 26, 5, .32), transparent 60%); }
/* the meadow's glow: a soft pale-green bloom laid over the field */
.light::after { content: ''; position: absolute; inset: 0; background: radial-gradient(60% 45% at 50% 42%, rgba(205, 255, 170, .22), transparent 70%); mix-blend-mode: screen; }

.stage { position: fixed; inset: 0; z-index: 3; perspective: 2600px; perspective-origin: 50% 46%; overflow: hidden; }
.cam { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; transform: scale(var(--s)); transition: transform 1.5s var(--ease); }
body[data-state="closed"] { --s: var(--sc); }
body[data-state="float"]  { --s: var(--sf); }
body[data-state="open"]   { --s: var(--so); }
.hover { position: absolute; left: 0; top: 0; transform-style: preserve-3d; }
body[data-state="float"] .hover, body[data-state="open"] .hover { animation: bob 6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-11px); } }
.book {
  position: absolute; left: calc(var(--P) / -2); top: calc(var(--H) / -2); width: var(--P); height: var(--H);
  transform-style: preserve-3d; font-size: var(--fs); cursor: pointer; outline: none;
  transform: rotateX(24deg) rotateZ(-7deg) rotateY(5deg);
  transition: transform 1.5s var(--ease);
}
body[data-state="float"] .book { transform: translateZ(150px) rotateX(18deg) rotateZ(-3deg) rotateY(4deg); }
body[data-state="open"] .book  { transform: translateX(calc(var(--P) / 2)) translateZ(40px) rotateX(14deg); }
/* the book's weight on the ground: a soft dark pool under it (the blades themselves flatten in the shader) */
.shadow { position: absolute; left: calc(var(--P) / -2 * 1.06); top: calc(var(--H) / -2 * 1.04); width: calc(var(--P) * 1.12); height: calc(var(--H) * 1.08); border-radius: 50%;
  background: radial-gradient(closest-side, rgba(4, 18, 3, .7), rgba(4, 18, 3, .35) 60%, transparent 100%); filter: blur(12px); transform: translateZ(-60px) rotateX(24deg) rotateZ(-7deg); transition: transform 1.5s var(--ease), opacity 1.2s ease; }
body[data-state="float"] .shadow { transform: translateZ(-60px) scale(1.15) rotateX(18deg); opacity: .4; }
body[data-state="open"] .shadow { transform: translate3d(calc(var(--P) / 2), 0, -60px) scale(2.05, 1.08) rotateX(14deg); opacity: .8; }
.book:focus-visible { outline: 2px solid #ffe9a0; }

.leaf { position: absolute; inset: 0; transform-origin: 0 50%; transform-style: preserve-3d; transition: transform var(--flip) cubic-bezier(.5, .04, .22, 1); pointer-events: none; }
.leaf.near { pointer-events: auto; }
.leaf.flipped .face.front, .leaf:not(.flipped) .face.back { pointer-events: none; }
.face, .rear {
  position: absolute; inset: 0; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .9), inset 0 0 40px rgba(255, 255, 255, .5), inset 0 0 90px rgba(220, 222, 232, .35);
  border: 1px solid rgba(214, 206, 180, .8); border-radius: 2px 7px 7px 2px; box-sizing: border-box;
}
.face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face.back { transform: rotateY(180deg); border-radius: 7px 2px 2px 7px; }
.face::before, .rear::before { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(120, 110, 90, .28), rgba(120, 110, 90, .07) 7%, transparent 14%); }
.face.back::before { background: linear-gradient(270deg, rgba(120, 110, 90, .28), rgba(120, 110, 90, .07) 7%, transparent 14%); }
.face.cover::before { background: linear-gradient(90deg, rgba(255, 255, 255, .6), transparent 6%); }
.face.cover, .rear { background-color: #f7f7fa; } /* the cover is solid stone: nothing shows through it */
.leaf.near .face::after, .face.cover::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 36%, rgba(255, 255, 255, .5) 48%, transparent 60%); background-size: 260% 100%; background-position: 130% 0;
  animation: sheen 9s linear infinite; mix-blend-mode: soft-light;
}
@keyframes sheen { to { background-position: -40% 0; } }
.in { position: absolute; inset: 0; z-index: 1; }
.leaf.cover-leaf .face.front { transform: translateZ(var(--Tc)); }
.leaf.cover-leaf .face.back { transform: translateZ(0) rotateY(180deg); }
.cedge { position: absolute; background: var(--motif-small), linear-gradient(90deg, #f4f2ec, #e6e2d6 50%, #f4f2ec); background-size: 24px 24px, auto; transform-origin: 0 0; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6); }
.cedge.r { left: 100%; top: 0; width: var(--Tc); height: 100%; transform: rotateY(90deg); }
.cedge.t { left: 0; top: 0; width: 100%; height: var(--Tc); transform: rotateX(90deg); }
.cedge.b { left: 0; top: 100%; width: 100%; height: var(--Tc); transform: rotateX(-90deg); }
.rear { transform: translateZ(calc(var(--T) * -1 - var(--Tc))); }
.spine, .edge-r, .edge-t, .edge-b { position: absolute; transform-origin: 0 0; }
.spine {
  left: 0; top: 0; width: calc(var(--T) + var(--Tc) * 2); height: 100%;
  transform: translateZ(calc(var(--T) * -1 - var(--Tc))) rotateY(-90deg); border-radius: 6px 0 0 6px;
  background: linear-gradient(180deg, transparent 7%, #c8a03a 7% 9%, transparent 9% 29%, #c8a03a 29% 31%, transparent 31% 49%, #c8a03a 49% 51%, transparent 51% 69%, #c8a03a 69% 71%, transparent 71% 91%, #c8a03a 91% 93%, transparent 93%),
    var(--motif-small), url(../assets/marble-2.webp), linear-gradient(90deg, rgba(255, 255, 255, .95), rgba(236, 236, 240, .95) 50%, rgba(255, 255, 255, .95));
  background-size: auto, 24px 24px, 400px, auto; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .7);
}
.edge-r { left: var(--P); top: 0; width: var(--T); height: 100%; transform: translateZ(calc(var(--Tc) * -1)) rotateY(90deg); }
.edge-b { left: 0; top: 100%; width: 100%; height: var(--T); transform: translateZ(calc(var(--Tc) * -1)) rotateX(-90deg); }
.edge-t { left: 0; top: 0; width: 100%; height: var(--T); transform: translateZ(calc(var(--T) * -1 - var(--Tc))) rotateX(90deg); }
.edge-r { background: var(--motif), repeating-linear-gradient(90deg, #fbfaf6 0 1.4px, #e9e5da 1.4px 2.8px); background-size: 30px 30px, auto; }
.edge-b, .edge-t { background: var(--motif), repeating-linear-gradient(180deg, #fbfaf6 0 1.4px, #e9e5da 1.4px 2.8px); background-size: 30px 30px, auto; }

/* cover furniture */
.gold { background: linear-gradient(175deg, #d9ae45 0%, #a97a1c 38%, #e9cd75 52%, #9a6c14 70%, #cfa23c 100%); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .9)) drop-shadow(0 -1px 0 rgba(95, 62, 6, .45)); }
.guard { position: absolute; width: 19%; height: auto; aspect-ratio: 1; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(60, 40, 5, .45)); z-index: 2; }
.guard.tl { left: -1.2%; top: -1%; } .guard.tr { right: -1.2%; top: -1%; transform: scaleX(-1); } .guard.bl { left: -1.2%; bottom: -1%; transform: scaleY(-1); } .guard.br { right: -1.2%; bottom: -1%; transform: scale(-1, -1); }
.motif-band { position: absolute; inset: 7.6%; pointer-events: none; padding: 18px; box-sizing: border-box; background: var(--motif); background-size: 30px 30px;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude; opacity: .95; }
.cv { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; height: 100%; padding: 0 16%; box-sizing: border-box; }
.cv-the { font-family: var(--display); font-size: 1.6em; letter-spacing: .3em; color: #9a7220; padding-left: .3em; }
.cv-title { font-family: var(--display); font-weight: 400; font-size: 3.1em; line-height: 1.05; letter-spacing: .06em; margin: .1em 0 0; }
.cv .div, .chant .div { width: 58%; height: auto; color: #b98a24; margin: 1em 0; }
.orn { position: absolute; left: 50%; top: 50%; width: 22%; transform: translate(-50%, -50%); color: #b98a24; opacity: .8; }
.inside { padding: 14% 12%; box-sizing: border-box; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: .6em; font-size: 1em; color: #6d5420; font-style: italic; line-height: 1.4; }
.inside .orn { position: static; transform: none; width: 30%; margin: 0 auto auto; }
.chant { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; height: 100%; padding: 0 13%; box-sizing: border-box; }
.chant .ch-head { font-family: var(--display); font-size: 1.9em; letter-spacing: .08em; color: #a97a1c; margin-bottom: .5em; filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .9)); }
.chant p { margin: 0; font-style: italic; font-size: 1.22em; line-height: 1.55; color: #4a3814; }
.chant .div { width: 46%; margin: .9em 0; }
.chant .turn { position: absolute; bottom: 9%; left: 0; right: 0; font-size: .85em; letter-spacing: .22em; text-transform: uppercase; color: #9a7a30; font-weight: 600; }

/* runes: Phoenician letters drifting up where there is no text */
.runes { position: absolute; pointer-events: none; z-index: 5; }
.book .runes { left: calc(var(--P) * -1); top: 0; width: calc(var(--P) * 2); height: var(--H); transform: translateZ(3px); }
#reader > .runes { position: fixed; inset: 0; z-index: 4; }
body.view-open #reader > .runes, body.ball-open #reader > .runes { display: none; }
.runes span { position: absolute; font-family: var(--rune); color: #c9a44a; opacity: 0; line-height: 1; text-shadow: 0 1px 0 rgba(255, 255, 255, .9), 0 0 8px rgba(255, 220, 140, .6); animation: rune 3s ease-out forwards; }
@keyframes rune { 0% { opacity: 0; transform: translateY(0) scale(.8); } 25% { opacity: .9; } 70% { opacity: .55; } 100% { opacity: 0; transform: translateY(-26px) scale(1.05); } }

/* ======================================================= scene two ======================================================= */
#reader { position: fixed; inset: 0; z-index: 2; background: #0a1a07; }
.spread { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; perspective: 2200px; }
.spread.single { grid-template-columns: 1fr; }
.spread.single .page.right { display: none; }
.page { position: relative; overflow: hidden; font-size: clamp(13px, calc(.62vw + .62vh), 20px); box-sizing: border-box; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .8); }
.page.left { box-shadow: inset -24px 0 30px -24px rgba(90, 80, 60, .45); }
.page.right { box-shadow: inset 24px 0 30px -24px rgba(90, 80, 60, .45); }
.flips { position: absolute; inset: 0; pointer-events: none; transform-style: preserve-3d; z-index: 5; }
.flipper { position: absolute; top: 0; height: 100%; width: 50%; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.42, .04, .28, 1); will-change: transform; pointer-events: none; }
.flipper .page { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flipper .fb { transform: rotateY(180deg); }
.flipper.right { left: 50%; transform-origin: left center; }
.flipper.left { left: 0; transform-origin: right center; }
.flipper.single { left: 0; width: 100%; transform-origin: left center; }
.flipper .ff::after, .flipper .fb::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(60, 50, 30, .28), transparent 30%, transparent 70%, rgba(60, 50, 30, .28)); opacity: 0; transition: opacity .45s ease; }
.flipper.go .ff::after, .flipper.go .fb::after { opacity: 1; }

/* the engraved frame every page carries: acanthus corners, a head and tail piece, a 50% veil over the marble */
.frame { position: absolute; inset: 5% 5.4%; border: 1px solid rgba(184, 138, 36, .9); box-shadow: inset 0 0 0 4px rgba(184, 138, 36, .3), 0 1px 0 rgba(255, 255, 255, .8); pointer-events: none; }
.frame .veil-in { position: absolute; inset: 5px; background: rgba(255, 255, 255, .5); }
.frame .fo { position: absolute; display: block; background: no-repeat center / contain; pointer-events: none; filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .95)) drop-shadow(0 0 1px rgba(255, 255, 255, .6)); }
.frame .c { width: 15%; aspect-ratio: 408 / 441; background-image: url(../assets/orn/corner-small.webp); }
.frame .c.tl { left: -1.6%; top: -1.4%; } .frame .c.tr { right: -1.6%; top: -1.4%; transform: scaleX(-1); }
.frame .c.bl { left: -1.6%; bottom: -1.4%; transform: scaleY(-1); } .frame .c.br { right: -1.6%; bottom: -1.4%; transform: scale(-1, -1); }
.frame .crest-t { left: 50%; top: -2.2%; width: 19%; aspect-ratio: 502 / 293; transform: translateX(-50%) scaleY(-1); background-image: url(../assets/orn/crest-top.webp); }
.frame .crest-b { left: 50%; bottom: -1.8%; width: 30%; aspect-ratio: 720 / 222; transform: translateX(-50%); background-image: url(../assets/orn/crest-bottom.webp); }
.frame.photo .c { width: 13%; }
.frame.cover-frame { inset: 5.4%; }
.frame.cover-frame .veil-in, .frame.cover-frame .fo { display: none; }
/* the inside cover and chant page wear the flowered corners */
.leaf .frame:not(.cover-frame) .c { width: 23%; aspect-ratio: 538 / 545; background-image: url(../assets/orn/corner-tl-flower.webp); }
.leaf .frame:not(.cover-frame) .c.bl { background-image: url(../assets/orn/corner-bl.webp); aspect-ratio: 563 / 559; transform: none; }
.leaf .frame:not(.cover-frame) .c.br { background-image: url(../assets/orn/corner-br.webp); aspect-ratio: 591 / 592; transform: none; }

/* bookmark ribbon: flush with the top edge; white until saved, metallic gold once saved */
.bm { position: absolute; top: 0; right: 8%; width: 5.4%; min-width: 28px; aspect-ratio: 24 / 32; padding: 0; border: 0; background: none; cursor: pointer; z-index: 3; transition: transform .25s ease; filter: drop-shadow(0 2px 2px rgba(60, 40, 5, .35)); }
.bm svg { width: 100%; height: 100%; display: block; overflow: visible; }
.bm .r1 { fill: #fff; stroke: #b98a24; stroke-width: 1.1; stroke-linejoin: round; transition: fill .3s ease; }
.bm .r2 { fill: none; stroke: #c9a44a; stroke-width: .7; opacity: .55; }
.bm .r3 { fill: none; stroke: #c9a44a; stroke-width: 1; stroke-linecap: round; opacity: .7; }
.bm.on .r1 { fill: url(#goldm); stroke: #6b4a0c; }
.bm.on .r2 { stroke: #fff3c4; opacity: .8; }
.bm.on .r3 { stroke: #6b4a0c; opacity: .6; }
.bm:hover { transform: translateY(3px); }
.bm:focus-visible { outline: 2px solid #ffe9a0; }

/* photo page */
.ph { position: absolute; inset: 11% 11% 11%; border: 1px solid rgba(184, 138, 36, .85); box-shadow: 0 0 0 4px rgba(255, 255, 255, .85), 0 0 0 5px rgba(184, 138, 36, .45); overflow: hidden; background: linear-gradient(160deg, #ece9e2, #d9d5cb); }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.ph img.broken { display: none; }
.ph.seeking::before { content: 'Seeking a picture\2026'; position: absolute; left: 0; right: 0; top: 46%; text-align: center; font-family: var(--display); font-size: 1.3em; letter-spacing: .08em; color: #a97a1c; opacity: .7; animation: seek 1.6s ease-in-out infinite; }
@keyframes seek { 50% { opacity: .3; } }
.ph .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 1.1em 1.2em; text-align: center; color: #fffdf3; background: linear-gradient(0deg, rgba(40, 28, 8, .66), transparent); }
.ph .cap b { display: block; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; font-size: 1.05em; }
.ph .cap span { font-style: italic; font-size: .98em; opacity: .9; }
.ph .cap a { color: inherit; }
.ph .cap .cr { display: block; font-size: .74em; opacity: .85; margin-top: .3em; font-style: normal; letter-spacing: .02em; }

/* recipe text page */
.rp { display: flex; flex-direction: column; height: 100%; padding: 13% 11% 13%; box-sizing: border-box; overflow: hidden; position: relative; }
.rp .no { font-weight: 600; font-size: .82em; letter-spacing: .32em; text-transform: uppercase; color: #9a7220; }
.rp h2 { font-family: var(--display); font-weight: 400; font-size: 2em; line-height: 1.08; margin: .22em 0 .25em; align-self: flex-start; letter-spacing: .02em; }
.rp h2.long { font-size: 1.55em; }
.rp .meta { font-style: italic; font-size: 1.1em; color: #6d5420; padding-bottom: .55em; border-bottom: 1px solid rgba(184, 138, 36, .7); }
.rp .intro { font-style: italic; margin: .5em 0 0; color: #5a4518; line-height: 1.35; }
.rp h3 { font-weight: 600; font-size: .82em; letter-spacing: .24em; text-transform: uppercase; color: #8f6a1a; margin: 1.05em 0 .4em; }
.rp h3:first-child { margin-top: 0; }
.rp ul { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 1.6em; font-size: 1.06em; line-height: 1.3; }
.rp ul li { padding: .16em 0; border-bottom: 1px dotted rgba(150, 110, 30, .4); break-inside: avoid; }
.rp ol { list-style: none; counter-reset: s var(--start, 0); padding: 0; margin: 0; font-size: 1.08em; line-height: 1.34; }
.rp ol li { counter-increment: s; position: relative; padding: 0 0 .5em 1.9em; }
.rp ol li::before { content: counter(s); position: absolute; left: 0; top: -.05em; font-family: var(--display); font-size: 1.15em; color: #a97a1c; }
.rp .src { margin-top: auto; padding-top: .6em; font-size: .8em; color: #8f6a1a; line-height: 1.35; }
.rp .src a { color: #8a6212; }
.rp .more { margin-top: auto; text-align: right; font-weight: 600; font-size: .78em; letter-spacing: .2em; text-transform: uppercase; color: #9a7a30; padding-top: .5em; }

/* nutrition page: a macro box, a two-column Nutrition Facts panel, the ingredient list and the net contents */
.np { height: 100%; padding: 9% 9% 9%; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; gap: .55em; position: relative; font-size: .9em; overflow: hidden; }
.np .macro { display: grid; grid-template-columns: repeat(3, 1fr); gap: .3em; border: 1px solid rgba(184, 138, 36, .85); background: rgba(255, 255, 255, .55); padding: .4em .6em .35em; text-align: center; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .7); }
.np .macro .mhead { grid-column: 1 / -1; font-family: var(--display); font-size: 1.35em; line-height: 1; color: #a97a1c; letter-spacing: .06em; padding-bottom: .25em; margin-bottom: .1em; border-bottom: 1px solid rgba(184, 138, 36, .5); }
.np .macro div b { display: block; font: 700 1.7em/1 var(--text); color: #a97a1c; }
.np .macro div span { display: block; margin-top: .25em; font-size: .7em; letter-spacing: .24em; text-transform: uppercase; font-weight: 600; color: #8f6a1a; }
.np .macro small { grid-column: 1 / -1; font-size: .72em; font-style: italic; color: #6d5420; letter-spacing: .05em; }
.label2 { border: 2px solid #3a2d12; padding: .4em .6em .35em; background: rgba(255, 255, 255, .64); font-size: .92em; color: #2d2008; }
.label2 .lhead { font-family: var(--display); font-size: 1.9em; line-height: 1; letter-spacing: .02em; padding-bottom: .1em; border-bottom: 1px solid #3a2d12; }
.label2 .lsub { font-size: .9em; color: #6d5420; padding: .3em 0; }
.label2 .lrow { display: grid; grid-template-columns: 1fr auto 2.9em; gap: .5em; padding: .13em 0; border-bottom: 1px solid rgba(58, 45, 18, .45); line-height: 1.25; align-items: baseline; }
.label2 .lrow.top { grid-template-columns: 1fr auto; }
.label2 .lrow.top i { display: none; }
.label2 .lrow span { font-weight: 600; }
.label2 .lrow.sub span, .label2 .lrow.sub2 span { font-weight: 400; padding-left: 1.1em; }
.label2 .lrow.sub2 span { padding-left: 2.1em; }
.label2 .lrow b { font-weight: 400; text-align: right; white-space: nowrap; }
.label2 .lrow i { text-align: right; font-style: normal; font-weight: 600; }
.label2 .kcal { display: flex; justify-content: space-between; align-items: baseline; border-top: 6px solid #3a2d12; border-bottom: 3px solid #3a2d12; padding: .12em 0; margin-top: .1em; }
.label2 .kcal span { font-weight: 700; font-size: 1.05em; }
.label2 .kcal b { font: 700 1.9em/1 var(--text); }
.label2 .cols { display: grid; grid-template-columns: 1fr 1fr; column-gap: 0; }
.label2 .col:first-child { border-right: 1px solid rgba(58, 45, 18, .35); padding-right: .9em; }
.label2 .col:last-child { padding-left: .9em; }
.label2 .dv { text-align: right; font-size: .78em; padding: .15em 0; border-bottom: 1px solid rgba(58, 45, 18, .45); font-weight: 600; }
.label2 .lfoot { font-size: .7em; color: #6d5420; line-height: 1.3; padding-top: .35em; border-top: 3px solid #3a2d12; margin-top: .1em; }
.np .ingl { font-size: .84em; line-height: 1.3; color: #3a2d12; }
.np .ingl b, .np .netc b { font-weight: 600; letter-spacing: .14em; text-transform: uppercase; font-size: .84em; color: #8f6a1a; }
.np .netc { font-size: .86em; color: #3a2d12; }
.fit { font-weight: 600; color: #7a5410; text-align: center; font-size: 1em; }

/* notes page: type on the lines, or switch to Draw and sketch over them */
.notes { padding: 13% 11% 13%; box-sizing: border-box; height: 100%; display: flex; flex-direction: column; gap: .3em; position: relative; }
.notes .nhead { display: flex; align-items: center; justify-content: space-between; gap: .6em; }
.notes h2 { font-family: var(--display); font-weight: 400; font-size: 1.9em; margin: 0; color: #a97a1c; }
.notes .nmode { display: inline-flex; border: 1px solid rgba(184, 138, 36, .85); border-radius: 99px; overflow: hidden; background: rgba(255, 255, 255, .55); }
.notes .nmode button { border: 0; background: none; padding: .35em 1em; font: 600 .74em var(--text); letter-spacing: .16em; text-transform: uppercase; color: #8a6212; cursor: pointer; }
.notes .nmode button.on { background: linear-gradient(135deg, #f1d98a, #b98a24); color: #2d2008; }
.notes .nsub { font-style: italic; color: #6d5420; font-size: .92em; margin-bottom: .3em; }
.notes .pad { position: relative; flex: 1; min-height: 0; }
.notes .note {
  position: absolute; inset: 0; width: 100%; height: 100%; box-sizing: border-box; resize: none; border: 0; outline: none; background: transparent; color: var(--ink);
  font: 400 1.08em/1.9em var(--text); padding: 0; margin: 0; overflow: hidden;
  background-image: repeating-linear-gradient(180deg, transparent 0 calc(1.9em - 1px), rgba(150, 110, 30, .4) calc(1.9em - 1px) 1.9em); background-attachment: local;
}
.notes .note::placeholder { color: rgba(109, 84, 32, .55); font-style: italic; }
.notes .ink { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.notes .pad.text .ink { pointer-events: none; }
.notes .pad.draw .ink { pointer-events: auto; cursor: url(../assets/pen-cursor.svg) 9 23, crosshair; }
.notes .pad.draw .note { pointer-events: none; }
.notes .pad.draw::after { content: ''; position: absolute; inset: -4px; border: 1px dashed rgba(184, 138, 36, .55); pointer-events: none; }
.notes .nfoot { display: flex; justify-content: space-between; align-items: center; font-size: .78em; color: #9a7a30; letter-spacing: .05em; }
.notes .nbtns { display: flex; gap: .45em; }
.notes .nbtns button { border: 1px solid rgba(184, 138, 36, .7); background: rgba(255, 255, 255, .5); color: #8a6212; border-radius: 99px; padding: .3em .9em; font: 400 .95em var(--text); cursor: pointer; }
.notes .nbtns button:hover { background: rgba(255, 255, 255, .85); }
.filler { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2em; }
.filler .rune-big { font-family: var(--rune); font-size: 5em; color: #c9a44a; opacity: .5; }
.filler .orn { position: static; transform: none; width: 30%; }

/* table of contents + planner pages (views) */
.toc, .planner { height: 100%; padding: 13% 11% 13%; box-sizing: border-box; display: flex; flex-direction: column; position: relative; }
.toc h2, .planner h2 { font-family: var(--display); font-weight: 400; font-size: 2em; margin: 0 0 .5em; color: #a97a1c; }
.toc h2.cont, .planner h2.cont { font-size: 1.3em; }
.toc ol { list-style: none; padding: 0; margin: 0; counter-reset: t; }
.toc li { counter-increment: t; }
.toc li button { display: flex; align-items: baseline; gap: .5em; width: 100%; padding: .45em 0; border: 0; background: none; color: var(--ink); font: 400 1.15em/1.3 var(--text); text-align: left; cursor: pointer; }
.toc li button::before { content: counter(t); font-family: var(--display); color: #a97a1c; width: 1.6em; }
.toc li button .dots { flex: 1; border-bottom: 1px dotted rgba(150, 110, 30, .6); transform: translateY(-.3em); }
.toc li button .o { font-style: italic; color: #6d5420; font-size: .85em; }
.toc li button:hover .t { color: #8a6212; }
.toc .empty, .planner .empty { font-style: italic; color: #6d5420; }
.toc .orn, .planner .orn { position: static; transform: none; width: 30%; margin: auto; }
.planner .grid { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: .8em; flex: 1; min-height: 0; }
.ncell { position: relative; display: flex; flex-direction: column; gap: .25em; padding: .7em .8em; border: 1px solid rgba(184, 138, 36, .6); background: rgba(255, 255, 255, .55); text-align: left; cursor: pointer; font: 400 .95em/1.3 var(--text); color: var(--ink); overflow: hidden; min-height: 0; }
.ncell b { font-weight: 600; font-size: 1.05em; padding-right: 3em; }
.ncell time { position: absolute; top: .7em; right: .8em; font-size: .78em; color: #9a7a30; }
.ncell img { max-height: 42%; width: auto; align-self: flex-start; border: 1px solid rgba(184, 138, 36, .4); background: #fff; }
.ncell p { margin: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; background-image: repeating-linear-gradient(180deg, transparent 0 calc(1.3em - 1px), rgba(150, 110, 30, .3) calc(1.3em - 1px) 1.3em); }
.ncell small { color: #8f6a1a; font-style: italic; margin-top: auto; }
.ncell:hover { background: rgba(255, 255, 255, .8); }

.measure { position: fixed; left: -9999px; top: 0; width: 50vw; height: 100vh; visibility: hidden; pointer-events: none; }
body.portrait .measure { width: 100vw; }
/* one column: the glass menu sits over the foot of the page, so pages whose last line matters end above it */
body.portrait .notes, body.portrait .np { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
body.portrait .rp { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
.measure .page { width: 100%; height: 100%; }

/* ---------- glass menu ---------- */
.menu { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 7; display: flex; gap: 10px; padding: 8px 12px; border-radius: 99px;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .5); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3); box-shadow: 0 10px 30px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .6); }
.menu button { position: relative; width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .22); color: #4a3814; cursor: pointer; padding: 0; display: grid; place-items: center; transition: background .25s ease, transform .25s ease; }
.menu button svg { width: 24px; height: 24px; }
.menu button:hover { background: rgba(255, 255, 255, .5); transform: translateY(-2px); }
.menu button.on { background: rgba(233, 205, 117, .75); }
.menu button[data-act="prev"], .menu button[data-act="next"] { width: 40px; }
.menu button .count { position: absolute; right: -4px; top: -4px; min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box; border-radius: 9px; background: #c49a30; color: #2a1d06; font: 700 11px/18px var(--text); text-align: center; }
.menu button .count:empty { display: none; }
.menu .mini-orb { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0, rgba(255, 255, 255, .6) 10%, rgba(120, 200, 255, .7) 30%, rgba(150, 70, 230, .8) 60%, rgba(20, 20, 70, .95) 100%); box-shadow: 0 0 10px rgba(140, 200, 255, .7); }
body.ball-open .menu, body.ball-open .hint, body.ball-open .pill, body.view-open .hint { opacity: 0 !important; pointer-events: none !important; }

/* ---------- views ---------- */
.view { position: absolute; inset: 0; z-index: 3; background: #0a1a07; }
.view .spread { inset: 0; }
#view-marks.cards .toc-spread { display: none; }
/* the bookmark shelf (js/shelf.js does the layout and every pointer decision; nothing here takes pointer events,
   so a shadow, a skewed corner or a rising card can never change what the pointer is over) */
.view { background: #050505; }
.shelf-wrap { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; background: #050505; isolation: isolate; }
.shelf-wrap.over { cursor: pointer; }
.shelf-wrap.dragging { cursor: grabbing; }
#view-marks.list .shelf-wrap { display: none; }
/* atmosphere: a slow gold-and-violet bloom behind the row, a glow on the floor under it, both warming when a card is up */
.shelf-wrap::before { content: ''; position: absolute; inset: -15%; z-index: -1; pointer-events: none;
  background: radial-gradient(42% 38% at 50% 50%, rgba(236, 200, 110, .38), transparent 74%), radial-gradient(38% 34% at 14% 18%, rgba(124, 92, 255, .38), transparent 74%), radial-gradient(38% 34% at 88% 84%, rgba(40, 206, 176, .3), transparent 74%), radial-gradient(60% 46% at 50% 104%, rgba(255, 150, 80, .22), transparent 72%);
  animation: atmos 11s ease-in-out infinite alternate; will-change: transform, opacity; }
.shelf-wrap::after { content: ''; position: absolute; left: 50%; top: 62%; width: min(86vw, 1100px); height: 26vh; transform: translate(-50%, 0); z-index: -1; pointer-events: none; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 214, 140, .32), rgba(255, 214, 140, .1) 60%, transparent 100%); filter: blur(10px); opacity: .75; transition: opacity .5s ease; }
.shelf-wrap.has-lift::after { opacity: 1; }
@keyframes atmos { from { opacity: .7; transform: scale(1) translate(0, 0); } to { opacity: 1; transform: scale(1.07) translate(1.2%, -1.4%); } }
.shelf-wrap .vrunes { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.shelf { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.scard { position: absolute; transform-origin: 0 0; pointer-events: none; border: 1px solid #c49a30; border-radius: 10px; overflow: hidden; background: #fbf9f4; outline: none; will-change: transform;
  box-shadow: -8px 2px 12px rgba(0, 0, 0, .55); transition: transform .4s cubic-bezier(.42, 0, .58, 1), box-shadow .4s cubic-bezier(.42, 0, .58, 1); }   /* an easy ease: gentle off the mark, gentle onto it */
.scard img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-drag: none; }
.scard img.broken, .scard img.seek { visibility: hidden; }
.scard .shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(255, 255, 255, .14), transparent 45%, rgba(0, 0, 0, .42)); pointer-events: none; }
.scard span { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 8px 8px; font: 600 clamp(11px, 1.05vw, 15px)/1.2 var(--text); color: #fff; text-align: center; letter-spacing: .04em; background: linear-gradient(0deg, rgba(30, 20, 5, .85), transparent); }
.scard.lift { box-shadow: 0 0 0 2px rgba(255, 255, 255, .92), -12px 4px 22px rgba(0, 0, 0, .6), 0 0 36px rgba(233, 205, 117, .38); }
.scard:focus-visible { box-shadow: 0 0 0 2px #ffe9a0, -8px 2px 12px rgba(0, 0, 0, .55); }
.sinfo { position: absolute; z-index: 1001; width: 220px; box-sizing: border-box; color: #fff6d8; opacity: 0; transform: translateX(-8px); transition: opacity .25s ease, transform .25s ease; pointer-events: none; }
.sinfo.on { opacity: 1; transform: none; }
.sinfo .t { display: block; font: 400 clamp(17px, 1.7vw, 25px)/1.08 var(--display); color: #f1d98a; letter-spacing: .04em; text-shadow: 0 0 10px rgba(241, 217, 138, .55), 0 2px 3px rgba(0, 0, 0, .8); margin-bottom: .4em; }
.sinfo i { display: flex; gap: .6em; font: 400 clamp(13px, 1.15vw, 16px)/1.5 var(--text); font-style: normal; text-shadow: 0 1px 2px rgba(0, 0, 0, .9); }
.sinfo i em { font-style: normal; color: #d9b85a; min-width: 4.6em; }
.sinfo small { display: block; margin: .3em 0 .7em; font: italic 400 12px/1.3 var(--text); color: rgba(255, 246, 216, .7); }
.scard .rx { position: absolute; left: 10px; top: 10px; width: 32px; height: 32px; padding: 0; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .75); background: rgba(20, 14, 4, .62); color: #fff6d8; font: 400 21px/1 var(--text); display: grid; place-items: center; cursor: pointer; z-index: 3;
  transform-origin: 0 0; transform: matrix(var(--ux, 1), var(--um, 0), 0, 1, 0, 0);   /* upright, whatever the card's squash and shear */
  opacity: 0; pointer-events: none; transition: opacity .22s ease, background .2s ease; }
.scard.lift .rx { opacity: .92; pointer-events: auto; transition-delay: .16s, 0s; }
.scard.lift .rx:hover, .scard.lift .rx:focus-visible { opacity: 1; background: rgba(150, 30, 20, .9); outline: none; }
/* the facts docked above the menu, for a screen too narrow to put them beside the card */
.sinfo.dock { display: grid; grid-template-columns: repeat(4, 1fr); column-gap: .4em; text-align: center; padding: 10px 14px 8px; border-radius: 14px; border: 1px solid rgba(255, 240, 190, .35); background: rgba(8, 8, 8, .74); backdrop-filter: blur(6px); transform: none; }
.sinfo.dock .t { grid-column: 1 / 4; text-align: left; margin-bottom: .3em; font-size: 17px; }
.sinfo.dock i { display: block; font-size: 13px; line-height: 1.3; }
.sinfo.dock i em { display: block; min-width: 0; font-size: 11px; }
.sinfo.dock small { grid-column: 4; grid-row: 1; text-align: right; align-self: center; margin: 0 0 .3em; }
.edge { position: absolute; top: calc(54px + env(safe-area-inset-top, 0px)); z-index: 5; min-width: 44px; height: 44px; padding: 0 12px; display: flex; align-items: center; justify-content: center; gap: .4em; border-radius: 22px; border: 1px solid rgba(255, 240, 190, .45); background: rgba(20, 16, 6, .6); color: #f1d98a; font: 600 14px/1 var(--text); cursor: pointer; box-shadow: 0 0 22px rgba(233, 205, 117, .3); backdrop-filter: blur(4px); }
.edge span { font-size: 24px; line-height: 1; }
.edge.l { left: 8px; } .edge.r { right: 8px; }
.edge[hidden] { display: none; }
.shelf-wrap .empty-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #fff6d8; font-style: italic; display: none; }
.shelf-wrap.empty .empty-msg { display: block; }
@media (prefers-reduced-motion: reduce) { .shelf-wrap::before { animation: none; } .scard { transition-duration: .01s; } }
.nsearch { position: absolute; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 4; width: min(92vw, 520px); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nsearch input { width: 100%; box-sizing: border-box; padding: .6em 1.1em; border-radius: 99px; border: 1px solid rgba(184, 138, 36, .9); background: rgba(255, 255, 255, .85); color: var(--ink); font: 400 16px/1.2 var(--text); outline: none; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); backdrop-filter: blur(6px); }
.nsearch input:focus { box-shadow: 0 0 0 3px rgba(233, 205, 117, .6), 0 6px 20px rgba(0, 0, 0, .3); }
.nsearch .nstatus { font-size: 12px; font-style: italic; color: #fff6d8; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); min-height: 1em; }
#view-notes .planner { padding-top: 17%; }

/* ---------- UI ---------- */
.ui { z-index: 8; }
.hint { position: fixed; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: calc(100% - 32px); box-sizing: border-box; text-align: center; padding: .5em 1.1em; border-radius: 99px;
  background: rgba(18, 38, 12, .5); color: #fff6d8; border: 1px solid rgba(255, 240, 190, .35); font: 400 14px/1.2 var(--text); letter-spacing: .05em; pointer-events: none; transition: opacity .5s ease; }
body[data-scene="landing"] .hint { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
.hint.off { opacity: 0; }
.pill { position: fixed; padding: .5em 1.1em; border-radius: 99px; cursor: pointer; background: rgba(18, 38, 12, .55); color: #fff6d8; border: 1px solid rgba(255, 240, 190, .4); font: 400 15px/1.2 var(--text); letter-spacing: .06em; opacity: 0; pointer-events: none; transition: opacity .6s ease; }
.pill:focus-visible { outline: 2px solid #ffe9a0; outline-offset: 2px; }
.closer { top: calc(14px + env(safe-area-inset-top, 0px)); left: 16px; }
.pill .ico { display: none; font-style: normal; }
body[data-scene="reader"] .closer, body[data-scene="reader"] .credits-btn { top: calc(6px + env(safe-area-inset-top, 0px)); width: 32px; height: 32px; padding: 0; border-radius: 50%; display: grid; place-items: center; font-size: 17px; line-height: 1; }
body[data-scene="reader"] .closer { left: 6px; }
body[data-scene="reader"] .credits-btn { left: 44px; }
body[data-scene="reader"] .pill .lbl { display: none; }
body[data-scene="reader"] .pill .ico { display: block; }
.credits-btn { top: calc(14px + env(safe-area-inset-top, 0px)); left: 16px; }
.goal-pill { top: calc(14px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); background: rgba(90, 60, 10, .7); border-color: #e9cd75; }
body[data-scene="reader"] .closer, .credits-btn, body[data-scene="reader"] .goal-pill:not([hidden]) { opacity: 1; pointer-events: auto; }

/* ---------- the crystal ---------- */
.ball-wrap { position: fixed; inset: 0; z-index: 9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(22px, 4vh, 44px); padding: 12px; box-sizing: border-box; opacity: 0; transition: opacity .5s ease; }
.ball-wrap.on { opacity: 1; }
.ball-wrap .dim { position: absolute; inset: 0; background: radial-gradient(60% 60% at 50% 45%, rgba(20, 8, 50, .6), rgba(4, 8, 4, .88)); }
.scene { --d: min(70vw, 400px, 46vh); position: relative; width: min(96vw, 980px); height: var(--d); flex: none; }
.crystal { position: absolute; left: 50%; top: 0; width: var(--d); height: var(--d); margin-left: calc(var(--d) / -2); border-radius: 50%; cursor: pointer; outline: none;
  transform: translateY(70px) scale(.9); transition: transform 1.3s cubic-bezier(.2, .9, .3, 1.1);
  filter: drop-shadow(0 0 40px rgba(140, 170, 255, .45)) drop-shadow(0 0 90px rgba(120, 90, 255, .25)); }
.ball-wrap.on .crystal { transform: translateY(0) scale(1); animation: floaty 5s ease-in-out 1.3s infinite; }
.crystal:focus-visible { outline: 2px solid #ffe9a0; outline-offset: 6px; }
@keyframes floaty { 50% { transform: translateY(-9px) scale(1); } }
.crystal canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; }
.ctext-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; perspective: calc(var(--d) * 1.6); pointer-events: none; }
.ctext { position: relative; width: 0; height: 0; transform-style: preserve-3d; font-family: var(--display); font-size: clamp(20px, calc(var(--d) * .105), 44px); color: #fbf8ff; white-space: nowrap; transition: opacity .32s ease; letter-spacing: .04em;
  text-shadow: 0 0 2px #fff, 0 0 8px rgba(190, 235, 255, .95), 0 0 18px rgba(140, 200, 255, .8), 0 0 34px rgba(120, 160, 255, .6), 0 2px 3px rgba(5, 2, 25, .9); animation: cglow 2.8s ease-in-out infinite; }
@keyframes cglow { 50% { filter: brightness(1.25) drop-shadow(0 0 6px rgba(200, 230, 255, .9)); } }
.ctext.flat { transform-style: flat; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; width: 80%; height: auto; white-space: normal; text-align: center; }
.ctext.flat span { position: static; transform: none !important; }
.ctext.swap { opacity: 0; }
.ctext span { position: absolute; left: 0; top: 0; display: inline-block; transform-origin: center; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.ctext[data-kind="result"] { color: #fff2c0; text-shadow: 0 0 2px #fff8e0, 0 0 8px rgba(255, 230, 150, .95), 0 0 18px rgba(255, 210, 110, .8), 0 0 36px rgba(255, 190, 80, .55), 0 2px 3px rgba(5, 2, 25, .9); }
.ctext[data-kind="suggest"] { color: #e4fbff; }
.crunes { position: absolute; inset: -14% -4%; overflow: hidden; pointer-events: none; }
.crunes span { position: absolute; font-family: var(--rune); color: #f2faff; opacity: 0; line-height: 1; text-shadow: 0 0 3px #fff, 0 0 9px #fff, 0 0 16px rgba(170, 220, 255, 1), 0 0 30px rgba(120, 170, 255, .9), 0 0 50px rgba(150, 120, 255, .6); animation: crune 4s ease-in-out forwards; }
@keyframes crune { 0% { opacity: 0; transform: translateY(14px) scale(.7); } 30% { opacity: .95; } 75% { opacity: .6; } 100% { opacity: 0; transform: translateY(-40px) scale(1.1); } }
.ctext[data-kind="info"] { color: #e6d6ff; font-size: clamp(14px, calc(var(--d) * .07), 26px); }
.crystal .x { position: absolute; top: 4%; right: 4%; width: 32px; height: 32px; padding: 0; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .6); background: rgba(255, 255, 255, .18); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; z-index: 2; }
.crystal .x:hover { background: rgba(255, 255, 255, .35); }
.tarot { position: absolute; inset: 0; pointer-events: none; }
.tcard { position: absolute; left: var(--x); top: var(--y); width: clamp(58px, 9vw, 112px); padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto; transform: rotate(var(--r)); transition: transform .35s ease, filter .35s ease; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .6)); }
.tcard img { width: 100%; height: auto; display: block; border-radius: 6px; }
.tcard:hover, .tcard:focus-visible { transform: rotate(0deg) scale(1.15); filter: drop-shadow(0 0 18px rgba(200, 180, 255, .85)); z-index: 2; outline: none; }
.ask-box { position: relative; width: min(92vw, 560px); display: flex; gap: .5em; }
.ask-box input { flex: 1; min-width: 0; padding: .7em 1.1em; border-radius: 99px; border: 1px solid rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .14); color: #fff; font: 400 17px/1.2 var(--text); outline: none; backdrop-filter: blur(4px); }
.ask-box input::placeholder { color: rgba(255, 255, 255, .6); }
.ask-box input:focus { border-color: #fff; box-shadow: 0 0 12px rgba(255, 255, 255, .5); }
.ask-box button { padding: .6em 1.2em; border-radius: 99px; border: 1px solid rgba(255, 255, 255, .6); background: rgba(255, 255, 255, .22); color: #fff; font: 600 15px/1.2 var(--text); letter-spacing: .06em; cursor: pointer; }
.ask-box button:hover { background: rgba(255, 255, 255, .35); }

/* ---------- panels ---------- */
.panel { position: fixed; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center; background: rgba(5, 12, 4, .7); padding: 16px; box-sizing: border-box; }
.panel.on { display: flex; }
.panel .card { max-width: 560px; width: 100%; max-height: 86vh; overflow: auto; background: #fbf9f4; color: var(--ink); border-radius: 10px; padding: 28px 30px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); font-size: 16px; line-height: 1.45; box-sizing: border-box; }
.panel h2 { font-family: var(--display); font-weight: 400; margin: 0 0 .4em; }
.panel h3 { font-weight: 600; font-size: .9em; letter-spacing: .18em; text-transform: uppercase; color: #8f6a1a; margin: 1.2em 0 .3em; }
.panel p { margin: .4em 0; }
.panel a { color: #8a6212; }
.panel .row { display: flex; gap: .6em; justify-content: flex-end; margin-top: 1em; }
.panel button { padding: .5em 1em; border-radius: 99px; border: 1px solid #b98a24; background: #fff8e6; color: var(--ink); font: 400 15px/1.2 var(--text); cursor: pointer; }
.panel button.btn-gold, .consent button.btn-gold { background: linear-gradient(135deg, #f1d98a, #b98a24); color: #2d2008; font-weight: 600; }
/* the pop-up that matches the pages: marble, a gold rule, the display face */
.panel .card.marble { max-width: 440px; background: url(../assets/marble-1.webp) center / 600px repeat; box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .8), inset 0 0 0 5px rgba(184, 138, 36, .8), 0 20px 60px rgba(0, 0, 0, .55); border-radius: 6px; padding: 30px 32px 26px; }
.panel .card.marble h2 { color: #a97a1c; font-size: 1.7em; }
.panel .card.marble .which { font-style: italic; color: #6d5420; }
.panel .chk { display: flex; align-items: center; gap: .5em; margin-top: .8em; font-size: .95em; color: #5a4518; cursor: pointer; }
.panel .chk input { accent-color: #b98a24; width: 16px; height: 16px; }
/* storage notice, shown once */
.consent { position: fixed; left: 50%; top: calc(56px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 11; width: min(94vw, 640px); box-sizing: border-box; padding: 14px 18px; border-radius: 16px; background: rgba(251, 249, 244, .96); color: var(--ink); border: 1px solid rgba(184, 138, 36, .8); box-shadow: 0 14px 40px rgba(0, 0, 0, .35); font: 400 14px/1.4 var(--text); }
.consent p { margin: 0 0 .7em; }
.consent .row { display: flex; gap: .6em; justify-content: flex-end; flex-wrap: wrap; }
.consent button { padding: .45em 1em; border-radius: 99px; border: 1px solid #b98a24; background: #fff8e6; color: var(--ink); font: 400 14px/1.2 var(--text); cursor: pointer; }
/* while the loading screen is up, the book takes its place without easing in behind it */
body.booting .cam, body.booting .book, body.booting .shadow, body.booting .leaf, body.booting .hover { transition: none !important; }

@media (max-width: 700px) {
  body[data-scene="reader"] .credits-btn { display: none !important; }
  .rp ul { columns: 1; }
  .planner .grid { grid-template-columns: 1fr; }
  .menu button { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  :root { --flip: .5s; }
  .cam, .book { transition-duration: .6s; }
  .hover { animation: none !important; }
  .leaf.near .face::after, .face.cover::after { animation: none; }
  .ball-wrap.on .crystal { animation: none; }
  .flipper { transition-duration: .3s; }
  .runes span { animation-duration: 1.2s; }
}
