/* Shared styling for the hybrid drafts (Codex + Nave, drawn in) */
:root{
  --leather:#24170f; --leather2:#3a2517;
  --paper:#f2e8d2; --paper2:#e8dcc0;
  --ink:#2a1f14; --ink-soft:#5a4a36;
  --oxblood:#7a1f1f; --gold:#a8822f; --rule:#cdbf9f;
  --cobalt:#1f3a7a; --emerald:#1f5a45; --amber:#d99a2b; --violet:#5a2d6e;
}
*{box-sizing:border-box}
body{margin:0;color:var(--ink);font-family:'EB Garamond',serif;line-height:1.55}
.draft-tag{position:fixed;top:.6rem;left:.8rem;z-index:60;font:12px/1 'EB Garamond',serif;letter-spacing:.12em;text-transform:uppercase;opacity:.75;pointer-events:none}

/* ---------- drawing primitives ---------- */
.ln{fill:none;stroke-dasharray:1;stroke-dashoffset:1}
.drawn .ln{animation:draw var(--dur,1.5s) cubic-bezier(.5,.1,.3,1) forwards var(--d,0s)}
.static .ln{stroke-dashoffset:0;animation:none}
.fillin{opacity:0}
.drawn .fillin{animation:appear 1.2s ease forwards var(--d,1.6s)}
.static .fillin{opacity:1;animation:none}
@keyframes draw{to{stroke-dashoffset:0}}
@keyframes appear{to{opacity:1}}
.write{clip-path:inset(-.25em 100% -.25em 0)}
.drawn .write{animation:write 1.3s cubic-bezier(.5,0,.25,1) forwards .15s}
.static .write{clip-path:none;animation:none}
@keyframes write{to{clip-path:inset(-.25em 0 -.25em 0)}}
.rise{opacity:0;transform:translateY(8px)}
.drawn .rise{animation:rise .9s ease forwards var(--d,.5s)}
.static .rise{opacity:1;transform:none;animation:none}
@keyframes rise{to{opacity:1;transform:none}}

/* order of arrival: drawings and headings first, then the body text fades in behind them */
:is(.pg,.two>div)>:not(svg):not(.kicker):not(h1):not(h2):not(.flourish):not(.folio):not(.title-page):not(.rise){opacity:0;transform:translateY(6px)}
.drawn :is(.pg,.two>div)>:not(svg):not(.kicker):not(h1):not(h2):not(.flourish):not(.folio):not(.title-page):not(.rise){animation:fadeup .9s ease forwards var(--bd,1.5s)}
.static :is(.pg,.two>div)>:not(svg):not(.kicker):not(h1):not(h2):not(.flourish):not(.folio):not(.title-page):not(.rise){opacity:1;transform:none;animation:none}
@keyframes fadeup{to{opacity:1;transform:none}}
:is(.pg,.two>div)>:nth-child(1){--bd:1.35s}:is(.pg,.two>div)>:nth-child(2){--bd:1.47s}:is(.pg,.two>div)>:nth-child(3){--bd:1.59s}
:is(.pg,.two>div)>:nth-child(4){--bd:1.71s}:is(.pg,.two>div)>:nth-child(5){--bd:1.83s}:is(.pg,.two>div)>:nth-child(6){--bd:1.95s}
:is(.pg,.two>div)>:nth-child(7){--bd:2.07s}:is(.pg,.two>div)>:nth-child(8){--bd:2.19s}:is(.pg,.two>div)>:nth-child(n+9){--bd:2.3s}

svg .ink{stroke:var(--ink)} svg .gold{stroke:var(--gold)} svg .red{stroke:var(--oxblood)}
.ico{width:58px;height:58px;display:block;margin:0 0 .5rem;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
.ico .ln{stroke:var(--oxblood)} .ico .ln.g{stroke:var(--gold)}
.flourish{display:block;width:min(260px,70%);height:16px;margin:1rem auto;stroke-width:1.2}
.flourish .ln{stroke:var(--gold)}

/* ---------- ribbons ---------- */
.ribbons{display:flex;gap:.5rem;justify-content:center;z-index:5;max-width:100%}
.ribbons button{
  font:600 .82rem 'IM Fell English SC',serif;letter-spacing:.08em;color:#f6e9c8;cursor:pointer;white-space:nowrap;
  background:linear-gradient(#8d2525,#6a1717);border:0;padding:.55rem .9rem 1rem;
  clip-path:polygon(0 0,100% 0,100% 100%,50% 82%,0 100%);
  transition:transform .35s ease,filter .35s ease;filter:saturate(.7) brightness(.85)}
.ribbons button:hover{transform:translateY(5px);filter:none}
.ribbons button.on{transform:translateY(8px);filter:none;background:linear-gradient(#a82f2f,#7a1f1f)}

/* ---------- the book ---------- */
.book{position:relative;width:min(1040px,96vw);height:clamp(540px,76vh,700px);display:grid;grid-template-columns:1fr 1fr;perspective:2600px;
  box-shadow:0 40px 80px rgba(0,0,0,.6),0 0 0 10px #4a2e1b,0 0 0 12px #2b1a0f,0 0 0 13px rgba(201,162,75,.45);border-radius:3px}
.page{position:relative;height:100%;overflow:hidden;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .33  0 0 0 0 .18  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    linear-gradient(var(--paper),var(--paper2))}
/* the reading area sits exactly inside the gold frame, so text scrolls within it and never runs under the border */
.page .pg{position:absolute;inset:.85rem;overflow:auto;padding:1.8rem 1.95rem 3rem;scrollbar-width:thin;scrollbar-color:var(--rule) transparent;
  -webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 34px),transparent 100%);mask-image:linear-gradient(to bottom,#000 calc(100% - 34px),transparent 100%)}
.page.left{border-radius:3px 0 0 3px;box-shadow:inset -34px 0 38px -26px rgba(60,35,10,.45),inset 4px 0 0 rgba(255,255,255,.2)}
.page.right{border-radius:0 3px 3px 0;box-shadow:inset 34px 0 38px -26px rgba(60,35,10,.45),inset -4px 0 0 rgba(255,255,255,.2)}
.page.verso{border-radius:3px;box-shadow:inset -22px 0 28px -20px rgba(60,35,10,.4)}
/* ruled frame, drawn in */
.page::before{content:'';position:absolute;inset:.85rem;pointer-events:none;z-index:2;opacity:.65;
  background:
    linear-gradient(var(--gold),var(--gold)) top left/0 1px no-repeat,
    linear-gradient(var(--gold),var(--gold)) top right/1px 0 no-repeat,
    linear-gradient(var(--gold),var(--gold)) bottom right/0 1px no-repeat,
    linear-gradient(var(--gold),var(--gold)) bottom left/1px 0 no-repeat;
  transition:background-size 1.5s ease .1s}
.page.drawn::before,.page.static::before{background-size:100% 1px,1px 100%,100% 1px,1px 100%}
.page.static::before{transition:none}
.page.verso::before{display:none}
.folio{position:absolute;bottom:.5rem;font:italic .85rem 'EB Garamond';color:var(--ink-soft);opacity:.8}
.left .folio{left:1.2rem}.right .folio{right:1.2rem}

/* the turning leaf */
.leaf{position:absolute;top:0;width:50%;height:100%;transform-style:preserve-3d;z-index:4;transition:transform 1.15s cubic-bezier(.6,.05,.3,1)}
.leaf.fwd{right:0;transform-origin:left center}
.leaf.back{left:0;transform-origin:right center}
.leaf.single{left:0;right:auto;width:100%;transform-origin:left center}
.leaf .face{position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden}
.leaf .face .page{position:absolute;inset:0}
.leaf .face.rev{transform:rotateY(180deg)}
.leaf .shade{position:absolute;inset:0;pointer-events:none;background:linear-gradient(90deg,rgba(40,20,5,0),rgba(40,20,5,.38));animation:shade 1.15s ease-in-out both;z-index:3}
@keyframes shade{0%{opacity:0}45%{opacity:1}100%{opacity:0}}

/* corners (dog-ears) */
.corner{position:absolute;bottom:0;width:80px;height:80px;border:0;background:transparent;cursor:pointer;z-index:6}
.corner.n{right:0}.corner.p{left:0}
.corner::after{content:'';position:absolute;bottom:0;width:26px;height:26px;transition:all .3s ease;background:linear-gradient(135deg,var(--paper2) 50%,rgba(0,0,0,.3) 50%)}
.corner.n::after{right:0;border-radius:6px 0 0 0}
.corner.p::after{left:0;transform:scaleX(-1);border-radius:6px 0 0 0}
.corner:hover::after{width:46px;height:46px}
.corner[disabled]{display:none}
.counter{margin-top:.2rem;font:italic .9rem 'EB Garamond';opacity:.7;text-align:center}

/* single-page mode (phones): one leaf at a time, same turn */
.book.single{display:block;width:min(540px,94vw);height:clamp(440px,calc(100vh - 170px),740px);height:clamp(440px,calc(100svh - 170px),740px);box-shadow:0 24px 50px rgba(0,0,0,.55),0 0 0 6px #4a2e1b,0 0 0 7px rgba(201,162,75,.45)}
.book.single{overflow:hidden}
.book.single .page.left{display:none}
.book.single .page.right{width:100%;border-radius:3px;box-shadow:inset 22px 0 26px -20px rgba(60,35,10,.45)}
.book.single .page .pg{padding:1.3rem 1.1rem 3.2rem}
.book.single .folio{display:none}
.book.single p{font-size:.98rem}

/* ---------- typography ---------- */
h1,h2,h3{font-family:'IM Fell English',serif;font-weight:400;margin:0}
.kicker{font:.78rem 'IM Fell English SC';letter-spacing:.2em;color:var(--oxblood);text-transform:uppercase;margin-bottom:.4rem}
h2{font-size:2rem;line-height:1.1;margin-bottom:.3rem}
h3{font-size:1.35rem;margin:1.2rem 0 .1rem}
.meta{font-style:italic;color:var(--ink-soft);font-size:.95rem;margin:0 0 .5rem}
p{margin:.55rem 0;font-size:1.04rem;hyphens:auto}
.initial::first-letter{font-family:'UnifrakturCook',serif;font-weight:700;color:var(--oxblood);float:left;font-size:3.9rem;line-height:.78;padding:.28rem .45rem 0 0;text-shadow:1px 1px 0 rgba(168,130,47,.4)}
a{color:var(--oxblood);text-decoration:none;border-bottom:1px solid transparent;transition:border-color .25s}
a:hover{border-bottom-color:var(--oxblood)}
.todo{background:repeating-linear-gradient(135deg,rgba(168,130,47,.18) 0 6px,transparent 6px 12px);padding:0 .3rem;font-style:italic}
.marg{font-family:'Ms Madi',cursive;font-size:1.55rem;color:#7b6a52;line-height:1.1;margin-top:.8rem}
.chips{display:flex;flex-wrap:wrap;gap:.4rem;margin:.5rem 0 1rem}
.chips span{border:1px solid var(--gold);padding:.1rem .6rem;border-radius:2px;font-size:.92rem;background:rgba(255,255,255,.25)}
ul.plain{padding-left:1.1rem;margin:.4rem 0}
.cols{columns:2;column-gap:1.6rem}.cols li{break-inside:avoid}
.title-page{text-align:center;padding-top:.4rem}
.title-page h1{font-size:clamp(2rem,4vw,3rem);line-height:1.02;margin:.6rem 0 .4rem;letter-spacing:-.5px}
.title-page .sub{font-style:italic;color:var(--oxblood);font-size:1.08rem;max-width:24ch;margin:0 auto}
.facade{display:block;width:min(230px,60%);height:auto;margin:0 auto;stroke-width:1.15;stroke-linecap:round;stroke-linejoin:round}
.facade .ln{stroke:var(--ink)} .facade .ln.g{stroke:var(--gold)} .facade .ln.r{stroke:var(--oxblood)}
.toc{list-style:none;padding:0;margin:1rem 0 0}
.toc li{display:flex;align-items:baseline;gap:.5rem;padding:.5rem 0;cursor:pointer}
.toc .num{font-family:'IM Fell English';color:var(--oxblood);width:2.2rem}
.toc .name{font-size:1.3rem;font-family:'IM Fell English'}
.toc .dots{flex:1;border-bottom:2px dotted var(--rule);transform:translateY(-4px)}
.toc .pg-no{font-style:italic;color:var(--ink-soft)}
.toc li:hover .name{color:var(--oxblood)}
.toc small{display:block;font-size:.9rem;color:var(--ink-soft);font-style:italic}

@media(max-width:780px){
  p{font-size:1.02rem} h2{font-size:1.75rem}
  .ribbons{flex-wrap:nowrap;overflow-x:auto;justify-content:flex-start;padding:0 .6rem 1rem;scrollbar-width:none}
  .ribbons::-webkit-scrollbar{display:none}
  .cols{columns:1}
}
@media(prefers-reduced-motion:reduce){
  .ln{stroke-dashoffset:0!important;animation:none!important}.fillin,.rise,:is(.pg,.two>div)>*{opacity:1!important;transform:none!important;animation:none!important}.write{clip-path:none!important;animation:none!important}
}

