/* ═══════════════════════════════════════════════════════════════
   FEATURED SHELF — 3D CSS BOOKSHELF COMPONENT
   ═══════════════════════════════════════════════════════════════ */

/* ── Section Container ────────────────────────────────────────── */
.cs-featured-shelf {
  padding: 4rem 0 5rem;
  background: linear-gradient(180deg, #fdf6ec 0%, #faf4e8 40%, #f5ebe0 100%);
  position: relative;
  overflow: visible;
}

.cs-featured-shelf::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: radial-gradient(ellipse at center top, rgba(196,112,30,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.cs-featured-shelf__wrapper {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.cs-featured-shelf .section-heading {
  text-align: center;
  margin-bottom: 0.75rem;
}

.cs-featured-shelf .shelf-ornament {
  color: #c4701e;
  font-size: 1.25rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* ── Shelf Container ──────────────────────────────────────────── */
.cs-shelf-container {
  position: relative;
  margin-top: 1rem;
  padding: 1rem 1rem 0;
  overflow: visible;
}

.cs-shelf-glow {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 100%;
  background: radial-gradient(ellipse at center 30%, rgba(255,248,235,0.9) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Books Row ────────────────────────────────────────────────── */
.cs-books-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem; /* Tooltip shows above books */
  position: relative;
  z-index: 2;
  flex-wrap: nowrap;
  overflow: visible;
  perspective: 800px;
  perspective-origin: center bottom;
}

/* Desktop/Mobile visibility */
.cs-books-row--mobile,
.cs-shelf-board--mobile {
  display: none;
}

.cs-books-row--desktop,
.cs-shelf-board--desktop {
  display: flex;
}

.cs-shelf-board--desktop {
  display: block;
}

/* ── Bookends ─────────────────────────────────────────────────── */
.cs-bookend {
  flex-shrink: 0;
  width: 20px;
  min-height: 180px;
  align-self: stretch;
  position: relative;
  border-radius: 3px;
}

.cs-bookend--left {
  background: linear-gradient(135deg, #a0703a 0%, #8b5e3c 40%, #5c3d1e 100%);
  box-shadow: 
    4px 3px 12px rgba(0,0,0,0.3),
    inset -2px 0 6px rgba(0,0,0,0.15),
    inset 2px 0 4px rgba(255,255,255,0.12);
}

.cs-bookend--right {
  background: linear-gradient(-135deg, #a0703a 0%, #8b5e3c 40%, #5c3d1e 100%);
  box-shadow: 
    -4px 3px 12px rgba(0,0,0,0.3),
    inset 2px 0 6px rgba(0,0,0,0.15),
    inset -2px 0 4px rgba(255,255,255,0.12);
}

/* ── Individual Book ──────────────────────────────────────────── */
.cs-book {
  --book-color: #6b2d3e;
  --book-text: #f5e9ce;
  --book-height: 200px;
  --book-width: 50px;
  
  position: relative;
  width: var(--book-width);
  height: var(--book-height);
  flex-shrink: 0;
  cursor: pointer;
  outline: none;
  z-index: 1;
  transform-style: preserve-3d;
  transform-origin: center bottom;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), z-index 0s 0.4s;
}

/* Hover/Active States - Book pulls forward from shelf */
.cs-book:hover,
.cs-book:focus-visible,
.cs-book.is-active {
  transform: scale(1.08) translateY(-12px);
  z-index: 20;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), z-index 0s;
}

.cs-book:focus-visible {
  outline: 3px solid #c4701e;
  outline-offset: 4px;
  border-radius: 3px;
}

/* Glow under book on hover/active */
.cs-book::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: -10px;
  right: -10px;
  height: 20px;
  background: radial-gradient(ellipse at center, rgba(196,112,30,0.5) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  filter: blur(5px);
  z-index: -1;
}

.cs-book:hover::after,
.cs-book:focus-visible::after,
.cs-book.is-active::after {
  opacity: 1;
}

/* ── Book Body ────────────────────────────────────────────────── */

/* ── Book Spine (The visible front of the book) ───────────────── */
.cs-book__spine {
  position: absolute;
  inset: 0;
  background: var(--book-color);
  border-radius: 3px 5px 5px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 0.25rem;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 
    3px 3px 10px rgba(0,0,0,0.35),
    inset -3px 0 8px rgba(0,0,0,0.15),
    inset 3px 0 6px rgba(255,255,255,0.08);
}

/* Left edge highlight */
.cs-book__spine::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, 
    rgba(255,255,255,0.25) 0%,
    rgba(255,255,255,0.1) 50%,
    rgba(0,0,0,0.05) 100%
  );
  border-radius: 3px 0 0 3px;
}

/* Right edge shadow */
.cs-book__spine::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: rgba(0,0,0,0.2);
  border-radius: 0 5px 5px 0;
}

.cs-book__spine-author {
  font-family: 'Lora', serif;
  font-size: 0.5rem;
  font-style: italic;
  color: var(--book-text);
  opacity: 0.75;
  text-align: center;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  transform: rotate(180deg);
  max-height: 32%;
  overflow: hidden;
  line-height: 1.2;
}

.cs-book__spine-ornament {
  color: var(--book-text);
  opacity: 0.4;
  font-size: 0.75rem;
}

.cs-book__spine-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--book-text);
  text-align: center;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  transform: rotate(180deg);
  max-height: 52%;
  overflow: hidden;
  line-height: 1.3;
}

/* ── Info Panel ───────────────────────────────────────────────── */
.cs-book__info {
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-bottom: 15px;
  transform: translateX(-50%) scale(0.92);
  width: 220px;
  padding: 1.1rem 1.25rem;
  background: linear-gradient(145deg, #3d2814 0%, #2a1a0a 100%);
  border-radius: 10px;
  color: #f5f0e8;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.3s;
  box-shadow: 
    0 12px 35px rgba(0,0,0,0.45),
    0 0 0 1px rgba(196,112,30,0.25),
    inset 0 1px 0 rgba(255,255,255,0.08);
  z-index: 100;
}

.cs-book__info::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #2a1a0a;
}

/* Show info on hover/focus/active */
.cs-book:hover .cs-book__info,
.cs-book:focus-visible .cs-book__info,
.cs-book.is-active .cs-book__info {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

.cs-book__info-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  color: #fff;
  line-height: 1.3;
}

.cs-book__info-author {
  font-family: 'Lora', serif;
  font-size: 0.82rem;
  font-style: italic;
  color: #c4701e;
  margin: 0 0 0.6rem;
}

.cs-book__info-desc {
  font-family: 'Lora', serif;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #e0d8c8;
  margin: 0 0 0.85rem;
}

.cs-book__info-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Lora', serif;
  font-size: 0.8rem;
  color: #d4a830;
  text-decoration: none;
  padding: 0.4rem 0.9rem;
  border: 1px solid rgba(212,168,48,0.4);
  border-radius: 20px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.cs-book__info-link:hover,
.cs-book__info-link:focus {
  background: rgba(212,168,48,0.18);
  border-color: #d4a830;
  color: #f0d860;
}

/* ── Wooden Shelf Board ───────────────────────────────────────── */
.cs-shelf-board {
  position: relative;
  z-index: 1;
  margin-top: 0;
}

.cs-shelf-board__top {
  height: 10px;
  background: linear-gradient(90deg,
    #6b4423 0%, #8b5e3c 10%, #a67c52 30%, #8b5e3c 50%, #a67c52 70%, #8b5e3c 90%, #6b4423 100%
  );
  border-radius: 3px 3px 0 0;
  box-shadow: 
    inset 0 2px 3px rgba(255,255,255,0.18),
    inset 0 -1px 3px rgba(0,0,0,0.08);
}

.cs-shelf-board__front {
  height: 20px;
  background: linear-gradient(180deg, #8b5e3c 0%, #6b4423 40%, #5c3d1e 100%);
  border-radius: 0 0 5px 5px;
  box-shadow: 
    inset 0 2px 5px rgba(0,0,0,0.25),
    0 4px 10px rgba(0,0,0,0.18);
  position: relative;
}

.cs-shelf-board__front::before {
  content: '';
  position: absolute;
  top: 0;
  left: 5%;
  right: 5%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
}

.cs-shelf-board__shadow {
  height: 15px;
  background: linear-gradient(180deg, rgba(92,61,30,0.22) 0%, rgba(92,61,30,0.06) 50%, transparent 100%);
  margin-top: 2px;
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  filter: blur(3px);
}

/* ── Browse Link ──────────────────────────────────────────────── */
.cs-shelf-browse {
  text-align: center;
  margin-top: 2.5rem;
}

.cs-shelf-browse__link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Lora', serif;
  font-size: 1.05rem;
  color: #c4701e;
  text-decoration: none;
  padding: 0.5rem 0;
  position: relative;
  transition: color 0.3s ease;
}

.cs-shelf-browse__link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #c4701e, #e8a050);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s ease;
}

.cs-shelf-browse__link:hover::after,
.cs-shelf-browse__link:focus-visible::after {
  transform: scaleX(1);
}

.cs-shelf-browse__link:hover,
.cs-shelf-browse__link:focus-visible {
  color: #8b5e3c;
}

.cs-shelf-browse__arrow {
  transition: transform 0.3s ease;
}

.cs-shelf-browse__link:hover .cs-shelf-browse__arrow,
.cs-shelf-browse__link:focus-visible .cs-shelf-browse__arrow {
  transform: translateX(4px);
}

/* ── Empty State ──────────────────────────────────────────────── */
.cs-shelf-empty {
  font-family: 'Lora', serif;
  font-style: italic;
  color: #8c7a65;
  text-align: center;
  padding: 2rem;
}

/* ── Responsive: Tablet ───────────────────────────────────────── */
@media (max-width: 900px) {
  .cs-books-row {
    gap: 0.4rem;
  }
}

/* ── Responsive: Mobile ───────────────────────────────────────── */
@media (max-width: 768px) {
  .cs-featured-shelf {
    padding: 3rem 0 4rem;
  }
  
  .cs-featured-shelf .section-heading {
    font-size: 2rem;
  }
  
  /* Hide desktop, show mobile rows */
  .cs-books-row--desktop,
  .cs-shelf-board--desktop {
    display: none;
  }
  
  .cs-books-row--mobile {
    display: flex;
    justify-content: center;
    gap: 0.35rem;
    padding: 0 0.5rem;
  }
  
  .cs-shelf-board--mobile {
    display: block;
    margin-bottom: 1.5rem;
  }
  
  /* No margin on the last shelf */
  .cs-shelf-board--mobile:last-of-type {
    margin-bottom: 0;
  }
  
  /* Smaller books on mobile to fit 5 per row */
  .cs-book {
    --book-height: 160px;
    --book-width: 55px;
  }
  
  .cs-book:hover,
  .cs-book:focus-visible,
  .cs-book.is-active {
    transform: translateY(-10px) translateZ(25px) scale(1.05);
  }
  
  /* Slightly smaller info panel on mobile */
  .cs-book__info {
    width: 200px;
    padding: 1rem;
  }
  
  .cs-book__info-title {
    font-size: 0.95rem;
  }
  
  .cs-book__info-desc {
    font-size: 0.75rem;
  }
  
  .cs-book__info-link {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }
}

/* ── Responsive: Small Mobile ─────────────────────────────────── */
@media (max-width: 480px) {
  .cs-books-row--mobile {
    gap: 0.2rem;
  }
  
  .cs-book {
    --book-height: 140px;
    --book-width: 46px;
  }
  
  .cs-book__spine-title {
    font-size: 0.5rem;
  }
  
  .cs-book__spine-author {
    font-size: 0.45rem;
  }
  
  .cs-book__spine-ornament {
    font-size: 0.65rem;
  }
}

/* ── Reduced Motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cs-book,
  .cs-book__info,
  .cs-shelf-browse__link,
  .cs-shelf-browse__arrow {
    transition-duration: 0.01ms;
  }
  
  .cs-book:hover,
  .cs-book:focus-visible,
  .cs-book.is-active {
    transform: translateY(-10px);
  }
}
