/* ==========================================================================
   BAMFLOW — du-an-hero3d.css · hero trang Dự án: cảnh "Tách lớp giao diện" + thanh 7 ứng dụng
   (du-an.html / en/projects.html). Nạp SAU du-an.css. Khối chữ hero giữ nguyên trong du-an.css (.srh__*).
   Mức: html[data-dh3d] = full | lite | poster (đoạn script trong <head>); JS: assets/js/du-an-hero3d.js.
   Bên phải: canvas three.js trong suốt phủ cả hero, trên .sky__aura, dưới khối chữ và thanh ứng dụng.
   ========================================================================== */
:root {
  --dh3-chip: rgba(15, 50, 134, 0.8);
  --dh3-rim: rgba(159, 214, 255, 0.75);
}
.srh__copy { position: relative; z-index: 2; }
.dh.sky.srh { position: relative; }

/* ---------- Khung đặt cảnh (JS đo để canh cửa sổ) ---------- */
.dh3-fig {
  position: relative; z-index: 2; margin: 0;
  width: 100%; max-width: 720px; justify-self: end;
  aspect-ratio: 660 / 470;
}
/* sân khấu: phủ cả hero, dưới khối chữ / khung / thanh ứng dụng (z 2) */
.dh3-stage { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.dh3-canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 260ms ease; }
html.dh3-live .dh3-canvas { opacity: 1; }

/* cửa sổ DOM (full/lite trước khi WebGL sẵn sàng, và khi WebGL lỗi): JS đặt matrix3d đúng tư thế của cảnh */
.dh3-win {
  position: absolute; left: 0; top: 0;
  width: 800px; height: 520px;
  transform-origin: 0 0;
  border-radius: var(--dh3-win-r, 28px);
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 0 0 1.5px rgba(207, 227, 255, 0.8);
  display: none;
  opacity: 0;
  backface-visibility: hidden;
}
.dh3-win__bar { position: relative; height: 20px; background: #eef3fa; border-bottom: 1px solid #dde6f2; }
.dh3-win__bar i { position: absolute; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: #c9d5e6; }
.dh3-win__bar i:nth-child(1) { left: 12px; } .dh3-win__bar i:nth-child(2) { left: 24px; } .dh3-win__bar i:nth-child(3) { left: 36px; }
.dh3-win__bar b { position: absolute; top: 5px; left: 50%; width: 220px; height: 10px; margin-left: -110px; border-radius: 5px; background: #e0e8f3; }
.dh3-win__img { display: block; width: 800px; height: 500px; max-width: none; }
/* shown only once JS has placed it (a window at 0,0 would cover the copy) */
html.dh3-placed .dh3-win { display: block; opacity: 1; transition: opacity 260ms ease; }
html.dh3-live .dh3-win { opacity: 0; }

/* ảnh tĩnh (mức poster, không JS): máy tính = ảnh tách lớp + nhãn DOM + dây nối CSS; điện thoại = cửa sổ phẳng */
.dh3-still { position: absolute; inset: 0; container-type: size; cursor: pointer; }
.dh3-still picture, .dh3-still__img { display: block; width: 100%; height: 100%; }
.dh3-still__img { object-fit: contain; }
html[data-dh3d="full"] .dh3-still, html[data-dh3d="lite"] .dh3-still { display: none; }
.dh3-still__labels { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; pointer-events: none; }
.dh3-still__labels li {
  position: absolute; left: calc(var(--x) * 100%); top: calc(var(--y) * 100%);
  transform: translateY(-50%);
  --dx: calc((var(--x) - var(--ex)) * 100cqw);
  --dy: calc((var(--y) - var(--ey)) * 100cqh);
}
.dh3-still__labels li::before {          /* từ đầu dây 3D (in trong ảnh) tới nhãn */
  content: ""; position: absolute; right: calc(100% + 2px); top: 50%;
  width: hypot(var(--dx), var(--dy)); height: 1px;
  background: var(--dh3-rim);
  transform-origin: 100% 50%;
  transform: rotate(atan2(var(--dy), var(--dx)));
}
.dh3-still__labels .dh3d-chip { max-width: min(176px, calc(100cqw * (1 - var(--x)) - 4px)); }
/* khung hẹp (vd. 1024–1179 px, hai cột): nhãn sẽ thành 3 dòng và chồng nhau → chỉ giữ ảnh */
@container (max-width: 560px) { .dh3-still__labels { display: none; } }

/* ---------- Nhãn lớp (DOM, cột bên phải cửa sổ, trong khung nội dung) ---------- */
.dh3-over { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.dh3d-labels { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; }
.dh3d-labels li { position: absolute; left: 0; top: 0; }
.dh3d-labels li[hidden] { display: none; }
.dh3d-labels .dh3d-chip { position: absolute; left: 0; top: 0; opacity: 0; will-change: transform, opacity; }
.dh3d-chip {
  display: inline-flex; align-items: center;
  box-sizing: border-box;
  width: max-content; max-width: 176px; min-height: 30px; padding: 6px 12px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: var(--dh3-chip);
  color: #ffffff; font-size: 13px; font-weight: 600; line-height: 1.3; letter-spacing: 0;
  text-wrap: balance;
  box-shadow: 0 8px 18px -12px rgba(3, 15, 60, 0.7);
}
.dh3d-lead { position: absolute; left: 0; top: 0; height: 1px; background: var(--dh3-rim); transform-origin: 0 50%; opacity: 0; will-change: transform, opacity; }

/* nút "Xem giới thiệu": góc dưới trái cửa sổ (JS đặt vị trí trong khung .dh3-fig) */
.dh3-play {
  position: absolute; left: 0; top: 0; z-index: 3;
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 18px 0 14px;
  border: 0; border-radius: 999px;
  background: #ffffff; color: #133c9f;
  font: 600 0.875rem/1 var(--font-body, inherit);
  text-decoration: none; white-space: nowrap;
  box-shadow: 0 2px 4px rgba(11, 20, 32, 0.08), 0 14px 28px -12px rgba(3, 15, 60, 0.55);
  cursor: pointer; pointer-events: auto;
  transition: background 200ms ease, opacity 260ms ease;
}
.dh3-play svg { width: 16px; height: 16px; color: #1d4ed8; flex: none; }
.dh3-play:hover { background: #eef4ff; color: #133c9f; }
main .dh3-play:focus-visible { outline: 2px solid #ffffff; outline-offset: 3px; }
/* full / lite: ẩn tới khi JS đặt đúng chỗ */
html[data-dh3d="full"]:not(.dh3-placed) .dh3-play, html[data-dh3d="lite"]:not(.dh3-placed) .dh3-play { opacity: 0; visibility: hidden; }
/* poster / không JS: góc dưới trái cửa sổ trong ảnh tĩnh (toạ độ đo trên ảnh) */
html:not(.dh3-placed) .dh3-play { left: calc(var(--pl, 0.06) * 100%); top: calc(var(--pt, 0.8) * 100%); transform: translateY(-100%); }

html.dh3-hot .srh { cursor: pointer; }
html.dh3-hot .srh .srh__copy { cursor: auto; }

/* ---------- Thanh 7 ứng dụng (kiểu anh Hòa đã duyệt: biểu tượng ô bo góc + tên 2 dòng; đang chọn = ô xanh đặc + nền xanh nhạt) ---------- */
/* khoảng dưới hero đủ để tiêu đề phần sau không bị mép màn hình cắt ngang ở 1440×900 */
.dh.sky.srh { padding-bottom: clamp(56px, 11vh, 104px); }
.dh3-rail { position: relative; z-index: 2; margin-top: clamp(40px, 6.5vh, 64px); }
.dh3-rail__list {
  list-style: none; margin: 0; padding: 6px;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px;
  background: #ffffff;
  border: 1px solid var(--c-line);
  border-radius: 28px;
  box-shadow: var(--c-sh-lift);
}
.dh3-rail__list li { min-width: 0; }
.dh3-tab {
  display: flex; align-items: center; gap: 8px;
  height: 100%; min-height: 62px; padding: 10px 8px 10px 10px;
  border-radius: 18px;
  color: var(--c-ink); text-decoration: none;
  transition: background 220ms ease, box-shadow 220ms ease;
}
.dh3-tab .fi {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 11px;
  background: var(--c-tint-2); color: var(--c-blue);
  transition: background 220ms ease, color 220ms ease;
}
.dh3-tab .fi svg { width: 17px; height: 17px; }
/* 7 cột ở ≥ 1240 px: ô tên ≈ 108 px, đủ cho hai dòng mà không tách "sản xuất", "trung tâm", "đào tạo" */
.dh3-tab__name { min-width: 0; font-size: 0.78125rem; font-weight: 600; line-height: 1.3; text-wrap: balance; }
.dh3-tab:hover { background: var(--c-card); color: var(--c-ink); }
.dh3-tab.is-on { background: var(--c-tint); }
.dh3-tab.is-on .fi { background: var(--c-blue); color: #ffffff; }
.dh3-tab.is-hot { box-shadow: inset 0 0 0 1.5px var(--c-line-3); }
main .dh3-tab:focus-visible { outline-offset: -2px; }

/* ---------- Bề rộng ---------- */
@media (max-width: 1239px) {
  .dh3-rail__list { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .dh3-tab { gap: 10px; padding: 10px 12px; }
  .dh3-tab .fi { width: 32px; height: 32px; border-radius: 12px; }
  .dh3-tab .fi svg { width: 18px; height: 18px; }
  .dh3-tab__name { font-size: 0.8125rem; }
}
/* 4 cột: ứng dụng thứ bảy chiếm luôn ô trống cuối hàng (tên dài không phải xuống 3 dòng) */
@media (min-width: 768px) and (max-width: 1239px) {
  .dh3-rail__list li:nth-child(7):last-child { grid-column: span 2; }
}
@media (max-width: 1023px) {
  .dh3-fig { justify-self: center; max-width: 640px; }
}
@media (max-width: 767px) {
  /* điện thoại: cửa sổ phẳng nghiêng (ảnh tĩnh, không nhãn), khung vừa đúng ảnh */
  .dh3-fig { aspect-ratio: var(--dh3-m-ar, 1080 / 820); }
  .dh3-still__labels { display: none; }
  html:not(.dh3-placed) .dh3-play { left: calc(var(--pl-m, 0.06) * 100%); top: calc(var(--pt-m, 0.8) * 100%); }
  .dh.sky.srh { padding-bottom: 36px; }
  .dh3-rail { margin-top: 28px; }
  .dh3-rail__list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; padding: 6px; box-shadow: var(--c-sh-panel); }
  /* ô tên ≥ 100 px ở 360 px: "Quản lý sản xuất / theo đơn" hai dòng; ứng dụng thứ bảy (lẻ) nằm hết hàng */
  .dh3-tab { min-height: 56px; gap: 8px; padding: 8px 6px 8px 8px; }
  .dh3-tab .fi { width: 30px; height: 30px; border-radius: 11px; }
  .dh3-tab .fi svg { width: 17px; height: 17px; }
  .dh3-tab__name { font-size: 0.78125rem; }
  .dh3-rail__list li:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .dh3-canvas, .dh3-win, .dh3-play, .dh3-tab, .dh3-tab .fi { transition: none !important; animation: none !important; }
}
@supports (corner-shape: superellipse(1.585)) {
  :root .dh3-rail__list { border-radius: 28px; corner-shape: superellipse(1.585); }
  :root .dh3-tab { border-radius: 18px; corner-shape: superellipse(1.585); }
  :root .dh3-tab .fi { corner-shape: superellipse(1.585); }
}
