/* ============================================================
   MinChi’s Virtual Bookshelf
   Requires shared.css for tokens, fonts, header, 3D book.
   ============================================================ */

:root {
  --paper-deep: #e6d98f;
  --modal-bg: #f3f2ef;
  --about-bg: #e8d5e6;
  --accent: #000;
  --gold: #000;
  --page-cream: #fdfdfb;
  --side-w: 280px;
  /* striped modal shadow (brutalist / SO-inspired) */
  --stripe-offset: 6px;
  --stripe-ink: #000;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-morph: cubic-bezier(0.32, 0.72, 0, 1);
}

/* shared striped drop shadow for float windows + filters
   Adapted from https://stackoverflow.com/a/63581829 (Temani Afif, CC BY-SA 4.0)
   Layer order (back → front):
     ::before = offset striped shadow
     ::after  = solid panel face
     > *      = content
   Windows must stay overflow:visible so the stripe isn’t clipped. */
.modal-card,
.filters-modal-card {
  --_stripe: var(--stripe-offset);
  --_face: var(--modal-bg);
  isolation: isolate;
  background: transparent !important;
}

.about-window {
  --_face: var(--about-bg);
}

/* back: striped shadow */
.modal-card::before,
.filters-modal-card::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: var(--_stripe);
  left: var(--_stripe);
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    -45deg,
    var(--stripe-ink) 0 1.5px,
    transparent 1.5px 4px
  );
  pointer-events: none;
  contain: strict;
}

/* middle: solid face — sits on top of the shadow overlap */
.modal-card::after,
.filters-modal-card::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  background: var(--_face);
  border: 1px solid var(--ink);
  pointer-events: none;
}

/* front: real content above the face */
.modal-card > *,
.filters-modal-card > * {
  position: relative;
  z-index: 2;
}

.modal-card > .modal-close,
.filters-modal-card > .modal-close {
  z-index: 3;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: var(--font);
  font-size: var(--size);
}

body {
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
  background-color: var(--bg, var(--paper));
  color: var(--ink);
  min-height: 100vh;
  transition: background-color 480ms ease;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
}

body.modal-open { overflow: hidden; }

::selection { background: color-mix(in srgb, var(--ink) 14%, transparent); }

/* ============ Layout: left nav + main ============ */

.layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
  overflow: visible;
}

/* ---- GeoKash-style left nav: one size, plain list ---- */

.side-nav {
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: var(--side-w);
  flex-shrink: 0;
  height: 100vh;
  padding: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg, var(--paper));
  overflow: hidden;
  /* keep below shelf books so open covers / shadows aren't clipped */
  z-index: 1;
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
  line-height: 1.35;
  color: var(--ink);
  transition: background-color 480ms ease;
}

/* fixed brand — never scrolls with filters */
.side-brand {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 0 22px 12px;
  background: var(--bg, var(--paper));
  transition: background-color 480ms ease;
}

/* desktop: Title → About → Search */
.side-brand .site-title { order: 0; }
.side-brand .brand-bar { order: 1; }
.side-brand .search-wrap { order: 2; }

/* only this region scrolls */
.side-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 22px 28px;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.side-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

/* About (+ mobile Filters / Reset) */
.brand-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: 100%;
}



/* desktop: filters panel always in sidebar; toggle is mobile-only */
.filters-toggle {
  display: none;
  font: inherit;
  font-size: inherit;
  font-weight: 400;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink);
  padding: 0 0 1px;
  cursor: pointer;
  line-height: 1.35;
  flex: 0 0 auto;
  white-space: nowrap;
  width: auto;
  max-width: max-content;
}

.filters-toggle:hover { opacity: 0.55; }

.filters-toggle.is-active {
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.filters-reset {
  font: inherit;
  font-size: inherit;
  font-weight: 400;
  color: var(--ink);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 1.35;
  flex: 0 0 auto;
  white-space: nowrap;
  width: auto;
  opacity: 0.55;
}

.filters-reset:hover { opacity: 1; }

/* desktop: reset is the floating control, not the brand bar */
.brand-bar > .filters-reset {
  display: none;
}

.filters-reset[hidden] {
  display: none !important;
}

/* floating corner actions — above shelf, books, and windows */
.float-action {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 200;
  margin: 0;
  padding: 10px 14px;
  font: inherit;
  font-size: var(--size);
  font-weight: 400;
  line-height: 1.35;
  color: var(--ink);
  background: var(--modal-bg);
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  opacity: 1;
  white-space: nowrap;
  pointer-events: auto;
  box-shadow: 3px 3px 0 var(--ink);
}

.float-action:hover {
  opacity: 1;
  background: #fff;
}

/* About — bottom right */
.float-action-about {
  right: max(16px, env(safe-area-inset-right));
  left: auto;
  background: var(--about-bg);
}

.float-action-about:hover {
  background: #f3e4f1;
}

/* Reset filters — bottom left (desktop only, when active) */
.filters-reset-float,
.float-action-reset {
  left: max(16px, env(safe-area-inset-left));
  right: auto;
  display: none;
}

.filters-reset-float:not([hidden]),
.float-action-reset:not([hidden]) {
  display: block;
}

@media (max-width: 860px) {
  .filters-reset-float,
  .float-action-reset {
    display: none !important;
  }
}

/* desktop: brand-bar only holds mobile Filters/Reset */
.brand-bar {
  display: none;
}

.filters-modal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 6px;
  margin-bottom: 8px;
  padding-right: 28px;
}

.filters-modal-head .filters-modal-title {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
  padding-right: 0;
}

.filters-modal-head .filters-reset {
  opacity: 1;
}

/* filters modal — used on mobile */
.filters-modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  visibility: hidden;
  pointer-events: none;
}

.filters-modal.visible {
  visibility: visible;
  pointer-events: auto;
}

.filters-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(239, 227, 163, 0.72);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  opacity: 0;
  transition: opacity 280ms ease;
}

.filters-modal.open .filters-modal-backdrop { opacity: 1; }

.filters-modal-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  padding: 24px;
}

.filters-modal-stage > * { pointer-events: auto; }

.filters-modal-card {
  position: relative;
  width: min(440px, 92vw);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  overflow: visible;
  border-radius: 0;
  padding: 24px 44px 28px 24px;
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 240ms ease, transform 320ms var(--ease-morph);
}

.filters-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(58vh, 480px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 4px;
}

.filters-modal-body::-webkit-scrollbar { display: none; }

/* scrollable regions: soft edge fade instead of a hard clip / visible bar */
.scroll-fade {
  --fade-size: 22px;
  -webkit-mask-image: linear-gradient(#000, #000);
  mask-image: linear-gradient(#000, #000);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.scroll-fade.fade-top {
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 var(--fade-size),
    #000 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 var(--fade-size),
    #000 100%
  );
}

.scroll-fade.fade-bottom {
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000 0,
    #000 calc(100% - var(--fade-size)),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    #000 0,
    #000 calc(100% - var(--fade-size)),
    transparent 100%
  );
}

.scroll-fade.fade-top.fade-bottom {
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 var(--fade-size),
    #000 calc(100% - var(--fade-size)),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 var(--fade-size),
    #000 calc(100% - var(--fade-size)),
    transparent 100%
  );
}

.filters-modal.open .filters-modal-card {
  opacity: 1;
  transform: none;
}

.filters-modal-title {
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
}

.filters-modal-body .side-block {
  margin-top: 20px;
}

.filters-modal-body .side-block:first-child {
  margin-top: 4px;
}

.site-title {
  font-family: "Playwrite NZ Guides", cursive;
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0.01em;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: none;
  /* room for script ascenders / descenders — tight top, more air below */
  padding: 0.02em 0 0.15em;
  margin: 0 0 14px;
}

/* desktop: stack title for script font */
.site-title .title-break {
  display: block;
}

.side-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 28px;
  flex-shrink: 0;
}

/* first filter section under search */
.side-scroll > .side-block:first-child {
  margin-top: 12px;
}

/* Sort label only in mobile filters modal (hidden in desktop sidebar) */
.side-head-sort {
  display: none;
}

.side-brand .search-wrap {
  width: 100%;
}

/* Hardware (11) — label + count + hairline */
.side-head {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 6px;
  margin-top: 0;
  margin-bottom: 2px;
}

.side-head h2 {
  font-size: inherit;
  font-weight: 400;
  text-transform: capitalize;
  letter-spacing: 0;
}

.search-wrap {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 0;
  top: 50%;
  translate: 0 -50%;
  width: 14px;
  height: 14px;
  color: var(--ink);
  pointer-events: none;
}

#search {
  width: 100%;
  height: auto;
  padding: 4px 0 4px 20px;
  font: inherit;
  font-size: inherit;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--ink);
  outline: none;
  transition: border-color 160ms ease;
}

#search::placeholder { color: var(--ink); opacity: 1; }
#search:focus-visible {
  border-bottom-color: var(--ink);
  outline: none;
}

/* plain link lists — sort / year / rating / genres */

.side-genres {
  min-height: 0;
}

/* About modal */

.about-modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  visibility: hidden;
  pointer-events: none;
}

.about-modal.visible {
  visibility: visible;
  pointer-events: auto;
}

.about-modal-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
  opacity: 0;
  transition: opacity 280ms ease;
}

.about-modal.open .about-modal-backdrop { opacity: 1; }

.about-modal-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  padding: 24px;
}

.about-modal-stage > * { pointer-events: auto; }

.about-modal-card {
  position: relative;
  width: min(440px, 92vw);
  max-height: min(80vh, 640px);
  overflow: visible;
  border-radius: 0;
  padding: 24px 44px 28px 24px;
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
  box-shadow: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 240ms ease, transform 320ms var(--ease-morph);
}

.about-modal.open .about-modal-card {
  opacity: 1;
  transform: none;
}

.about-modal-title {
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 6px;
  margin-bottom: 16px;
  padding-right: 28px;
}

.about-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: min(60vh, 480px);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
}

.about-modal-body::-webkit-scrollbar {
  display: none;
}

.about-modal-body p {
  margin: 0;
  text-wrap: pretty;
}

.about-modal-body a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.about-modal-body a:hover {
  opacity: 0.55;
}

.link-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.link-item {
  height: auto;
  min-height: 22px;
  padding: 3px 0;
  display: flex;
  align-items: center;
  width: 100%;
  font: inherit;
  font-size: inherit;
  font-weight: 400;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  text-align: left;
  transition: opacity 120ms ease;
}

.link-item:hover {
  opacity: 0.55;
}

.link-item:active { opacity: 0.4; }

.link-item.active {
  background: transparent;
  color: var(--ink);
  font-weight: 400;
  opacity: 1;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--ink) 25%, transparent);
  text-underline-offset: 4px;
}

.link-item:focus-visible {
  outline: none;
}

/* ---- main content ---- */

.main {
  flex: 1;
  min-width: 0;
  overflow: visible;
  position: relative;
  z-index: 2;
}

.shelf {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 40px 28px 56px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(188px, 1fr));
  justify-items: center;
  align-items: start;
  column-gap: 28px;
  row-gap: 52px;
  overflow: visible;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 0;
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
}

/* ---- one book cell ---- */

.book-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: center;
  border-radius: 8px;
  opacity: 1;
  transition: scale 160ms var(--ease-out);
  overflow: visible;
}

.book-cell.morphing {
  opacity: 0 !important;
  transition: none;
  pointer-events: none;
}

.book-cell:focus-visible {
  outline: none;
}

/* ============================================================
   3D Book — after CodePen filipz/VYwqwXN (GSAP 3D Book Effect)
   Back cover + 3 paper pages + front cover + spine effect + light
   Hover/open: cover rotateY(-12°) translateX scaleX(.96),
   pages slide out, light sweeps in — 0.7s cubic-bezier(0.25, 1, 0.5, 1)
   ============================================================ */

/* open state — hover / keyboard focus on shelf */
@media (hover: hover) and (pointer: fine) {
  .book-cell:hover .b-image,
  .book-cell:focus-visible .b-image {
    transform: perspective(2000px) translateX(calc(var(--bw) * -0.027)) rotateY(-12deg) scaleX(0.96);
    box-shadow:
      10px 10px 20px rgba(0, 0, 0, 0.25),
      20px 20px 40px rgba(0, 0, 0, 0.2),
      40px 40px 60px rgba(0, 0, 0, 0.15);
  }

  .book-cell:hover .b-light,
  .book-cell:focus-visible .b-light {
    opacity: 0.1;
    transform: perspective(2000px) rotateY(-12deg);
  }

  .book-cell:hover .b-effect,
  .book-cell:focus-visible .b-effect {
    margin-left: 4.5%;
  }

  .book-cell:hover .b-page:nth-child(1),
  .book-cell:focus-visible .b-page:nth-child(1) {
    transform: translateX(calc(var(--bw) * 0.018));
  }

  .book-cell:hover .b-page:nth-child(2),
  .book-cell:focus-visible .b-page:nth-child(2) {
    transform: translateX(calc(var(--bw) * 0.009));
  }
}

/* open state — modal & flying morph */
.book-3d.is-open .b-image {
  transform: perspective(2000px) translateX(calc(var(--bw) * -0.027)) rotateY(-12deg) scaleX(0.96);
  box-shadow:
    10px 10px 20px rgba(0, 0, 0, 0.25),
    20px 20px 40px rgba(0, 0, 0, 0.2),
    40px 40px 60px rgba(0, 0, 0, 0.15);
}

.book-3d.is-open .b-light {
  opacity: 0.2;
  transform: perspective(2000px) rotateY(-12deg);
}

.book-3d.is-open .b-effect {
  margin-left: 4.5%;
}

.book-3d.is-open .b-page:nth-child(1) {
  transform: translateX(calc(var(--bw) * 0.018));
}

.book-3d.is-open .b-page:nth-child(2) {
  transform: translateX(calc(var(--bw) * 0.009));
}

.book-cell:active { scale: 0.98; }



/* ============ Flying morph clone ============ */

.book-fly {
  position: fixed;
  z-index: 80;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.book-fly .book-scene {
  width: 100%;
  height: 100%;
}

/* book opens/closes in sync with the flight */
.book-fly .b-image,
.book-fly .b-light,
.book-fly .b-effect,
.book-fly .b-page {
  transition-duration: 520ms;
}

/* ============ Floating book windows ============ */

.book-windows {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: visible;
  /* allow striped shadows to paint past edges */
  contain: none;
}

.float-window {
  position: fixed;
  pointer-events: auto;
  border-radius: 0;
  box-shadow: none;
  /* must stay visible so striped ::before isn’t clipped */
  overflow: visible;
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
  opacity: 1;
  transform: none;
  transition: none;
  cursor: default;
}

.float-window.is-dragging {
  transition: none;
  cursor: grabbing;
  user-select: none;
}

.float-window.is-dragging * {
  cursor: grabbing !important;
}

/* drag strip overlays top edge — does not eat into padding */
.window-drag {
  position: absolute;
  top: 0;
  left: 0;
  right: 32px; /* leave close button free */
  height: 28px;
  margin: 0;
  cursor: grab;
  touch-action: none;
  background: transparent;
  z-index: 2;
}

/* book window — cover left + text right; hug content; stripe needs overflow visible */
.book-window {
  box-sizing: border-box;
  width: min(520px, calc(100vw - 32px));
  height: auto;
  max-width: 520px;
  max-height: min(85vh, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  overflow: visible;
}

.book-window-main {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  min-height: 0;
  flex: 1 1 auto;
  overflow: visible;
}

.book-window .card-title,
.book-window .card-author,
.book-window .card-book {
  cursor: grab;
}

.book-window .card-book {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
  flex-shrink: 0;
  /* room for soft cover shadow */
  padding: 2px 10px 14px 2px;
  overflow: visible;
}

.book-window .card-book .book-scene {
  overflow: visible;
}

.book-window .card-book .book-3d,
.book-window .card-book .b-image {
  overflow: visible;
}

/* lighter, tighter shadow in the detail window */
.book-window .b-image {
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 4px 10px rgba(0, 0, 0, 0.05);
}

.book-window .card-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  padding: 0;
}

.book-window .card-title {
  font-size: inherit;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0;
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
  padding-bottom: 6px;
  padding-right: 28px;
  margin: 0;
}

.book-window .card-author {
  margin-top: 10px;
  font-size: inherit;
  color: var(--ink-soft);
}

.book-window .card-meta {
  margin-top: 10px;
  font-size: inherit;
  color: var(--ink-soft);
}

.book-window .card-genres {
  margin-top: 12px;
  gap: 4px 12px;
}

.book-window .card-genres .g {
  font-size: inherit;
  font-weight: 400;
  color: var(--ink);
  padding: 0;
  border: none;
  background: none;
  outline: none;
}

.book-window .card-notes {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(42vh, 300px);
  overflow-x: hidden;
  overflow-y: auto;
  margin-top: 16px;
  padding-top: 12px;
  padding-right: 2px;
  border-top: 1px solid var(--ink);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.book-window .card-notes::-webkit-scrollbar {
  display: none;
}

.book-window .card-notes p {
  font-size: inherit;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 10px;
}

.book-window .card-notes p.quote {
  font-size: inherit;
  line-height: 1.55;
  color: var(--ink);
  padding-left: 12px;
  border-left: 2px solid var(--ink);
}

.book-window .card-notes p.quotes-head {
  font-size: inherit;
  color: var(--ink-soft);
  margin: 14px 0 6px;
}

.book-window .card-nav {
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--ink);
  padding-top: 12px; /* space above rule only */
}

/* about window — hug content; stripe visible; body scrolls if needed */
.about-window {
  --_face: var(--about-bg);
  box-sizing: border-box;
  width: min(380px, calc(100vw - 32px));
  height: auto;
  max-width: 380px;
  max-height: min(85vh, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  overflow: visible;
}

.about-window-title {
  font-family: var(--font);
  font-size: inherit;
  font-weight: 400;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 6px;
  padding-right: 28px;
  margin: 0;
  flex-shrink: 0;
  cursor: grab;
}

.about-window-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(50vh, 340px);
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.about-window-body::-webkit-scrollbar {
  display: none;
}

.about-window-body p {
  margin: 0;
  text-wrap: pretty;
}

.about-window-body a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.about-window-body a:hover {
  opacity: 0.55;
}

.card-book {
  display: block;
  min-width: 0;
}

.card-book .book-scene {
  /* same 2:3 ratio as shelf listing */
  --bw: 160px;
  --bh: 240px;
}

/* no open/close motion if cover is shown elsewhere */
.card-book .b-image,
.card-book .b-light,
.card-book .b-effect,
.card-book .b-page {
  transition: none !important;
}

.card-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.card-title {
  font-family: var(--font);
  font-weight: 400;
  font-size: var(--size);
  line-height: 1.35;
  letter-spacing: 0;
  text-wrap: balance;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 6px;
}

.card-author {
  margin-top: 10px;
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
  color: var(--ink-soft);
}

.card-meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.card-genres {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.card-genres .g {
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
  padding: 0;
  border-radius: 0;
  color: var(--ink);
  outline: none;
}

.card-notes {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--ink);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.card-notes::-webkit-scrollbar {
  display: none;
}

.card-notes p {
  font-family: var(--font);
  font-size: var(--size);
  font-weight: 400;
  line-height: 1.55;
  color: color-mix(in srgb, var(--ink) 75%, transparent);
  text-wrap: pretty;
  margin-bottom: 10px;
}

.card-notes p.quote {
  font-size: var(--size);
  color: color-mix(in srgb, var(--ink) 65%, transparent);
  padding-left: 12px;
  border-left: 2px solid color-mix(in srgb, var(--ink) 28%, transparent);
  margin-bottom: 8px;
}

.card-notes p.quotes-head {
  font-family: var(--font);
  font-weight: 400;
  font-size: var(--size);
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-soft);
  margin: 14px 0 6px;
}

.stars { position: relative; display: inline-block; font-size: 13px; line-height: 1; letter-spacing: 1.5px; }
.stars .base { color: color-mix(in srgb, var(--ink) 14%, transparent); }
.stars .fill {
  position: absolute;
  inset: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--gold);
}

/* close — inside every modal (book / about / filters), same control */
.modal-close {
  position: absolute;
  top: 0;
  right: 0;
  left: auto;
  z-index: 3;
  box-sizing: border-box;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--ink);
  border-top: none;
  border-right: none;
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  box-shadow: none;
  padding: 0;
  margin: 0;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  line-height: 0;
}

/* fixed square mark — bars rotate around its center */
.modal-close-x {
  position: relative;
  display: block;
  width: 12px;
  height: 12px;
  flex: none;
  pointer-events: none;
}

.modal-close-x::before,
.modal-close-x::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  margin-top: -0.5px;
  background: currentColor;
}

.modal-close-x::before {
  transform: rotate(45deg);
}

.modal-close-x::after {
  transform: rotate(-45deg);
}

.modal-close:focus { outline: none; }

.modal-close:focus-visible {
  outline: none;
}

.modal-close:hover,
.modal-close:active {
  opacity: 1;
}

/* prev / next — footer bar inside modal */
.card-nav {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--ink);
  height: auto;
}

.modal-nav {
  position: static;
  z-index: auto;
  width: auto;
  height: auto;
  min-height: 0;
  display: inline;
  align-items: unset;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  margin: 0;
  outline: none;
  font: inherit;
  font-size: inherit;
  font-weight: 400;
  line-height: 1.35;
  transition: opacity 160ms ease;
}

.modal-nav:focus { outline: none; }

.modal-nav:focus-visible {
  outline: none;
}

.modal-nav:hover { opacity: 0.55; }
.modal-nav:active { opacity: 0.4; }

/* ============ Responsive ============ */

/* tablet */
@media (max-width: 960px) {
  :root { --side-w: 240px; }

  .site-title {
    font-size: clamp(24px, 3.5vw, 30px);
  }

  .shelf {
    padding: 32px 20px 48px;
    column-gap: 20px;
    row-gap: 40px;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    justify-items: center;
  }

  .book-scene {
    --bw: 168px;
    --bh: 252px;
  }
}

/* phone + small tablet */
@media (max-width: 860px) {
  .layout {
    flex-direction: column;
    min-height: 100dvh;
  }

  .side-nav {
    position: static;
    width: 100%;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: none;
    padding: 0;
    overflow: visible;
    z-index: 10;
  }

  /* identical geometry to the homepage's mobile .page (44px top, 20px sides) */
  .side-brand {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 44px 20px 10px;
    padding-top: max(44px, env(safe-area-inset-top));
  }

  /* line 1: title · line 2: search · line 3: Filters */
  .site-title {
    order: 0;
    font-size: 26px;
    line-height: 1.35;
    white-space: normal;
    width: 100%;
  }

  .site-title .title-break {
    display: inline;
  }

  .side-brand .search-wrap {
    order: 1;
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
  }

  .side-brand .brand-bar {
    order: 2;
  }

  .brand-bar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    width: 100%;
    /* hairline above the filters row, not below the bar */
    border-top: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
    padding-top: 10px;
  }

  .side-brand .search-icon {
    opacity: 0.55;
  }

  .side-brand #search {
    width: 100%;
    padding-left: 20px;
    min-width: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--ink) 20%, transparent);
  }

  .side-brand #search::placeholder {
    opacity: 0.55;
  }

  .filters-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    width: auto;
    font-size: 17px; /* matches the menu */
    align-items: center;
    border-bottom: none;
    text-decoration: none;
    padding: 0;
    margin-left: auto;
  }

  .filters-toggle.is-active {
    font-weight: 400;
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  /* mobile: reset next to Filters in the top bar */
  .brand-bar > .filters-reset:not([hidden]) {
    display: inline-flex;
  }

  /* sidebar filters live in the modal on mobile */
  .side-scroll {
    display: none !important;
  }

  .side-head-sort {
    display: flex;
  }

  .side-block {
    margin-top: 22px;
  }

  .link-list {
    gap: 4px;
  }

  .link-item {
    min-height: 36px;
    padding: 6px 0;
  }

  .main {
    width: 100%;
    min-width: 0;
  }

  .shelf {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-items: center;
    column-gap: 12px;
    row-gap: 28px;
    padding: 20px 12px max(40px, env(safe-area-inset-bottom));
    width: 100%;
  }

  .book-scene {
    --bw: min(180px, 44vw);
    --bh: min(270px, 66vw);
    --paper-w: 14px;
  }

  .book-cell {
    gap: 12px;
    width: 100%;
    overflow: visible;
  }

  .book-cell .book-scene {
    width: min(180px, 44vw);
    height: min(270px, 66vw);
  }

  /* ---- modals ---- */
  .about-modal-stage,
  .filters-modal-stage {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    align-items: end;
  }

  @media (min-height: 700px) {
    .about-modal-stage,
    .filters-modal-stage {
      align-items: center;
    }
  }

  .book-window {
    width: min(420px, calc(100vw - 20px));
    height: auto;
    max-height: min(92dvh, calc(100dvh - 16px));
    gap: 14px;
    padding: 18px 18px 16px;
    overflow: visible;
  }

  /* cover on top, text below */
  .book-window-main {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    gap: 14px;
    min-height: 0;
    overflow: visible;
    align-items: stretch;
  }

  .book-window .card-book {
    justify-content: center;
    padding: 12px 8px 10px;
  }

  .book-window .card-book .book-scene {
    --bw: min(68px, 20vw);
    --bh: min(102px, 30vw);
    width: min(68px, 20vw);
    height: min(102px, 30vw);
  }

  .book-window .card-body {
    overflow: visible;
    max-height: none;
  }

  .book-window .card-title {
    padding-right: 32px;
  }

  .book-window .card-notes {
    max-height: min(42dvh, 360px);
    flex: 1 1 auto;
  }

  .book-window .card-nav {
    margin-top: 0;
  }

  .about-window {
    width: min(360px, calc(100vw - 24px));
    height: auto;
    max-height: none;
    padding: 20px;
    overflow: visible;
  }

  .about-window-body {
    max-height: min(45vh, 300px);
  }

  .filters-modal-card {
    width: 100%;
    max-width: 100%;
    max-height: min(85dvh, 640px);
    padding: 22px 40px 24px 20px;
  }

  .filters-modal-body {
    max-height: min(62dvh, 520px);
  }

  .filters-modal-body .side-block:first-child {
    margin-top: 2px;
  }

  .float-window > .modal-close,
  .filters-modal-card > .modal-close {
    top: 0;
    right: 0;
    left: auto;
    width: 36px;
    height: 36px;
  }

  .modal-nav {
    min-height: 0;
    height: auto;
    padding: 0;
    margin: 0;
  }
}

/* very small phones */
@media (max-width: 380px) {
  .shelf {
    column-gap: 10px;
    row-gap: 22px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .site-title { font-size: 22px; }

  .side-brand {
    padding-left: 20px;
    padding-right: 20px;
  }

  .side-scroll {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* ============ Reduced motion ============ */

@media (prefers-reduced-motion: reduce) {
  .book-cell { transition: none; }
  .book-3d,
  .b-page,
  .b-back { transition: none; }
  .book-window { transition: none; }
  .about-modal-card { transition: opacity 220ms ease; transform: none; }
}

/* site header comes from shared.css; only page-specific spacing here */
.site-head { margin-bottom: 0; }

/* ============================================================
   Homepage-aligned layout: header + filters on TOP, shelf under
   (≤860px keeps the existing mobile top layout + filters modal)
   ============================================================ */

@media (min-width: 861px) {
  .layout { display: block; }

  .side-nav {
    position: static;
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    padding: 48px 48px 0;
  }

  .side-brand {
    display: block;
    padding: 0 0 8px;
  }

  .side-scroll {
    overflow: visible;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0 40px;
    align-items: start;
    width: 100%;
    margin-top: 56px;
  }

  .side-block {
    margin: 0;
    position: relative;
  }

  .side-scroll > .side-block:first-child { margin-top: 0; }

  .side-head-sort { display: flex; }

  .side-head,
  .side-head-sort {
    margin: 0;
  }

  /* exposed columns: options visible under each heading */
  .side-block .link-list {
    padding-top: 8px;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  /* headings are labels, not toggles */
  summary.side-head {
    pointer-events: none;
    cursor: default;
  }

  summary.side-head::after { content: none; }
}

/* details/summary dropdown chrome (all widths) */
summary.side-head {
  cursor: pointer;
  list-style: none;
}

summary.side-head::-webkit-details-marker { display: none; }


@media (min-width: 861px) {
  /* fixed-width book tracks spread edge to edge:
     first column flush left, last column flush right */
  .shelf {
    padding: 64px 48px 56px;
    grid-template-columns: repeat(auto-fill, 188px);
    justify-content: space-between;
    justify-items: start;
  }
}


/* ============================================================
   Modal scroll clarity: visible thin scrollbars, no hidden caps
   ============================================================ */

/* the head row only exists when Reset is showing */
.filters-modal-head:not(:has(.filters-reset:not([hidden]))) {
  display: none;
}

.filters-modal-card {
  font-size: 17px;
  max-height: min(86vh, 760px);
  /* symmetric padding — the old 44px right gutter pushed the scrollbar
     toward the middle and left a dead strip on the right */
  padding: 24px 24px 28px;
}

.filters-modal-body {
  max-height: min(70vh, 640px);
  /* scrollbar hugs the card edge instead of the content */
  margin-right: -14px;
  padding-right: 14px;
}

.filters-modal-body,
.card-notes,
.about-window-body,
.book-window-main,
.side-block .link-list {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filters-modal-body::-webkit-scrollbar,
.card-notes::-webkit-scrollbar,
.about-window-body::-webkit-scrollbar,
.book-window-main::-webkit-scrollbar,
.side-block .link-list::-webkit-scrollbar {
  display: none;
}

/* Transitions.dev — Card resize (next/prev book height tween) */
:root {
  --resize-dur: 300ms;
  --resize-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.t-resize {
  transition:
    width  var(--resize-dur) var(--resize-ease),
    height var(--resize-dur) var(--resize-ease),
    top    var(--resize-dur) var(--resize-ease);
  will-change: height;
}

@media (prefers-reduced-motion: reduce) {
  .t-resize { transition: none !important; }
}

/* filter headings + their underlines in the secondary color */
.side-head {
  border-bottom-color: color-mix(in srgb, var(--ink) 15%, transparent);
  color: var(--ink-soft);
}

.side-head h2 { color: var(--ink-soft); }

/* book windows grow with their content; the window's max-height is the
   only cap, so long notes get a much taller scroll area */
.book-window {
  max-height: min(88vh, calc(100vh - 40px));
}

.book-window .card-notes {
  max-height: none;
}

@media (max-width: 860px) {
  .book-window .card-notes {
    max-height: none;
  }
}

/* ============================================================
   Book window top bar: prev/next icons left, close right —
   ghost buttons, no borders, replaces the bottom nav
   ============================================================ */

.book-window .window-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 4; /* above the drag strip */
  margin: -8px -8px 0;
}

.window-bar-nav {
  display: flex;
  gap: 2px;
}

.book-window .modal-nav,
.book-window .modal-close {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  color: var(--ink);
  opacity: 0.55;
  cursor: pointer;
}

.book-window .modal-nav:hover,
.book-window .modal-close:hover {
  opacity: 1;
  background: transparent;
}

/* svg icon buttons: center the icon in every close/nav button */
.modal-close,
.modal-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal-close svg,
.modal-nav svg {
  display: block;
}

/* wider book window + label/value metadata rows */
.book-window {
  width: min(680px, calc(100vw - 32px));
  max-width: 680px;
}

.card-meta-rows {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 4px 24px;
  align-items: baseline;
  margin-top: 10px;
}

.meta-row {
  display: contents;
}

.meta-label {
  color: var(--ink-soft);
}

.meta-value {
  color: var(--ink);
}

.meta-value.card-author {
  margin: 0;
  color: var(--ink);
}

/* book title leads the window */
.book-window .card-title {
  font-size: 26px;
  line-height: 1.3;
}

@media (max-width: 860px) {
  .book-window .card-title {
    font-size: 26px;
  }
}

/* bigger cover in the book window, with a real shadow */
.book-window .card-book .book-scene {
  --bw: 168px;
  --bh: 252px;
  width: 168px;
  height: 252px;
}

.book-window .b-image {
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.18),
    0 14px 28px rgba(0, 0, 0, 0.14);
}

/* meta rows share one rhythm; genres row had a stray extra margin */
.meta-value.card-genres {
  margin-top: 0;
}

/* cover column matches the bigger cover */
.book-window-main {
  grid-template-columns: 168px minmax(0, 1fr);
}

/* airier window sections with super-light divider lines */
.book-window .card-title {
  border-bottom-color: color-mix(in srgb, var(--ink) 15%, transparent);
  padding-bottom: 14px;
}

.card-meta-rows {
  margin-top: 16px;
}

.book-window .card-notes {
  border-top: none;
  margin-top: 24px;
  padding-top: 0;
}

/* the rule sits above the scroll area so the fade can't erase it */
.book-window .card-meta-rows {
  padding-bottom: 20px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 15%, transparent);
}

.book-window .card-meta-rows { margin-top: 12px; }

/* footer sits in the shelf's gutter */
.main .footer {
  margin-top: 0;
  padding: 0 48px 40px;
}

@media (max-width: 860px) {
  .main .footer {
    padding: 0 20px 32px;
  }
}


/* star rows (Bootstrap icons) */
.star-row {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  line-height: 1;
}

.star-row svg {
  display: block;
  flex: none;
}

.link-item .star-row { color: var(--ink); }

/* window bar: nav left, link + close right */
.window-bar-right {
  display: flex;
  align-items: center;
  gap: 2px;
}

.modal-nav.copy-link.copied { opacity: 1; }

/* "Link copied" confirmation under the share button */
.modal-nav.copy-link {
  position: relative;
}

.modal-nav.copy-link[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  padding: 4px 8px;
  background: var(--ink);
  color: var(--modal-bg);
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  border-radius: 4px;
  pointer-events: none;
  animation: tip-in 160ms ease-out both;
}

@keyframes tip-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-nav.copy-link[data-tip]::after { animation: none; }
}

/* the whole window is a drag surface; controls and text keep their cursors */
.float-window { cursor: grab; }
.float-window:active { cursor: grabbing; }
.float-window button,
.float-window a { cursor: pointer; }
.float-window .card-notes,
.float-window .card-title,
.float-window .card-meta-rows { cursor: auto; }

/* rating filter: the active row reads at full strength, the rest recede */
#rating-list .link-item {
  opacity: 0.45;
  transition: opacity 140ms ease;
}

#rating-list .link-item:hover,
#rating-list .link-item.active {
  opacity: 1;
}



/* back to top */
.scroll-top {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--modal-bg);
  border: 1px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  opacity: 0;
  translate: 0 6px;
  transition: opacity 180ms ease, translate 180ms ease;
}

.scroll-top svg {
  display: block;
  width: 18px;
  height: 18px;
}

.scroll-top.is-visible {
  opacity: 1;
  translate: 0 0;
}

.scroll-top:hover { translate: 0 -2px; }

.scroll-top:focus-visible {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-top { transition: none; }
}

/* detail window: same book as the shelf, minus the layers that stick out */
.book-window .card-book .b-back-cover,
.book-window .card-book .b-inside {
  display: none;
}

/* ============================================================
   Mobile: the window is a fixed sheet. It never scrolls itself —
   the card paints its face and striped shadow with absolutely
   positioned layers, so scrolling it would drag the face away
   from the content. The content column scrolls instead.
   ============================================================ */

@media (max-width: 860px) {
  .book-window {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    top: 50% !important;
    bottom: auto !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    /* hug short content; only tall content fills the viewport */
    max-height: calc(100dvh - 24px) !important;
    transform: translateY(-50%) !important;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 16px;
    overflow: visible;
    cursor: default;
  }

  .book-window .book-window-main.scroll-fade {
    --fade-size: 18px;
  }

  /* the one scroll surface inside the sheet */
  .book-window .book-window-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-right: 2px;
  }

  /* notes flow with that column rather than scrolling separately,
     so the edge-fade mask that belongs to a scroll area must go */
  .book-window .card-notes {
    max-height: none;
    overflow: visible;
  }

  /* no dangling space after the last paragraph */
  .book-window .card-notes > *:last-child {
    margin-bottom: 0;
  }

  .book-window .card-notes blockquote:last-child,
  .book-window .card-notes p:last-child {
    margin-bottom: 0;
  }

  .book-window .card-notes.scroll-fade,
  .book-window .card-notes.fade-top,
  .book-window .card-notes.fade-bottom,
  .book-window .card-notes.fade-both {
    -webkit-mask-image: none;
    mask-image: none;
  }

  /* the bar sits above the scroll area on an opaque strip, so content
     is cut off cleanly at the hairline instead of showing through */
  .book-window .window-bar {
    position: relative;
    z-index: 6;
    flex: none;
    margin: 0;
    padding: 0 0 8px;
    background: var(--modal-bg);
    border-bottom: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
  }

  .book-window .window-drag { display: none; }
}

body.window-open {
  overflow: hidden;
}

/* metadata reads as supporting detail, not body copy */
.card-meta-rows {
  font-size: 15px;
}

.card-meta-rows .star-row svg {
  width: 13px;
  height: 13px;
}

/* the back-to-top control gets out of the way of an open window */
body.window-open .scroll-top {
  opacity: 0;
  pointer-events: none;
}

/* hairline under the window controls */
.book-window .window-bar {
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
  padding-bottom: 8px;
}


/* author leads the card, at body size, above the title */
.book-window .card-author {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink-soft);
}

/* rating and finished date share a line under the title */
.card-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 15px;
  color: var(--ink-soft);
}

.card-line .star-row svg {
  width: 13px;
  height: 13px;
}

.card-line .card-date { color: var(--ink-soft); }

/* title: balanced line breaks, room on the right, no rule beneath */
.book-window .card-title {
  border-bottom: none;
  padding-bottom: 0;
}

.card-line { gap: 16px; }


/* author sits quietly above the title */
.book-window .card-author {
  font-size: 15px;
}

.book-window .card-title {
  margin: 10px 0 12px 0;
}

.card-line { margin-top: 0; }

.book-window .card-title {
  padding-right: 0;
}

/* genres on the meta line */
.card-line .card-genres {
  display: inline-flex;
  align-items: baseline;
  margin: 0;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.card-line .card-genres,
.card-line .card-genres .g {
  font-size: inherit;
  line-height: inherit;
  color: var(--ink-soft);
}

.card-line .card-genres .g {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-more {
  color: var(--ink-soft);
  cursor: help;
  white-space: nowrap;
}

/* body-level tooltip: never clipped by the window */
.tip-pop {
  position: fixed;
  z-index: 500;
  max-width: min(260px, 80vw);
  padding: 6px 9px;
  background: var(--ink);
  color: var(--modal-bg);
  font-size: 13px;
  line-height: 1.35;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.tip-pop.is-visible { opacity: 1; }

/* the hairline now sits under the meta line */
.book-window .card-line {
  padding-bottom: 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 15%, transparent);
}

.book-window .card-genres {
  margin-top: 0;
}

@media (max-width: 860px) {
  /* stars, date and genres stack instead of crowding one line */
  .book-window .card-line {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

/* desktop: only the first genre, the rest live in the +N tooltip */
.card-line .card-genres .g-extra {
  display: none;
}

@media (max-width: 860px) {
  /* mobile has the room: show every genre, drop the chip */
  .card-line .card-genres .g-extra { display: inline; }
  .card-line .g-more { display: none; }

  /* rating and date share a line; genres wrap to the next */
  .book-window .card-line {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
  }

  .book-window .card-line .card-genres {
    flex: 0 0 100%;
    flex-wrap: wrap;
    gap: 4px 12px;
  }
}
