/* Sách 3D (thử nghiệm 24/10/2026): nút trên ảnh bìa đầu trang + khung xem toàn màn hình.
   Phần 3D chỉ tải khi khách bấm (assets/js/sach-3d.js). */

/* Ảnh bìa thành nút bấm — giữ nguyên dáng nghiêng, bóng, hiệu ứng nổi của ảnh cũ */
.bia-nut { position: relative; z-index: 1; display: block; width: 100%; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.bia-nut:focus-visible { outline: none; }
.bia-nut:focus-visible .bia { box-shadow: var(--focus-vong); }
.bia-nut.khong-3d { cursor: default; }
.bia-nut.khong-3d .nhan-3d { display: none; }

/* Đặt dưới tên tác giả + logo trên bìa (khoảng 1/5 chiều cao), lấn ra ngoài mép phải một chút */
.nhan-3d { position: absolute; z-index: 3; top: 21%; right: calc(-1 * var(--k-4)); display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 var(--k-3) 0 10px; border-radius: var(--bo-tron); background: var(--nut-nen); color: var(--nut-chu);
  font-size: 0.875rem; font-weight: 700; line-height: 1; white-space: nowrap; box-shadow: var(--bong); transition: background .2s ease, transform .2s ease; }
.nhan-3d svg { width: 18px; height: 18px; flex: none; }
.bia-nut:hover .nhan-3d, .bia-nut:focus-visible .nhan-3d { background: var(--nut-nen-hover); transform: translateY(-1px); }
.bia-nut:active .nhan-3d { background: var(--nut-nen-active); }
.nhan-bam { display: none; }
@media (hover: hover) and (pointer: fine) { .nhan-cham { display: none; } .nhan-bam { display: inline; } }

/* Mũi tên xoay quay 1 vòng lúc mới vào trang, rồi đứng yên — đủ để khách để ý, không gây rối mắt */
@media (prefers-reduced-motion: no-preference) {
  .nhan-3d svg { animation: s3d-xoay 1.1s cubic-bezier(.4, 0, .2, 1) 1.4s 2 both; }
}
@keyframes s3d-xoay { to { transform: rotate(-360deg); } }

/* Khung xem 3D: toàn màn hình trên điện thoại, hộp giữa màn hình trên máy tính */
.hop-3d { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0;
  background: radial-gradient(120% 70% at 50% 35%, var(--mau-nen) 0%, var(--mau-nen-sau) 100%); color: var(--mau-chu); }
.hop-3d::backdrop { background: color-mix(in oklch, var(--mau-nen-sau) 80%, transparent); }
@media (min-width: 760px) {
  .hop-3d { width: min(760px, 92vw); height: min(820px, 90vh); margin: auto; border: 1px solid var(--the-vien); border-radius: var(--bo-lon); box-shadow: var(--bong); }
}
.hop-3d-khung { display: flex; flex-direction: column; gap: var(--k-3); height: 100%;
  padding: max(var(--k-3), env(safe-area-inset-top)) var(--k-4) max(var(--k-4), env(safe-area-inset-bottom)); }
.hop-3d-dau { display: flex; align-items: center; justify-content: space-between; gap: var(--k-4); }
/* Tiêu đề nhận con trỏ khi mở khung (để nút ✕ không hiện vòng sáng sẵn); bản thân tiêu đề không bấm được nên không cần vòng */
.hop-3d-ten:focus, .hop-3d-ten:focus-visible { outline: none; box-shadow: none; }
.hop-3d-ten { margin: 0; font-family: var(--font-tieu-de); font-weight: 700; font-size: 1.125rem; color: var(--mau-nhan); }
.hop-3d-dong { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--nut-phu-vien); border-radius: var(--bo-tron);
  background: transparent; color: var(--mau-chu); cursor: pointer; }
.hop-3d-dong svg { width: 20px; height: 20px; }
.hop-3d-dong:hover { background: var(--nut-phu-nen-hover); }
.hop-3d-dong:focus-visible, .hop-3d canvas:focus-visible { outline: none; box-shadow: var(--focus-vong); }

.hop-3d-san { position: relative; flex: 1; min-height: 0; border-radius: var(--bo-vua); }
.hop-3d-san canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; opacity: 0; transition: opacity .4s ease; border-radius: inherit; }
.hop-3d-san canvas:active { cursor: grabbing; }
.hop-3d-poster { position: absolute; left: 50%; top: 50%; height: 72%; width: auto; max-width: 80%; object-fit: contain;
  transform: translate(-50%, -50%); border-radius: var(--bo-nho); box-shadow: var(--bong); transition: opacity .4s ease; }
.hop-3d-tai { position: absolute; left: 0; right: 0; bottom: var(--k-2); margin: 0; text-align: center; font-size: 0.9375rem; color: var(--mau-chu-phu); }
.hop-3d-tai .bao-loi { display: none; }
.hop-3d.san-sang canvas { opacity: 1; }
.hop-3d.san-sang .hop-3d-poster, .hop-3d.san-sang .hop-3d-tai { opacity: 0; visibility: hidden; }
.hop-3d.loi .dang-tai { display: none; }
.hop-3d.loi .bao-loi { display: inline; }
.hop-3d.loi [data-mo-sach], .hop-3d.loi .hop-3d-goi-y { display: none; }

.hop-3d-goi-y { margin: 0; text-align: center; font-size: 0.9375rem; color: var(--mau-chu-phu); }
.hop-3d-nut { display: grid; grid-template-columns: 1fr 1fr; gap: var(--k-3); }
.hop-3d-nut .nut { width: 100%; margin: 0; min-height: 52px; padding-inline: var(--k-3); text-align: center; }
.hop-3d.loi .hop-3d-nut { grid-template-columns: 1fr; }
@media (max-width: 479px) { .hop-3d-nut { grid-template-columns: 1fr; gap: var(--k-2); } .hop-3d-nut .nut { min-height: 50px; } }
