/* ===================================================================
   TÔNG ĐƠ HERO — object 3D to, tự xoay theo scroll ngay từ đầu, không
   cần bấm nút. Xem kiến trúc đầy đủ: tài liệu "Ba Vật Thể Cinematic"
   =================================================================== */

/* Loading toàn trang — che tới khi 3 model 3D load xong (xem
   js/site-loader.js cho phần ẩn/timeout an toàn). */
#site-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #f5bd1c;
  transition: opacity 0.5s ease;
}
#site-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
}
.site-loader-mark {
  font-family: "Espaavh", "Archivo Narrow", sans-serif;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #0a0a0a;
}
.site-loader-text {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(10, 10, 10, 0.7);
}
@media (prefers-reduced-motion: reduce) {
  #site-loader { transition: none; }
}

/* ---- Barber pole loader — 2 ảnh PNG thật (thiết kế riêng, "barber on/off",
   cùng khung 600×1800px) xếp chồng: lớp "off" (tối) nằm dưới cố định, lớp
   "on" (đỏ/trắng/xanh) nằm trên bị che bằng clip-path theo chiều dọc, lộ dần
   từ ĐÁY lên ĐỈNH đúng % tải thật (xem updateLoading trong hero-3d.js) —
   đầy 100% là lộ hết = sáng hoàn toàn = xong. ---- */
.site-loader-pole {
  position: relative;
  width: clamp(64px, 12vh, 90px);
  aspect-ratio: 600 / 1800;
}
.site-loader-pole-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.site-loader-pole-img.is-off {
  z-index: 1;
}
.site-loader-pole-img.is-on {
  z-index: 2;
  clip-path: inset(100% 0 0 0); /* JS cập nhật theo % tải — xem updateLoading */
  transition: clip-path 0.3s ease, filter 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
  .site-loader-pole-img.is-on { transition: none; }
}

/* Canvas 3D — KHÔNG cố định 1 chỗ. JS (hero-3d.js) tự đọc toạ độ thật
   của ô ".td-3d-slot" đang active trong layout mỗi section rồi di
   chuyển/resize canvas khớp đúng vào đó (top/left/width/height set qua
   inline style) — object nằm "trong" bố cục nội dung thật, không phải
   lớp nền phủ ngoài. CSS ở đây chỉ định vị trí ban đầu/fallback. */
#hero-3d-mount {
  position: fixed;
  top: 0;
  left: 0;
  width: min(66vw, 320px);
  height: min(66vw, 320px);
  /* JS (updateMountPosition) ghi translate3d(rect.left, rect.top, 0) mỗi khi
     ô .td-3d-slot đang active đổi vị trí — dùng transform (không phải
     top/left) để tránh layout reflow mỗi khung hình, đỡ tốn CPU khi cuộn
     trên di động. Giá trị dưới đây chỉ là fallback trước khi JS chạy. */
  transform: translate3d(50%, 50%, 0);
  z-index: 2; /* trên nội dung của chính section đang active — object là tiêu điểm */
  pointer-events: none;
  transition: opacity 0.25s ease;
  /* Object 3D render RA TRẮNG TOÀN BỘ khi mount bị dịch transform ra ngoài
     viewport dù chỉ 1 phần (vd top âm lúc section vừa cuộn qua khỏi đỉnh
     màn hình) — nghi trình duyệt bỏ composite layer canvas khi tính toán
     nó "chủ yếu ở ngoài khung nhìn". will-change ép layer này luôn được
     GPU composite độc lập, không phụ thuộc suy đoán vị trí. */
  will-change: transform;
}
#hero-3d-mount canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Ô chứa 3D trong layout từng section — không tự có kích thước (là div
   rỗng thay cho ảnh/khoảng trống cũ), phải khai kích thước tối thiểu để
   không co về 0 và để phần còn lại của layout (badge/card/chữ) có chỗ
   dựa vào đúng như khi còn là ảnh thật. */
.td-3d-slot {
  min-width: 240px;
  min-height: 320px;
}
/* Hero: to, chiếm phần lớn chiều cao màn hình — chữ/CTA neo dưới cùng */
.td-3d-slot--hero {
  width: min(90vw, 580px);
  min-height: 0;
  flex: 1 1 auto;
  max-height: 60vh;
  margin: 0 auto;
}

.td-wrap {
  position: relative;
  z-index: 1;
  height: 300vh;
  height: 300svh;
  background: transparent;
}

.td-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding: 6vh 24px 8vh;
  text-align: center;
  color: #fff;
  background: transparent;
}

.td-content-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.td-loading {
  position: absolute;
  top: 3vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9a9a9a;
  transition: opacity 0.4s ease;
}

.td-headline {
  position: relative;
  z-index: 5;
  /* Espaavh — font gothic chính của site, đã dùng cho .offer-title (Ưu Đãi) */
  font-family: "Espaavh", "Oswald", "Archivo Narrow", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  font-size: clamp(1.7rem, 7vw, 2.7rem);
  line-height: 1.15;
  text-wrap: balance;
  margin: 0;
  max-width: 22ch;
  /* nền tối phía sau bắt buộc — model 3D đằng sau sáng/bận, chữ trắng
     trơn sẽ gần như vô hình nếu không có lớp nền riêng */
  background-color: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(6px);
  padding: 16px 24px;
  border-radius: 14px;
  border: 1px solid rgba(245, 189, 28, 0.25);
}

.td-ctas {
  position: relative;
  z-index: 5;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.td-ctas a {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 30px;
  /* Bỏ pill bo tròn (đọc "mềm/hiện đại") — góc gần vuông + khung khắc góc
     vàng (giống .barber-frame) cho cảm giác gothic/branded hơn. */
  border-radius: 3px;
  font-family: "Espaavh", "Oswald", "Archivo Narrow", sans-serif;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.td-ctas a::before,
.td-ctas a::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: #f5bd1c;
  border-style: solid;
  pointer-events: none;
}
.td-ctas a::before { top: 5px; left: 5px; border-width: 2px 0 0 2px; }
.td-ctas a::after  { bottom: 5px; right: 5px; border-width: 0 2px 2px 0; }
.td-ctas a.nut-red-white {
  background: linear-gradient(155deg, #ff4438, #c8102e);
  color: #fff;
  box-shadow: 0 10px 26px rgba(200, 16, 46, 0.45);
}
.td-ctas a.nut-red-white:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(200, 16, 46, 0.55); }
.td-ctas a.nut-red-white::before,
.td-ctas a.nut-red-white::after { border-color: #fff; }
.td-ctas a.nut-outline-white {
  background: rgba(0, 0, 0, 0.4);
  border: 1.5px solid #f5bd1c;
  color: #f5bd1c;
  backdrop-filter: blur(4px);
}
.td-ctas a.nut-outline-white:hover { background: rgba(245, 189, 28, 0.15); transform: translateY(-2px); }

.td-scrollhint {
  position: relative;
  z-index: 5;
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #9a9a9a;
}

/* Fallback tĩnh: reduced-motion / data-saver / JS chưa load / lỗi GSAP */
.td-wrap.td-static {
  height: auto;
}
.td-wrap.td-static .td-stage {
  position: relative;
  height: auto;
  min-height: 78vh;
}
#hero-3d-mount.is-static { display: none; }

@media (prefers-reduced-motion: reduce) {
  .td-wrap { height: auto; }
  .td-wrap .td-stage { position: relative; height: auto; min-height: 78vh; }
  #hero-3d-mount { display: none; }
}

@media (min-width: 768px) {
  .td-headline { font-size: clamp(2rem, 4vw, 3rem); }
}
