/* =============================================================================
   Bookshelf page styles — inherits from styles.css (variables, brand gradient,
   nav, footer). Scoped additions only.
   ============================================================================= */

/* ---------- Stats row inside page-header ---------- */
.bookshelf-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin-top: 28px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.bookshelf-stats strong { color: var(--text); font-weight: 600; }
.bookshelf-stats .stat-sep { color: var(--text-dim); opacity: 0.5; }

/* ---------- Controls (filter chips + search) ---------- */
.bookshelf-controls-wrap {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}
.bookshelf-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.bookshelf-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Filter chips use site-standard .filter-chip style; add compact count span */
.filter-chip .chip-count {
  margin-left: 6px;
  font-size: 10px;
  font-weight: 500;
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
}
.filter-chip { cursor: pointer; }

.bookshelf-search {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
  max-width: 300px;
}
.bookshelf-search svg {
  position: absolute;
  left: 12px;
  color: var(--text-dim);
  pointer-events: none;
}
.bookshelf-search input {
  width: 100%;
  padding: 10px 14px 10px 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.bookshelf-search input::placeholder { color: var(--text-dim); }
.bookshelf-search input:focus {
  border-color: var(--blue-deep);
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.15);
}
@media (max-width: 640px) {
  .bookshelf-search { max-width: 100%; }
}

/* ---------- Split layout ---------- */
.bookshelf-body {
  padding: 36px 0 80px;
}
.bookshelf-split {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 48px;
}
@media (max-width: 1023px) {
  .bookshelf-split {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* ---------- Grid of covers ---------- */
.bookshelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 40px 20px;
}
@media (max-width: 560px) {
  .bookshelf-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 28px 14px;
  }
}

/* Skeleton placeholders while data loads */
.bookshelf-skeleton {
  display: contents;
}
.bookshelf-skeleton > div {
  aspect-ratio: 2 / 3;
  border-radius: 3px;
  background: linear-gradient(180deg, #0c1824, #07131c);
  animation: bs-pulse 1.6s ease-in-out infinite;
}
@keyframes bs-pulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 0.9; }
}

/* Cover tile */
.bs-tile {
  position: relative;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
  outline: none;
  animation: bs-fade-in 420ms ease-out both;
}
@keyframes bs-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.bs-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 3px;
  overflow: hidden;
  background: #0e1a26;
  box-shadow: 0 10px 22px -12px rgba(0,0,0,0.9), 0 2px 6px -2px rgba(0,0,0,0.6);
  transition: transform 180ms ease, box-shadow 220ms ease;
}
.bs-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), inset 0 -30px 40px -30px rgba(0,0,0,0.7);
  pointer-events: none;
  border-radius: inherit;
}
.bs-tile:hover .bs-cover { transform: translateY(-3px); }

.bs-tile.is-selected .bs-cover {
  transform: scale(1.02);
  box-shadow: 0 18px 50px -18px rgba(201, 137, 58, 0.35), 0 6px 16px -8px rgba(0,0,0,0.9);
}
.bs-tile.is-selected .bs-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 2px;
  border-radius: inherit;
  background: linear-gradient(
    135deg,
    #0077a8 0%,
    #00b4d8 22%,
    #48cae4 42%,
    #a06828 68%,
    #c9893a 85%,
    #e8a44a 100%
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 2;
}

.bs-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 400ms ease;
  display: block;
}
.bs-cover img.is-loaded { opacity: 1; }

/* Fallback cover when no ISBN image available */
.bs-cover.is-fallback {
  background: linear-gradient(155deg, #12202e 0%, #0a1520 60%, #060e17 100%);
}
.bs-cover.is-fallback .bs-fallback-inner {
  position: absolute;
  inset: 0;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.bs-cover.is-fallback .bs-fallback-year {
  font-family: var(--font-ui);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--blue-glow);
  opacity: 0.9;
}
.bs-cover.is-fallback .bs-fallback-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.15;
  color: rgba(232, 244, 248, 0.95);
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bs-cover.is-fallback .bs-fallback-author {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 11px;
  color: rgba(232, 244, 248, 0.55);
  margin-top: 6px;
}
.bs-cover.is-fallback::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, rgba(72,202,228,0.55), transparent);
  z-index: 1;
  pointer-events: none;
}

/* Rating chip on hover */
.bs-tile .bs-rating-chip {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  background: rgba(0, 10, 17, 0.72);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  border-radius: 3px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
  opacity: 0;
  transition: opacity 200ms ease;
  z-index: 3;
}
.bs-tile.is-selected .bs-rating-chip,
.bs-tile:hover .bs-rating-chip { opacity: 1; }
.bs-tile .bs-rating-chip svg { color: var(--blue-glow); }

/* Caption under cover */
.bs-caption {
  margin-top: 12px;
  padding: 0 2px;
}
.bs-caption .bs-title {
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  color: rgba(232, 244, 248, 0.9);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bs-caption .bs-author {
  margin-top: 2px;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Focus ring */
.bs-tile:focus-visible {
  outline: 2px solid var(--blue-glow);
  outline-offset: 3px;
  border-radius: 4px;
}

/* End of shelf + empty state */
.bookshelf-end {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.bookshelf-empty {
  text-align: center;
  padding: 80px 20px;
}
.bookshelf-empty-title {
  font-family: var(--font-serif);
  font-size: 20px;
  color: rgba(232, 244, 248, 0.85);
}
.bookshelf-empty-sub {
  margin-top: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Detail pane (desktop) ---------- */
.bookshelf-detail-pane {
  display: block;
}
@media (max-width: 1023px) {
  .bookshelf-detail-pane { display: none; }
}
.bookshelf-detail {
  position: sticky;
  top: 88px;
  background: linear-gradient(180deg, var(--surface) 0%, #021520 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 620px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}

/* Empty state art */
.bookshelf-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  text-align: center;
}
.bookshelf-detail-empty-art .book-mark {
  position: relative;
  width: 120px;
  height: 88px;
  display: flex;
  gap: 3px;
}
.book-mark > span {
  flex: 1;
  background: linear-gradient(160deg, #0e1a26, #07131c);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px var(--border-hover);
}
.book-mark .seam {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: linear-gradient(to bottom, #00b4d8, #c9893a);
  opacity: 0.65;
  transform: translateX(-50%);
}
.bookshelf-detail-empty-title {
  margin-top: 28px;
  font-family: var(--font-serif);
  font-size: 21px;
  color: rgba(232, 244, 248, 0.9);
}
.bookshelf-detail-empty-sub {
  margin-top: 10px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-muted);
}

/* Detail content */
.bs-detail {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.bs-detail-head {
  padding: 28px 28px 22px;
}
.bs-detail-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 22px;
}
.bs-detail-eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--border-hover);
}
.bs-detail-hero {
  display: flex;
  gap: 22px;
}
.bs-detail-cover {
  position: relative;
  flex-shrink: 0;
  width: 128px;
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  overflow: hidden;
  background: #0e1a26;
  box-shadow: 0 20px 40px -20px rgba(0,0,0,0.9), 0 6px 14px -6px rgba(0,0,0,0.8);
  box-shadow: 0 20px 40px -20px rgba(0,0,0,0.9), 0 6px 14px -6px rgba(0,0,0,0.8), inset 0 0 0 1px rgba(255,255,255,0.06);
}
.bs-detail-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.bs-detail-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.bs-detail-title {
  font-family: var(--font-serif);
  font-size: clamp(22px, 2.2vw, 32px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
}
.bs-detail-author {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 6px;
}
.bs-detail-stars {
  display: flex;
  gap: 3px;
  margin-top: 18px;
}
.bs-detail-stars svg { flex-shrink: 0; }
.bs-detail-unrated {
  margin-top: 8px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.bs-detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}
.bs-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.bs-detail-divider {
  height: 1px;
  margin: 0 28px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
}

.bs-detail-review {
  padding: 24px 28px 28px;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}
.bs-detail-review::-webkit-scrollbar { width: 8px; }
.bs-detail-review::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 999px; }
.bs-detail-review-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.bs-detail-review-body {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.65;
  color: #d6dde6;
}
.bs-detail-review-body p { margin: 0 0 1em; }
.bs-detail-review-body p:last-child { margin-bottom: 0; }
.bs-detail-review-empty {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-muted);
}
.bs-detail-goodreads {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.bs-detail-goodreads a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.bs-detail-goodreads a:hover { color: var(--blue-glow); }
.bs-detail-goodreads a svg { transition: transform var(--t-fast); }
.bs-detail-goodreads a:hover svg { transform: translateX(2px); }

/* ---------- Mobile modal ---------- */
.bookshelf-modal[hidden] { display: none; }
.bookshelf-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.bookshelf-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 4, 8, 0.72);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
}
.bookshelf-modal-panel {
  position: relative;
  width: 100%;
  max-height: 94vh;
  background: linear-gradient(180deg, var(--surface) 0%, #021520 100%);
  border-top: 1px solid var(--border-hover);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -30px 60px -20px rgba(0, 0, 0, 0.8);
  overflow-y: auto;
  animation: bs-slide-up 320ms cubic-bezier(.2,.8,.2,1) both;
}
@keyframes bs-slide-up {
  from { transform: translateY(100%); opacity: 0.6; }
  to   { transform: translateY(0); opacity: 1; }
}
.bookshelf-modal-grabber {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-hover);
}
.bookshelf-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(11, 22, 32, 0.8);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--t-fast);
}
.bookshelf-modal-close:hover { background: rgba(11, 22, 32, 1); }
.bookshelf-modal-body { padding-top: 18px; }
