/* MXA Works: a small library on a wall. One stylesheet for the shelf, the privacy page and the "not found" page.
   Paper, ink and real type: flat colours only, no gradients, no glow, no blur, no texture.
   Each work's colours arrive from works.css as --cover, --ink, --band, --spine-w and --spine-h on its <li>, so the
   page's own colours use other names (--text, --green and so on). Nothing moves unless the visitor did something,
   and nothing moves at all under prefers-reduced-motion. The one exception, on purpose and only this (docs/CONTRACT.md
   section 11): the librarian, the owner's paper cut-out on the plank. He does one backflip when the page has opened and
   dances while the pointer is on him. Both are steps through the cells of mascot.webp, both are the only two
   @keyframes of this file, and both sit inside prefers-reduced-motion: no-preference. */

/* Fonts, self-hosted, SIL Open Font License 1.1 (fonts/OFL.txt). One file per family and script range; the latin-ext
   files carry the Turkish letters of "Başlı" and "İzmir". */
@font-face{font-family:'Libre Franklin';font-style:normal;font-weight:100 900;font-display:swap;src:url(fonts/libre-franklin-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:'Libre Franklin';font-style:normal;font-weight:100 900;font-display:swap;src:url(fonts/libre-franklin-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:'Courier Prime';font-style:normal;font-weight:400;font-display:swap;src:url(fonts/courier-prime-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:'Courier Prime';font-style:normal;font-weight:400;font-display:swap;src:url(fonts/courier-prime-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:'Pixelify Sans';font-style:normal;font-weight:400 700;font-display:swap;src:url(fonts/pixelify-sans-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:'Pixelify Sans';font-style:normal;font-weight:400 700;font-display:swap;src:url(fonts/pixelify-sans-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:'Grandstander';font-style:normal;font-weight:500 800;font-display:swap;src:url(fonts/grandstander-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:'Grandstander';font-style:normal;font-weight:500 800;font-display:swap;src:url(fonts/grandstander-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:'Lilita One';font-style:normal;font-weight:400;font-display:swap;src:url(fonts/lilita-one-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:'Lilita One';font-style:normal;font-weight:400;font-display:swap;src:url(fonts/lilita-one-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:'Alfa Slab One';font-style:normal;font-weight:400;font-display:swap;src:url(fonts/alfa-slab-one-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:'Alfa Slab One';font-style:normal;font-weight:400;font-display:swap;src:url(fonts/alfa-slab-one-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}

/* The six letterings a spine may ask for (tools/build.js FACES). One rule each. --title-scale evens out how wide the
   faces run (--title-fit says how wide a lettering runs where that differs from how large it is drawn: only the pixel one).
   Neither makes a title fit: a long title gets smaller by itself, from --title-len (the number of letters, written into
   works.css) and the spine's own --spine-w and --spine-h, in the rules for .spine-title below. */
.f-house{font-family:'Libre Franklin',Arial,sans-serif;font-weight:800;--title-scale:1}
.f-typed{font-family:'Courier Prime','Courier New',Courier,monospace;font-weight:400;--title-scale:.95}
.f-pixel{font-family:'Pixelify Sans','Courier New',monospace;font-weight:600;--title-scale:1.18;--title-fit:1.08}
.f-round{font-family:'Grandstander','Arial Rounded MT Bold',sans-serif;font-weight:700;--title-scale:1}
.f-candy{font-family:'Lilita One','Arial Black',sans-serif;font-weight:400;--title-scale:1.06}
.f-slab{font-family:'Alfa Slab One',Rockwell,Georgia,serif;font-weight:400;--title-scale:.86}

:root{
  /* the room */
  --wall:#dde4de;          /* flat plaster, cool grey-green (also the theme colour in the pages' head) */
  --green:#1f4636;         /* the house colour: plank, bookends, wall lettering, links */
  --green-dark:#14301f;    /* the same green in shadow: the bookends' steel */
  --text:#1b1d1b;          /* typed ink */
  --muted:#4a554e;         /* quieter ink, 6:1 on the wall */
  --line:#b5c0b8;          /* hairlines on the wall */
  /* paper */
  --card:#f8f7f1;          /* catalogue card stock */
  --card-edge:#d3d1c6;
  --paper:#fbfbf6;         /* stickers, labels, the flag */
  --rule:#c8463d;          /* the red rule under a card's top line */
  --red:#b3261e;           /* stamp ink, 6:1 on the card */
  --violet:#5b2d8e;        /* the other stamp ink, 8.8:1 on the card */
  --steel:#7d868c;         /* the paper clip */
  /* sizes */
  --spine-base-w:4.5rem;
  --spine-base-h:20rem;
  --plank:1.9rem;
  --desk-w:32rem;
  --desk-min:59rem;
  --house:'Libre Franklin',Arial,sans-serif;
  --typed:'Courier Prime','Courier New',Courier,monospace;
  color-scheme:light;
}

*,*::before,*::after{box-sizing:border-box}
html{background:var(--wall);color:var(--text);-webkit-text-size-adjust:100%;text-size-adjust:100%;scroll-padding-top:1rem}
body{position:relative;max-width:90rem;margin:0 auto;padding:2.5rem 3rem 3rem;background:var(--wall);font:400 1rem/1.5 var(--house);font-synthesis:none;overflow-wrap:break-word}
img{max-width:100%}
a{color:var(--green);text-decoration-thickness:.08em;text-underline-offset:.18em}
a:hover{color:var(--text);text-decoration-thickness:.14em}
:focus-visible{outline:3px solid var(--text);outline-offset:3px}
.vh{position:absolute!important;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}

/* the skip link: out of sight until the Tab key reaches it */
.skip{position:absolute;left:1rem;top:-12rem;z-index:5;display:inline-flex;align-items:center;min-height:2.75rem;padding:.6rem 1rem;background:var(--paper);color:var(--text);border:2px solid var(--text);font:700 1rem/1.2 var(--house);text-decoration:none}
.skip:focus{top:1rem}

/* ---------- the sign, painted on the wall ---------- */
.sign{container-type:inline-size}
.sign-name{display:block;margin:0;color:var(--green);font:900 clamp(2.5rem,9vw,5.5rem)/.86 var(--house);font-size:clamp(2.5rem,13cqi,5.5rem);letter-spacing:-.012em;text-transform:uppercase}
.sign-by{margin:.5rem 0 0;color:var(--green);font:500 1.3rem/1.2 var(--house)}
.sign-line{max-width:36rem;margin:.9rem 0 0;font:400 1rem/1.5 var(--typed)}
.sign-small .sign-name{display:inline-flex;align-items:center;min-height:2.75rem;font-size:clamp(1.7rem,8cqi,2.6rem);text-decoration:none}
.sign-small .sign-name:hover{color:var(--text)}
.sign-small .sign-by{margin-top:.1rem;font-size:1.05rem}

/* ---------- the shelf (standing books, from 48em up) ---------- */
.shelf{display:flex;flex-wrap:wrap;align-items:flex-end;margin-top:7rem}
/* past about eight books the row wraps; every book carries its own piece of plank, so every row gets one. Where the books
   stand, the list gives its box up and the books join the shelf's own row ("the end of the row", further down). */
#shelf{display:flex;flex-wrap:wrap;align-items:flex-end;row-gap:3rem;flex:0 1 auto;min-width:0;margin:0;padding:0;list-style:none}
.book{flex:none;padding:0 1px;border-bottom:var(--plank) solid var(--green)}
.book details{display:block}

.spine{display:block;position:relative;width:calc(var(--spine-w,1) * var(--spine-base-w));height:calc(var(--spine-h,1) * var(--spine-base-h));min-width:2.75rem;background:var(--cover,#555);color:var(--ink,#fff);border-radius:2px 2px 0 0;box-shadow:inset .2rem 0 0 rgb(255 255 255 / .12),inset -.25rem 0 0 rgb(0 0 0 / .2);cursor:pointer;list-style:none;-webkit-user-select:none;user-select:none}
.spine::-webkit-details-marker{display:none}
.spine::marker{content:""}
.spine:focus-visible{outline-offset:4px}
.spine-body{display:flex;flex-direction:column;align-items:center;height:100%;overflow:hidden;border-radius:inherit}
.spine-band{flex:none;align-self:stretch;display:flex;align-items:center;justify-content:center;height:3.6rem;background:var(--band,#999)}
.spine-band svg{display:block;width:2.4rem;height:2.4rem;padding:.42rem;border-radius:50%;background:var(--cover,#555);color:var(--ink,#fff)}
.spine-title{flex:1 1 0;min-height:0;padding:.8rem 0;writing-mode:vertical-rl;text-align:center;font-size:calc(var(--title-scale,1) * (1.05rem + var(--spine-w,1) * .5rem));line-height:1.05;overflow-wrap:anywhere}
/* A long title gets smaller until it fits (the build writes --title-len, the number of letters, into works.css). The size is capped at the
   square root of the room the title has per letter: the spine's width times the length left for the title, in rem (a spine is 4.5rem
   wide and 20rem high at 1; the band, the sticker and the padding take 8.46rem of the height). The .65 was measured, not guessed:
   with it, titles of 6 to 28 letters (mixed case, capitals, one long word, the widest letters) in all six letterings fit every
   spine from 0.7 to 1.4 wide and 0.7 to 1.1 high, and the four titles of today keep their own size (Egg Crush loses a pixel).
   A browser that cannot do sqrt() keeps the plain size above. */
@supports (font-size:calc(1rem * sqrt(4))){
  .spine-title{font-size:min(calc(var(--title-scale,1) * (1.05rem + var(--spine-w,1) * .5rem)),calc(1rem * sqrt(.65 * 4.5 * var(--spine-w,1) * (20 * var(--spine-h,1) - 8.46) * var(--title-fit,var(--title-scale,1)) / var(--title-len,12))))}
}
.spine-sticker{flex:none;display:flex;flex-direction:column;align-items:center;min-width:2.9rem;margin:.35rem 0 .75rem;padding:.24rem .3rem .2rem;background:var(--paper);color:var(--text);border-radius:2px;font:400 .72rem/1.2 var(--typed);letter-spacing:.02em}
/* the paper flag lies across the top of its spine, in type that can be read (never less than .8rem). Raised with its open
   book it reaches 2.6rem above the spine, less than the 3rem between two planks, so it never covers the row above. */
.spine-flag{position:absolute;bottom:100%;left:0;inline-size:max-content;padding:.3rem .55rem .32rem;background:var(--paper);color:var(--text);border:1px solid var(--card-edge);border-bottom:0;font:400 .8rem/1.2 var(--typed);white-space:nowrap}
details[open]>.spine{transform:translateY(-1rem)}

.shelf-end{flex:none;margin:3rem 0 0;padding:0 .3rem 0 .1rem;border-bottom:var(--plank) solid var(--green)}
/* a steel bookend seen from the side: an upright plate and a foot, a shade darker than the plank so the foot shows */
.bookend{display:block;width:2.9rem;height:7.5rem;border-left:.6rem solid var(--green-dark);border-bottom:.5rem solid var(--green-dark);border-top-left-radius:.35rem .6rem}
.room{flex:1 1 0;display:flex;align-items:flex-end;min-width:0;margin:3rem 0 0;padding:0 0 .45rem 1rem;border-bottom:var(--plank) solid var(--green)}
.room-note{display:inline-block;max-width:100%;padding:.4rem .6rem .45rem;background:var(--paper);border:1px solid var(--card-edge);font:400 .85rem/1.3 var(--typed);transform:rotate(-1deg)}
.shelf-label{flex:0 0 100%;display:flex;margin:calc(.32rem - var(--plank)) 0 0;padding-left:1rem;line-height:1}
.shelf-label span{display:inline-block;padding:.26rem .45rem .24rem;background:var(--paper);border:1px solid var(--card-edge);font:400 .74rem/1 var(--typed);letter-spacing:.02em}

/* ---------- catalogue cards and the library's own card ---------- */
.card,.libcard{--pad:1.3rem;--margin:4.3rem;position:relative;margin:0;padding:1.1rem var(--pad) 1rem calc(var(--pad) + var(--margin));background:var(--card);color:var(--text);border:1px solid var(--card-edge);border-radius:3px;box-shadow:0 1px 0 rgb(0 0 0 / .05),0 14px 24px -18px rgb(0 0 0 / .5);font:400 1rem/1.5 var(--typed);letter-spacing:0;text-align:left;text-transform:none;writing-mode:horizontal-tb;cursor:auto}
.libcard{--margin:0rem}
/* the punched hole, centred on the card at its foot; it ends the card's own flow, so it never sits on the text */
.card::after,.libcard::after{content:"";display:block;clear:both;position:relative;left:calc(var(--margin) / -2);width:.95rem;height:.95rem;margin:1.2rem auto 0;border-radius:50%;background:var(--wall);box-shadow:inset 0 1px 1px rgb(0 0 0 / .3)}
:where(.card,.libcard) :where(p){margin:0}
.card-callno{position:absolute;top:1.1rem;left:var(--pad);display:flex;flex-direction:column;line-height:1.5}
.card-callno span:nth-child(2){line-height:calc(1.5em + 2px)}
.card-author,.libcard h2,.libcard h1{margin:0 calc(-1 * var(--pad)) 0 calc(-1 * (var(--pad) + var(--margin)));padding:0 var(--pad) .1rem calc(var(--pad) + var(--margin));border-bottom:2px solid var(--rule)}
.card-title{margin:.45rem 0 .2rem;font:400 1.45rem/1.25 var(--typed);letter-spacing:-.01em}
.libcard h2,.libcard h1{padding-bottom:.3rem;font:400 1.2rem/1.35 var(--typed)}
.libcard h1{font-size:1.45rem}
.libcard p{margin-top:.75rem;line-height:1.55}
.card-about{margin-top:.8rem;font-size:1.02rem;line-height:1.56}
.card-notes{margin:.85rem 0 0;padding:0;list-style:none}
.card-notes li{padding-left:1.2em;text-indent:-1.2em}
.card-notes li::before{content:"- ";content:"- " / ""}   /* the dash is drawn, not read aloud; a browser that does not know the alternative keeps the first line */
.card-tracing{margin-top:.85rem;font-size:.92rem}
.card-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.6rem 1rem;margin-top:1rem}
.card-foot .card-out{order:1}
.card-foot .stamp{order:2;margin:0 .2rem 0 auto}
.libcard-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.75rem 1rem;margin-top:1.1rem}
.card-out{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:.8rem}
.take,.back{display:inline-flex;align-items:center;min-height:2.75rem;color:var(--green);font:800 1.35rem/1.1 var(--house);text-decoration:underline;text-decoration-thickness:.1em;text-underline-offset:.2em}
.take:hover,.back:hover{color:var(--text)}
.back{font-size:1.1rem}
.card-host{font:400 .95rem/1.4 var(--typed);overflow-wrap:anywhere}
.card-out-soon{display:block;max-width:24rem;font-size:.98rem}
.card-out-soon .card-host{display:block;margin-top:.15rem;font-size:1rem}
.libcard-updated{color:var(--muted)}
.libcard-page a{display:inline-flex;align-items:center;min-height:2.75rem}

/* the picture, held to the card by a paper clip */
.card-plate{position:relative;float:right;width:9.5rem;margin:.35rem -.2rem .7rem 1.1rem;padding:.3rem;background:#fff;border:1px solid var(--card-edge)}
.card-plate img{display:block;width:100%;height:auto}
.card-plate::before,.card-plate::after{content:"";position:absolute;border:2px solid var(--steel)}
.card-plate::before{top:-.95rem;right:1.4rem;width:.75rem;height:2.6rem;border-radius:.38rem}
.card-plate::after{top:-.6rem;right:1.57rem;width:.41rem;height:1.85rem;border-radius:.21rem;border-bottom-color:transparent}
/* on the shelf the picture leads to the work too: an empty second link lies over it, out of the Tab order and hidden from a
   screen reader ("Take it out" stays the one link). The picture itself is not inside that link, so its alt text is still read. */
.card-plate a{position:absolute;top:0;right:0;bottom:0;left:0}

/* A card reads in this order: heading, title, the work's own line, imprint and kind, then the way out and the stamp, then the
   picture at the width of the text, then the long text. So "Take it out" is on the first screen and the picture is large
   enough to show the work. (Ties in `order` keep the order of the page.) */
.card{display:flex;flex-direction:column}
.card>*{order:7}
.card>.card-callno,.card>.card-author{order:0}
.card>.card-title{order:1}
.card>.card-line{order:2}
.card>.card-imprint{order:3}
.card>.card-kind{order:4}
.card>.card-foot{order:5;margin-top:.9rem}
.card>.card-plate{order:6;float:none;width:auto;margin:1rem 0 .2rem}
.card::after{order:9}
.card-line{margin-bottom:.35rem;font-size:1.02rem;line-height:1.45}

/* rubber stamps */
.stamp{display:inline-flex;flex-direction:column;align-items:center;margin:0;padding:.3rem .7rem .35rem;border:3px double currentColor;color:var(--red);font:800 .92rem/1.2 var(--house);letter-spacing:.07em;text-transform:uppercase;transform:rotate(-2deg)}
.stamp time{font-weight:700;letter-spacing:.06em}
.stamp-soon{color:var(--violet)}

/* the desk: the library's own card shows while no book is out */
.desk{margin-top:1.5rem}

/* ---------- the catalogue ---------- */
.catalogue{max-width:46rem;margin-top:3.75rem}
.catalogue h2,.colophon h2{margin:0;color:var(--green);font:800 1.05rem/1.2 var(--house);letter-spacing:.08em;text-transform:uppercase}
.catalogue-intro{margin:.4rem 0 0;font:400 .95rem/1.45 var(--typed)}
#catalogue{margin:1rem 0 0;padding:0;list-style:none;font:400 1rem/1.4 var(--typed)}
#catalogue li{display:grid;grid-template-columns:3.6ch auto minmax(1.5rem,1fr) auto;grid-template-areas:"no title dots host" ". state state state";column-gap:.65rem;align-items:center;padding:.15rem 0 .5rem;border-top:1px solid var(--line)}
#catalogue li:last-child{border-bottom:1px solid var(--line)}
.cat-no{grid-area:no;color:var(--muted)}
.cat-title{grid-area:title;display:inline-flex;align-items:center;min-height:2.75rem;overflow-wrap:anywhere}
.cat-title a{display:inline-flex;align-items:center;min-height:2.75rem}
.cat-dots{grid-area:dots;align-self:center;height:0;margin-top:.5em;border-bottom:2px dotted var(--muted)}
.cat-host{grid-area:host;overflow-wrap:anywhere}
.cat-state{grid-area:state;color:var(--muted);font-size:.88rem}

/* ---------- the colophon ---------- */
.colophon{max-width:46rem;margin-top:3.75rem;padding-top:1.1rem;border-top:2px solid var(--green);color:var(--muted);font:400 .92rem/1.5 var(--house)}
.colophon p{margin:.3rem 0 0}
.colophon a{display:inline-flex;align-items:center;min-height:2.75rem}

/* ---------- the privacy page and the "not found" page ---------- */
.page-small main{max-width:40rem}
.libcard-page{margin-top:2.25rem}
.libcard .libcard-back{margin-top:1rem}
.libcard-foot .libcard-back{margin-top:0}
.gap-shelf{display:flex;align-items:flex-end;margin-top:4rem;padding-left:1.5rem;border-bottom:var(--plank) solid var(--green)}
.gap-shelf .bookend-left{border-left:0;border-right:.6rem solid var(--green-dark);border-top-left-radius:0;border-top-right-radius:.35rem .6rem}
.gap-space{width:5rem;height:15rem;margin:0 .15rem;border:2px dashed var(--line);border-bottom:0}

/* ---------- the librarian: the owner, a paper cut-out standing on the plank right of the bookend ---------- */
/* docs/CONTRACT.md section 11. mascot.webp is a strip of 30 cells by 2 rows, each cell 264 by 352 px. The top row is the
   backflip (cell 29 is him standing, facing the visitor), the bottom row is the dance (cells 0 to 23). A background size of
   3000% by 200% makes one cell as big as the box at any size, and a position of 100% * k / 29 shows cell k. His feet stand
   10 px above the bottom edge of a cell, so the box hangs 3.8% of its width low and the feet land on the plank. The box
   catches no click: only the standing figure answers the pointer (::after), so the empty part of his cell never blocks a
   spine or a link. The typed label (copy.librarianLabel) is the .room-note, stuck on the plank's front under his feet. */
.shelf{--lib-w:12.5rem}
.librarian{position:relative;flex:none;width:var(--lib-w);margin:3rem 0 0;padding:0;border-bottom:var(--plank) solid var(--green);pointer-events:none}
.librarian-figure{display:block;width:100%;aspect-ratio:264 / 352;margin-bottom:-3.8%;background:url(mascot.webp) 100% 0% / 3000% 200% no-repeat}
.librarian::after{content:"";position:absolute;left:31.4%;right:31.8%;top:26.6%;bottom:0;pointer-events:auto}
.room{position:relative;padding:0}
.room-note{position:absolute;left:calc(var(--lib-w) / -2);top:calc(100% + .32rem);max-width:none;padding:.26rem .45rem .24rem;white-space:nowrap;font:400 .8rem/1 var(--typed);letter-spacing:.02em;transform:translateX(-50%) rotate(-1deg)}

/* ---------- the end of the row, where the books stand (from 48em up, in a browser that knows :has) ---------- */
/* However many books there are, the librarian stands beside the last one. The list has no box of its own here
   (display:contents): its books, the bookend, the librarian and the free plank are one row that wraps. The last book keeps
   room at its right for the bookend and for him (--zone), and both are pulled back into that room, so the three always
   wrap together: he never drops to a plank of his own and the bookend never leaves its book. His cell is wider than he is,
   so --over of its empty right side may lie over the free plank, or past the shelf's edge when the row is full (the wall
   is empty there). The extra 1px keeps a rounding error from pushing him to the next row. The label "Newest first" sticks
   to the front of the first plank, at its left end, where the row starts.
   His own label is centred under him, but never hangs past the end of the plank: it is centred in a box that reaches from
   the end of the row as far to the left of his middle as the end is to its right. When the label is wider than that box,
   the two margins cannot both be auto, and in a box that runs right to left (direction:rtl on .room, which holds nothing
   but this label) the rule for that case keeps the right edge and lets the left one go. */
@media (min-width:48em){
  @supports selector(:has(*)){
    #shelf{display:contents}
    .shelf{--end-w:3.3rem;--over:1.25rem;--zone:calc(var(--end-w) + var(--lib-w) - var(--over));margin-top:4rem}
    .book{margin-top:3rem}
    #shelf>li:last-child{padding-right:calc(1px + var(--zone))}
    .shelf:has(.book) .shelf-end{margin-left:calc(-1 * var(--zone))}
    .librarian{margin-right:calc(-1px - var(--over))}
    /* the plank under him is the last book's (its kept room) and then the free plank's: his own piece would stick out past a full row */
    .shelf:has(.book) .librarian{border-bottom-color:transparent}
    .room{direction:rtl}
    .room-note{left:calc(2px + 2 * var(--over) - var(--lib-w) - 100%);right:0;width:max-content;margin-left:auto;margin-right:auto;direction:ltr;transform:rotate(-1deg)}
    .shelf-label{order:-1;flex:none;align-self:flex-end;position:relative;width:0;height:0;margin:0;padding:0}
    .shelf-label span{position:absolute;left:1rem;top:calc(.32rem - var(--plank));white-space:nowrap}
  }
}

/* ---------- motion: only as an answer to the visitor, never under reduced motion ---------- */
@media (prefers-reduced-motion:no-preference){
  .spine{transition:transform .18s cubic-bezier(.2,.8,.3,1)}
  details:not([open])>.spine:hover{transform:translateY(-.3rem)}
}
@media (prefers-reduced-motion:no-preference){
  details::details-content{opacity:0}
  details[open]::details-content{opacity:1;transition:opacity .16s ease-out}
}
/* The librarian's two movements, the only @keyframes here. Both step through the cells (jump-none: every cell is held for the
   same time, the first and the last included), with no easing and no other movement. The flip is 30 cells at 24 a second
   (1.25 s) and ends on cell 29, which is the standing figure. shelf.js adds .flip once the picture has loaded and takes it
   away when the flip is over. The dance is 24 cells at 12 a second (a 2 s loop): it runs while the pointer is on him, or
   twice after a tap (.tap, added by shelf.js, for a screen that has no pointer to hover with). Without the script he stands
   and still dances under the pointer. */
@media (prefers-reduced-motion:no-preference){
  @keyframes librarian-flip{from{background-position:0% 0%}to{background-position:100% 0%}}
  @keyframes librarian-dance{from{background-position:0% 100%}to{background-position:79.3103% 100%}}
  .librarian.flip .librarian-figure{animation:librarian-flip 1.25s steps(30,jump-none) 1}
  .librarian.tap .librarian-figure{animation:librarian-dance 2s steps(24,jump-none) 2}
}
@media (prefers-reduced-motion:no-preference) and (hover:hover){
  .librarian:hover .librarian-figure{animation:librarian-dance 2s steps(24,jump-none) infinite}
}

/* ---------- wide: the desk stands beside the shelf, from the top of the page ---------- */
/* A card lies on the desk (position:absolute) only where the browser can also hide the library's own card while a book is
   out (:has). Any other browser keeps the pile of the phone, with every card in the page flow under its spine (the copy of
   the phone's rules under @supports not, below). */
@media (min-width:72em){
  @supports selector(:has(*)){
    body{padding-right:calc(6rem + var(--desk-w))}
    .desk,.book .card{position:absolute;top:2.5rem;right:3rem;width:var(--desk-w);margin:0}
    .book .card{z-index:2;max-height:calc(100% - 5.5rem);overflow-y:auto}
    .card-plate{transform:rotate(1.5deg)}
    main:has(#shelf details[open]) .desk{visibility:hidden}
  }
}
/* a little less room for the librarian where the shelf is narrowest. He is small here and his label is wider than he is,
   so no part of his cell lies past the row (--over): the label would hang over the plank's end with it. */
@media (min-width:72em) and (max-width:79.99em){
  .shelf{--lib-w:8rem;--over:0rem}
}

/* ---------- middle: the desk lies under the shelf ---------- */
@media (min-width:48em) and (max-width:71.99em){
  @supports selector(:has(*)){
    body{padding:2.25rem 2rem 3rem}
    .shelf{position:relative}
    .book .card{position:absolute;z-index:2;top:calc(100% + 1.5rem);left:0;width:min(100%,44rem);max-height:var(--desk-min);overflow-y:auto}
    .card>.card-plate{max-width:22rem}
    .desk{max-width:44rem}
    main:has(#shelf details[open]) .desk{visibility:hidden;min-height:var(--desk-min)}
  }
}

/* ---------- phone: the books lie flat in a pile, newest on top ---------- */
@media (max-width:47.99em){
  /*pile-start*/
  body{padding:1.5rem 1rem 2.5rem}
  .sign-by{font-size:1.15rem}
  .sign-line{font-size:.95rem}
  .shelf{--lib-w:6.5rem;display:flex;flex-direction:column;flex-wrap:nowrap;align-items:stretch;max-width:40rem;margin-top:3rem}
  #shelf{flex-direction:column;flex-wrap:nowrap;align-items:stretch;gap:.45rem}
  .book{padding:0;border-bottom:0}
  .book:nth-child(4n+2){--jitter:.55}
  .book:nth-child(4n+3){--jitter:.2}
  .book:nth-child(4n){--jitter:.85}
  .spine{--lay:calc(.55 + var(--spine-h,1) * .41);width:calc((100% - .75rem) * var(--lay));height:max(2.75rem,calc(var(--spine-w,1) * 3.25rem));margin-left:calc((100% - .75rem) * (1 - var(--lay)) * var(--jitter,0));border-radius:0 2px 2px 0;box-shadow:inset 0 .2rem 0 rgb(255 255 255 / .12),inset 0 -.25rem 0 rgb(0 0 0 / .2)}
  .spine-body{flex-direction:row}
  .spine-band{align-self:stretch;width:3.1rem;height:auto}
  .spine-band svg{width:2.1rem;height:2.1rem;padding:.36rem}
  .spine-title{flex:1 1 auto;align-self:center;min-width:0;padding:.2rem .7rem;writing-mode:horizontal-tb;text-align:left;font-size:calc(var(--title-scale,1) * 1.22rem);line-height:1}
  /* the same for a title that lies: the room is the bar's length left of the band and the sticker (at the narrowest phone, 288px wide) times the bar's height */
  @supports (font-size:calc(1rem * sqrt(4))){
    .spine-title{font-size:min(calc(var(--title-scale,1) * 1.22rem),calc(1rem * sqrt(.85 * (17.25 * (.55 + .41 * var(--spine-h,1)) - 7.75) * (max(2.75, 3.25 * var(--spine-w,1)) - .4) * var(--title-fit,var(--title-scale,1)) / var(--title-len,12))))}
  }
  .spine-sticker{flex-direction:column;min-width:2.7rem;margin:0 .55rem 0 0}
  .spine:has(.spine-flag){margin-top:1.55rem}
  .spine-flag{left:.6rem}
  details[open]>.spine{transform:translateX(.75rem)}
  .book .card{margin:.6rem 0 1.1rem}
  .shelf-end{display:none}
  .shelf-label{flex:none;margin:0 0 .8rem;padding:0;order:-3}
  /* the librarian stands on top of the pile, small: his band has no height, its lower edge is the top of the first book */
  .librarian{order:-2;width:auto;height:0;margin:0;border-bottom:0;align-self:stretch}
  .librarian-figure{position:absolute;right:.4rem;bottom:calc(var(--lib-w) * -.038);width:var(--lib-w);margin:0}
  .librarian::after{left:auto;right:calc(.4rem + var(--lib-w) * .318);top:auto;bottom:0;width:calc(var(--lib-w) * .367);height:calc(var(--lib-w) * .951)}
  .room{order:-2;flex:none;display:block;height:0;min-width:0;margin:0;padding:0;border-bottom:0}
  .room-note{left:auto;right:calc(.4rem + var(--lib-w) * .66);top:auto;bottom:.2rem;max-width:5.8rem;white-space:normal;transform:rotate(-1deg)}
  .desk{max-width:40rem;margin-top:2rem}
  .card{--pad:1rem;--margin:3rem;font-size:.97rem}
  .libcard{--pad:1rem;font-size:.97rem}
  .card-title{font-size:1.32rem}
  .card-plate{float:none;width:auto;max-width:16rem;margin:.9rem 0 .7rem}
  .card-host,.card-out-soon .card-host{font-size:min(.95rem,calc((100vw - 7.2rem) / 19.2))}
  #catalogue{font-size:.95rem}
  #catalogue li{grid-template-columns:auto minmax(0,1fr);grid-template-areas:"no title" "host host" "state state";column-gap:.8ch;row-gap:0;padding-bottom:.6rem}
  .cat-dots{display:none}
  .catalogue,.colophon{margin-top:3rem}
  /*pile-end*/
}
/* ---------- the same pile, for a browser that does not know :has: at every width, cards in the page flow ---------- */
@supports not selector(:has(*)){
  /*pile-start*/
  body{padding:1.5rem 1rem 2.5rem}
  .sign-by{font-size:1.15rem}
  .sign-line{font-size:.95rem}
  .shelf{--lib-w:6.5rem;display:flex;flex-direction:column;flex-wrap:nowrap;align-items:stretch;max-width:40rem;margin-top:3rem}
  #shelf{flex-direction:column;flex-wrap:nowrap;align-items:stretch;gap:.45rem}
  .book{padding:0;border-bottom:0}
  .book:nth-child(4n+2){--jitter:.55}
  .book:nth-child(4n+3){--jitter:.2}
  .book:nth-child(4n){--jitter:.85}
  .spine{--lay:calc(.55 + var(--spine-h,1) * .41);width:calc((100% - .75rem) * var(--lay));height:max(2.75rem,calc(var(--spine-w,1) * 3.25rem));margin-left:calc((100% - .75rem) * (1 - var(--lay)) * var(--jitter,0));border-radius:0 2px 2px 0;box-shadow:inset 0 .2rem 0 rgb(255 255 255 / .12),inset 0 -.25rem 0 rgb(0 0 0 / .2)}
  .spine-body{flex-direction:row}
  .spine-band{align-self:stretch;width:3.1rem;height:auto}
  .spine-band svg{width:2.1rem;height:2.1rem;padding:.36rem}
  .spine-title{flex:1 1 auto;align-self:center;min-width:0;padding:.2rem .7rem;writing-mode:horizontal-tb;text-align:left;font-size:calc(var(--title-scale,1) * 1.22rem);line-height:1}
  /* the same for a title that lies: the room is the bar's length left of the band and the sticker (at the narrowest phone, 288px wide) times the bar's height */
  @supports (font-size:calc(1rem * sqrt(4))){
    .spine-title{font-size:min(calc(var(--title-scale,1) * 1.22rem),calc(1rem * sqrt(.85 * (17.25 * (.55 + .41 * var(--spine-h,1)) - 7.75) * (max(2.75, 3.25 * var(--spine-w,1)) - .4) * var(--title-fit,var(--title-scale,1)) / var(--title-len,12))))}
  }
  .spine-sticker{flex-direction:column;min-width:2.7rem;margin:0 .55rem 0 0}
  .spine:has(.spine-flag){margin-top:1.55rem}
  .spine-flag{left:.6rem}
  details[open]>.spine{transform:translateX(.75rem)}
  .book .card{margin:.6rem 0 1.1rem}
  .shelf-end{display:none}
  .shelf-label{flex:none;margin:0 0 .8rem;padding:0;order:-3}
  /* the librarian stands on top of the pile, small: his band has no height, its lower edge is the top of the first book */
  .librarian{order:-2;width:auto;height:0;margin:0;border-bottom:0;align-self:stretch}
  .librarian-figure{position:absolute;right:.4rem;bottom:calc(var(--lib-w) * -.038);width:var(--lib-w);margin:0}
  .librarian::after{left:auto;right:calc(.4rem + var(--lib-w) * .318);top:auto;bottom:0;width:calc(var(--lib-w) * .367);height:calc(var(--lib-w) * .951)}
  .room{order:-2;flex:none;display:block;height:0;min-width:0;margin:0;padding:0;border-bottom:0}
  .room-note{left:auto;right:calc(.4rem + var(--lib-w) * .66);top:auto;bottom:.2rem;max-width:5.8rem;white-space:normal;transform:rotate(-1deg)}
  .desk{max-width:40rem;margin-top:2rem}
  .card{--pad:1rem;--margin:3rem;font-size:.97rem}
  .libcard{--pad:1rem;font-size:.97rem}
  .card-title{font-size:1.32rem}
  .card-plate{float:none;width:auto;max-width:16rem;margin:.9rem 0 .7rem}
  .card-host,.card-out-soon .card-host{font-size:min(.95rem,calc((100vw - 7.2rem) / 19.2))}
  #catalogue{font-size:.95rem}
  #catalogue li{grid-template-columns:auto minmax(0,1fr);grid-template-areas:"no title" "host host" "state state";column-gap:.8ch;row-gap:0;padding-bottom:.6rem}
  .cat-dots{display:none}
  .catalogue,.colophon{margin-top:3rem}
  /*pile-end*/
}
/* the librarian's feet stand on the first book: when that book carries the flag it is pushed down by the flag's room */
@media (max-width:47.99em){
  @supports selector(:has(*)){
    .shelf:has(#shelf>li:first-child .spine-flag) .librarian-figure{bottom:calc(var(--lib-w) * -.038 - 1.55rem)}
    .shelf:has(#shelf>li:first-child .spine-flag) .librarian::after{bottom:-1.55rem}
    .shelf:has(#shelf>li:first-child .spine-flag) .room-note{bottom:calc(.2rem - 1.55rem)}
  }
}
/* the narrowest phones: the call number moves from the card's margin to its first line */
@media (max-width:21.99em){
  .card{--margin:0rem;padding-top:.9rem}
  .card .card-callno{position:static;flex-direction:row;gap:.6ch;margin:0 0 .35rem;color:var(--muted)}
  .card-callno span:nth-child(2){line-height:1.5}
  .card-host,.card-out-soon .card-host{font-size:min(.95rem,calc((100vw - 4.2rem) / 19.2))}
}

/* ---------- forced colours (Windows high contrast) ---------- */
@media (forced-colors:active){
  .spine{border:2px solid CanvasText}
  .card,.libcard,.spine-sticker,.spine-flag,.room-note,.shelf-label span{border:1px solid CanvasText}
  .book,.shelf-end,.room,.gap-shelf{border-bottom-color:CanvasText}
}
