/* Roger Swiss: shared styles for every page.
   Rules, in short:
   1. One character grid. Monospace (IBM Plex Mono) carries structure: headings, labels, data, controls.
      One cell = 0.6 x body size; Chinese glyphs are scaled to exactly two cells. Running text is IBM Plex Sans on the same rows.
   2. Black and white. The one colour, green, marks visited links and the reading position.
   3. Headings are 1, 2 and 3 times the body size, so their cells stay on the grid.
   4. Everything you can act on reacts to the pointer by turning black; nothing else does. */

/* ---------- fonts (self-hosted) ---------- */
@font-face{font-family:"IBM Plex Mono";font-weight:300;font-style:normal;font-display:block;src:url(../fonts/plex-mono-300.woff2) format("woff2")}
@font-face{font-family:"IBM Plex Mono";font-weight:400;font-style:normal;font-display:block;src:url(../fonts/plex-mono-400.woff2) format("woff2")}
@font-face{font-family:"IBM Plex Mono";font-weight:600;font-style:normal;font-display:block;src:url(../fonts/plex-mono-600.woff2) format("woff2")}
@font-face{font-family:"IBM Plex Sans";font-weight:400;font-style:normal;font-display:block;src:url(../fonts/plex-sans-400.woff2) format("woff2")}
@font-face{font-family:"IBM Plex Sans";font-weight:600;font-style:normal;font-display:block;src:url(../fonts/plex-sans-600.woff2) format("woff2")}
@font-face{font-family:"IBM Plex Sans";font-weight:400;font-style:italic;font-display:block;src:url(../fonts/plex-sans-400-italic.woff2) format("woff2")}
/* arrows and box-drawing characters, which Plex lacks; 0.6 em wide like Plex Mono */
@font-face{font-family:"GG Box";font-weight:100 900;font-display:block;src:url(../fonts/gg-box.woff2) format("woff2");unicode-range:U+2190-21FF,U+2500-259F,U+2580-259F}
/* Chinese, cut down by the build to the characters the site uses, scaled so one glyph is two Latin cells */
@font-face{font-family:"GG CJK";font-weight:400;font-display:block;src:url(../fonts/cjk-400.woff2) format("woff2");size-adjust:120%;unicode-range:U+2E80-9FFF,U+3000-303F,U+FF00-FFEF}
@font-face{font-family:"GG CJK";font-weight:600;font-display:block;src:url(../fonts/cjk-600.woff2) format("woff2");size-adjust:120%;unicode-range:U+2E80-9FFF,U+3000-303F,U+FF00-FFEF}

/* ---------- tokens ---------- */
:root{
  --paper:#FFFFFF; /* white */
  --paper-rgb:255,255,255;--ink:#000000;--core:#1A7F48;
  /* body size grows with the window: 16px on phones and tablets, about 18px on a 13-inch laptop, 20px on 24- and 32-inch screens */
  --b:clamp(16px,calc(0.4vw + 12px),20px);--l:calc(var(--b)*1.65);
  --cell:calc(var(--b)*0.6); /* one monospace cell: every layout width is a whole number of these */
  --nav-h:calc(2*var(--l) + env(safe-area-inset-top,0px));
  --mono:"GG Box","IBM Plex Mono","GG CJK",ui-monospace,monospace;
  --sans:"GG Box","IBM Plex Sans","GG CJK",system-ui,sans-serif;
  color-scheme:light;box-sizing:border-box}
*,*::before,*::after{box-sizing:inherit}
html{background:var(--paper);scroll-padding-top:calc(3*var(--l))}
body{margin:0;background:var(--paper);color:var(--ink);font:400 var(--b)/var(--l) var(--sans);-webkit-text-size-adjust:100%;
  padding-bottom:env(safe-area-inset-bottom,0px)}
h1,h2,h3,p,ul,ol,dl,dd,figure,pre{margin:0;padding:0}
ul{list-style:none}
h1,h2,h3,dt,dd,button,.mono{font-family:var(--mono)}
h1{font-size:calc(3*var(--b));line-height:calc(2*var(--l));font-weight:600}
h2{font-size:calc(2*var(--b));line-height:calc(2*var(--l));font-weight:600}
h3{font-size:var(--b);line-height:var(--l);font-weight:600}

/* ---------- what is what: one visual language for everything you can act on ----------
   underlined          a link; the glyph after it says where it goes:
                       ↗ another site   → another page here   ↓ ↑ further down or up this page
   dotted underline    sets a figure to the state the sentence describes (small frame icon)
   [bracketed words]   buttons
   + and −             open and close a section
   green underline     a link you have already visited */
a{color:inherit;text-decoration:underline;text-underline-offset:4px;text-decoration-thickness:1px;cursor:pointer}
a:visited{text-decoration-color:var(--core)}
a:hover,a:focus-visible{background:var(--ink);color:var(--paper);text-decoration:none;outline:none}
a[data-go]::after{font-family:"GG Box",var(--mono);font-weight:400;display:inline-block;margin-left:.15em}
a[data-go="ext"]::after{content:"\2197"}
a[data-go="page"]::after{content:"\2192"}
a[data-go="down"]::after{content:"\2193"}
a[data-go="up"]::after{content:"\2191"}
a.state{text-decoration-style:dotted;text-decoration-thickness:1.5px}
a.state::after{content:"";display:inline-block;width:.7em;height:.7em;margin-left:.25em;vertical-align:-.02em;background-color:currentColor;
  -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Crect x='.75' y='.75' width='8.5' height='8.5' fill='none' stroke='black' stroke-width='1.5'/%3E%3Crect x='3.5' y='3.5' width='3' height='3'/%3E%3C/svg%3E") center/contain no-repeat;
  mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Crect x='.75' y='.75' width='8.5' height='8.5' fill='none' stroke='black' stroke-width='1.5'/%3E%3Crect x='3.5' y='3.5' width='3' height='3'/%3E%3C/svg%3E") center/contain no-repeat}
button{font-size:inherit;line-height:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer;min-height:var(--l)}
button:hover,button:focus-visible{background:var(--ink);color:var(--paper);outline:none}
@media (pointer:coarse){button{min-height:44px}}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* ---------- navigation ----------
   One bar on every page: the name goes home, the rest are the site's sections. It hides while you read down
   and comes back as soon as you scroll up, so it never covers the text for long. */
.site-nav{position:sticky;top:0;z-index:30;background:var(--paper);box-shadow:inset 0 -1px 0 var(--ink);
  padding-top:env(safe-area-inset-top,0px);transition:transform .25s cubic-bezier(.2,.7,.2,1)}
body.nav-hidden .site-nav{transform:translateY(-100%)}
.site-nav .in{width:var(--col-w);margin-left:var(--col-x);display:flex;align-items:center;justify-content:space-between;gap:2ch;
  height:calc(2*var(--l));font-family:var(--mono)}
.site-nav .home{font-weight:600;text-decoration:none}
.site-nav ul{display:flex;gap:3ch}
.site-nav ul a{text-decoration:none}
.site-nav ul a[aria-current]{text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:6px}
.site-nav ul a[aria-current]:hover{text-decoration:none}
.site-nav a[data-go]::after{content:none}
.site-nav .menu{display:none}
@media (max-width:47.5em){
  .site-nav .in{width:calc(100vw - 4ch);margin-left:2ch}
  .site-nav .menu{display:inline-block}
  .site-nav ul{display:none;position:absolute;left:0;right:0;top:100%;flex-direction:column;gap:0;background:var(--paper);
    box-shadow:inset 0 -1px 0 var(--ink);padding:calc(.5*var(--l)) 2ch var(--l)}
  .site-nav ul li a{display:block;line-height:calc(1.6*var(--l))}
  .site-nav.open ul{display:flex}
}

/* ---------- reveal: the page waits for its fonts, then comes into focus like an object pressed against ground glass ---------- */
html.fonts-wait body>*:not(.site-nav){opacity:0;filter:blur(6px)}
html.fonts-in body>*{transition:opacity .35s ease-out,filter .45s cubic-bezier(.2,.7,.2,1)}

/* ---------- section links: § appears in the margin beside a heading; click to copy a link to it ---------- */
.anchor{position:absolute;left:-2.5ch;top:0;width:2ch;height:100%;min-height:0;font-family:var(--mono);font-weight:400;font-size:var(--b);
  opacity:0;display:flex;align-items:center;justify-content:center}
h2:hover .anchor,h3:hover .anchor,.anchor:focus-visible{opacity:1}
/* no margin to hang it in on narrow windows, and no hover on touch: the § is left out there */
@media (max-width:47.5em),(hover:none){.anchor{display:none}}
.copied{position:fixed;left:50%;bottom:calc(2*var(--l));transform:translateX(-50%);background:var(--ink);color:var(--paper);
  font-family:var(--mono);padding:0 1ch;z-index:40}

/* ---------- standard mode: the browser's usual link language, for readers who rely on it ---------- */
body.compat a,body.compat a.state,body.compat .cite{color:#0000EE;text-decoration-line:underline;text-decoration-color:currentColor}
body.compat a:visited{color:#551A8B}
body.compat a:hover,body.compat a:focus-visible{background:none;color:#0000EE;text-decoration-thickness:2px}
body.compat a[data-go]::after,body.compat a.state::after{display:none}
body.compat button{background:#EFEFEF;border:1px solid #767676;border-radius:3px;padding:0 .6em;color:#000}
body.compat button:hover,body.compat button:focus-visible{background:#E5E5E5;color:#000}
body.compat .cite{background:none;border:0;padding:0}
body.compat .site-nav ul a{color:#0000EE}
body.compat :focus-visible{outline:2px solid #0000EE!important;outline-offset:2px}

@media (prefers-reduced-motion:reduce){
  .site-nav,html.fonts-in body>*{transition:none}
  html.fonts-wait body>*:not(.site-nav){filter:none}
}

/* ---------- print: black on white paper, no controls; links print their address; notes print in place ---------- */
@media print{
  :root{--b:10.5pt;--l:15pt}
  @page{margin:18mm 20mm}
  .site-nav,.toc,.refpop,.compat-btn,.gridbtn,.anchor,.fig .controls,.copied,.gridview{display:none!important}
  html.fonts-wait body>*{opacity:1!important;filter:none!important}
  body{padding:0}
  .page{width:auto!important;margin:0!important;left:0!important;padding:0!important}
  a{text-decoration:none}
  a[data-go="ext"]::after,a[data-go="page"]::after{content:" (" attr(href) ")";font-family:var(--mono);font-size:.8em;word-break:break-all}
  a[data-go="down"]::after,a[data-go="up"]::after,a.state::after{content:none}
  h2,h3{break-after:avoid}
  article h2,.sechead{box-shadow:none!important;border-bottom:1px solid #000}
  figure,.abstract,.sidenote{break-inside:avoid}
}

/* skip link: hidden until it has keyboard focus, then the first thing on the page */
.skip{position:absolute;left:calc(2*var(--cell));top:0;z-index:50;transform:translateY(-200%);background:var(--ink);color:var(--paper);font-family:var(--mono);padding:0 var(--cell);text-decoration:none}
.skip:focus{transform:none}
.page:focus{outline:none}
