/* ==========================================================================
   bfcs · Kitaplık (uygulama rafı)
   Gerçek ciltli kitap hissi: kapalı kitaplar sırtı dönük rafta durur; seçilen
   kitap sakin 3B dönüşle ön kapağını çevirir. Varsayılan olarak ilk kitap açık
   başlar, böylece toplam raf genişliği sabit kalır ve kitap geçişlerinde düzen
   kaymaz. Tıklayarak veya ← → ok tuşlarıyla kitap seçilir.
   Mobilde kitaplar yatay yığın olarak dizilir.

   <div class="shelf"><div class="bookshelf" data-bookshelf>
     <article class="book is-open" style="--cover: …; --h: 100%">
       <div class="book-body">
         <button class="book-spine" type="button" aria-expanded="true">
           <img src="icon.png" alt=""><span class="book-spine-title">Ad</span>
           <span class="book-spine-dot" aria-hidden="true"></span>
         </button>
         <div class="book-cover">
           <a class="book-link" href="…" aria-label="Ad"></a>
           <span class="book-tag">Etiket</span>
           <img class="book-icon" src="icon.png" alt="">
           <h3 class="book-title">Ad</h3><p class="book-desc">Kısa açıklama</p>
           <div class="book-actions">…butonlar…</div>
         </div>
       </div>
     </article>
   </div></div>
   ========================================================================== */

/* Kitaplık sahnesi ve raf yüzeyi (tema uyumlu: koyu siyaha yakın, açık beyaza yakın) */
.shelf-wall:has(.bookshelf) {
  padding: var(--space-12) 0 var(--space-10);
  background:
    radial-gradient(ellipse 68% 58% at 50% 22%, rgba(255, 255, 255, 0.035), transparent 70%),
    linear-gradient(180deg, #121211, #0C0C0B);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
[data-theme="light"] .shelf-wall:has(.bookshelf) {
  background:
    radial-gradient(ellipse 68% 58% at 50% 20%, #FFFFFF, transparent 72%),
    linear-gradient(180deg, #FDFDFC, #F6F5F2);
  box-shadow: inset 0 0 0 1px rgba(12, 11, 10, 0.07);
}

.shelf:has(.bookshelf)::after {
  height: 14px;
  margin: 0 calc(-1 * var(--space-6)) 0;
  background: linear-gradient(180deg, #2C2B29 0%, #191918 45%, #0F0F0E 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 0 rgba(0, 0, 0, 0.6),
    0 18px 32px -6px rgba(0, 0, 0, 0.78),
    0 4px 10px rgba(0, 0, 0, 0.5);
}
[data-theme="light"] .shelf:has(.bookshelf)::after {
  background: linear-gradient(180deg, #FFFFFF 0%, #F1F0EC 50%, #DFDDD7 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(12, 11, 10, 0.1),
    0 16px 26px -8px rgba(12, 11, 10, 0.14),
    0 3px 8px rgba(12, 11, 10, 0.07);
}

/* Kitaplık dizilimi */
.bookshelf {
  --spine: clamp(58px, 5.8vw, 68px);
  --open: clamp(352px, 38vw, 384px);
  --book-h: clamp(368px, 39vw, 420px);
  --book-dur: 680ms;
  --book-ease: var(--ease-calm);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  height: calc(var(--book-h) + 18px);
  padding-top: 18px;
}

/* Her kitabın raf üzerindeki yuvası */
.book {
  position: relative;
  flex: 0 0 var(--spine);
  height: var(--book-h);
  z-index: 1;
  transition: flex-basis var(--book-dur) var(--book-ease);
}
/* Rafa temas gölgesi */
.book::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: -3px;
  height: 9px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  filter: blur(5px);
  pointer-events: none;
  z-index: 0;
  transition: opacity 320ms var(--book-ease), transform 320ms var(--book-ease);
}
[data-theme="light"] .book::after { background: rgba(12, 11, 10, 0.24); }
.book:not(.is-open):hover { z-index: 2; }
.book:not(.is-open):hover::after { opacity: 0.55; transform: scaleX(0.92); }
.book.is-open {
  flex-basis: var(--open);
  z-index: 3;
}

/* Kitap gövdesi (her yüz kendi 3B dönüşünü yapar; singular 90° ebeveyn matrisi olmaz) */
.book-body {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  perspective: 1500px;
}

/* İlk yüklemede animasyon sıçramasını önler */
.bookshelf.is-initializing .book,
.bookshelf.is-initializing .book-body,
.bookshelf.is-initializing .book-spine,
.bookshelf.is-initializing .book-cover {
  transition: none !important;
}

/* ---------- Sırt (kapalı görünüm) ---------- */
.book-spine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--spine);
  transform-origin: left center;
  transform: translateY(0) rotateY(0deg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 0 24px;
  border: 0;
  border-radius: 3px 2px 2px 3px;
  overflow: hidden;
  background:
    linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.17) 0%,
      rgba(255, 255, 255, 0.04) 15%,
      transparent 34%,
      transparent 68%,
      rgba(0, 0, 0, 0.28) 91%,
      rgba(0, 0, 0, 0.48) 100%
    ),
    var(--cover, var(--surface-3));
  color: #F3EFE9;
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    4px 10px 18px -6px rgba(0, 0, 0, 0.48);
  transition:
    transform var(--book-dur) var(--book-ease),
    opacity var(--book-dur) var(--book-ease),
    filter 260ms var(--ease-standard),
    box-shadow 260ms var(--ease-standard);
}
/* Kapalı sırtın üzerine gelince sakin ve kontrollü hafif kalkış (yerleşim kaymaz) */
.book:not(.is-open):hover .book-spine {
  transform: translateY(-7px) rotateY(0deg);
  transition-duration: 320ms, 320ms, 260ms, 260ms;
  filter: brightness(1.07);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -2px 0 rgba(0, 0, 0, 0.32),
    6px 16px 24px -8px rgba(0, 0, 0, 0.56);
}
.book.is-open .book-spine {
  transform: translateY(0) rotateY(-90deg);
  opacity: 0;
  pointer-events: none;
}

/* Cilt şeritleri (üst ve alt çift çizgi) */
.book-spine::before,
.book-spine::after {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  height: 4px;
  border-top: 1px solid rgba(243, 239, 233, 0.28);
  border-bottom: 1px solid rgba(243, 239, 233, 0.13);
  pointer-events: none;
}
.book-spine::before { top: 12px; }
.book-spine::after { bottom: 12px; }

.book-spine img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
  box-shadow:
    0 4px 10px rgba(12, 11, 10, 0.42),
    0 0 0 1px rgba(255, 255, 255, 0.12);
}
.book-spine-title {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 16px;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
  color: rgba(243, 239, 233, 0.92);
  white-space: nowrap;
}
.book-spine .ti-lock {
  margin-top: auto;
  font-size: 14px;
  opacity: 0.58;
}
.book-spine-dot {
  margin-top: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3DD68C;
  box-shadow: 0 0 0 3px rgba(61, 214, 140, 0.24);
}
.book-spine:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2.5px var(--focus), 4px 10px 18px -6px rgba(0, 0, 0, 0.48);
}

/* ---------- Ön Kapak (açık görünüm) ---------- */
.book-cover {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--open);
  transform-origin: left center;
  transform: translateX(var(--spine)) rotateY(90deg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  opacity: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 26px 22px 24px 32px;
  border-radius: 2px 9px 9px 2px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 85% 60% at 22% 14%, rgba(255, 255, 255, 0.13), transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 36%, rgba(0, 0, 0, 0.24) 100%),
    var(--cover, var(--surface-3));
  color: #F3EFE9;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -2px 0 rgba(0, 0, 0, 0.34),
    10px 22px 34px -14px rgba(0, 0, 0, 0.58);
  pointer-events: none;
  transition:
    transform var(--book-dur) var(--book-ease),
    opacity var(--book-dur) var(--book-ease);
}
.book.is-open .book-cover {
  transform: translateX(0) rotateY(0deg);
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

/* Cilt menteşe oluğu (sol kenarda gerçek sert kapak kıvrımı) */
.book-cover::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 22px;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.44) 0px,
    rgba(255, 255, 255, 0.14) 3px,
    rgba(0, 0, 0, 0.06) 6px,
    rgba(0, 0, 0, 0.36) 11px,
    rgba(255, 255, 255, 0.12) 13px,
    transparent 22px
  );
}

/* Sağ kenarda gömülü fildişi sayfa bloğu */
.book-cover::after {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  right: 0;
  width: 5px;
  pointer-events: none;
  z-index: 2;
  border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(
    90deg,
    #D4CCC0 0px,
    #EFEAE1 1px,
    #C5BDB0 2px
  );
  box-shadow:
    inset 1px 0 2px rgba(12, 11, 10, 0.45),
    -1px 0 0 rgba(12, 11, 10, 0.32);
}

.book-link {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.book-link:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2.5px var(--focus);
}
.book-cover > :not(.book-link) {
  position: relative;
  z-index: 1;
}
.book-cover > :not(.book-link, .book-actions) { pointer-events: none; }

.book-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  letter-spacing: 0.01em;
  color: rgba(243, 239, 233, 0.78);
}
.book:not(.is-locked) .book-tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3DD68C;
  box-shadow: 0 0 0 3px rgba(61, 214, 140, 0.24);
}

.book-icon {
  width: 72px;
  height: 72px;
  margin-top: auto;
  border-radius: 18px;
  object-fit: cover;
  box-shadow:
    0 12px 24px rgba(12, 11, 10, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.14);
}
.book-title {
  margin: 4px 0 0;
  font-size: clamp(24px, 2.2vw, 28px);
  line-height: 1.08;
  font-weight: var(--fw-bold);
  letter-spacing: -0.025em;
}
.book-desc {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.45;
  color: rgba(243, 239, 233, 0.8);
  max-width: 26ch;
}

.book-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 8px;
}
.book-actions .btn {
  height: 32px;
  padding: 0 10px;
  gap: 5px;
  font-size: 12px;
  white-space: nowrap;
  flex: 0 0 auto;
  background: #F3EFE9;
  color: #0C0B0A;
  box-shadow: 0 2px 8px rgba(12, 11, 10, 0.24);
  transition: transform 200ms var(--ease-standard), background-color 200ms var(--ease-standard);
}
.book-actions .btn:hover {
  background: #FFFFFF;
  transform: translateY(-1px);
}
.book-actions .btn + .btn {
  background: rgba(12, 11, 10, 0.42);
  color: #F3EFE9;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.book-actions .btn + .btn:hover {
  background: rgba(12, 11, 10, 0.62);
}

.book-cover .soon-badge {
  position: static;
  margin-top: 8px;
  padding: 5px 11px;
  font-size: 12px;
  background: rgba(12, 11, 10, 0.44);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* Kilitli kitap */
.book.is-locked .book-spine img,
.book.is-locked .book-icon {
  filter: saturate(0.72);
}

/* ---------- Mobil: yatay kitap yığını ---------- */
@media (max-width: 767px) {
  .shelf-wall:has(.bookshelf) {
    padding: var(--space-6) 0 var(--space-6);
  }
  .bookshelf {
    --spine: 64px;
    --open: 196px;
    --book-dur: 480ms;
    flex-direction: column;
    align-items: stretch;
    height: auto;
    gap: 8px;
    padding-top: 0;
  }
  .book {
    flex: 0 0 var(--spine);
    height: auto;
    max-height: none;
    perspective: none;
    border-radius: 8px 8px 4px 4px;
    overflow: hidden;
    background: var(--cover, var(--surface-3));
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.14),
      0 8px 18px -6px rgba(0, 0, 0, 0.45);
  }
  .book::after { display: none; }
  .book.is-open { flex-basis: var(--open); }
  .book-body {
    perspective: none;
  }
  .book-spine {
    position: relative;
    width: 100%;
    height: var(--spine);
    transform: none;
    opacity: 1;
    flex-direction: row;
    gap: var(--space-3);
    padding: 0 var(--space-5);
    border-radius: 0;
    border-bottom: 1px solid rgba(12, 11, 10, 0.3);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 45%, rgba(0, 0, 0, 0.18));
    box-shadow: none;
    transition: none;
  }
  .book.is-open .book-spine { transform: none; opacity: 1; pointer-events: auto; }
  .book:not(.is-open):hover .book-spine { transform: none; filter: none; box-shadow: none; }
  .book-spine::before,
  .book-spine::after {
    left: auto;
    right: auto;
    top: 10px;
    bottom: 10px;
    width: 4px;
    height: auto;
    border-top: 0;
    border-bottom: 0;
    border-left: 1px solid rgba(243, 239, 233, 0.24);
    border-right: 1px solid rgba(243, 239, 233, 0.12);
  }
  .book-spine::before { left: 8px; }
  .book-spine::after { right: 8px; }
  .book-spine img { width: 38px; height: 38px; border-radius: 10px; }
  .book-spine-title { writing-mode: horizontal-tb; transform: none; font-size: 17px; }
  .book-spine .ti-lock,
  .book-spine-dot { margin: 0 0 0 auto; }

  .book-cover {
    position: relative;
    left: 0;
    width: 100%;
    height: calc(var(--open) - var(--spine));
    transform: none;
    border-radius: 0;
    padding: 14px 16px 18px;
    background: transparent;
    box-shadow: none;
    opacity: 0;
    transition: opacity 280ms var(--ease-standard);
  }
  .book-actions { gap: 5px; }
  .book-actions .btn { height: 30px; padding: 0 9px; gap: 4px; font-size: 11.5px; }
  .book-actions .btn .ti { font-size: 14px; }
  .book-cover::before,
  .book-cover::after { display: none; }
  .book.is-open .book-cover { transform: none; opacity: 1; transition-delay: 80ms; }
  .book-cover .book-tag,
  .book-cover .book-icon,
  .book-cover .book-title { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .book,
  .book::after,
  .book-body,
  .book-spine,
  .book-cover {
    transition-duration: 0ms !important;
  }
}
