/* EndoLore — layout shared by the document pages (Project, and later Wet Lab…): hero,
   numbered sections, prose, the violet band, sources, "continue reading". Each page adds
   only its own pieces. Load after site.css. */
html, body { margin: 0; padding: 0; background: #fffcf6; }
* { box-sizing: border-box; }
body { font-family: 'Open Sans', sans-serif; color: #1b1024; overflow-x: clip; }
a { color: #5a1faf; text-decoration-color: rgba(90,31,175,0.35); text-underline-offset: 3px; }
::selection { background: #edd84a; color: #000; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 clamp(20px, 6vw, 90px); }
.mono { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; }

/* --- hero --- */
.hero { padding-top: clamp(140px, 20vh, 200px); }
.hero .crumb { color: #5a1faf; }
.hero h1 { margin: 22px 0 0; font-family: 'Arapey', serif; font-weight: 400; font-size: clamp(48px, 8.4vw, 124px); line-height: 0.98; letter-spacing: -0.01em; max-width: 12ch; }
.hero h1 .accent { font-family: 'Pacifico', cursive; color: #5a1faf; font-size: 0.78em; }
.hero .lede { margin: 34px 0 0; font-family: 'Arapey', serif; font-size: clamp(19px, 2.1vw, 25px); line-height: 1.55; color: #3a3145; max-width: 50ch; border-top: 1px solid rgba(27,16,36,0.14); padding-top: 22px; }
/* --- sections: number and label held in the margin while the text scrolls --- */
.sec { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 7fr); gap: 0 clamp(24px, 5vw, 80px); padding-top: 13vh; }
.sec-side .stick { position: sticky; top: 104px; display: flex; flex-direction: column; gap: 10px; }
.sec-no { font-family: 'Arapey', serif; font-size: clamp(56px, 7vw, 104px); line-height: 0.9; color: #d3b8ff; }
.sec-lbl { color: #5a1faf; }
.sec h2 { margin: 0 0 28px; font-family: 'Arapey', serif; font-weight: 400; font-size: clamp(32px, 4.2vw, 56px); line-height: 1.05; letter-spacing: -0.005em; max-width: 18ch; }
.prose p { margin: 0 0 1.1em; font-family: 'Arapey', serif; font-size: clamp(18px, 1.6vw, 21px); line-height: 1.68; color: #22182c; max-width: 62ch; }
.prose mark { background: linear-gradient(transparent 60%, #fbf7c8 60%); color: inherit; padding: 0 2px; }
sup.ref { font-family: 'IBM Plex Mono', monospace; font-size: 11px; line-height: 0; margin-left: 2px; }
sup.ref a { text-decoration: none; }
.more { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; text-decoration: none; white-space: nowrap; }

/* --- the violet band: a turn in the story, crossed by the thread --- */
.band { position: relative; margin-top: 15vh; background: #5a1faf; color: #fffcf6; padding: 17vh 0; overflow: hidden; }
.band > svg { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 100%; height: 70%; pointer-events: none; overflow: visible; }
.band .wrap { position: relative; }
.band > .wrap > p { margin: 0; font-family: 'Arapey', serif; font-size: clamp(30px, 4.4vw, 64px); line-height: 1.12; max-width: 22ch; }
.band > .wrap > p.quiet { margin-top: 0.35em; color: rgba(211,184,255,0.9); }
.band > .wrap > p.turn { margin-top: 1.4em; }
.band .accent { font-family: 'Pacifico', cursive; color: #edd84a; font-size: 0.86em; }

/* --- figures --- */
.slot { margin: 10px 0 34px; min-height: 240px; flex-direction: column; justify-content: center; padding: 26px 28px; border-radius: 18px; }
figcaption { margin-top: 16px; font-family: 'Open Sans', sans-serif; font-size: 13px; line-height: 1.65; color: #4a4155; max-width: 62ch; }

/* --- status ledger: what is proven, pending, not started --- */
.ledger { list-style: none; margin: 4px 0 30px; padding: 0; border-top: 1px solid rgba(27,16,36,0.14); max-width: 70ch; }
.ledger li { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 6px 22px; padding: 18px 0; border-bottom: 1px solid rgba(27,16,36,0.14); }
.ledger .state { display: flex; align-items: center; gap: 10px; font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #2a2130; }
.ledger .state i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ledger .done i { background: #5a1faf; }
.ledger .wip i { background: #edd84a; }
.ledger .next i { border: 1.5px solid #9959d1; }
.ledger .what { font-family: 'Arapey', serif; font-size: 18px; line-height: 1.5; color: #22182c; }

/* --- sources --- */
.refs { list-style: none; margin: 0; padding: 0; border-top: 1px solid rgba(27,16,36,0.14); }
.refs li { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 14px 8px; border-bottom: 1px solid rgba(27,16,36,0.1); font-size: 14px; line-height: 1.6; color: #3a3145; overflow-wrap: anywhere; }
.refs li .n { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: #5a1faf; padding-top: 3px; }
.refs li:target { background: #fbf7c8; }

/* --- continue reading --- */
.next-read { margin-top: 15vh; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid rgba(27,16,36,0.14); }
.next-read a { display: flex; flex-direction: column; gap: 12px; padding: 30px 24px 30px 0; text-decoration: none; color: #1b1024; }
.next-read a + a { border-left: 1px solid rgba(27,16,36,0.14); padding-left: 24px; }
.next-read .t { font-family: 'Arapey', serif; font-size: clamp(28px, 3.4vw, 46px); line-height: 1; transition: color .25s ease; }
.next-read .s { font-family: 'Arapey', serif; font-size: 17px; line-height: 1.45; color: #4a4155; }
.next-read a:hover .t { color: #5a1faf; }

/* sections come in once, as they reach the viewport (page.js adds .is-in) */
[data-reveal] { opacity: 0; transform: translateY(24px); transition: opacity .8s ease, transform .8s cubic-bezier(.2,.7,.2,1); }
[data-reveal].is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* --- table of contents (built by page.js): the page's parts, held against the right edge.
   A part's own headings show only while it is the one being read. Laptop gutters
   hold a numbered rail; wide screens have room for the full section labels. --- */
.toc { display: none; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .25s ease, visibility 0s linear .25s; }
.toc.is-visible { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
/* Keep scroll visibility intact while the main navigation temporarily takes priority.
   Immediate visibility changes also remove hidden links from keyboard navigation. */
body:has(.site-nav .navgroup:is(:hover, :focus-within, .open, .hover-open)) .toc,
body:has(.site-nav.menu-open) .toc { opacity: 0; visibility: hidden; pointer-events: none; transition-delay: 0s; }
@media (min-width: 1041px) {
  .toc { display: block; position: fixed; right: clamp(14px, 2.2vw, 40px); top: 50%; transform: translateY(-50%); z-index: 20; width: 186px; max-height: 66vh; overflow-y: auto; scrollbar-width: none; }
  .toc::-webkit-scrollbar { display: none; }
  .toc ol { list-style: none; margin: 0; padding: 0; }
  .toc > ol > li + li { margin-top: 13px; }
  .toc a { text-decoration: none; font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: #6b6478; transition: color .25s ease, border-color .25s ease; }
  .toc a:hover { color: #5a1faf; }
  .toc > ol > li > a { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 9px; padding: 3px 0 3px 11px; border-left: 2px solid rgba(27,16,36,0.13); line-height: 1.45; }
  .toc > ol > li.is-active > a { color: #5a1faf; border-left-color: #5a1faf; }
  .toc .n { color: #d3b8ff; }
  .toc > ol > li.is-active .n { color: #9959d1; }
  .toc .subs { visibility:hidden; margin: 0 0 0 11px; max-height: 0; opacity: 0; overflow: hidden; transition: max-height .35s ease, opacity .3s ease; }
  .toc > ol > li.is-active .subs { visibility:visible; max-height: 240px; opacity: 1; }
  .toc .subs a { display: block; padding: 6px 0 6px 12px; border-left: 1px solid rgba(27,16,36,0.13); font-size: 9.5px; letter-spacing: 0.1em; }
  .toc .subs a:hover { border-left-color: #5a1faf; }
}
@media (min-width:1041px) and (max-width:1559px) {
  body .toc { right:6px; width:42px; padding:4px 2px; background:rgba(255,252,246,.96); border-radius:10px; }
  body .toc > ol > li { display:block; margin:0; }
  body .toc > ol > li + li { margin-top:3px; }
  body .toc > ol > li > a { display:flex; justify-content:center; align-items:center; width:36px; min-height:32px; padding:4px 0; gap:0; }
  body .toc .l { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
  body .toc .subs { margin:0; }
  body .toc .subs a { min-height:28px; padding:2px; font-size:0; letter-spacing:0; text-align:center; }
  body .toc .subs a::before { content:'·'; font-size:18px; }
  body .toc .n { font-size:11px; color:#6b6478; }
  body .toc > ol > li.is-active .n { color:#5a1faf; }
}
.toc a:focus-visible { outline:2px solid #5a1faf; outline-offset:2px; }
@media (prefers-reduced-motion: reduce) {
  .toc, .toc .subs { transition: none; }
}

@media (max-width: 860px) {
  .sec { grid-template-columns: minmax(0, 1fr); padding-top: 10vh; }
  .sec-side .stick { position: static; flex-direction: row; align-items: baseline; gap: 16px; margin-bottom: 14px; }
  .sec-no { font-size: 48px; }
  .ledger li { grid-template-columns: minmax(0, 1fr); }
  .next-read { grid-template-columns: minmax(0, 1fr); }
  .next-read a + a { border-left: 0; padding-left: 0; border-top: 1px solid rgba(27,16,36,0.14); }
}
