/* =========================================================
   STYLE — CONGB812
   Biến màu / font chỉnh nhanh ở :root
   ========================================================= */
:root {
  --font-main: "Inter", system-ui, sans-serif;
  --bg: #000;
  --blue: #3f7fc4;
  --blue-light: #9fd4ff;
  --text: #e8eef7;
  --muted: rgba(232, 238, 247, 0.55);
  --cursor-star-size: 48px;   /* con trỏ ngôi sao (trang 1) */
  --cursor-boat-size: 74px;   /* con trỏ thuyền (trang 2), ảnh gốc 99px */
  --cursor-fade: 0.5s;        /* thời gian chuyển giữa 2 con trỏ */
  --hero-scale: 0.8;          /* độ to cụm CONGB812 + thuyền (trang 1), 1 = như preview */
  --map-scale: 0.82;          /* độ to chòm sao (trang 2) */
  --light-size: 260px;           /* bán kính luồng sáng trên chữ */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  background: var(--bg);
}

body {
  font-family: var(--font-main);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { user-select: none; -webkit-user-drag: none; }

/* ---------- Nền thiên hà ---------- */
.space-bg {
  position: fixed; inset: 0; z-index: -3;
  background:
    radial-gradient(ellipse 60% 45% at 62% 40%, rgba(70, 60, 160, 0.16), transparent 70%),
    radial-gradient(ellipse 50% 40% at 25% 75%, rgba(30, 90, 170, 0.12), transparent 70%),
    url("../assets/bg-stars.jpg") center / cover no-repeat,
    #000;
}
#starfield {
  position: fixed; inset: 0; z-index: -2;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* ---------- Trang ---------- */
.page {
  position: relative;
  height: 100vh; height: 100svh;
  width: 100%;
  display: grid; place-items: center;
  overflow: hidden;
}

/* Khung 16:9 theo preview 1920x1080, luôn vừa màn hình */
.stage {
  position: relative;
  width: calc(min(100vw, 177.78svh) * var(--stage-scale, 1));
  aspect-ratio: 16 / 9;
}

/* ---------- Trang 1: logo + luồng sáng ---------- */
.hero-logo {
  position: absolute;
  /* left/top/width do main.js đặt từ content.js */
  filter: drop-shadow(0 0 18px rgba(80, 160, 255, 0.0));
  transition: filter 0.4s;
}
.hero-logo img { display: block; width: 100%; height: auto; }
.hero-logo__light {
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(
    circle var(--light-size) at var(--mx, -999px) var(--my, -999px),
    rgba(255, 255, 255, 1) 0%,
    rgba(190, 235, 255, 1) 16%,
    rgba(100, 180, 255, 0.75) 38%,
    rgba(50, 120, 240, 0.25) 58%,
    rgba(40, 100, 220, 0) 72%
  );
  -webkit-mask: url("../assets/logo-congb812.png") center / 100% 100% no-repeat;
          mask: url("../assets/logo-congb812.png") center / 100% 100% no-repeat;
  opacity: var(--light-on, 0);
  transition: opacity 0.35s;
}
.hero-logo.is-lit { filter: drop-shadow(0 0 14px rgba(90, 170, 255, 0.22)); }

/* ---------- Thuyền ---------- */
.boat-zone { position: absolute; pointer-events: none; }
.boat {
  display: block; width: 100%; height: auto;
  will-change: transform;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 20px rgba(160, 200, 255, 0.12));
}

/* ---------- Gợi ý cuộn ---------- */
.scroll-hint {
  position: absolute; bottom: 130px; left: 50%;
  width: 34px; height: 34px; margin-left: -17px;
  color: var(--blue-light);
  filter: drop-shadow(0 0 6px rgba(160, 210, 255, 0.8));
  animation: arrowBlink 1.6s ease-in-out infinite;
}
.scroll-hint svg { width: 100%; height: 100%; display: block; }
.scroll-hint:hover { animation-play-state: paused; opacity: 1; color: #fff; }
@keyframes arrowBlink {
  0%, 100% { opacity: 0.25; transform: translateY(-4px); }
  50%      { opacity: 1;    transform: translateY(4px); }
}

/* ---------- Trang 2: chòm sao Nhân Mã ---------- */
/* Hiệu ứng loang: vùng hiện nét đứt lan dần từ ngôi sao trung tâm ra ngoài (mép mềm) */
@property --reveal { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
.constellation__lines {
  position: absolute;
  pointer-events: none;
  --reveal: 0%;
  --mask: radial-gradient(circle at 55% 32%, #000 calc(var(--reveal) - 14%), transparent var(--reveal));
  -webkit-mask-image: var(--mask);
          mask-image: var(--mask);
  transition: --reveal 1s cubic-bezier(.5, 0, .75, 0);          /* cuộn ra: thu lại */
}
.page-hero .stage { --stage-scale: var(--hero-scale); }
.page-constellation .stage { --stage-scale: var(--map-scale); }

.is-visible .constellation__lines {
  --reveal: 135%;
  transition: --reveal 2.6s cubic-bezier(.25, .6, .3, 1) .15s;  /* cuộn vào: loang ra */
}
.constellation__lines { filter: drop-shadow(0 0 3px rgba(170, 215, 255, 0.85)); }

/* Nét đứt lấp lánh: ảnh line làm mặt nạ, bên trong là ánh sáng chạy + hạt kim tuyến nhấp nháy */
.constellation__lines img { display: none; }
.constellation__sparkle {
  position: absolute; inset: 0;
  -webkit-mask: url("../assets/sagittarius-lines.png") center / 100% 100% no-repeat;
          mask: url("../assets/sagittarius-lines.png") center / 100% 100% no-repeat;
  background:
    /* luồng sáng quét ngang */
    linear-gradient(110deg, transparent 42%, rgba(255,255,255,1) 50%, transparent 58%) 0 0 / 250% 100% no-repeat,
    /* hạt lấp lánh */
    radial-gradient(circle, rgba(255,255,255,1) 0 1.5px, transparent 2.5px) 0 0 / 23px 19px,
    radial-gradient(circle, rgba(200,230,255,1) 0 1.5px, transparent 2.5px) 9px 7px / 31px 27px,
    /* màu nền của nét: trắng-xanh nhạt */
    linear-gradient(90deg, #cfe6ff, #ffffff 30%, #a9d2ff 60%, #ffffff 85%, #cfe6ff);
  background-size: 250% 100%, 23px 19px, 31px 27px, 200% 100%;
  animation: lineSweep 4.5s linear infinite, lineFlicker 3.2s ease-in-out infinite;
}
@keyframes lineSweep {
  from { background-position: 150% 0, 0 0, 9px 7px, 0 0; }
  to   { background-position: -150% 0, 46px 76px, -62px 81px, 200% 0; }
}
@keyframes lineFlicker {
  0%, 100% { opacity: 0.95; }
  20% { opacity: 0.55; }
  35% { opacity: 1; }
  60% { opacity: 0.7; }
  80% { opacity: 1; }
}

.star {
  position: absolute;
  width: 4.4%; aspect-ratio: 1;
  transform: translate(-50%, -50%) scale(0);
  background: none; border: 0; padding: 0;
  transition: transform 0.45s ease-in;
}
.is-visible .star {
  transform: translate(-50%, -50%) scale(var(--s, 1));
  transition: transform 0.6s cubic-bezier(.3, 1.6, .5, 1) var(--delay, 0s);
}
.star img {
  width: 100%; height: 100%; display: block;
  animation: twinkle var(--tw, 3s) ease-in-out infinite;
  animation-delay: var(--twd, 0s);
  filter: drop-shadow(0 0 6px rgba(200, 230, 255, 0.7));
  transition: filter 0.3s;
}
.star::before {               /* vùng hào quang khi hover */
  content: ""; position: absolute; inset: -30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 190, 255, 0.45), transparent 65%);
  opacity: 0; transform: scale(0.6);
  transition: opacity 0.3s, transform 0.3s;
}
.star:hover::before, .star:focus-visible::before { opacity: 1; transform: scale(1); }
.star:hover img { filter: drop-shadow(0 0 14px rgba(160, 210, 255, 1)); animation-duration: 0.9s; }
.star:focus-visible { outline: none; }

@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(0.72) rotate(12deg); opacity: 0.7; }
}

/* ---------- Popup ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  visibility: hidden;
}
.modal.is-open { visibility: visible; }
html.modal-lock { overflow: hidden; }   /* khoá cuộn trang khi đang xem popup */
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 4, 14, 0.7);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.modal.is-open .modal__backdrop { opacity: 1; }
.modal.is-closing .modal__backdrop { opacity: 0; transition-duration: 1s; }
/* Hiệu ứng cát tan: main.js vẽ mặt nạ hạt cát lên khung + bắn hạt cát ra */
.modal__card.is-sanding { -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.modal__card {
  position: relative;
  width: min(92vw, 760px);
  max-height: 86vh; overflow: auto;
  overscroll-behavior: contain;
  background: linear-gradient(160deg, rgba(20, 34, 60, 0.92), rgba(6, 10, 22, 0.95));
  border: 0;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(60, 130, 255, 0.15);
}
.modal__close {               /* chỉ chữ ×, không khung tròn */
  position: absolute; top: 10px; right: 14px; z-index: 2;
  width: 40px; height: 40px;
  border: 0; background: none; padding: 0;
  color: rgba(255, 255, 255, 0.75);
  font-family: var(--font-main); font-size: 30px; font-weight: 300; line-height: 1;
  transition: color 0.25s, text-shadow 0.25s, transform 0.25s;
}
.modal__close:hover { color: #fff; text-shadow: 0 0 12px rgba(140, 200, 255, 0.9); transform: scale(1.1); }
.modal__close:focus { outline: none; }
.modal__close:focus-visible { color: #fff; text-shadow: 0 0 12px rgba(140, 200, 255, 0.9); }
.modal__media {
  aspect-ratio: 16 / 9; width: 100%;
  border-radius: 18px 18px 0 0; overflow: hidden;
  background: #050a16;
}
.modal__media img, .modal__media video, .modal__media iframe {
  width: 100%; height: 100%; object-fit: contain; border: 0; display: block;
}
/* Popup "TBU": khung đen trong suốt, gradient xanh hắt từ dưới lên, chữ TBU có luồng sáng theo chuột */
.modal__card.is-tbu {
  background:
    linear-gradient(to top, rgba(40, 110, 220, 0.55) 0%, rgba(30, 80, 180, 0.22) 35%, rgba(0, 0, 0, 0) 70%),
    rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 20px 70px -20px rgba(60, 140, 255, 0.45);
}
.modal__card.is-tbu .modal__media { background: transparent; border-radius: 18px; }
.modal__card.is-tbu .modal__body { display: none; }
.tbu {
  position: relative;
  width: 100%; height: 100%;
  display: grid; place-items: center;
}
.tbu__text {
  position: relative;
  width: clamp(110px, 22%, 170px);   /* độ to hình TBU */
}
.tbu__base {
  display: block; width: 100%; height: auto;
  opacity: 0.12;
  transition: opacity 0.45s;
}
.tbu__light {              /* luồng sáng theo chuột, chỉ sáng trong hình chữ */
  position: absolute; inset: 0;
  -webkit-mask: url("../assets/tbu.png") center / 100% 100% no-repeat;
          mask: url("../assets/tbu.png") center / 100% 100% no-repeat;
  background-image: radial-gradient(
    circle var(--tbu-r, 120px) at var(--tx, -999px) var(--ty, -999px),
    #fff 0%, #bfe8ff 18%, rgba(100, 180, 255, 0.8) 40%, rgba(60, 130, 240, 0) 72%
  );
  opacity: 0; transition: opacity 0.35s;
  pointer-events: none;
}
.tbu__text { transition: filter 0.35s; }
.tbu.is-lit .tbu__light { opacity: 1; }
.tbu.is-lit .tbu__base { opacity: 0.55; }
.tbu.is-lit .tbu__text { filter: drop-shadow(0 0 14px rgba(120, 190, 255, 0.7)) drop-shadow(0 0 30px rgba(80, 150, 255, 0.4)); }
.modal__body { padding: 22px 28px 28px; }
.modal__title { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.modal__desc { color: var(--muted); line-height: 1.6; }

/* ---------- Watermark đáy ---------- */
.brandmark {
  position: fixed; left: 50%; bottom: 44px; z-index: 40;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.brandmark img { height: 26px; width: auto; opacity: 0.9; }
.brandmark span {
  font-size: 10.5px; letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
}

/* Thiết bị cảm ứng: bỏ cursor tuỳ chỉnh */
@media (hover: none) {
  .cursor { display: none; }   /* giữ canvas #dust vì hiệu ứng cát tan vẽ trên đó */
}
@media (prefers-reduced-motion: reduce) {
  .star img, .scroll-hint { animation: none; }
}

/* ---------- Con trỏ tuỳ chỉnh (ngôi sao <-> thuyền, chuyển kiểu fade) ---------- */
@media (hover: hover) {
  html, body, a, button, .star, .modal * { cursor: none !important; }
}
.cursor {
  position: fixed; left: 0; top: 0; z-index: 100;
  width: 0; height: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  will-change: transform;
}
.cursor.is-active { opacity: 1; }
.cursor img {
  position: absolute; left: 0; top: 0;
  height: auto;
  transition: opacity var(--cursor-fade) ease, transform var(--cursor-fade) cubic-bezier(.3, 1.3, .5, 1);
}
.cursor__star {
  width: var(--cursor-star-size);
  transform: translate(-50%, -50%) scale(1) rotate(0deg);
  filter: drop-shadow(0 0 6px rgba(190, 225, 255, 0.9));
}
.cursor__boat {
  width: var(--cursor-boat-size);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5) rotate(-12deg);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}
body.on-map .cursor__star { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(90deg); }
body.on-map .cursor__boat { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
.cursor.is-pointer .cursor__boat, .cursor.is-pointer .cursor__star { filter: drop-shadow(0 0 10px rgba(160, 210, 255, 1)); }
.cursor.is-down img { transition-duration: 0.15s; }
.cursor.is-down .cursor__star { transform: translate(-50%, -50%) scale(0.8); }
body.on-map .cursor.is-down .cursor__boat { transform: translate(-50%, -50%) scale(0.88); }


/* Bụi tiên */
#dust {
  position: fixed; inset: 0; z-index: 99;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* =========================================================
   MOBILE / TABLET DỌC (3:4, 9:16)
   ========================================================= */
:root {
  --hero-scale-mobile: 1;     /* độ to cụm logo + thuyền trên mobile */
  --map-scale-mobile: 1;      /* độ to chòm sao trên mobile */
  --sweep-speed: 3.6s;        /* tốc độ ánh sáng quét qua logo */
}

/* Ánh sáng quét qua logo (tự chạy, không cần con trỏ) */
.hero-logo.is-sweep .hero-logo__light {
  opacity: 1;
  background:
    linear-gradient(105deg,
      transparent 38%,
      rgba(120, 190, 255, 0.55) 45%,
      rgba(255, 255, 255, 1) 50%,
      rgba(160, 215, 255, 0.7) 54%,
      transparent 62%)
    0 0 / 300% 100% no-repeat;
  animation: logoSweep var(--sweep-speed) cubic-bezier(.45, .05, .35, 1) infinite;
}
.hero-logo.is-sweep { animation: logoGlow var(--sweep-speed) ease-in-out infinite; }
@keyframes logoSweep {
  0%   { background-position: 100% 0; }
  60%  { background-position: 0% 0; }
  100% { background-position: 0% 0; }
}
@keyframes logoGlow {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(90, 170, 255, 0)); }
  30%      { filter: drop-shadow(0 0 16px rgba(90, 170, 255, 0.35)); }
  60%      { filter: drop-shadow(0 0 0 rgba(90, 170, 255, 0)); }
}

@media (max-aspect-ratio: 4/5) {
  /* Trang 1: khung dọc 3:4 */
  .page-hero .stage {          /* khung 9:16 rộng bằng màn hình, logo tràn mép như ref */
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: calc(100vw * var(--hero-scale-mobile));
    aspect-ratio: 9 / 16;
  }
  .scroll-hint { bottom: 110px; }

  /* Trang 2: xoay chòm sao 90° và phóng to cho vừa màn hình dọc */
  .page-constellation .stage {
    position: absolute; left: 50%; top: 50%;
    width: calc(min(118svh, 195vw) * var(--map-scale-mobile));
    transform: translate(-50%, -50%) rotate(90deg);
  }
  .star { width: 5.2%; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-logo.is-sweep, .hero-logo.is-sweep .hero-logo__light { animation: none; }
}

/* ---------- Popup trên mobile / tablet dọc ---------- */
body.is-portrait .modal__card {
  width: 90vw;
  max-height: 84svh;
  border-radius: 22px;
}
body.is-portrait .modal__media { border-radius: 22px 22px 0 0; }
/* Khung TBU: dựng đứng cho dễ nhìn */
body.is-portrait .modal__card.is-tbu .modal__media {
  aspect-ratio: 4 / 5;
  max-height: 78svh;
  border-radius: 22px;
}
body.is-portrait .tbu__text { width: 52%; }
/* Poster: hiện theo đúng tỉ lệ ảnh, không bị bóp vào khung ngang */
body.is-portrait .modal__media:has(> img) { aspect-ratio: auto; }
body.is-portrait .modal__media > img { height: auto; max-height: 68svh; }
body.is-portrait .modal__body { padding: 18px 20px 24px; }
body.is-portrait .modal__title { font-size: 22px; }
body.is-portrait .modal__close { width: 44px; height: 44px; font-size: 34px; top: 8px; right: 10px; }

/* TBU trên mobile: không có hover nên ánh sáng tự quét qua, lặp lại như logo homepage */
body.is-portrait .tbu .tbu__light {
  opacity: 1;
  background:
    linear-gradient(105deg,
      transparent 38%,
      rgba(120, 190, 255, 0.55) 45%,
      rgba(255, 255, 255, 1) 50%,
      rgba(160, 215, 255, 0.7) 54%,
      transparent 62%)
    0 0 / 300% 100% no-repeat;
  animation: logoSweep var(--sweep-speed) cubic-bezier(.45, .05, .35, 1) infinite;
}
body.is-portrait .tbu .tbu__base { animation: tbuPulse var(--sweep-speed) ease-in-out infinite; }
body.is-portrait .tbu .tbu__text { animation: logoGlow var(--sweep-speed) ease-in-out infinite; }
@keyframes tbuPulse {
  0%, 100% { opacity: 0.14; }
  30%      { opacity: 0.5; }
  60%      { opacity: 0.14; }
}
@media (prefers-reduced-motion: reduce) {
  body.is-portrait .tbu .tbu__light, body.is-portrait .tbu .tbu__base, body.is-portrait .tbu .tbu__text { animation: none; }
}

/* Mobile: popup mở ra bằng fade nhẹ (đóng vẫn là cát tan) */
.modal__card.is-fade-in { animation: popupFadeIn 0.45s ease-out both; }
@keyframes popupFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
