:root {
  --page: #ece5d8; /* the warm wall; the Lighting choice (controls panel) can make it cool and Calm makes it softer: the colours live in access.js, which sets --page on <html> in the head, before the page paints */
  /* These three are the warm, normal ones, for a page where scripts are off. access.js sets them (and --page) on <html> before the first paint, for warm or cool and for Calm and
     Crisp: --ink (text), --mute (quieter text, at least 7:1 on its wall: AAA) and --bubble (the Sort and Share bubbles: lighter than the wall, not white). */
  --ink: #1d1b19;
  --mute: #4f4a43;
  --bubble: #f7f5f0;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Courier New', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--page); color: var(--ink); font-family: var(--sans);
  overflow: hidden; -webkit-font-smoothing: antialiased;
}

.mark {
  position: fixed; top: 26px; left: 30px; z-index: 1; display: flex; gap: 14px;
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
}

/* The picture is one WebGL canvas. The shelf list holds a button over each spine (placed by shelf.js) for mouse,
   touch and keyboard. While a book is out the buttons are inert, so a click anywhere else reaches the canvas. */
.stage { position: fixed; inset: 0; z-index: 2; } /* above the caption text, below the button bar */
.gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.shelf { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; pointer-events: none; user-select: none; -webkit-user-select: none; }
.slot { position: absolute; }
.hit {
  position: absolute; inset: 0; margin: 0; padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto;
  -webkit-appearance: none; appearance: none; font: inherit; color: inherit; touch-action: none;
}
.hit:focus { outline: none; }
.hit:focus-visible::after {
  content: ''; position: absolute; left: -3px; right: -3px; top: -3px; bottom: -3px; border: 2px solid var(--ink); border-radius: 2px;
}
.stage.out .hit { pointer-events: none; }
/* Focus moved by the page while the mouse or touch is in use (see focusOn in shelf.js) shows no ring; a key press brings it back. */
.hit.no-ring:focus-visible::after { display: none; }
.linklike.no-ring:focus-visible { outline: none; }

.caption {
  position: fixed; left: 0; right: 0; bottom: calc(6vh + 26px - var(--drop, 0px)); z-index: 1; text-align: center; padding: 0 20px; /* --drop (shelf.js): how far the caption moves down to stay clear of the shelf on a short window */
  opacity: 0; transform: translateY(6px); pointer-events: none; visibility: hidden; /* hidden, so its buttons can't be tabbed to */
  transition: opacity 0.5s ease, transform 0.5s ease, visibility 0s linear 0.5s;
}
.caption.on { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition-delay: 0s; }
.caption .title { display: block; font-family: var(--serif); font-size: clamp(18px, 2.4vw, 26px); }
.caption .by { display: block; margin-top: 4px; font-size: 13px; letter-spacing: 0.04em; color: var(--mute); }
.caption .gap { height: 70px; } /* where the button bar sits, plus the space above it (about 42px of clear space between the byline and the button text) */
.actions {
  position: fixed; left: 0; right: 0; bottom: calc(6vh + 24px - var(--drop, 0px)); z-index: 5; display: flex; gap: 6px; justify-content: center;
  opacity: 0; transform: translateY(6px); pointer-events: none; visibility: hidden;
  transition: opacity 0.5s ease, transform 0.5s ease, visibility 0s linear 0.5s;
}
.actions.on { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
.actions .linklike { pointer-events: auto; }
.linklike { /* (the base look is in linklike.css) */
  text-decoration: none; /* (a trial: links are not underlined; to bring it back use `text-decoration: underline; text-underline-offset: 4px;` here, and add it to .linklike in controls.css) */
}
.linklike:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

/* The sorry screen: when the window is too small for the shelf (fit-mode.js adds the class too-small to <html>), the shelf, caption, buttons, Sort and Share are hidden
   (hidden or display: none, either way they are out of the keyboard order and the screen reader too) and a message is shown in their place. */
.sorry { display: none; }
html.too-small .sorry {
  position: fixed; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  padding: 0 30px; text-align: center; font-family: var(--mono); color: var(--ink); background: var(--page); /* (its own wall, so it covers everything behind it) */
}
.sorry-face { margin: 0; font-size: clamp(56px, 18vw, 96px); font-weight: 700; line-height: 1; }
.sorry-msg { margin: 0; max-width: 26em; font-size: 14px; line-height: 1.5; }
html.too-small .mark { z-index: 9; } /* (the title stays above the sorry screen's own background) */
html.too-small .stage { visibility: hidden; } /* (hidden, not removed: a removed canvas can make a browser drop its graphics context) */
html.too-small .caption, html.too-small .actions, html.too-small .sorter, html.too-small .sharer, html.too-small #shelf-help { display: none; }

.plain-list { position: fixed; top: 80px; left: 30px; margin: 0; font-family: var(--serif); line-height: 1.8; }

@media (max-width: 600px) {
  .mark { top: 18px; left: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .caption, .actions { transition: none; }
}

/* Read by screen readers only. */
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }


.linklike[aria-pressed="true"] { color: var(--ink); }
.linklike[hidden] { display: none; }
.linklike:disabled { opacity: 0.35; cursor: default; }
.mark .name { font: inherit; margin: 0; }


/* Sort: a link in the bottom-left corner (30px from the side and about 26px from the bottom, like the title from the top-left) opens a
   bubble above it, in the same style as the share bubble: Meow at the top left and a close × at the top right, then four columns
   (each sort's up and down side by side). Under 460px wide it becomes two columns. */
.sorter { position: fixed; left: 22px; bottom: 10px; z-index: 6; pointer-events: none; display: flex; align-items: center; } /* (a row: Sort · Calm · Crisp; the panel is positioned above it) */
.sorter .linklike { pointer-events: auto; min-height: 44px; padding: 0 8px; justify-content: flex-start; }
.linklike[aria-disabled="true"] { opacity: 0.35; cursor: default; text-decoration: line-through; }
.sort-panel {
  position: absolute; left: 0; bottom: calc(100% + 4px); display: grid; grid-template-columns: repeat(4, auto); gap: 6px 14px; padding: 7px 14px 20px;
  white-space: nowrap;
}
.sort-panel[hidden] { display: none; }
.sort-meow { grid-column: 1 / -1; justify-self: start; }
.sort-meow[data-off] { visibility: hidden; }
@media (max-width: 600px) { .sorter { left: 12px; bottom: 2px; } }
.sorter .dot { color: var(--mute); font-size: 12px; pointer-events: none; user-select: none; -webkit-user-select: none; }
@media (max-width: 380px) { .sorter .linklike { padding: 0 6px; } }
@media (max-width: 459px) { .sort-panel { grid-template-columns: repeat(2, auto); gap: 6px 18px; } }

/* The sort and share bubbles share one look: the wall colour, 12px corners, a soft shadow, and a small pointer toward their link
   (on the left for Sort, on the right for Share). */
.sort-panel, .share-bubble { background: var(--bubble); border-radius: 12px; box-shadow: 0 6px 28px rgba(0, 0, 0, 0.18); pointer-events: auto; }
.sort-panel::after, .share-bubble::after { content: ''; position: absolute; bottom: -6px; width: 12px; height: 12px; background: var(--bubble); transform: rotate(45deg); box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.08); }
.sort-panel::after { left: 26px; }
.share-bubble::after { right: 26px; }

/* Share: a link in the bottom-right corner (like Sort at the bottom-left) opens a bubble above it with a picture of the shelf. */
.sharer { position: fixed; right: 22px; bottom: 10px; z-index: 6; pointer-events: none; }
.sharer[hidden], .share-bubble[hidden] { display: none; }
.sharer .linklike { pointer-events: auto; min-height: 44px; padding: 0 8px; }
.share-bubble {
  position: absolute; right: 0; bottom: calc(100% + 4px); width: 318px; padding: 21px 14px 20px;
}
.share-preview { line-height: 0; }
.share-preview img { display: block; width: 100%; height: auto; border-radius: 8px; } /* (the picture keeps the wall colour, so it reads as a card on the lighter bubble) */
.share-preview:not(:has(img)) { line-height: 1.4; font-size: 12px; color: var(--mute); }
.share-looks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 6px; padding: 0 14px; } /* (the bubble's own side padding is 14px: this line has as much again, so 28px in all) */
/* The three picture styles are real radio buttons (one choice, the arrow keys move between them), each a label round a box and its words. The input is visually hidden but
   still focusable; the focus ring is drawn round the box and the words together (.look), like the ring round the buttons. */
.share-look { position: relative; display: flex; align-items: center; justify-content: center; min-height: 44px; cursor: pointer; }
.share-look .look { display: inline-flex; align-items: center; font-size: 12.5px; color: var(--mute); }
.share-look:hover .look, .share-look input:checked + .look { color: var(--ink); }
.share-look input:checked + .look .mk .tick { visibility: visible; }
.share-look input:focus-visible + .look { outline: 2px solid var(--ink); outline-offset: 4px; }
.share-actions { display: flex; justify-content: space-between; margin: 17px 0 0; }
.share-status { margin: 4px 0 0; min-height: 1.4em; font-size: 12px; line-height: 1.4; color: var(--mute); text-align: center; }
.share-status input { display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 12px; padding: 8px; border: 1px solid var(--mute); border-radius: 6px; background: var(--bubble); color: var(--ink); }
@media (max-width: 600px) { .sharer { right: 12px; bottom: 2px; } .share-bubble { width: min(318px, calc(100vw - 24px)); } }
.bubble-close {
  position: absolute; top: 4.5px; right: 4.5px; width: 44px; height: 44px; padding: 0; border: 0; font: inherit; font-size: 22px; line-height: 1;
  color: var(--mute); cursor: pointer; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--bubble); /* a circle in the bubble's own colour behind the ×, so it reads cleanly where it overlaps the picture's corner */
}
.bubble-close:hover { color: var(--ink); }
.bubble-close:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; color: var(--ink); }

/* Sort and Share can both be open: the one touched last is on top. */
.sorter.is-front, .sharer.is-front { z-index: 7; }

/* Calm and Crisp (access.js puts data-calm and data-crisp on <html>, and sets the colours that depend on them: the wall, --ink, --mute and --bubble; Calm's are softer with a deeper
   --mute, Crisp's make the quiet text full ink). Crisp also makes the focus rings thicker and gives the bubbles a line round them. Nothing in Crisp changes a size, a weight or a
   border width, so nothing moves when it is switched. */
html[data-crisp] .linklike:focus-visible, html[data-crisp] .share-look input:focus-visible + .look, html[data-crisp] .bubble-close:focus-visible { outline-width: 3px; }
html[data-crisp] .hit:focus-visible::after { border-width: 3px; }
html[data-crisp] .sort-panel, html[data-crisp] .share-bubble { box-shadow: 0 0 0 1px var(--ink), 0 6px 28px rgba(0, 0, 0, 0.18); }
html[data-crisp] .sort-panel::after, html[data-crisp] .share-bubble::after { box-shadow: 1px 1px 0 var(--ink); }

/* The on/off box before Spin, Calm and Crisp (index.html draws it in the text colour): empty, with the tick shown only while the button is pressed. It has its own fixed room, so
   the label never moves when it is switched. In forced-colours mode it follows the system's text colour, because it is drawn with currentColor.
   What ticks it: aria-pressed (a switch that is on), aria-current (the face a book is on, the sort the shelf is in, Meow after a shuffle), aria-expanded (Sort and Share, while their
   bubble is open), data-done (Shelve, for the moment the bar fades out after a put-back).
   Sort and Share carry both a box and a chevron: the box is the default; with the controls panel's "Use chevrons" (data-chevrons on <html>, set by access.js) the chevron is shown instead,
   a caret up while closed and down while open (they open upward). */
.mk { flex: none; margin-right: 5px; }
.mk .tick, .mk.chev .down { visibility: hidden; }
.linklike[aria-pressed="true"] .mk .tick, .linklike[aria-current="true"] .mk .tick, .linklike[aria-expanded="true"] .mk .tick, .linklike[data-done] .mk .tick { visibility: visible; }
.linklike[aria-current="true"] { color: var(--ink); }
@media (max-width: 420px) { .actions .linklike { padding: 0 4px; } } /* (the bar's five links, each with a box, must fit a phone) */
.mk.chev { display: none; }
html[data-chevrons] .linklike[aria-expanded] .mk:not(.chev) { display: none; }
html[data-chevrons] .linklike[aria-expanded] .mk.chev { display: inline; }
.linklike[aria-expanded="true"] .mk.chev .up { visibility: hidden; }
.linklike[aria-expanded="true"] .mk.chev .down { visibility: visible; }
