/* ground: the water. paper: core centres and the reading view. swirl: the pale
   drops in the background. ink1..ink6: the rings, of which --ink-count are used,
   --inks-per-core to each core. text: lettering on light colours; text-on-dark:
   lettering on dark ones; title-text: titles on light ones. The script picks
   light or dark for whatever is underneath (--ui-text, --paper-text...).
   title-scale enlarges every title, for fonts that run small. */
:root{
  --ground:#f4ecf2; --paper:#e8fdea; --swirl:#630331;
  --ink1:#e6d6f0; --ink2:#2b397d; --ink3:#d5fbe4;
  --text:#1d2a91; --text-on-dark:#f3ecdc; --title-text:#20337e;
  --ink-count:3; --inks-per-core:2;
  --font-title:"VT323",monospace; --title-weight:400; --title-scale:1.4;
  --font-body:"Space Mono",monospace;
  --ui-text:#26302f; --ui-muted:#3f4b4a; --paper-text:#2a2f30;
  color-scheme:light;
  box-sizing:border-box;
  padding-top:env(safe-area-inset-top,0px);
  padding-bottom:env(safe-area-inset-bottom,0px);
}
*,*::before,*::after{box-sizing:inherit}
html,body{height:100%;margin:0}
html{scroll-padding-top:env(safe-area-inset-top,0px)}
body{background:var(--ground);overflow:hidden;font-family:var(--font-body);color:var(--ui-text)}
canvas{position:fixed;inset:0;width:100%;height:100%;display:block;touch-action:none;cursor:crosshair}
canvas.over-core{cursor:pointer}

.masthead{position:fixed;left:clamp(1rem,3vw,2.25rem);top:calc(env(safe-area-inset-top,0px) + clamp(1rem,3vw,2rem));pointer-events:none}
.masthead h1{margin:0;font-family:var(--font-title);font-weight:var(--title-weight);font-size:calc(clamp(1.35rem,2.4vw,2rem) * var(--title-scale));letter-spacing:-.01em;line-height:1.1}
.masthead p{margin:.25rem 0 0;font-size:clamp(.85rem,1.1vw,.95rem);color:var(--ui-muted)}

.foot{position:fixed;left:clamp(1rem,3vw,2.25rem);right:clamp(1rem,3vw,2.25rem);bottom:calc(env(safe-area-inset-bottom,0px) + clamp(.9rem,2.5vw,1.6rem));display:flex;justify-content:space-between;align-items:end;gap:1rem;pointer-events:none}
.foot p{margin:0;font-size:.85rem;line-height:1.5;color:var(--ui-muted);max-width:40ch}
.foot button{pointer-events:auto;flex:none;white-space:nowrap;font:inherit;font-size:.85rem;color:var(--ui-text);background:transparent;border:1px solid currentColor;border-radius:999px;padding:.4rem .9rem;cursor:pointer}
.foot button:hover{background:var(--paper);color:var(--paper-text);border-color:var(--paper)}

.core{position:fixed;left:0;top:0;transform:translate(-50%,-50%);border:0;background:transparent;color:transparent;font:inherit;text-align:center;cursor:pointer;padding:.5rem .75rem;border-radius:1rem;will-change:transform}
.core .t{display:block;font-family:var(--font-title);font-weight:var(--title-weight);line-height:1.05;letter-spacing:-.01em;white-space:nowrap}
.core .s{display:block;margin-top:.3em;font-size:.95rem;font-weight:400;white-space:nowrap}
.core:focus-visible,.foot button:focus-visible{outline:2px solid var(--ui-text);outline-offset:3px}
.masthead h1,.masthead p{color:transparent;white-space:nowrap}
.foot{transition:opacity .4s ease}
body.reading .foot{opacity:0;pointer-events:none}
body.reading .foot button{pointer-events:none}

/* the section page is written straight onto the white the ink has opened up */
.sheet{position:fixed;inset:0;pointer-events:none}
.sheet-inner{position:absolute;left:50%;top:50%;transform:translate(-50%,calc(-50% + 10px));width:min(34rem,76vw);color:var(--paper-text);opacity:0;transition:opacity .5s ease,transform .6s cubic-bezier(.2,.7,.2,1)}
.sheet.open .sheet-inner{opacity:1;transform:translate(-50%,-50%);pointer-events:auto}
/* no scrollbar: the text fades out at whichever edge has more to scroll to */
.sheet-scroll{max-height:min(68vh,40rem);overflow-y:auto;padding:.25rem .5rem;scrollbar-width:none;--fade-top:0px;--fade-bottom:0px;
  -webkit-mask-image:linear-gradient(to bottom,transparent,#000 var(--fade-top),#000 calc(100% - var(--fade-bottom)),transparent);
  mask-image:linear-gradient(to bottom,transparent,#000 var(--fade-top),#000 calc(100% - var(--fade-bottom)),transparent)}
.sheet-scroll::-webkit-scrollbar{display:none}
.sheet-scroll.more-above{--fade-top:3rem}
.sheet-scroll.more-below{--fade-bottom:4rem}
/* pixel arrows, drawn on a 7×4 grid at 2px a pixel to match the pixel title font.
   Pale when there is nothing more that way, hidden when nothing scrolls. */
.sheet-frame{position:relative}
.arrow{position:absolute;right:-1.9rem;width:1.75rem;height:1.75rem;display:grid;place-items:center;padding:0;border:0;border-radius:4px;background:none;color:var(--paper-title);cursor:pointer;transition:opacity .25s}
.arrow svg{width:14px;height:8px;fill:currentColor;shape-rendering:crispEdges}
.arrow.close-x{top:0}
.arrow.close-x svg{height:14px}
.arrow.close-x:active svg{transform:scale(.85)}
.arrow.up{top:2.25rem}
.arrow.down{bottom:0}
.arrow:disabled{opacity:.18;cursor:default}
.arrow.up:not(:disabled):active svg{transform:translateY(-2px)}
.arrow.down:not(:disabled):active svg{transform:translateY(2px)}
.arrow:focus-visible{outline:2px solid var(--paper-text);outline-offset:1px}
.sheet-inner.no-scroll .arrow.up,.sheet-inner.no-scroll .arrow.down{visibility:hidden}
/* on opening, the down arrow blinks three times like a cursor */
.sheet-inner.hint .arrow.down:not(:disabled) svg{animation:blink 1s steps(1) 3}
@keyframes blink{50%{opacity:0}}
.sheet h2,.sheet h3{font-family:var(--font-title);font-weight:var(--title-weight);color:var(--paper-title);letter-spacing:-.015em;line-height:1}
.sheet h2{margin:0 0 1.1rem;font-size:calc(clamp(2.2rem,5vw,3.4rem) * var(--title-scale))}
.sheet h3{margin:2rem 0 0;font-size:calc(1.5rem * var(--title-scale))}
.sheet p,.sheet li{font-size:1rem;line-height:1.7;max-width:60ch}
.sheet ul{padding:0;list-style:none;margin:2rem 0}
.sheet li{padding:1.1rem 0;border-top:1px solid var(--paper-text)}
.sheet li strong{display:block;font-weight:700}
.sheet .meta{display:block;margin-bottom:.2rem;font-size:.85rem;opacity:.75}
.sheet .langs{display:grid;grid-template-columns:max-content 1fr;column-gap:1.5rem;margin:0}
.sheet .langs dd{margin:0;opacity:.75}
.sheet a{color:inherit}

/* phones: width is scarce, height isn't. A wider, taller box, with the arrows
   tucked into its right margin rather than hanging outside it. */
@media (max-width: 520px){
  .sheet-inner{width:calc(100vw - 2rem)}
  .sheet-scroll{max-height:86vh;padding-right:2rem}
  .arrow{right:0}
  .sheet-scroll.more-below{--fade-bottom:2.5rem}
}

@media (prefers-reduced-motion: reduce){
  .sheet-inner,.foot{transition:none}
  .sheet-inner.hint .arrow.down:not(:disabled) svg{animation:none}
}
