/* The weekly mystery ("the book"): chapter pages, clue cards, logic grids, glossary words, ending.
   Owned by the story team. Inside the book the player's reading choices (body.reading + th-/ft-/sz-
   classes from tokens.css) change colours, font, size and width. */

body.reading main{font-family:var(--f-read)}
body.reading h1,body.reading h2{font-family:var(--f-display)}
body.reading button,body.reading input,body.reading select,body.reading textarea,body.reading .pill{font-family:var(--f-ui)}

/* ---------- the casebook page (story/day.js): one scene per page ---------- */
.phead{position:relative;display:flex;align-items:center;gap:var(--s3);padding-right:56px;margin:0 0 var(--s2)}
.pback{background:none;border:0;padding:8px 0;min-height:var(--tap-sm);font:750 1rem var(--f-ui);color:var(--ink)}
.pcount{margin-left:auto;color:var(--mut);font:600 var(--t-sm) var(--f-ui)}
.ribbon{position:absolute;right:14px;top:-80px;width:20px;height:120px;background:var(--case);clip-path:polygon(0 0,100% 0,100% 100%,50% 86%,0 100%);pointer-events:none}
.bar.thin{height:6px;border-width:0;background:var(--ln2);margin:0 0 var(--s4)}
.pagestage{position:relative;overflow:hidden;touch-action:pan-y}
.page{position:relative;padding-top:var(--s4);min-height:50vh}
/* the faint drawing of the place: behind the heading, fading out before the text */
.pageart{position:absolute;left:-16px;right:-16px;top:0;width:calc(100% + 32px);height:220px;object-fit:cover;object-position:center top;opacity:.11;pointer-events:none;
 -webkit-mask-image:linear-gradient(var(--ink) 45%,transparent);mask-image:linear-gradient(var(--ink) 45%,transparent)}
body.th-black .pageart{filter:invert(1);opacity:.2}
.page>*:not(.pageart){position:relative}
.dtitle{font-size:var(--t-3xl);margin:var(--s8) 0 var(--s4)}
.scene{margin:0}
.scene h2{font:900 clamp(2rem,8vw,2.6rem)/.92 var(--f-display);margin:var(--s10) 0 var(--s5)}
.dtitle+.recap+.scene h2,.dtitle+.scene h2{margin-top:var(--s6)}
.scene p{margin:0 0 .95em;hyphens:auto;-webkit-hyphens:auto}
.page .scene h2::after{content:"";display:block;width:44px;height:6px;margin-top:14px;border-radius:3px;background:var(--case)}
.readit{margin-top:var(--s6)}
.worktitle{font-size:var(--t-2xl);margin:var(--s8) 0 var(--s2)}
.workfoot{margin-top:var(--s6)}
/* turning a page: the new page swings in from the side it comes from */
.page.turn-next{animation:turnNext .32s var(--ease) both;transform-origin:left center}
.page.turn-prev{animation:turnPrev .32s var(--ease) both;transform-origin:right center}
@keyframes turnNext{from{opacity:0;transform:perspective(1400px) translateX(34%) rotateY(-16deg)}}
@keyframes turnPrev{from{opacity:0;transform:perspective(1400px) translateX(-34%) rotateY(16deg)}}
/* page-turn bar at the bottom */
.pager{position:fixed;left:0;right:0;bottom:0;z-index:31;display:flex;align-items:center;gap:var(--s3);padding:10px 14px calc(10px + env(safe-area-inset-bottom));background:var(--sf);border-top:var(--bw) solid var(--edge);font-family:var(--f-ui)}
.pturn{flex:none;width:52px;height:52px;border-radius:50%;border:var(--bw) solid var(--edge);background:var(--sf);color:var(--ink);font:500 1.7rem/1 var(--f-ui);display:flex;align-items:center;justify-content:center;padding:0 0 3px}
.pturn.next{background:var(--ink);color:var(--on)}
.pturn:disabled{opacity:.3}
.plabel{flex:1;min-width:0;text-align:center;font-weight:700;font-size:var(--t-sm);line-height:1.3;color:var(--ink);overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
@media (min-width:900px){.pager{left:50%;right:auto;transform:translateX(-50%);bottom:16px;width:min(720px,calc(100% - 32px));border:var(--bw) solid var(--edge);border-radius:var(--r-pill);padding:8px}}
.workcase{margin:var(--s8) 0 var(--s2);padding-top:var(--s4);border-top:2px solid var(--ink)}.workcase h2{margin:0 0 6px}
.recap{font-size:.95em;background:var(--sf)}.recap b{font-family:var(--f-ui);font-size:var(--t-sm);font-weight:750}

/* ---------- clue and question cards ---------- */
.q{font-weight:650}.fx{font-size:.92em;font-weight:600;padding-left:10px;border-left:6px solid var(--case)}
.qbtn,.opt{display:block;width:100%;text-align:left;margin:var(--s2) 0}
.opt{background:var(--sf);border:var(--bw) solid var(--edge);border-radius:var(--r);padding:12px 14px;min-height:var(--tap);color:var(--ink);line-height:1.4;transition:border-color .12s,background .12s}
.opt:hover{background:var(--sf2)}
.opt.sel{background:var(--ink);color:var(--on)}.opt.sel .mut{color:inherit}
.qa{border-left:4px solid var(--case);padding-left:var(--s3);margin:var(--s3) 0}
.clues{padding-left:22px}.clues li{margin:4px 0}

/* ---------- day page layout: chapter + side panel on wide screens ---------- */
.dayside{display:none}.daygrid{display:block}
@media (min-width:1100px){
 main.daywide{max-width:1240px}
 .daygrid{display:grid;grid-template-columns:minmax(0,780px) minmax(300px,1fr);gap:var(--s8);align-items:start}
 .dayside{display:block;position:sticky;top:84px}
 .cards-grid,.chapters{grid-template-columns:repeat(auto-fill,minmax(min(100%,320px),1fr))}
}

/* ---------- logic grid (story/grid.js) ---------- */
.grid{border-collapse:separate;border-spacing:4px;margin:6px 0 12px;font-family:var(--f-ui)}
.grid th{font-weight:500;font-size:.85rem;padding:0;color:var(--mut)}
.grid .gr{text-align:right;white-space:nowrap;padding-right:8px;height:46px;vertical-align:middle;font-weight:600;color:var(--ink)}
.grid .gh{width:46px;height:auto;padding:0 0 4px;vertical-align:bottom;text-align:center;font-size:.78rem;font-weight:600;line-height:1}
.grid .gh span{display:block;margin:0 auto;writing-mode:vertical-rl;transform:rotate(180deg);white-space:nowrap;line-height:1.2;max-height:14em;overflow:hidden;text-overflow:ellipsis;padding-bottom:2px}
.cell{display:block;width:46px;height:46px;padding:0;border:1.5px solid var(--ln);background:var(--sf);border-radius:var(--r-sm);font-size:1.15rem;font-weight:800;color:var(--ink);transition:background .1s}
.cell:hover{background:var(--sf2)}
.cell.yes{color:var(--case-ink);background:var(--case);border-width:var(--bw)}

/* ---------- glossary words ---------- */
.gl{border-bottom:2px dotted var(--ink);cursor:pointer}

/* floating Listen button (story/narrate.js): reading starts from the page you are on */
.listenfab{position:fixed;right:14px;bottom:calc(78px + env(safe-area-inset-bottom));z-index:44;display:flex;align-items:center;gap:8px;height:52px;padding:0 18px 0 14px;border-radius:var(--r-pill);background:var(--ink);color:var(--on);border:var(--bw) solid var(--ink);box-shadow:3px 3px 0 var(--case);font:750 .95rem var(--f-ui);cursor:pointer;animation:rise .25s var(--ease)}
body.paging .listenfab{bottom:calc(88px + env(safe-area-inset-bottom))}
.listenfab svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
@media (min-width:900px){.listenfab{bottom:28px;right:96px}body.paging .listenfab{bottom:96px}}

/* ---------- the Archive: a filing cabinet (story/archive.js) ---------- */
.cabinet{border:3px solid var(--edge);border-bottom:0;border-radius:var(--r) var(--r) 0 0;padding:12px 10px 0;margin:var(--s4) 0;max-width:640px}
.drawer{display:block;width:100%;margin:0 0 12px;padding:0;background:none;border:0;text-align:inherit;color:inherit}
.dbox{padding:8px 6px 0;overflow:hidden}
.files{display:flex;flex-direction:column;padding-top:6px}
.folder{position:relative;display:block;width:100%;height:118px;margin-top:-56px;padding:0;text-align:left;background:none;border:0;color:var(--ink);transition:transform .18s var(--ease)}
.folder:first-child{margin-top:0}
.ftab{position:absolute;top:0;height:32px;width:46%;max-width:190px;display:flex;align-items:center;gap:8px;padding:0 10px;background:var(--sf);border:var(--bw) solid var(--edge);border-bottom:0;border-radius:10px 10px 0 0;font:800 .82rem var(--f-ui)}
.folder.t0 .ftab{left:4%}.folder.t1 .ftab{left:28%}.folder.t2 .ftab{left:52%}.folder.t3 .ftab{left:16%}
.ffront{position:absolute;top:30px;left:0;right:0;bottom:0;display:flex;justify-content:space-between;align-items:flex-start;gap:10px;padding:8px 12px;background:var(--sf);border:var(--bw) solid var(--edge);border-radius:4px 8px 0 0}
.ffront b{font:800 1.3rem/1 var(--f-display);text-transform:uppercase;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
.fstate{flex:none;font:700 .75rem var(--f-ui);padding:3px 10px;border-radius:var(--r-pill);border:1.5px solid var(--edge)}
.folder.live .ftab{background:var(--case);color:var(--case-ink)}
.folder.live .fstate{background:var(--ink);color:var(--on)}
.folder.blank .ftab,.folder.blank .ffront{border-color:var(--ln2);color:var(--mut)}
.femblem{width:20px;height:20px}
.folder.up{transform:translateY(-14px)}
.folder.live:hover,.folder.live:focus-visible{transform:translateY(-14px)}
/* riffle: when the drawer opens, the folders pop up one after another and settle */
.folder.rise{animation:riffle .5s var(--ease) backwards;animation-delay:var(--d,0ms)}
@keyframes riffle{0%{transform:translateY(26px);opacity:0}55%{transform:translateY(-12px);opacity:1}100%{transform:none}}
.dfront{position:relative;display:flex;justify-content:center;height:96px;margin:0 -4px;border:3px solid var(--edge);border-radius:6px;background:var(--sf)}
.drawer.open .dfront{background:var(--ink);color:var(--on);animation:pull .45s var(--ease) both}
@keyframes pull{from{transform:translateY(-40px)}}
.dlabel{margin-top:12px;height:46px;min-width:190px;padding:4px 14px;display:flex;flex-direction:column;align-items:center;justify-content:center;background:var(--sf);color:var(--ink);border:var(--bw) solid var(--edge);border-radius:3px;line-height:1.1}
.dlabel b{font:900 1.15rem var(--f-display);text-transform:uppercase}.dlabel small{font-size:.7rem;font-weight:650;color:var(--mut)}
.dhandle{position:absolute;bottom:12px;left:50%;width:110px;height:14px;margin-left:-55px;border:3px solid currentColor;border-top:0;border-radius:0 0 10px 10px}
.drawer.open .dhandle{border-color:var(--case)}
.drawer.shut{opacity:.7}
.cell.auto{color:var(--mut)}
