/* THE TALE, AS A BOOK (book.js, 2026-10-31): paper pages over the dark of the tray, gold for the book's own bars */
#book { position: fixed; inset: 0; z-index: 90; display: none; flex-direction: column; align-items: center; justify-content: space-between;
  background: radial-gradient(120% 90% at 50% 45%, rgba(26,18,10,.94), rgba(4,3,2,.985) 70%);
  font-family: Montserrat, sans-serif; color: #f3e6cc; opacity: 0; transition: opacity .45s ease;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  box-sizing: border-box; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
#book.on { display: flex; }
#book.in { opacity: 1; }
#book button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }

/* the bars: what is being read, and the reader's own buttons */
#book .bk-top { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; flex: none; }
#book .bk-btn { min-height: 40px; min-width: 44px; padding: 0 12px; border: 0; border-radius: 3px; background: rgba(214,173,98,.1); box-shadow: inset 0 0 0 1px rgba(214,173,98,.45);
  font-size: 10px; letter-spacing: .22em; font-weight: 700; color: #f7dca0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
#book .bk-btn:active { background: rgba(214,173,98,.28); }
#book .bk-btn small { font-size: 11px; margin-left: 1px; }
#book .bk-tools { display: flex; gap: 6px; }
#book .bk-x { position: relative; width: 12px; height: 12px; }
#book .bk-x::before, #book .bk-x::after { content: ''; position: absolute; left: 50%; top: 50%; width: 14px; height: 1.6px; background: currentColor; transform: translate(-50%, -50%) rotate(45deg); }
#book .bk-x::after { transform: translate(-50%, -50%) rotate(-45deg); }
#book .bk-run { flex: 1; min-width: 0; text-align: center; line-height: 1.25; overflow: hidden; }
#book .bk-run i { display: block; font-style: normal; font-size: 8.5px; letter-spacing: .4em; color: rgba(214,173,98,.8); }
#book .bk-run span { display: block; font: 600 15px/1.2 'Cormorant Garamond', Georgia, serif; letter-spacing: .06em; color: #fbecd0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#book .bk-foot { width: min(100%, 720px); flex: none; display: flex; flex-direction: column; align-items: center; gap: 5px; padding-bottom: 2px; }
#book .bk-prog { width: 100%; height: 2px; background: rgba(214,173,98,.18); border-radius: 2px; overflow: hidden; }
#book .bk-prog b { display: block; height: 100%; background: linear-gradient(90deg, #a8742e, #f3d394); transform-origin: 0 50%; transform: scaleX(0); transition: transform .4s ease; }
#book .bk-where { font-size: 8.5px; letter-spacing: .26em; color: rgba(243,230,204,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* the book itself */
#book .bk-stage { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; perspective: 1800px; }
#book .bk-book { position: relative; flex: none; }
#book .bk-paper { position: absolute; inset: 0; border-radius: 2px 4px 4px 2px; overflow: hidden;
  background: linear-gradient(180deg, rgba(255,250,236,.5), rgba(0,0,0,0) 12%, rgba(0,0,0,0) 88%, rgba(120,90,50,.12)),
    radial-gradient(140% 100% at 50% 50%, #f4ead2 55%, #e6d5b0 100%);
  box-shadow: 0 0 0 1px rgba(90,62,30,.55), 0 2px 0 3px #1c130b, 0 3px 0 4px rgba(214,173,98,.55), 0 18px 50px rgba(0,0,0,.75); }
#book.two .bk-paper { border-radius: 3px; }
/* the gutter: the two pages bend into the spine */
#book .bk-gutter { display: none; position: absolute; top: 0; bottom: 0; left: 50%; width: 14%; transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(0,0,0,0), rgba(70,45,20,.1) 30%, rgba(50,30,12,.32) 49.5%, rgba(255,255,255,.18) 50.5%, rgba(70,45,20,.1) 70%, rgba(0,0,0,0)); }
#book.two .bk-gutter { display: block; }
#book .bk-text { position: absolute; overflow: hidden; }
#book .bk-flow { column-fill: auto; height: 100%;
  font: 500 var(--bk-fs, 16px)/1.5 'Cormorant Garamond', Georgia, serif; color: #2b1d10; text-align: justify; hyphens: auto; -webkit-hyphens: auto;
  font-kerning: normal; text-rendering: optimizeLegibility; }
#book .bk-flow p { margin: 0; text-indent: 1.4em; orphans: 2; widows: 2; }
#book .bk-flow p.bk-first, #book .bk-flow .bk-head + p, #book .bk-flow .bk-act + p { text-indent: 0; }
#book .bk-flow p.bk-i { font-style: italic; color: #3a2814; }
#book .bk-flow em { font-style: italic; }
#book .bk-flow .bk-br { text-align: center; text-indent: 0; margin: .7em 0; color: #8a6430; letter-spacing: .4em; }
#book .bk-flow .bk-act { text-align: center; text-indent: 0; font-style: italic; color: #7a5424; margin: 0 0 1em; }
#book .bk-flow .bk-end, #book .bk-flow .bk-more { text-align: center; text-indent: 0; font-style: italic; color: #7a5424; margin-top: 1.2em; }
#book .bk-flow .bk-more { font-size: .9em; color: #8a6a40; }
/* a chapter's opening: its number, its name, a rule, and a drop capital */
#book .bk-head { break-inside: avoid; text-align: center; padding-top: 1.6em; margin-bottom: 1.3em; }
#book .bk-num { margin: 0; text-indent: 0 !important; font: 700 .58em/1 Montserrat, sans-serif; letter-spacing: .42em; color: #8a6430; }
#book .bk-head h3 { margin: .45em 0 0; font-weight: 600; font-size: 1.7em; line-height: 1.12; color: #2b1d10; text-align: center; }
#book .bk-rule { width: 3.2em; height: 1px; margin: .9em auto 0; background: #a87c3c; position: relative; }
#book .bk-rule::after { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; background: #a87c3c; transform: translate(-50%, -50%) rotate(45deg); }
#book .bk-head + p::first-letter, #book .bk-head + .bk-act + p::first-letter { float: left; font-size: 3.35em; line-height: .82; padding: .05em .08em 0 0; color: #7a3d14; font-weight: 600; }
/* a part's title page: a page to itself */
#book .bk-title { break-after: column; -webkit-column-break-after: always; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
#book .bk-title .bk-tk { margin: 0 0 1.2em; text-indent: 0; font: 700 .62em/1 Montserrat, sans-serif; letter-spacing: .6em; color: #8a6430; }
#book .bk-title h1 { margin: 0; font: 700 .8em/1.2 Montserrat, sans-serif; letter-spacing: .5em; color: #6a4418; }
#book .bk-title h2 { margin: .5em 0 0; font-weight: 600; font-size: 2.2em; line-height: 1.1; color: #2b1d10; }
#book .bk-orn { width: 5em; height: 1px; margin: 1.6em auto; background: linear-gradient(90deg, transparent, #a87c3c, transparent); position: relative; }
#book .bk-orn::after { content: ''; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; border: 1px solid #a87c3c; transform: translate(-50%, -50%) rotate(45deg); background: #f4ead2; }
/* the page numbers */
#book .bk-folio { position: absolute; bottom: 3.2%; font: 600 calc(var(--bk-fs, 16px) * .72)/1 'Cormorant Garamond', Georgia, serif; color: #8a6a40; pointer-events: none; }
#book .bk-folio-l { left: 0; width: 100%; text-align: center; }
#book.two .bk-folio-l { width: 50%; }
#book .bk-folio-r { display: none; }
#book.two .bk-folio-r { display: block; left: 50%; width: 50%; text-align: center; }
/* where a tap turns: a third of the book each side, and the middle too on one page */
#book .bk-hit { position: absolute; top: 0; bottom: 0; cursor: pointer; z-index: 3; }
#book .bk-hit-l { left: 0; width: 38%; }
#book .bk-hit-r { right: 0; width: 62%; }
#book.two .bk-hit-l { width: 50%; }
#book.two .bk-hit-r { width: 50%; }
#book.at-start .bk-hit-l, #book.at-end .bk-hit-r { cursor: default; }
/* the leaf: a sheet swept over as a page turns (blank: the words are already on the page under it) */
#book .bk-leaf { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; pointer-events: none; z-index: 2; transform-style: preserve-3d; visibility: hidden; transform-origin: 0 50%; }
#book.two .bk-leaf { left: 50%; width: 50%; }
#book .bk-leaf-f, #book .bk-leaf-b { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: linear-gradient(90deg, rgba(60,40,18,.28), rgba(0,0,0,0) 18%, rgba(255,255,255,.18) 60%, rgba(70,48,22,.18)), #efe3c6; box-shadow: 0 0 22px rgba(0,0,0,.35); }
#book .bk-leaf-b { transform: rotateY(180deg); background: linear-gradient(270deg, rgba(60,40,18,.28), rgba(0,0,0,0) 18%, rgba(255,255,255,.14) 60%, rgba(70,48,22,.18)), #ece0c2; }
#book .bk-leaf.go { visibility: visible; animation: bkTurn .55s cubic-bezier(.45,.05,.3,1) both; }
#book .bk-leaf.back { visibility: visible; animation: bkBack .55s cubic-bezier(.45,.05,.3,1) both; }
@keyframes bkTurn { 0% { transform: rotateY(0deg); opacity: 1; } 85% { opacity: 1; } 100% { transform: rotateY(-180deg); opacity: 0; } }
@keyframes bkBack { 0% { transform: rotateY(-180deg); opacity: 0; } 15% { opacity: 1; } 100% { transform: rotateY(0deg); opacity: 0; } }
#book:not(.two) .bk-leaf.go { animation-name: bkTurn1; }
#book:not(.two) .bk-leaf.back { animation-name: bkBack1; }
@keyframes bkTurn1 { 0% { transform: rotateY(0deg); opacity: .95; } 100% { transform: rotateY(-100deg); opacity: 0; } }
@keyframes bkBack1 { 0% { transform: rotateY(-100deg); opacity: 0; } 30% { opacity: .9; } 100% { transform: rotateY(0deg); opacity: 0; } }

/* the contents */
#book .bk-toc { position: absolute; inset: 0; z-index: 5; display: flex; justify-content: center; background: rgba(5,3,2,.9); opacity: 0; pointer-events: none; transition: opacity .3s ease; }
#book .bk-toc.on { opacity: 1; pointer-events: auto; }
#book .bk-toc-in { width: min(560px, 100%); max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px 16px 24px; box-sizing: border-box; }
#book .bk-toc h4 { margin: 4px 0 10px; text-align: center; font-size: 11px; letter-spacing: .5em; color: #f7dca0; }
#book .bk-tpart { margin: 18px 0 6px; text-align: center; }
#book .bk-tpart b { display: block; font-size: 9px; letter-spacing: .45em; color: rgba(214,173,98,.9); }
#book .bk-tpart span { display: block; margin-top: 3px; font: 600 17px/1.2 'Cormorant Garamond', Georgia, serif; color: #fbecd0; }
#book .bk-tch { display: flex; align-items: baseline; gap: 14px; width: 100%; min-height: 42px; padding: 8px 12px; border: 0; border-bottom: 1px solid rgba(214,173,98,.14); background: none; text-align: left; cursor: pointer; }
#book .bk-tch i { flex: none; width: 2.2em; text-align: right; font: italic 600 15px/1 'Cormorant Garamond', Georgia, serif; color: rgba(214,173,98,.8); }
#book .bk-tch span { font: 600 17px/1.25 'Cormorant Garamond', Georgia, serif; color: #f3e6cc; }
#book .bk-tch.here { background: rgba(214,173,98,.12); }
#book .bk-tch.here span { color: #f7dca0; }
#book .bk-tch:active { background: rgba(214,173,98,.22); }
#book .bk-tclose { display: flex; margin: 18px auto 0; }
#book .bk-wait { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 10px; letter-spacing: .3em; color: rgba(243,230,204,.6); display: none; text-align: center; max-width: 80%; }
#book.loading .bk-wait { display: block; }
#book.loading .bk-stage, #book.loading .bk-foot { visibility: hidden; }

/* the TALE page in the front: the cover, and the chapters to open it at */
#front .ftale .fcover { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 6px 0 4px; }
#front .ftale .fcover .fbk { width: 92px; height: 124px; margin: 2px 0 12px; border-radius: 2px 5px 5px 2px; position: relative;
  background: linear-gradient(90deg, #2a1708 0 8%, #4a2a10 9%, #3a200b 60%, #2c180a); box-shadow: 0 0 0 1px rgba(214,173,98,.6), 0 8px 18px rgba(0,0,0,.6), inset -3px 0 0 #f0e2c0, inset -4px 0 0 #b89a64; }
#front .ftale .fcover .fbk::before { content: 'ÀBÍKÚ'; position: absolute; left: 12%; right: 8%; top: 30%; text-align: center; font: 700 10px/1 Montserrat, sans-serif; letter-spacing: .32em; color: #f3d394; }
#front .ftale .fcover .fbk::after { content: ''; position: absolute; left: 50%; top: 52%; width: 14px; height: 14px; border: 1px solid #d6ad62; transform: translate(-30%, -50%) rotate(45deg); }
#front .ftale .fcover h3 { margin: 0; font: 600 22px/1.15 'Cormorant Garamond', Georgia, serif; color: #fbecd0; letter-spacing: .04em; }
#front .ftale .fcover .hb { margin-top: 14px; }
#front .ftale .fchap { display: flex; align-items: baseline; gap: 12px; width: 100%; min-height: 40px; padding: 7px 10px; border: 0; border-bottom: 1px solid rgba(214,173,98,.14); background: none; color: inherit; text-align: left; cursor: pointer; font: inherit; }
#front .ftale .fchap i { flex: none; width: 1.8em; text-align: right; font: italic 600 14px/1 'Cormorant Garamond', Georgia, serif; color: rgba(214,173,98,.8); }
#front .ftale .fchap span { font: 600 16px/1.25 'Cormorant Garamond', Georgia, serif; color: #f3e6cc; }
#front .ftale .fchap:active { background: rgba(214,173,98,.18); }

@media (prefers-reduced-motion: reduce) { #book .bk-leaf.go, #book .bk-leaf.back { animation: none; visibility: hidden; } }
