/* Books I've read — a theme-reactive bookshelf, embedded in the page.
   Scoped under .bookcase so nothing leaks into the rest of the garden.
   Colours derive from Quartz's Flexoki vars (--light/--dark/--gray/...),
   so the whole thing follows light/dark automatically. */

.bookcase {
  --gap: clamp(14px, 2.4vw, 34px);
  --bookmax: clamp(104px, 15vw, 168px);
  --radius: 2px;

  /* theme-local tokens (light defaults) */
  --shelf-face: #e7e0cd;
  --shelf-edge: #cfc6ad;
  --shelf-top: rgba(255, 255, 255, 0.6);
  --contact: rgba(16, 15, 15, 0.30);
  --glow: 0.55;

  display: flex;
  flex-direction: column;
  gap: clamp(30px, 4.5vw, 56px);
  margin: 2rem 0 1.5rem;
  /* a gentle breakout so the shelf breathes wider than the prose column */
  width: min(108%, 1040px);
  margin-inline: 50%;
  transform: translateX(-50%);
}

:root[saved-theme="dark"] .bookcase {
  --shelf-face: #2b2926;
  --shelf-edge: #1c1a18;
  --shelf-top: rgba(255, 252, 240, 0.06);
  --contact: rgba(0, 0, 0, 0.6);
  --glow: 0.75;
}

.shelf {
  position: relative;
}

.shelf-books {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, var(--bookmax)));
  justify-content: center;
  align-items: end;
  gap: var(--gap);
  padding: 0 6px 8px;
}

/* ---- a single book ---- */
.book {
  position: relative;
  justify-self: center;
  width: 100%;
  max-width: var(--bookmax);
  transform-origin: bottom center;
  transition: transform 0.4s cubic-bezier(0.2, 0.85, 0.25, 1);
  cursor: pointer;
}

/* covers keep their natural proportions (some are square, some portrait) */
.book img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: 0 5px 14px -10px var(--contact);
  transition: box-shadow 0.4s ease;
}

/* coloured glow halo, keyed to each cover's dominant colour (--accent) */
.book::before {
  content: "";
  position: absolute;
  inset: -30% -26% -16%;
  background: radial-gradient(ellipse at center 48%, var(--accent, var(--tertiary)), transparent 70%);
  border-radius: 50%;
  opacity: 0;
  filter: blur(20px);
  transform: scale(0.72);
  transition: opacity 0.45s ease, transform 0.45s ease;
  z-index: -2;
  pointer-events: none;
}

/* ---- hover: lift, glow, reveal ---- */
.book:hover {
  transform: translateY(-16px) scale(1.05);
  z-index: 8;
}
.book:hover img {
  box-shadow: 0 16px 30px -16px var(--contact);
}
.book:hover::before {
  opacity: var(--glow);
  transform: scale(1.06);
}

/* ---- the shelf plank ---- */
.shelf-ledge {
  height: 11px;
  border-radius: 1px 1px 3px 3px;
  background: linear-gradient(var(--shelf-face), var(--shelf-edge));
  box-shadow:
    0 1px 0 var(--shelf-top) inset,
    0 14px 26px -10px var(--contact);
  margin-top: -5px;
}

/* ---- hover info card ---- */
.book-info {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translate(-50%, 8px);
  width: max-content;
  max-width: 210px;
  text-align: center;
  background: color-mix(in srgb, var(--light) 86%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid var(--lightgray);
  border-radius: 9px;
  padding: 8px 12px 9px;
  box-shadow: 0 10px 26px -10px var(--contact);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s ease, transform 0.32s ease;
  z-index: 9;
}
.book:hover .book-info {
  opacity: 1;
  transform: translate(-50%, 0);
}
.book-info .bi-stars {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 1.5px;
  line-height: 1;
  margin-bottom: 4px;
}
.bi-star {
  color: #e0a912;
}
.bi-star.empty {
  color: var(--lightgray);
}
.bi-unrated {
  color: var(--gray);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.book-info .bi-title {
  display: block;
  font-weight: 650;
  font-size: 0.82rem;
  line-height: 1.18;
  color: var(--dark);
}
.book-info .bi-author {
  display: block;
  font-size: 0.72rem;
  color: var(--gray);
  margin-top: 1px;
}
.book-info .bi-meta {
  display: block;
  font-size: 0.64rem;
  color: var(--gray);
  margin-top: 5px;
  letter-spacing: 0.02em;
}
/* little pointer under the card */
.book-info::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-1px);
  border: 6px solid transparent;
  border-top-color: color-mix(in srgb, var(--light) 86%, transparent);
}

/* ============================================================
   Currently reading — a featured book that sits above the shelf.
   Same glow language as the shelf, but always-on and roomier.
   ============================================================ */
.now-reading {
  --nr-cover: clamp(120px, 26vw, 184px);
  display: flex;
  align-items: center;
  gap: clamp(20px, 4vw, 40px);
  width: min(108%, 1040px);
  margin: 1.5rem 0 0.5rem;
  margin-inline: 50%;
  transform: translateX(-50%);
}

.nr-book {
  position: relative;
  flex: 0 0 auto;
  width: var(--nr-cover);
  margin: 0;
}
.nr-book img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
  box-shadow: 0 10px 30px -12px var(--contact);
  transition: transform 0.45s cubic-bezier(0.2, 0.85, 0.25, 1);
}
/* accent glow — hidden by default, blooms on hover (matches the shelf) */
.nr-book::before {
  content: "";
  position: absolute;
  inset: -22% -20% -14%;
  background: radial-gradient(ellipse at center 48%, var(--accent, var(--tertiary)), transparent 70%);
  border-radius: 50%;
  filter: blur(22px);
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 0.45s ease, transform 0.45s ease;
  z-index: -2;
  pointer-events: none;
}
.nr-book:hover::before {
  opacity: calc(var(--glow) * 0.7);
  transform: scale(1.04);
}
.nr-book:hover img {
  transform: translateY(-6px) scale(1.03);
}

.nr-body {
  min-width: 0;
}
.nr-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent, var(--secondary));
}
/* the little "live" pulse dot */
.nr-eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent, var(--secondary));
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent);
  animation: nr-pulse 2.4s ease-out infinite;
}
@keyframes nr-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.nr-title {
  margin: 0.4rem 0 0;
  font-size: clamp(1.3rem, 3.4vw, 1.85rem);
  line-height: 1.12;
  color: var(--dark);
}
.nr-author {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.92rem;
  color: var(--gray);
}
.nr-blurb {
  margin: 0.85rem 0 0;
  font-style: italic;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--darkgray);
  max-width: 42ch;
}

@media (max-width: 750px) {
  .bookcase {
    width: 100%;
    margin-inline: 0;
    transform: none;
  }
  .now-reading {
    width: 100%;
    margin-inline: 0;
    transform: none;
    gap: 20px;
  }
}
