/* ============================================================
   MODULE CSS 04 · popups.css — Popup phat video (lightbox) + lop phu dang tai/loi cua trinh phat + giam chuyen dong (prefers-reduced-motion).
   ============================================================ */
/* ---------- Popup phát video (lightbox) ---------- */
.video-modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 18px; }
.video-modal[hidden] { display: none; }
.video-modal-backdrop { position: absolute; inset: 0; background: rgba(18, 28, 12, 0.82); backdrop-filter: blur(4px); }
.video-modal-box {
  position: relative; width: min(920px, 100%);
  background: var(--surface); border-radius: var(--radius-l); overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  animation: videoIn 0.25s ease both;
}
@keyframes videoIn { from { opacity: 0; transform: translateY(12px) scale(0.985); } to { opacity: 1; transform: none; } }
.video-modal-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px 13px 20px; }
.video-modal-title { margin: 0; flex: 1; font-size: 0.98rem; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-modal-close {
  flex: 0 0 auto; width: 40px; height: 40px; min-height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.video-modal-close:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.video-modal-close svg { width: 17px; height: 17px; fill: currentColor; }
.video-modal-frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.video-modal-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
/* Lớp phủ trên trình phát: lúc đang tải hiện ảnh xem trước + vòng xoay,
   KHÔNG để khung đen trống; nếu sau vài giây trình phát vẫn chưa sẵn sàng
   (video nhúng bị môi trường xem chặn — lỗi 153, chỉ thấy màn hình đen)
   thì lớp phủ chuyển thành thông báo kèm nút “Xem trên YouTube” thật và
   nút thử lại, để người xem không bao giờ kẹt ở màn hình đen. Khi trình
   phát báo đã sẵn sàng, lớp phủ mờ dần và biến mất. */
.video-modal-frame .vm-player { position: absolute; inset: 0; }
.vm-overlay { position: absolute; inset: 0; z-index: 2; overflow: hidden; background: #171b18; transition: opacity 0.35s ease; }
.vm-overlay[hidden] { display: none; }
.vm-overlay.is-done { opacity: 0; pointer-events: none; }
.vm-overlay .vm-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vm-overlay .vm-shade { position: absolute; inset: 0; background: rgba(16, 26, 10, 0.55); }
.vm-ui { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; }
.vm-spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.25); border-top-color: #ffffff; animation: vmSpin 0.8s linear infinite; }
.vm-spinner[hidden] { display: none; }
@keyframes vmSpin { to { transform: rotate(360deg); } }
.vm-status { margin: 0; color: #ffffff; font-size: 0.95rem; font-weight: 600; max-width: 30em; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4); }
.vm-yt-btn {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--accent); color: #ffffff; text-decoration: none;
  font-weight: 700; font-size: 1rem; padding: 13px 24px; border-radius: var(--radius-pill);
  min-height: 48px; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}
.vm-yt-btn:hover { background: var(--accent); color: #ffffff; }
.vm-yt-btn svg { width: 16px; height: 16px; fill: #ffffff; flex: 0 0 auto; }
.vm-yt-btn[hidden] { display: none; }
.vm-retry {
  background: transparent; border: 1px solid rgba(255, 255, 255, 0.65); color: #ffffff;
  border-radius: var(--radius-pill); padding: 9px 18px; font: inherit; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; min-height: 40px;
}
.vm-retry:hover { background: rgba(255, 255, 255, 0.12); }
.vm-retry[hidden] { display: none; }
.video-modal-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 11px 20px 13px; border-top: 1px solid var(--line);
  font-size: 0.88rem; color: var(--muted);
}
.video-modal-foot a { font-weight: 700; white-space: nowrap; margin-left: auto; }
@media (max-width: 580px) {
  .video-modal { padding: 10px; }
  .video-modal-title { font-size: 0.9rem; }
  /* Khung 16:9 trên điện thoại khá thấp: thu gọn lớp phủ để thông báo,
     nút YouTube và nút thử lại nằm gọn trong khung, không tràn ra ngoài */
  .vm-ui { gap: 9px; padding: 12px; }
  .vm-status { font-size: 0.86rem; }
  .vm-yt-btn { min-height: 44px; padding: 11px 20px; font-size: 0.95rem; }
  .vm-retry { min-height: 36px; padding: 7px 15px; }
  .vm-spinner { width: 34px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  [data-page].page-active { animation: none; }
  .video-modal-box { animation: none; }
  .img-modal-box { animation: none; }
  .vm-spinner { animation: none; }
  .vm-overlay { transition: none; }
}
