/* My Library — the book tree up close (library.js). Two colours only, the tree's: --site-bg (the page, and the type on
   the spines) and --site-ink (the books). Every book is a filled, upright rectangle. Each spine = a day number at the left
   (plain, boxed, disc, ring, star, tall serif, heavy italic, plate, fraction, «день») + a separator (rule, bar,
   double rule, dot, slash, dash, diamond, air) + a title treatment, read off two shelves (ref: the PP Museum stack and
   a row of film boxes).
   House rules (Сергей, 2026-11-29): titles only, no authors; nothing turned or mirrored — every word reads at a glance;
   no hand-lettered faces; no outlined (stroked) type; the number always at the left end.
   Faces are free Google Fonts with Cyrillic, standing in for the refs':
     Tenor Sans — PP Museum's Optima-like caps («FOR EVERY ERA»)         Jost 200 — the hairline sans («Flares on Display»)
     Cormorant Garamond — the bookish serif («As Rare as a First edition», «The Catalogue»; spaced caps)
     Montserrat 900 italic — «PP MUSEUM»; 700 caps spread — «A DIFFERENT MAN»
     Alegreya 900 — the soft heavy serif («Sans the Ordinary», «The Weight of Words»)
     Fira Sans Extra Condensed 800 — «FRIENDSHIP», «SING SING»     Oranienbaum — the narrow didone («THE BRUTALIST», «DEATH OF A UNICORN»)
     Prata — «Babygirl»   Unbounded — the wide tracked caps («HERETIC»)   Yeseva One — the fat didone display
     Oswald, Alumni Sans 900 — frames, condensed caps   JetBrains Mono — the day numbers and mono titles. */

/* the head's word faces (the home page's set, site.css / index.html): the Google ones load with the page's link;
   Droid 1997 ships in fonts/ */
@font-face {
  font-family: 'Droid 1997';
  src: url('fonts/droid-1997.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --site-bg: #fe81e9;
  --site-ink: #0242cb;
  --lib-rule: 1.5px;
}

html { scrollbar-width: thin; scrollbar-color: var(--site-ink) transparent; }
body.ui { margin: 0; overflow-x: hidden; background: var(--site-bg); }

/* the page scrolls as usual over .lib — a spacer as tall as the scene (library.js); the scene is pinned to the window
   and glides after the scroll position */
.lib { position: relative; overflow: hidden; }
.lib-scene { position: fixed; left: 0; top: 0; width: 100%; will-change: transform; }
/* touch screens: the scene sits in the page and scrolls with it, no glide (library.js sets data-native) */
.lib[data-native] .lib-scene { position: absolute; will-change: auto; }

/* ── the head: the home page's words, caption and star (library.js headPlan) ── */
.lib-head { position: absolute; display: block; overflow: visible; user-select: none; }
.lib-star { transform-box: fill-box; transform-origin: center; }
.lib-star path { fill: var(--site-ink) !important; } /* tree.js draws it gold; here it takes the books' colour */
.lib-star polygon { fill: transparent !important; } /* the hit area: the whole star is the button */
/* a click on the star = the next palette (library.js nextPalette, as on the tree); the hover tease as on the tree
   (site.css): the core takes the next palette's background colour and swells, the ring leans in a touch */
.lib-star { cursor: pointer; outline: none; }
.lib-star path { transition: transform 420ms cubic-bezier(0.34, 1.56, 0.64, 1), fill 220ms ease; transform-box: view-box; transform-origin: 0 0; }
.lib-star:hover .bt-star-core, .lib-star:focus-visible .bt-star-core { fill: var(--star-next, var(--site-ink)) !important; animation: lib-star-tease 1.1s cubic-bezier(0.45, 0, 0.55, 1) 120ms infinite; }
.lib-star:hover .bt-star-ring, .lib-star:focus-visible .bt-star-ring { transform: scale(1.06); }
.lib-star:focus-visible path { stroke: var(--site-ink); stroke-width: 4; stroke-opacity: 0.35; }
@keyframes lib-star-tease {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.38); }
  70% { transform: scale(1.22); }
}
@media (prefers-reduced-motion: reduce) { .lib-star:hover .bt-star-core, .lib-star:focus-visible .bt-star-core { animation: none; } .lib-star:hover .bt-star-ring { transform: none; } }
/* the palette reveal from the star (library.js revealFromStar): no cross-fade — the new page shows only through the
   growing star, the old one stays whole underneath; the new colours arrive at once */
:root[data-reveal]::view-transition-group(*), :root[data-reveal]::view-transition-image-pair(*),
:root[data-reveal]::view-transition-old(*), :root[data-reveal]::view-transition-new(*) { animation: none; mix-blend-mode: normal; }
:root[data-reveal] *, :root[data-reveal] body.ui { transition: none !important; }

/* ── a book ── */
.lb {
  position: absolute; box-sizing: border-box;
  background: var(--site-ink); color: var(--site-bg);
  display: flex; align-items: center; gap: var(--g, 14px);
  padding: 0 var(--px, 18px);
  overflow: hidden;
  will-change: transform;
}
.lb > * { flex: none; }
.lb-t { flex: 0 1 auto; min-width: 0; line-height: 1.22; white-space: nowrap; }
.lb-t[data-grow] { flex: 1 1 0; }
.lb-tx { display: inline-block; white-space: nowrap; }
.lb-t.is-wrap { white-space: normal; }
.lb-t.is-wrap .lb-tx { white-space: normal; display: block; line-height: 0.98; text-wrap: balance; }
.lb-t[data-spread] .lb-tx { display: flex; justify-content: space-between; gap: 0.5em; width: 100%; }
.lb-rule { flex: 1 1 0; min-width: 12px; height: var(--lib-rule); background: currentColor; }
.lb-push { flex: 1 1 0; min-width: 0; }
.lb-bar { width: var(--lib-rule); align-self: stretch; margin-block: calc(var(--h) * 0.2); background: currentColor; } /* margins in px of the thickness: a % margin would be % of the width */

/* the day number, always at the left end — seven treatments of the number alone (library.js NUMS), dealt so neighbours differ */
.lb-n { font: 500 var(--nfs, 15px) / 1 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; white-space: nowrap; }
.lb-n[data-v='box'] { background: var(--site-bg); color: var(--site-ink); padding: 0.32em 0.42em 0.26em; }
.lb-n[data-v='disc'] { background: var(--site-bg); color: var(--site-ink); width: 2em; height: 2em; border-radius: 50%; display: grid; place-items: center; font-size: calc(var(--nfs, 15px) * 0.9); }
.lb-n[data-v='ring'] { border: var(--lib-rule) solid currentColor; padding: 0.32em 0.42em 0.26em; }
.lb-n[data-v='big'] { font-family: 'Oranienbaum', serif; font-size: calc(var(--h) * 0.8); line-height: 0.8; letter-spacing: -0.02em; }
.lb-n[data-v='italic'] { font-family: 'Montserrat', sans-serif; font-style: italic; font-weight: 900; font-size: calc(var(--nfs, 15px) * 1.6); letter-spacing: -0.04em; }
.lb-n[data-v='plate'] {
  align-self: stretch; margin-block: calc(var(--h) * 0.12); margin-left: calc(var(--h) * 0.12 - var(--px, 18px));
  background: var(--site-bg); color: var(--site-ink); display: grid; place-items: center;
  font: 900 calc(var(--h) * 0.5) / 1 'Alumni Sans', sans-serif; letter-spacing: 0;
}

/* what parts the number from the title (library.js SEPS) */
.lb-sep[data-v='rule'] { width: var(--lib-rule); align-self: stretch; background: currentColor; }
.lb-sep[data-v='bar'] { width: var(--lib-rule); height: calc(var(--h) * 0.42); background: currentColor; }
.lb-sep[data-v='double'] { width: 5px; align-self: stretch; margin-block: calc(var(--h) * 0.14); border-inline: var(--lib-rule) solid currentColor; box-sizing: border-box; }
.lb-sep[data-v='dot'] { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.lb-sep[data-v='slash'] { font: 200 calc(var(--h) * 0.56) / 1 'Jost', sans-serif; }
.lb-sep[data-v='dash'] { width: 24px; height: var(--lib-rule); background: currentColor; }
.lb-sep[data-v='diamond'] { width: 9px; height: 9px; background: currentColor; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }


/* ── the faces, one per design ── */
.f-era { font-family: 'Tenor Sans', serif; text-transform: uppercase; letter-spacing: -0.01em; }
.f-flare { font-family: 'Jost', sans-serif; font-weight: 200; letter-spacing: -0.01em; }
.f-rare { font-family: 'Cormorant Garamond', serif; font-weight: 500; font-style: italic; }
.f-vault { font-family: 'Cormorant Garamond', serif; font-weight: 600; letter-spacing: 0.01em; }
.f-punct { font-family: 'Montserrat', sans-serif; font-weight: 700; letter-spacing: -0.01em; }
.f-museum { font-family: 'Montserrat', sans-serif; font-weight: 900; font-style: italic; text-transform: uppercase; letter-spacing: -0.03em; }
.f-ordinary { font-family: 'Alegreya', serif; font-weight: 900; letter-spacing: -0.02em; }
.f-weight { font-family: 'Alegreya', serif; font-weight: 800; letter-spacing: 0.04em; }
.f-friend { font-family: 'Fira Sans Extra Condensed', sans-serif; font-weight: 800; text-transform: uppercase; letter-spacing: -0.02em; }
.f-diff { font-family: 'Montserrat', sans-serif; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.f-unicorn { font-family: 'Oranienbaum', serif; text-transform: uppercase; letter-spacing: -0.01em; }
.f-brutal { font-family: 'Anton', sans-serif; font-weight: 400; text-transform: uppercase; letter-spacing: 0.01em; }
.f-leader { font-family: 'Jost', sans-serif; font-weight: 500; }
.lb-dots { flex: 1 1 0; min-width: 20px; height: 0; border-top: 2.5px dotted currentColor; }
.lb-end { font: 400 var(--nfs, 15px) / 1 'JetBrains Mono', monospace; }
.f-stripes { font-family: 'Montserrat', sans-serif; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.lb-stripes { flex: 1 1 0; min-width: 16px; height: var(--lib-rule); background: currentColor; box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor; }
.f-under { font-family: 'Yeseva One', serif; text-decoration: underline; text-decoration-thickness: 0.07em; text-underline-offset: 0.16em; }
.f-baby { font-family: 'Prata', serif; letter-spacing: -0.02em; }
.f-heretic { font-family: 'Unbounded', sans-serif; font-weight: 500; text-transform: uppercase; letter-spacing: 0.32em; }
.f-mono { font-family: 'JetBrains Mono', monospace; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; }
.f-label { font-family: 'Yeseva One', serif; letter-spacing: 0.005em; }
.f-outline { font-family: 'Oswald', sans-serif; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.f-band { font-family: 'Alumni Sans', sans-serif; font-weight: 900; text-transform: uppercase; letter-spacing: 0.01em; }

/* designs that change the book itself */
/* every book is a filled, upright rectangle (Сергей, 2026-11-29): the PP Museum book keeps its heavy italic type and
   rules, but not the slant */
.lb[data-d='museum'] .lb-bar { margin-block: calc(var(--h) * 0.1); }
/* the framed book: filled like the rest, a thin frame in the page colour printed just inside the edge */
.lb[data-d='outline'] { box-shadow: inset 0 0 0 5px var(--site-ink), inset 0 0 0 6.5px var(--site-bg); }
.lb-label { flex: 0 1 auto; min-width: 0; background: var(--site-bg); color: var(--site-ink); align-self: center; height: 64%; display: flex; align-items: center; justify-content: center; padding-inline: 1.1em; }
.lb-rails { flex: 1 1 0; min-width: 0; align-self: stretch; margin-block: calc(var(--h) * 0.2); border-block: var(--lib-rule) solid currentColor; display: flex; align-items: center; justify-content: center; }
.lb-rails .lb-t { line-height: 1.1; }

/* the trunk: two plain filled books in the home tree's silhouette — drawn as SVG (library.js bookBlock), so the box itself is bare */
.lb-edge { background: none; padding: 0; display: block; overflow: visible; }
.lb-edge svg { display: block; }

/* ── gifts: every book wrapped until its day (library.js paper): one sheet in the books' colour with a fine pattern
   (and ribbons) cut out of it, the page showing through. While wrapped the spine under it is hidden, or
   the holes would show the book instead of the page. The tear is the home tree's: the ribbon-less sheet splits along a
   jagged line, the halves drift apart and fade, the spine breathes in. */
.lb[data-wrap='locked'], .lb[data-wrap='ready'] { background: none; box-shadow: none; }
.lb[data-wrap='locked'] > :not(.lb-wrap), .lb[data-wrap='ready'] > :not(.lb-wrap) { visibility: hidden; }
.lb[data-wrap='ready'] { cursor: pointer; }
.lb[data-wrap='locked'] { cursor: default; }
.lb[data-wrap]:focus-visible { outline: 2px solid var(--site-ink); outline-offset: 4px; }
.lb-wrap { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.lb-wrap .gw, .lb-wrap .gw-half { transform-box: fill-box; transform-origin: 50% 50%; }
.lb-wrap .gw-l { transform-origin: 0% 50%; }
.lb-wrap .gw-r { transform-origin: 100% 50%; }
.lb-wrap .gw-edge { opacity: 0; }
.lb:not([data-wrap='tearing']) .gw-paper { display: none; }
.lb[data-wrap='tearing'] { overflow: visible; pointer-events: none; }
.lb[data-wrap='tearing'] .gw-whole { display: none; }
.lb[data-wrap='tearing'] .gw { animation: gw-breath 220ms var(--ease) both; }
.lb[data-wrap='tearing'] .gw-edge { opacity: 1; }
/* the date sticker lifts off first (the home tree's ribbon move), then the paper tears */
.lb-wrap .gw-ribbon { transform-box: fill-box; transform-origin: 50% 50%; }
.lb[data-wrap='tearing'] .gw-ribbon { animation: gw-ribbon 300ms var(--ease) both; }
@keyframes gw-ribbon { to { translate: 0 -18px; opacity: 0; } }
.lb[data-wrap='tearing'] .gw-l { animation: gw-tear-l 680ms var(--ease) 150ms both; }
.lb[data-wrap='tearing'] .gw-r { animation: gw-tear-r 680ms var(--ease) 150ms both; }
.lb[data-wrap='tearing'] > :not(.lb-wrap) { animation: gw-reveal 620ms var(--ease-pop) 260ms both; }
@keyframes gw-breath { 50% { scale: 1.03; } }
@keyframes gw-tear-l { 45% { opacity: 1; } to { translate: -46px 10px; rotate: 6deg; opacity: 0; } }
@keyframes gw-tear-r { 45% { opacity: 1; } to { translate: 46px 10px; rotate: -6deg; opacity: 0; } }
@keyframes gw-reveal { from { scale: 0.965; } }
/* the crumple (crumple.js, the default): the sheet and its sticker hide while their copy is crushed into a ball frame by
   frame — stop motion, so no CSS motion on the paper at all; the spine underneath shows at once */
.lb[data-fx='crumple'] .gw, .lb[data-fx='crumple'] .lb-sticker { animation: none; }
.lb[data-fx='crumple'] .gw-paper, .lb[data-fx='crumple'] .gw-whole, .lb[data-fx='crumple'] .lb-sticker { display: none; }
.lb[data-fx='crumple'] .lb-wrap { z-index: 2; }
/* a gift whose day has come rocks gently now and then — the cue that it may be opened (no hover motion) */
.lb[data-wrap='ready'] .lb-wrap { animation: lb-ready 3.2s var(--ease) infinite; transform-origin: 50% 100%; }
@keyframes lb-ready { 0%, 78%, 100% { rotate: 0deg; } 84% { rotate: -1.2deg; } 90% { rotate: 1deg; } 95% { rotate: -0.5deg; } }
@media (prefers-reduced-motion: reduce) { .lb[data-wrap='ready'] .lb-wrap { animation: none; } }
/* a locked gift answers a click with a small shake of its paper */
.lb.is-nudge .lb-wrap { animation: lb-nudge 360ms var(--ease) both; }
@keyframes lb-nudge { 20% { translate: -5px 0; } 45% { translate: 4px 0; } 70% { translate: -2px 0; } to { translate: 0 0; } }
@media (prefers-reduced-motion: reduce) { .lb.is-nudge .lb-wrap { animation: none; } }

/* what a click on a wrapped book says */
.lib-note {
  position: fixed; z-index: 4; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  translate: -50% 12px; opacity: 0; transition: opacity 240ms var(--ease), translate 240ms var(--ease);
  background: var(--site-ink); color: var(--site-bg); padding: 10px 16px; border-radius: 999px;
  font: 500 14px / 1.2 'Inter', system-ui, sans-serif; white-space: nowrap; pointer-events: none;
}
.lib-note.is-on { translate: -50% 0; opacity: 1; }

/* ── an opened book leads to its page ── */
.lb[data-wrap='open'] { cursor: pointer; }

/* the cover turn (book-open-cover.js, now): a CSS 3D box over the library — the spine face is the clicked spine, the
   cover face carries the book page's cover (book-cover.css) under a sheet of the books' colour that lifts as the art
   comes in; the page colour floods the window behind the book. Flat fills only. */
.bc { position: fixed; inset: 0; z-index: 10; cursor: pointer; }
.bc-flood { position: absolute; inset: 0; background: var(--bk-page); opacity: 0; pointer-events: none; }
.bc-stage { position: absolute; inset: 0; perspective: 1800px; transform-style: preserve-3d; pointer-events: none; }
.bc-book { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; }
.bc-face { position: absolute; left: 0; top: 0; transform-origin: 0 0; backface-visibility: hidden; overflow: hidden; background: var(--bc-ink); }
.bc-cover { background: var(--bk-page); }
.bc-cover .bk-cover { position: absolute; left: 0; top: 0; }
.bc-sheet { position: absolute; inset: -1px; background: var(--bc-ink); transition: opacity 480ms var(--ease); }
.bc-sheet.is-off { opacity: 0; }
.bc-pages { background: var(--bk-page); box-shadow: inset 0 0 0 2px var(--bc-ink); }
.bc-spine > .lb { position: absolute; }
.bc-measure { position: fixed; left: 0; top: 0; visibility: hidden; pointer-events: none; }
/* the book page has no scrollbar: while the book is out, the library's goes clear (no layout change), so the turn's end
   picture and the page match to the edge */
html:has(.bc) { scrollbar-color: transparent transparent; }

/* the fan (book-open-fan.js, saved variant): the title leaves the spine, then lab 16's book opening plays in a
   window-wide layer over the library and its pages' colour (--bo-page) grows over the window */
.lb.is-leaving > * { opacity: 0; transition: opacity 160ms var(--ease); }
.bo { position: fixed; inset: 0; z-index: 10; cursor: pointer; }
.bo-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.bo-fill { position: absolute; inset: 0; background: var(--bo-page); opacity: 0; pointer-events: none; }

/* ── chrome ── */
/* the close cross back to the tree (close-cross.css, the same as on a book page — Сергей, 2026-11-29, in place of the
   «Ёлка» button), in the books' colour. No arrival growth here: the library is reached through the star wipe, whose
   last frame (this page in an iframe) must match the page that takes over */
.lib-back { --x-color: var(--site-ink); }
/* the way back to the tree (star-wipe.js back): a same-document view transition — the library's snapshot stays whole
   underneath, the stars-and-tree layer shows only outside a shrinking star (its clip is animated by the script);
   no default crossfade */
html.sw-back::view-transition-old(root), html.sw-back::view-transition-new(root) { animation: none; mix-blend-mode: normal; }


/* cross-document view transition (Сергей, 2026-11-29): between the tree and the library the browser keeps the old page's
   last frame until the new one has rendered and crossfades them — the star wipe's last frame and the library are the
   same picture, so the swap cannot blink (star-wipe.js). Browsers without it simply navigate. */
@view-transition { navigation: auto; }
