@font-face { font-family: "Bricolage Grotesque"; font-weight: 400; font-display: swap; src: url("vendor/fonts/bricolage-grotesque-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 600; font-display: swap; src: url("vendor/fonts/bricolage-grotesque-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 800; font-display: swap; src: url("vendor/fonts/bricolage-grotesque-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Libre Caslon Text"; font-weight: 400; font-display: swap; src: url("vendor/fonts/libre-caslon-text-latin-400-normal.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: "Libre Caslon Text"; font-weight: 400; font-display: swap; src: url("vendor/fonts/libre-caslon-text-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, 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 Caslon Text"; font-weight: 400; font-style: italic; font-display: swap; src: url("vendor/fonts/libre-caslon-text-latin-400-italic.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: "Libre Caslon Text"; font-weight: 400; font-style: italic; font-display: swap; src: url("vendor/fonts/libre-caslon-text-latin-ext-400-italic.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, 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; }


/* Newsprint: white paper, black ink, serif type and hairline rules. The globe and the book jackets carry the colour. */
:root {
  --paper: #FBFBF8;
  --ink: #121212;
  --muted: #666661;
  --rule: #8C8C87;
  --accent: #121212;
  --accent-ink: #FFFFFF;
  --veil: rgba(251, 251, 248, 0.94);
  --page-edge: #F6F3EA;
  --page-line: #DAD5C7;
  --serif: "Libre Caslon Text", "Iowan Old Style", Georgia, serif;
  --sans: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --book-w: min(40vw, 9.5rem);
  --space: clamp(1.5rem, 3vw, 2rem); /* the one vertical gap used between page elements */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121212; --ink: #ECECE8; --muted: #9B9B96; --rule: #77776F; --accent: #ECECE8; --accent-ink: #121212;
    --veil: rgba(18, 18, 18, 0.94); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121212; --ink: #ECECE8; --muted: #9B9B96; --rule: #77776F; --accent: #ECECE8; --accent-ink: #121212;
  --veil: rgba(18, 18, 18, 0.94); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font-family: var(--serif); font-size: 1rem; line-height: 1.6; overflow-x: hidden; }
a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
button, input { font: inherit; color: inherit; }
.icon { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.18em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.page { max-width: 72rem; margin: 0 auto; padding: 0 16px 3rem; overflow-x: clip; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space); justify-items: center; text-align: center; }
.stage { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: var(--space); }

/* The globe */
/* The globe takes what is left of the first screen after the question, search and tag pills. */
.globe-wrap { position: relative; width: min(100%, calc(100svh - 25rem), 44rem); min-width: min(100%, 16rem); margin: var(--space) auto 0; }
#globe { position: relative; display: block; width: 100%; aspect-ratio: 1; touch-action: pan-y; cursor: grab; }
#globe:active { cursor: grabbing; }
.globe-label { position: absolute; top: 0; left: 0; pointer-events: none; white-space: nowrap; margin: -2.6rem 0 0; translate: -50% 0; padding: 0.3rem 0.6rem; border-radius: 2px;
  background: #121212; color: #FFFFFF; font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.01em; }
.globe-label strong { font-weight: 700; }

/* A random book rises over the globe. */
.book-reveal { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; border-radius: 50%;
  background: rgba(0, 0, 0, 0.4); animation: veil 0.5s ease both; }
.book-reveal[hidden] { display: none; }
.reveal-shelf { list-style: none; margin: 0; padding: 0; --book-w: min(30vw, 12rem); }
.revealed .book-body { animation: rise 1.1s cubic-bezier(0.2, 0.85, 0.25, 1) backwards; }
.reveal-shelf .book { transition: width 0.6s cubic-bezier(0.25, 0.8, 0.25, 1); }
.reveal-shelf .expanded { --book-w: min(44vw, 46vh, 17rem); }
.reveal-shelf .expanded .back { padding: 12% 12% 10%; gap: 0.7rem; font-size: 0.88rem;
  background: #1D2A33; color: #F3EAD0; }
.reveal-shelf .expanded .back-author { font-size: 1.1rem; }
.reveal-shelf .expanded .blurb { font-size: 0.98rem; line-height: 1.42; -webkit-line-clamp: 10; }
.reveal-shelf .expanded .caption { display: none; }
.book-reveal:has(.expanded) .reveal-more { display: none; }
@keyframes rise { 0% { transform: translateY(60px) scale(0.3); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }
@keyframes veil { from { opacity: 0; } }
.reveal-close, .modal-close { width: 2.5rem; height: 2.5rem; border: 0; background: none; color: var(--ink); font-family: var(--sans); font-size: 1.7rem; line-height: 1; cursor: pointer; }
.reveal-close { position: absolute; top: 8%; right: 12%; z-index: 2; border-radius: 50%; background: rgba(0, 0, 0, 0.45); font-size: 1.4rem; }
.modal-close { position: fixed; top: 12px; right: 12px; }
.reveal-more { padding: 0.2rem 0; border: 0; background: none; color: #FFFFFF; font-family: var(--serif); font-style: italic; font-size: 1.05rem; cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 0.5px; text-underline-offset: 0.3em; }
.reveal-more:hover { text-decoration-thickness: 1px; }

/* An opened book: large, centred, turned over. */
.book-modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.4); animation: veil 0.3s ease both; }
.book-modal[hidden] { display: none; }
.modal-shelf { list-style: none; margin: 0; padding: 0; --book-w: min(64vw, 40vh, 19rem); }
.modal-book .book { animation: fly 0.55s cubic-bezier(0.2, 0.85, 0.25, 1) both; will-change: transform; }
@keyframes fly { from { transform: translate(var(--dx, 0), var(--dy, 0)) scale(var(--s, 1)); } }
.modal-book .book-body { animation: none; transition: transform 0.7s cubic-bezier(0.3, 0.7, 0.2, 1); will-change: transform; }
.modal-book .book::after { display: none; }
/* A deep, soft shadow under the enlarged book, on whichever cover is facing. */
.modal-book .front, .modal-book .back, .revealed .front { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 28px 60px rgba(0, 0, 0, 0.45), 0 8px 18px rgba(0, 0, 0, 0.3); }
.modal-book .caption, .reveal-shelf .caption, .modal-book .prize.pick, .reveal-shelf .prize.pick, .modal-book .caption a.buy, .reveal-shelf .caption a.buy { color: #FFFFFF; }
.reveal-close, .modal-book ~ .modal-close, .book-modal .modal-close { color: #FFFFFF; }
.modal-book .back { padding: 12% 12% 10%; gap: 0.7rem; font-size: 0.9rem; }
.modal-book .back-author { font-size: 1.15rem; }
.modal-book .original-title { font-size: 0.85rem; }
.modal-book .blurb { font-size: 1rem; line-height: 1.45; -webkit-line-clamp: 10; }
.modal-book .back-hint .icon { width: 1.3rem; height: 1.3rem; }
.modal-book .caption { animation: veil 0.6s 0.4s ease both; }

/* Search */
.search { width: min(100%, 32rem); }
.search label[for="q"] { display: block; font-style: italic; font-size: 1.45rem; line-height: 1.2; margin-bottom: var(--space); }
.search-row { display: flex; align-items: center; gap: 0.5rem; border-bottom: 0.5px solid var(--rule); }
#q { flex: 1; min-width: 0; padding: 0.55rem 0; font-size: 1.15rem; border: 0; background: transparent; outline: none; text-align: left; }
#q::placeholder { color: var(--muted); font-style: italic; }
.icon-button { flex: none; width: 2.4rem; height: 2.4rem; display: grid; place-items: center; border: 0; background: none; color: var(--ink); cursor: pointer; }
.icon-button .icon { width: 1.2rem; height: 1.2rem; }
.icon-button:hover { color: var(--muted); }
.icon-button.submit { margin-bottom: 0; }
.icon-button.submit .icon { width: 1.35rem; height: 1.35rem; stroke-width: 1.8; }

/* Tag pills */
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.35rem; margin-top: calc(var(--space) * 0.75); max-width: 46rem; margin-inline: auto; }
.tag-row { display: contents; }
.tag { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.6rem; border: 0.5px solid var(--rule); border-radius: 999px; background: none;
  font-family: var(--sans); font-size: 0.74rem; color: var(--muted); cursor: pointer; transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
.tag .icon { width: 0.95rem; height: 0.95rem; }
.tag:hover { border-color: var(--ink); color: var(--ink); }
.tag[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* Results */
#results { width: 100%; min-height: 12rem; scroll-margin-top: 1rem; }
.intro p, .status { color: var(--muted); max-width: 40ch; margin: 0 auto 0.4rem; font-style: italic; }
.intro .icon, .status .icon, .empty .icon { display: none; }
.tier + .tier { margin-top: calc(var(--space) * 1.5); }
.tier h2 { margin: 0 0 var(--space); padding: 0.7rem 0 0.6rem; border-top: 0.5px solid var(--rule); border-bottom: 0.5px solid var(--rule);
  font-weight: 400; font-size: clamp(1.6rem, 5vw, 2.3rem); line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
.tier h2:focus { outline: none; }
.tier h2 .icon { display: none; }
/* The featured book: larger, alone. */
.featured-shelf { --book-w: min(52vw, 13rem); }
.featured-tier h2 { font-style: italic; }

.empty-title { font-size: 1.4rem; margin: 0 0 0.25rem; }
.empty p { margin-top: 0; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem 1.25rem; margin: 1rem auto 1.5rem; max-width: 40rem; }
.chip { padding: 0; border: 0; background: none; font-size: 1.05rem; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; cursor: pointer; }
.surprise { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.55rem 1.1rem; border: 1px solid var(--ink); border-radius: 2px; background: none; font-family: var(--sans); font-size: 0.85rem; cursor: pointer; }

/* The shelf */
.shelf { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, var(--book-w)); justify-content: center; gap: 2.5rem clamp(1rem, 3vw, 2.5rem); }
.shelf-item { display: flex; flex-direction: column; align-items: center;
  /* Thickness from the real page count: about 0.05 mm a page against a 13 cm wide cover. */
  --d: clamp(3px, calc(var(--book-w) * var(--pages) / 2600), 96px); }
.shelf-item.featured .book { outline: 1px solid var(--ink); outline-offset: 8px; }

.book { position: relative; width: var(--book-w); aspect-ratio: 2 / 3; padding: 0; border: 0; background: none; cursor: pointer; perspective: 900px; }
.book::after { content: ""; position: absolute; left: 6%; right: 6%; bottom: -10px; height: 12px; background: radial-gradient(closest-side, rgba(0, 0, 0, 0.18), transparent); pointer-events: none; }
.book-body { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
  animation: arrive 0.8s ease backwards; animation-delay: calc(var(--i) * 60ms); }
@media (hover: hover) {
  .book:hover .book-body { transform: translateY(-4px); }
}
.book[aria-pressed="true"] .book-body { transform: rotateY(180deg); }
@keyframes arrive { from { transform: translateY(12px); opacity: 0; } }

.face { position: absolute; top: 0; left: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.front, .back { width: 100%; height: 100%; border-radius: 1px 3px 3px 1px; }
.front { transform: translateZ(calc(var(--d) / 2)); display: flex; flex-direction: column; padding: 16% 11% 12% 15%; color: var(--cloth-ink); font-family: var(--serif); text-align: left;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.1) 0, rgba(0, 0, 0, 0.02) 3%, transparent 4.5%), var(--cloth);
  box-shadow: inset 0 0 0 0.5px rgba(29, 42, 51, 0.35), 0 4px 12px rgba(0, 0, 0, 0.14); }
/* A fine neat line inside the cover, like the frame of a printed chart. */
.front::before, .back::before { content: ""; position: absolute; inset: 5% 6%; border: 0.5px solid currentColor; opacity: 0.4; pointer-events: none; }
.cover-title { line-height: 1.12; overflow-wrap: break-word; }
.size-xl { font-size: 1.35rem; }
.size-l { font-size: 1.05rem; }
.size-m { font-size: 0.88rem; }
.size-s { font-size: 0.74rem; }
.cover-rule { width: 2.4em; height: 1px; margin: 0.9em 0; background: currentColor; opacity: 0.55; flex: none; }
.cover-author { margin-top: auto; font-style: italic; font-size: 0.72rem; line-height: 1.3; opacity: 0.92; }

.spine { width: var(--d); height: 100%; transform: translateX(calc(var(--d) / -2)) rotateY(-90deg); display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.38), rgba(255, 255, 255, 0.1) 45%, rgba(0, 0, 0, 0.32)), var(--cloth); }
.spine-title { writing-mode: vertical-rl; font-family: var(--serif); font-size: 0.62rem; color: var(--cloth-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: 86%; }
.spine.thin .spine-title { display: none; }
.pages { width: var(--d); height: calc(100% - 6px); top: 3px; left: calc(100% - var(--d)); transform: translateX(calc(var(--d) / 2 - 2px)) rotateY(90deg);
  background: repeating-linear-gradient(90deg, var(--page-edge) 0 1.5px, var(--page-line) 1.5px 2.5px); }
.top { width: calc(100% - 4px); height: var(--d); transform: translateY(calc(var(--d) / -2 + 3px)) rotateX(90deg); background: repeating-linear-gradient(0deg, var(--page-edge) 0 1.5px, var(--page-line) 1.5px 2.5px); }
.back { transform: rotateY(180deg) translateZ(calc(var(--d) / 2)); display: flex; flex-direction: column; gap: 0.5rem; padding: 13% 12% 10%; overflow: hidden; color: var(--cloth-ink); font-size: 0.7rem; line-height: 1.3; text-align: left;
  background: var(--cloth); }
.back-author { font-family: var(--serif); font-size: 0.84rem; line-height: 1.2; }
.original-title { font-family: var(--serif); font-size: 0.68rem; opacity: 0.75; margin-top: -0.3rem; }
.blurb { font-family: var(--serif); font-style: italic; font-size: 0.72rem; line-height: 1.32; opacity: 0.95; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.facts { display: flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; margin-top: auto; }
.fact { display: inline-flex; align-items: flex-start; gap: 0.3rem; }
.fact.wide { flex-basis: 100%; }
.fact .icon { width: 1.05em; height: 1.05em; opacity: 0.85; margin-top: 0.05em; }
.back-hint { align-self: flex-end; opacity: 0.6; line-height: 0; }
.back-hint .icon { width: 1rem; height: 1rem; }

.caption { margin: 1.1rem 0 0; width: calc(var(--book-w) + 1rem); font-family: var(--sans); font-size: 0.74rem; line-height: 1.45; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }
.prize { display: block; }
.prize .icon { display: none; }
.prize.pick { font-family: var(--serif); font-style: italic; font-size: 0.82rem; color: var(--ink); }
.caption a.buy { margin-top: 0.25rem; color: var(--ink); }
.buy .icon { display: none; }

footer { margin: calc(var(--space) * 2) auto 0; padding-top: 1.25rem; border-top: 0.5px solid var(--rule); color: var(--muted); font-family: var(--sans); font-size: 0.76rem; max-width: 72ch; text-align: center; }
.footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem 1.4rem; }
.footer-links li { display: inline-flex; align-items: center; gap: 0.35rem; }
.footer-links .icon { width: 1em; height: 1em; }
.fine-print { margin: 0.9rem 0 0; }

.button-label { display: none; }

/* Phones: labelled icons, wrapped tag pills and swipeable shelves. */
@media (max-width: 40rem) {
  .button-label { display: block; font-family: var(--sans); font-size: 0.62rem; line-height: 1; }
  .icon-button { width: auto; height: auto; min-width: 2.9rem; padding: 0.35rem 0.4rem; display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
  .tags { gap: 0.3rem; }
  .tag { padding: 0.28rem 0.55rem; font-size: 0.72rem; }
  .shelf:not(.featured-shelf) { contain: paint; --book-w: 38vw; display: flex; justify-content: flex-start; gap: 1rem; overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; margin-inline: -16px; padding: 0.25rem 16px 1rem; scrollbar-width: none; }
  .shelf:not(.featured-shelf)::-webkit-scrollbar { display: none; }
  .shelf:not(.featured-shelf) .shelf-item { flex: none; scroll-snap-align: start; }
  .shelf:not(.featured-shelf) .size-xl { font-size: 1.1rem; }
  .shelf:not(.featured-shelf) .size-l { font-size: 0.92rem; }
  .shelf:not(.featured-shelf) .size-m { font-size: 0.78rem; }
  .shelf:not(.featured-shelf) .size-s { font-size: 0.68rem; }
  .shelf:not(.featured-shelf) .cover-author { font-size: 0.66rem; }
  .caption { margin-top: 0.8rem; gap: 0; }
  .caption a.buy { margin-top: 0.15rem; }
}
@media (max-width: 30rem) {
  .globe-wrap { width: min(100%, calc(100svh - 28rem)); min-width: min(100%, 12rem); }
  .search label[for="q"] { font-size: 1.25rem; }
  .book-reveal { gap: 0.6rem; }
  .reveal-shelf .expanded .back { font-size: 0.78rem; gap: 0.5rem; }
  .reveal-shelf .expanded .back-author { font-size: 0.95rem; }
  .reveal-shelf .expanded .blurb { font-size: 0.84rem; line-height: 1.35; -webkit-line-clamp: 7; }
}
@media (min-width: 40rem) {
  :root { --book-w: 9.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .book-body, .revealed .book-body, .book-reveal, .book-modal, .modal-book .book, .modal-book .caption { animation: none; transition: none; }
}
