/* ==========================================================================
   Local fork (mrsamberapple.com): the Library ([pretty_bookshelf_library]).
   Colours follow the theme (currentColor / inherit), so light and dark modes both work.
   The 3D book matches the shelf in showcase.css: thickness from the page count,
   page block on the fore-edge, and the back cover's rim showing past the pages.
   ========================================================================== */
.pbs-library{--pbs-lib-gap-x:clamp(18px,3vw,34px);--pbs-lib-gap-y:clamp(30px,4vw,48px);--pbs-lib-min:150px;--pbs-lib-max:280px;margin:0 0 3rem;color:inherit;font-family:inherit}
.pbs-library *,.pbs-library *::before,.pbs-library *::after{box-sizing:border-box}
.pbs-lib-intro{font-size:1.05em;line-height:1.7;margin:0 0 1rem}
.pbs-lib-intro>:last-child{margin-bottom:0}
.pbs-lib-stats{text-align:center;font-size:.8em;letter-spacing:.12em;text-transform:uppercase;opacity:.7;margin:0 0 1.5rem}

/* Controls: hidden until library.js runs, since they need it. */
.pbs-library:not(.pbs-lib-ready) .pbs-lib-controls{display:none}
.pbs-lib-controls{display:flex;flex-direction:column;gap:14px;margin:0 0 2.5rem}
.pbs-lib-row{display:flex;flex-wrap:wrap;justify-content:center;gap:12px;align-items:center}
.pbs-lib-search-wrap{flex:0 1 280px;min-width:0;margin:0}
.pbs-library input.pbs-lib-search{width:100%;margin:0;padding:10px 14px;font:inherit;font-size:.95em;color:inherit;background:transparent;border:1px solid rgba(128,128,128,.5);border-radius:999px;box-shadow:none;text-align:left;text-transform:none;letter-spacing:normal}
.pbs-library input.pbs-lib-search::placeholder{color:inherit;opacity:.55;text-transform:none;letter-spacing:normal}
.pbs-library input.pbs-lib-search:focus{outline:2px solid currentColor;outline-offset:2px}
.pbs-lib-sort-wrap{position:relative;display:flex;align-items:center;gap:8px;margin:0;font-size:.85em;letter-spacing:.06em;text-transform:uppercase;white-space:nowrap}
.pbs-library select.pbs-lib-sort{margin:0;padding:9px 44px 9px 18px;-webkit-appearance:none;appearance:none;background-image:none;font:inherit;font-size:1em;letter-spacing:0;text-transform:none;color:inherit;background:transparent;border:1px solid rgba(128,128,128,.5);border-radius:999px;width:auto}
/* Own chevron, set in from the capsule's curved end; drawn in the text colour so it suits light and dark. */
.pbs-lib-sort-wrap::after{content:"";position:absolute;right:20px;top:50%;width:7px;height:7px;margin-top:-6px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg);opacity:.75;pointer-events:none}
.pbs-library select.pbs-lib-sort::-ms-expand{display:none}
.pbs-library select.pbs-lib-sort option{color:#222;background:#fff}
.pbs-library .pbs-lib-shuffle,.pbs-library .pbs-lib-chip,.pbs-library .pbs-lib-reset{display:inline-flex;align-items:center;gap:6px;margin:0;padding:8px 16px;font:inherit;font-size:.85em;line-height:1.3;letter-spacing:.04em;color:inherit;background:transparent;border:1px solid rgba(128,128,128,.5);border-radius:999px;box-shadow:none;cursor:pointer;text-transform:none;transition:background .2s,border-color .2s,transform .15s}
.pbs-library .pbs-lib-shuffle:hover,.pbs-library .pbs-lib-chip:hover,.pbs-library .pbs-lib-reset:hover{background:rgba(128,128,128,.14);border-color:currentColor;color:inherit}
.pbs-library .pbs-lib-shuffle:active,.pbs-library .pbs-lib-chip:active{transform:scale(.96)}
.pbs-library .pbs-lib-shuffle:focus-visible,.pbs-library .pbs-lib-chip:focus-visible,.pbs-library .pbs-lib-reset:focus-visible{outline:2px solid currentColor;outline-offset:2px}
.pbs-lib-chips{display:flex;flex-wrap:wrap;justify-content:center;gap:8px}
.pbs-library .pbs-lib-chip[aria-pressed="true"]{background:rgba(128,128,128,.24);border-color:currentColor;font-weight:600}
.pbs-library .pbs-lib-shuffle svg{flex:none}
.pbs-library .pbs-lib-chip[hidden]{display:none}
.pbs-lib-chip-count{font-size:.85em;opacity:.6;font-weight:400}
.pbs-lib-count{margin:0;text-align:center;font-size:.8em;opacity:.7}

/* Books in centred rows. library.js sets --pbs-lib-w from the number of books showing: as many columns as
   fit (at least --pbs-lib-min wide), but never more columns than books, so a short row of results grows to
   fill the row (up to --pbs-lib-max). position:relative holds the "leaving" copies library.js animates out. */
.pbs-library ul.pbs-lib-grid{position:relative;display:flex;flex-wrap:wrap;justify-content:center;align-items:flex-start;gap:var(--pbs-lib-gap-y) var(--pbs-lib-gap-x);margin:0;padding:0;list-style:none}
.pbs-library li.pbs-lib-book{container-type:inline-size;flex:0 0 auto;width:var(--pbs-lib-w,170px);transform-origin:0 0;display:flex;flex-direction:column;min-width:0;margin:0;padding:0;list-style:none;background:none}
.pbs-library li.pbs-lib-book::before{content:none}
.pbs-library li.pbs-lib-book[hidden]{display:none}
.pbs-library li.pbs-lib-ghost{position:absolute;pointer-events:none;z-index:1}
.pbs-lib-cover-link{display:block;margin:0 0 14px;color:inherit;border:0;box-shadow:none;text-decoration:none}

/* 3D book. */
.pbs-lib-cover{--pbs-book-ratio:clamp(.05, .02 + var(--pbs-pages,300) * .00034, .5);--pbs-book-width:calc(100cqw / 1.12);--pbs-book-depth:calc(var(--pbs-book-width) * var(--pbs-book-ratio));--pbs-book-turn:-22deg;position:relative;display:block;width:var(--pbs-book-width);aspect-ratio:5/8;transform-style:preserve-3d;transform-origin:left center;transform:perspective(1300px) rotateY(var(--pbs-book-turn));transition:transform .45s ease}
.pbs-lib-book:hover .pbs-lib-cover,.pbs-lib-book:focus-within .pbs-lib-cover{--pbs-book-turn:-8deg}
.pbs-lib-cover img{position:absolute;inset:0;display:block;width:100%;height:100%;max-width:none;margin:0;object-fit:cover;object-position:center;border-radius:0 2px 2px 0;box-shadow:none}
.pbs-lib-cover::before{content:"";position:absolute;top:5px;bottom:5px;left:calc(100% - 6px);width:calc(var(--pbs-book-depth) - 4px);transform-origin:left center;transform:translateZ(-1px) rotateY(90deg);background:linear-gradient(to right,rgba(0,0,0,0),rgba(0,0,0,.12) 45%,rgba(0,0,0,.5)),repeating-linear-gradient(to right,#fbf8f1 0 2px,#e4ddcf 2px 3px);box-shadow:inset 0 0 6px rgba(0,0,0,.12)}
.pbs-lib-cover::after{content:"";position:absolute;inset:0;transform:translateZ(calc(var(--pbs-book-depth) * -1));background:linear-gradient(rgba(0,0,0,.6),rgba(0,0,0,.6)),var(--pbs-cover-image,none) center/cover no-repeat,#5a4d42;border-radius:0 2px 2px 0;box-shadow:inset 0 0 0 1px rgba(0,0,0,.25),-12px 14px 28px rgba(0,0,0,.35)}

/* Text under each book. */
.pbs-library h3.pbs-lib-title{margin:0 0 .3em;font-size:1em;line-height:1.3;letter-spacing:.04em;overflow-wrap:anywhere}
.pbs-library h3.pbs-lib-title a{color:inherit;text-decoration:none;border:0;box-shadow:none}
.pbs-library h3.pbs-lib-title a:hover,.pbs-library h3.pbs-lib-title a:focus-visible{text-decoration:underline;text-underline-offset:.15em}
.pbs-library p.pbs-lib-author{margin:0 0 .25em;font-size:.88em;line-height:1.4;opacity:.8}
.pbs-library p.pbs-lib-meta{margin:0;font-size:.75em;line-height:1.4;letter-spacing:.03em;opacity:.6}

.pbs-lib-empty{padding:2.5rem 0;text-align:center}
.pbs-lib-empty p{margin:0 0 1rem}

@media (max-width:600px){.pbs-library{--pbs-lib-min:120px}.pbs-lib-search-wrap{flex:1 1 100%}.pbs-lib-sort-wrap{flex:1 1 100%}.pbs-library select.pbs-lib-sort{flex:1}}
@media (prefers-reduced-motion:reduce){.pbs-lib-cover{transition:none}.pbs-lib-book:hover .pbs-lib-cover,.pbs-lib-book:focus-within .pbs-lib-cover{--pbs-book-turn:-22deg}}
/* Apple-style capsules with continuous corners: every control is fully rounded (radius 999px), and the
   ends ease into the straight edges instead of meeting them at a point. superellipse(1.25) keeps them
   capsules; full "squircle" (2) would square them off. Browsers without corner-shape show plain capsules. */
.pbs-library input.pbs-lib-search,.pbs-library select.pbs-lib-sort,.pbs-library .pbs-lib-shuffle,.pbs-library .pbs-lib-chip,.pbs-library .pbs-lib-reset{corner-shape:superellipse(1.25)}
@supports (corner-shape:squircle){.pbs-library input.pbs-lib-search:focus,.pbs-library select.pbs-lib-sort:focus-visible,.pbs-library .pbs-lib-shuffle:focus-visible,.pbs-library .pbs-lib-chip:focus-visible,.pbs-library .pbs-lib-reset:focus-visible{outline-offset:3px}}
/* Selected chip: a solid, inverted capsule so the current choice in every group is obvious. !important because
   the theme (and its dark-mode stylesheet) forces every button's background and border with !important,
   which made the selected chip look like all the others. */
.pbs-library .pbs-lib-chip[aria-pressed="true"]{background:#333!important;border-color:#333!important;color:#fff!important;font-weight:600}
.pbs-library .pbs-lib-chip[aria-pressed="true"] .pbs-lib-chip-count{opacity:.75}
html[data-theme="dark"] .pbs-library .pbs-lib-chip[aria-pressed="true"]{background:var(--dm-heading,#f2efe9)!important;border-color:var(--dm-heading,#f2efe9)!important;color:var(--dm-bg,#1c1b19)!important}
html[data-theme="dark"] .pbs-library .pbs-lib-chip:not([aria-pressed="true"]):hover{border-color:var(--dm-text,#dedad1)!important}
/* The theme's inline ".content button{color:#fff!important}" turned the unselected chips and Shuffle white on white in light mode. */
.pbs-library .pbs-lib-shuffle,.pbs-library .pbs-lib-chip,.pbs-library .pbs-lib-reset{color:inherit!important}

/* Top row (Shuffle · Search · Sort): one shared height, so the three line up as a set. */
.pbs-library{--pbs-ctl-h:42px}
.pbs-library .pbs-lib-shuffle{height:var(--pbs-ctl-h);padding-top:0;padding-bottom:0}
.pbs-library input.pbs-lib-search{height:var(--pbs-ctl-h);padding-top:0;padding-bottom:0;line-height:normal;text-align:center}
.pbs-library input.pbs-lib-search::placeholder{text-align:center}
.pbs-library select.pbs-lib-sort{height:var(--pbs-ctl-h);padding-top:0;padding-bottom:0;font-size:.95em;line-height:normal}
.pbs-lib-sort-wrap{gap:0;font-size:1em;text-transform:none;letter-spacing:normal}
/* Search focus: a thin highlight (the border brightens) instead of the thick outline ring.
   :not(#pbs-lib-x) lifts specificity above the theme's dark-mode input rule, which also uses !important. */
.pbs-library input.pbs-lib-search:not(#pbs-lib-x):focus{outline:none!important;border-color:currentColor!important;box-shadow:none!important}
@media (max-width:600px){.pbs-library .pbs-lib-search-wrap{flex:1 1 160px}.pbs-library .pbs-lib-sort-wrap{flex:1 1 100%}}
/* Book count ("All 11 books"): uppercase like the stats line, and centred in the space between the filters and the books
   (2rem above it, counting the controls' 14px gap, and 2rem below). */
.pbs-library .pbs-lib-controls{margin-bottom:0}
.pbs-library .pbs-lib-count{margin:calc(2rem - 14px) 0 2rem;text-transform:uppercase;letter-spacing:.12em;font-size:.75em}
