/* Trang sản phẩm /san-pham/<slug> và trang "không tìm thấy" do máy chủ dựng (store_pages.py), theo thiết kế "Bàn làm việc" (ADR-0045, Đợt A Task 4):
   màu, phông và khung của thiết kế, cấu trúc giữ nguyên (hình lớn 16:9 bên trái, khung mua bên phải, dải hình phụ, nội dung giới thiệu, hộp phóng to).
   Thay web/stage-product.css. Mọi luật nằm dưới <main class="store-product">. Token ở tokens.css (cỡ chữ nhân --d-text-scale nên nút "Aa" tới được), nút ở public-ui.css. */

/* ---- Khung trang và đường dẫn ---- */
.store-product { box-sizing: border-box; max-width: 1180px; margin: auto; padding: 20px 16px 40px; color: var(--d-ink); font: 400 var(--d-fs-body) / var(--d-lh-body) var(--d-font-sans); }
.store-product .store-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; margin-bottom: 6px; color: var(--d-muted); font: 600 var(--d-fs-caption) / 1.4 var(--d-font-sans); }
.store-product .store-breadcrumb a { display: inline-flex; align-items: center; min-height: var(--d-control-s); color: var(--d-brand-deep); font-weight: 700; }
.store-product .product-detail { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; gap: 28px; margin: 0; padding: 10px 0 24px; }

/* ---- Hình lớn: khung 16:9 như bìa của thẻ bài, ảnh nằm trọn (không cắt) dù cao, rộng hay hỏng, nên trang không dịch khi ảnh về ---- */
.store-product .product-media { position: relative; align-self: start; aspect-ratio: 16 / 9; margin: 0; overflow: hidden; border: 2px solid var(--d-line); border-radius: 26px; background: #FFF4DC; }
.store-product .product-media img, .store-product .product-zoom { display: block; width: 100%; height: 100%; }
.store-product .product-media img { object-fit: contain; }
/* Nhân vật thay ảnh (chưa có ảnh, hoặc ảnh hỏng thì JS thêm lớp này): luôn giữa khung dù nằm trực tiếp trong khung hay trong nút phóng to. */
.store-product .product-media img.is-fallback { position: absolute; left: 50%; top: 50%; width: auto; height: 72%; aspect-ratio: 1; transform: translate(-50%, -50%); }
.store-product .product-zoom { position: relative; padding: 0; border: 0; background: none; cursor: zoom-in; }
/* Giấy nhớ "Phóng to", chỉ khi nút đang bật: máy chủ dựng nút tắt, store-page.js bật nó từ 901px rộng và 590px cao (từ đó hộp phóng to mới lớn hơn hình
   trong trang). Nút tắt (điện thoại, máy tính bảng dọc, cửa sổ thấp, không có JavaScript, ảnh hỏng) không có giấy nhớ và không hứa phóng to. */
.store-product .product-zoom::before { content: "Phóng to"; position: absolute; right: 12px; bottom: 12px; padding: 4px 12px; border-radius: 4px 4px 4px 14px; background: var(--d-sun-tint); color: var(--d-sun-ink);
  font: 700 var(--d-fs-badge) / var(--d-lh-badge) var(--d-font-sans); transform: rotate(-1.5deg); }
/* Khung có overflow:hidden cắt vòng focus ở ngoài: vòng nằm trong khung, mực ngoài, dải trắng, mực trong, để thấy trên ảnh sáng lẫn tối. */
.store-product .product-zoom:focus-visible { outline: 3px solid var(--d-ink); outline-offset: -3px; }
.store-product .product-zoom:focus-visible::after { content: ""; position: absolute; inset: 3px; border: 3px solid #fff; box-shadow: inset 0 0 0 2px var(--d-ink); pointer-events: none; }
.store-product .product-zoom:disabled { cursor: default; opacity: 1; }  /* button:disabled của styles.css làm mờ: đây chỉ là hình, không phải nút hỏng */
.store-product .product-zoom:disabled::before { display: none; }

/* ---- Khung ảnh nhiều hình (ADR-0066, băng chuyền): bìa là hình 1, ảnh xem thêm là hình 2…9, cùng một khung 16:9 ở đầu trang. Không có JavaScript: hàng hình cuộn ngang
   (scroll-snap, thanh cuộn hiện) và hàng ảnh nhỏ là liên kết #hinh-N, nên vẫn xem được mọi hình. store-page.js thêm lớp is-ready (ẩn thanh cuộn), mũi tên, bộ đếm.
   Trên điện thoại ảnh nhỏ thành chấm (ảnh không tải), nên khung "Gói bán" chỉ xuống thêm khoảng 48px. Trang chỉ có bìa không có khối này. ---- */
.store-product .product-carousel { position: relative; min-width: 0; }
.store-product .product-carousel > .product-media { aspect-ratio: 16 / 9; }
.store-product .product-slides { display: flex; height: 100%; margin: 0; padding: 0; list-style: none; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scrollbar-width: thin; }
.store-product .product-carousel.is-ready .product-slides { scrollbar-width: none; }
.store-product .product-carousel.is-ready .product-slides::-webkit-scrollbar { display: none; }
.store-product .product-slide { position: relative; flex: 0 0 100%; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; }
.store-product .product-slide > button { display: block; width: 100%; height: 100%; }
.store-product .product-slide > .product-preview { aspect-ratio: auto; border: 0; border-radius: 0; background: none; }
.store-product .product-slide > .product-preview:not(:disabled) { cursor: zoom-in; }
.store-product .product-preview { position: relative; display: block; width: 100%; padding: 0; overflow: hidden; }
.store-product .product-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.store-product .product-preview:disabled { cursor: default; opacity: 1; }
.store-product .product-preview:focus-visible { outline: 3px solid var(--d-ink); outline-offset: -3px; }
.store-product .product-preview:focus-visible::after { content: ""; position: absolute; inset: 3px; border: 3px solid #fff; box-shadow: inset 0 0 0 2px var(--d-ink); pointer-events: none; }
/* Mũi tên (36px trên máy tính, 44px dưới 901px), bộ đếm "Hình 2 / 9": JS dựng, nằm trên khung. Hết hình thì nút bên đó mờ đi, không quay vòng. */
.store-product .carousel-arrow { position: absolute; z-index: 2; top: 50%; display: grid; place-items: center; width: 36px; height: 36px; margin-top: -18px; padding: 0;
  border: 2px solid var(--d-ink); border-radius: 50%; background: rgb(255 255 255 / .94); color: var(--d-ink); font: 800 22px / 1 var(--d-font-sans); cursor: pointer; }
.store-product .carousel-prev { left: 8px; }
.store-product .carousel-next { right: 8px; }
.store-product .carousel-arrow:disabled { opacity: .3; cursor: default; }
.store-product .carousel-arrow:focus-visible { outline: 3px solid var(--d-ink); outline-offset: 2px; box-shadow: 0 0 0 2px #fff; }
.store-product .carousel-count { position: absolute; z-index: 2; top: 10px; left: 10px; padding: 2px 10px; border-radius: 999px; background: rgb(29 43 40 / .82); color: #fff;
  font: 700 var(--d-fs-badge) / var(--d-lh-badge) var(--d-font-sans); pointer-events: none; }
.store-product .carousel-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.store-product .product-carousel:not(.is-ready) :is(.carousel-arrow, .carousel-count) { display: none; }
/* Nút "Phóng to" của khung (JS dựng, không đè lên ảnh trên máy tính): máy tính nằm cuối hàng ảnh nhỏ, ngoài khung; điện thoại là kính lúp tròn 32px ở góc trên phải. */
.store-product .carousel-zoom { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; margin-top: 10px; padding: 0 12px; border: 2px solid var(--d-ink);
  border-radius: 999px; background: var(--d-surface); color: var(--d-ink); font: 700 var(--d-fs-caption) / 1.2 var(--d-font-sans); white-space: nowrap; cursor: zoom-in; }
.store-product .carousel-zoom[hidden] { display: none; }
.store-product .product-slide > .product-zoom::before { display: none; }  /* bìa trong khung: không còn giấy nhớ trên ảnh (nút "Phóng to" ở trên thay) */
.store-product .carousel-zoom:focus-visible { outline: 3px solid var(--d-ink); outline-offset: 2px; box-shadow: 0 0 0 2px #fff; }
@media (min-width: 901px) {
  .store-product .product-carousel.is-ready { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; align-items: start; }
  .store-product .product-carousel.is-ready > .product-media { grid-column: 1 / -1; }
  .store-product .product-carousel.is-ready > .carousel-zoom { grid-column: 2; }
}
/* Hàng ảnh nhỏ: máy tính thấy cả hàng (mỗi ô ≥ 36px cao), hình đang xem viền xanh ngọc. */
.store-product .product-thumbs { display: flex; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.store-product .product-thumbs li { flex: 1 1 0; min-width: 0; max-width: 112px; }
.store-product .product-thumb { position: relative; display: block; aspect-ratio: 16 / 9; min-height: 36px; overflow: hidden; border: 2px solid var(--d-line); border-radius: var(--d-radius-sm, 8px); background: #FFF4DC; }
.store-product .product-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.store-product .product-thumb[aria-current="true"] { border-color: var(--d-brand); box-shadow: 0 0 0 2px var(--d-brand); }
.store-product .product-thumb:focus-visible { outline: 3px solid var(--d-ink); outline-offset: 2px; }
@media (max-width: 900px) {
  /* Điện thoại, máy tính bảng dọc: mũi tên 32px hạ xuống hai góc dưới (dải chân ảnh, lề trang), không che chữ giữa slide; vùng chạm vẫn 44px (::after).
     Bộ đếm chỉ "3 / 9". Kính lúp ở góc trên phải. */
  .store-product .carousel-arrow { top: auto; bottom: 8px; width: 32px; height: 32px; margin-top: 0; font-size: 20px; }
  .store-product .carousel-prev { left: 8px; }
  .store-product .carousel-next { right: 8px; }
  .store-product :is(.carousel-arrow, .carousel-zoom)::after { content: ""; position: absolute; inset: -8px; }
  .store-product .carousel-count { top: 8px; left: 8px; padding: 2px 8px; }
  .store-product .carousel-count-word { display: none; }
  .store-product .carousel-zoom { position: absolute; z-index: 2; top: 8px; right: 8px; width: 32px; min-height: 0; height: 32px; margin: 0; padding: 0; border-radius: 50%;
    background: rgb(255 255 255 / .94); }
  .store-product .carousel-zoom-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .store-product .product-thumbs { flex-wrap: wrap; justify-content: center; gap: 0; margin-top: 4px; }
  .store-product .product-thumbs li { flex: 1 1 30px; max-width: 44px; }  /* chấm giãn theo chỗ trống (9 chấm: khoảng 40px ở 390), vẫn một hàng ở 320 */
  .store-product .product-thumb { display: grid; place-items: center; width: 100%; height: 44px; min-height: 0; aspect-ratio: auto; border: 0; border-radius: 0; background: none; box-shadow: none; }
  .store-product .product-thumb[aria-current="true"] { box-shadow: none; }
  .store-product .product-thumb img { display: none; }
  .store-product .product-thumb::before { content: ""; width: 10px; height: 10px; border: 2px solid var(--d-ink); border-radius: 50%; background: var(--d-surface); }
  .store-product .product-thumb[aria-current="true"]::before { width: 20px; border-radius: 6px; border-color: var(--d-brand-deep); background: var(--d-brand); }
}
@media (prefers-reduced-motion: reduce) { .store-product .product-slides { scroll-behavior: auto; } }
.store-product .product-lightbox-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.store-product .product-lightbox-nav[hidden] { display: none; }
.store-product .product-lightbox-nav .d-btn { justify-self: auto; min-height: 44px; }
.store-product .product-lightbox-nav [data-zoom-count] { font-weight: 800; white-space: nowrap; }
.store-product .product-lightbox-nav .d-btn { white-space: nowrap; }
.store-product .product-lightbox-nav .d-btn:disabled { opacity: .35; }
/* Khung có ảnh nhiều hình: hàng trên có "Phóng to chữ" và "Đóng"; ảnh nằm trong một vùng cuộn. Phóng to chữ: ảnh rộng ít nhất 1200px (chữ giáo án khoảng 14px), kéo hoặc
   chụm hai ngón trong vùng đó; chạm vào ảnh cũng bật/tắt. */
.store-product .product-lightbox-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.store-product .product-lightbox-bar .d-btn { min-height: 44px; }
.store-product .product-lightbox-view { overflow: hidden; max-height: calc(100vh - 190px); max-height: calc(100dvh - 190px); border-radius: var(--d-radius-sm); background: #fff; }
.store-product .product-lightbox .product-lightbox-view img { max-height: calc(100vh - 190px); max-height: calc(100dvh - 190px); border-radius: 0; cursor: zoom-in; touch-action: pan-y pinch-zoom; }  /* vuốt ngang trên hình là sang hình khác */
.store-product .product-lightbox-view.is-magnified { overflow: auto; overscroll-behavior: contain; }
.store-product .product-lightbox .product-lightbox-view.is-magnified img { width: max(1200px, 150%); max-width: none; max-height: none; cursor: zoom-out; touch-action: auto; }

/* ---- Khung mua: nhãn loại, tên (Lora), lớp · môn, mô tả, gói bán ---- */
.store-product .product-summary { min-width: 0; overflow-wrap: anywhere; }
.store-product .product-summary .eyebrow { margin: 0; color: var(--d-brand-deep); letter-spacing: 0; text-transform: none; font: 700 var(--d-fs-caption) / 1.3 var(--d-font-sans); }
.store-product .product-summary h1 { margin: 8px 0 10px; color: var(--d-ink); letter-spacing: 0; font: 700 var(--d-fs-title-l) / 1.3 var(--d-font-display); }
.store-product .product-where { margin: 0 0 10px; color: var(--d-muted); font: 700 var(--d-fs-caption) / 1.4 var(--d-font-sans); }
.store-product .product-lead { max-width: 62ch; margin: 0 0 14px; color: var(--d-ink-soft); font: 400 var(--d-fs-body) / var(--d-lh-body) var(--d-font-sans); }
.store-product .product-offers h2 { margin: 18px 0 8px; color: var(--d-ink); font: 700 var(--d-fs-title-s) / var(--d-lh-title-s) var(--d-font-display); }
.store-product .product-soon { margin: 8px 0 0; color: var(--d-muted); font-weight: 700; }
.store-product .offer-list { display: grid; gap: 10px; margin: 8px 0 0; padding: 0; list-style: none; }
.store-product .offer-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; min-height: 56px; padding: 12px 16px;
  border: 2px solid var(--d-line); border-radius: var(--d-radius-lg); background: var(--d-surface); font-size: var(--d-fs-body); }
.store-product .offer-name { flex: 1 1 120px; min-width: 0; overflow-wrap: anywhere; font-weight: 700; }
.store-product .offer-prefix { color: var(--d-muted); font-weight: 600; }
.store-product .offer-price { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; gap: 2px 8px; min-width: 0; margin-left: auto; overflow-wrap: anywhere; }
.store-product .offer-price strong { color: var(--d-brand); font: 700 var(--d-fs-title-s) / 1.3 var(--d-font-display); }
.store-product .offer-price .is-free { color: var(--d-brand-deep); }
.store-product .offer-price s { color: var(--d-muted); font-size: var(--d-fs-caption); }
.store-product .offer-list small { flex-basis: 100%; color: var(--d-muted); font-size: var(--d-fs-caption); }
.store-product .offer-list .d-btn { flex: 1 1 100%; }
.store-product .product-notice { margin: 14px 0 0; padding: 12px 16px; border-radius: 4px 4px 4px 18px; background: var(--d-sun-tint); color: var(--d-sun-ink); font: 700 var(--d-fs-line) / 1.45 var(--d-font-sans); }

/* ---- Nội dung giới thiệu do HocAI soạn. overflow-wrap: break-word, không phải anywhere: `anywhere` làm cỡ tối thiểu của ô bảng chỉ một ký tự, nên bảng nhiều cột trên
   điện thoại bị bẻ từng chữ ("Tu/ần"); với break-word các từ giữ nguyên và bảng cuộn ngang trong chính nó. max-width chỉ giữ độ dài dòng: khối nằm sát trái, thẳng hàng
   với đường dẫn và hình. ---- */
.store-product .product-content { max-width: 820px; margin: 8px 0 40px; overflow-wrap: break-word; font: 400 var(--d-fs-body) / 1.7 var(--d-font-sans); }
.store-product .product-content :is(p, li, blockquote) { max-width: 62ch; }
.store-product .product-content :is(h2, h3, h4) { margin: 1.4em 0 .5em; font-family: var(--d-font-display); font-weight: 700; line-height: 1.3; }
.store-product .product-content img { max-width: 100%; height: auto; }
.store-product .product-content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.store-product .product-content :is(th, td) { padding: 6px 10px; border: 1px solid var(--d-line-strong); }

/* ---- Hộp phóng to: <dialog> gốc, Esc đóng, phần còn lại của trang bị khóa khi mở. Chiều rộng xác định để hình luôn được phóng lên, kể cả ảnh nhỏ. ---- */
.store-product .product-lightbox { box-sizing: border-box; width: 100%; max-width: min(96vw, 1100px); max-height: calc(100% - 16px); padding: 12px; border: 2px solid var(--d-line); border-radius: var(--d-radius-xl);
  background: var(--d-surface); color: var(--d-ink); box-shadow: none; }
.store-product .product-lightbox:not([open]) { display: none; }
.store-product .product-lightbox[open] { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; overflow: auto; }  /* cột không nở theo hàng nút (320px) */
@media (max-width: 359px) { .store-product .zoom-step-word { display: none; } .store-product .product-lightbox-nav .d-btn { min-width: 44px; } }
.store-product .product-lightbox::backdrop { background: rgb(29 43 40 / .78); backdrop-filter: none; }  /* nền mực phẳng, không làm mờ */
.store-product .product-lightbox .d-btn { justify-self: end; }
.store-product .product-lightbox img { display: block; width: 100%; height: auto; max-height: calc(100vh - 130px); max-height: calc(100dvh - 130px); object-fit: contain; border-radius: var(--d-radius-sm); background: #fff; }

/* ---- Không tìm thấy sản phẩm ---- */
.store-product .store-missing { max-width: 560px; margin: 48px auto; text-align: center; }
.store-product .store-missing img { display: block; width: 140px; height: 140px; margin: 0 auto 12px; }
.store-product .store-missing h1 { margin: 0 0 10px; font: 700 var(--d-fs-title-l) / 1.3 var(--d-font-display); }
.store-product .store-missing p { max-width: 62ch; margin: 0 auto 20px; color: var(--d-ink-soft); }

@media (max-width: 900px) { .store-product .product-detail { grid-template-columns: 1fr; } }
@media (forced-colors: active) {
  .store-product :is(.product-media, .product-thumb, .offer-list li) { border-color: CanvasText; }
  .store-product .product-thumb[aria-current="true"] { outline: 3px solid Highlight; }
  .store-product .product-zoom::before { border: 1px solid CanvasText; transform: none; }
}
