:root, :root[data-theme='dark'] {
  --bg: #050a14;
  --ink: #e8f1ff;
  --muted: #8aa3c4;
  --accent: #3d9bff;
  --accent-2: #6fe3ff;
  --glass: rgba(10, 20, 38, 0.62);
  --line: rgba(111, 170, 255, 0.22);
  --nav-fade: rgba(5, 10, 20, 0.85);
  --vignette: rgba(3, 6, 14, 0.75);
  --hero-glow: rgba(61, 155, 255, 0.35);
}
:root[data-theme='light'] {
  --bg: #e9eff7;
  --ink: #0b1b33;
  --muted: #4d6480;
  --accent: #1f6fe0;
  --accent-2: #0b74c9;
  --glass: rgba(255, 255, 255, 0.74);
  --line: rgba(20, 80, 160, 0.16);
  --nav-fade: rgba(233, 239, 247, 0.9);
  --vignette: rgba(160, 185, 215, 0.35);
  --hero-glow: rgba(255, 255, 255, 0.8);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: 'Be Vietnam Pro', system-ui, sans-serif; overflow: hidden; transition: background 0.6s, color 0.6s; }
#map { position: fixed; inset: 0; }
.vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 40%, transparent 55%, var(--vignette) 100%); }
.maplibregl-ctrl-attrib { background: var(--glass) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Video cầu nối 3D → ảnh thật: khung đầu trùng khung cuối của bản đồ nên chỉ cần hiện nhanh. */
#bridge { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; pointer-events: none; transition: opacity 0.35s ease; background: transparent; }
#bridge.show { opacity: 1; }
#bridge.fade-slow { transition-duration: 0.6s; }
/* Ảnh chụp toàn cảnh ngay trước khi đổi sáng/tối, mờ dần để lộ giao diện mới bên dưới. */
#theme-fade { position: fixed; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.btn, .chip, .timeline, .story, .stats div, .scrub-hint, .nav, .maplibregl-ctrl-attrib { transition: background-color 1.2s ease, color 1.2s ease, border-color 1.2s ease, opacity 0.4s; }

.nav { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 16px; padding: 18px 40px; background: linear-gradient(var(--nav-fade), transparent); z-index: 5; }
.logo { font-weight: 700; font-size: 26px; letter-spacing: 0.04em; }
.nav nav { display: flex; gap: 26px; margin-left: 40px; flex: 1; }
.nav a { color: var(--muted); font-size: 14px; cursor: pointer; }
.nav a:hover { color: var(--ink); }

.btn { border: 1px solid var(--line); background: var(--glass); color: var(--ink); padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; font-family: inherit; cursor: pointer; backdrop-filter: blur(8px); }
.btn.primary { background: linear-gradient(135deg, #2f86ff, #36c6ff); color: #fff; border: 0; box-shadow: 0 6px 24px rgba(47, 134, 255, 0.4); }
.btn.wide { width: 100%; margin-top: 18px; padding: 14px; }
.btn.round { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
#theme-toggle .moon { display: none; }
:root[data-theme='dark'] #theme-toggle .sun { display: none; }
:root[data-theme='dark'] #theme-toggle .moon { display: inline; }

.hero { position: fixed; left: 40px; bottom: 150px; max-width: 560px; z-index: 4; transition: opacity 0.8s, transform 0.8s; pointer-events: none; }
.focused .hero { opacity: 0; transform: translateY(24px); }
.kicker { color: var(--accent-2); font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; margin-bottom: 14px; font-weight: 600; }
.hero h1 { margin: 0; font-size: clamp(32px, 4.4vw, 58px); line-height: 1.05; font-weight: 700; text-shadow: 0 4px 40px var(--hero-glow); }
.hero h1 span { background: linear-gradient(90deg, #2f86ff, #36c6ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: 16px; margin-top: 18px; }

.panel { position: fixed; top: 96px; right: 32px; width: 340px; padding: 24px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(14px); z-index: 6; transform: translateX(420px); opacity: 0; transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.6s, background-color 1.2s ease, color 1.2s ease, border-color 1.2s ease; }
.panel.open { transform: none; opacity: 1; }
.back { background: none; border: 0; color: var(--muted); font-weight: 500; font-size: 13px; font-family: inherit; cursor: pointer; padding: 0; margin-bottom: 16px; }
.back:hover { color: var(--ink); }
.code { color: var(--accent-2); font-size: 12px; letter-spacing: 0.16em; font-weight: 600; }
.panel h2 { margin: 6px 0 18px; font-size: 26px; line-height: 1.2; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats div { border: 1px solid var(--line); border-radius: 12px; padding: 12px 10px; }
.stats b { display: block; font-size: 20px; }
.stats span { color: var(--muted); font-size: 11px; }
.fresh { margin-top: 8px; font-size: 11px; color: var(--muted); }
.story { margin-top: 12px; padding: 14px; border-radius: 12px; border: 1px dashed var(--line); }
.story-tag { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.story p { margin: 8px 0 10px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.story-cta { font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; }

.scrub-hint { position: fixed; left: 50%; bottom: 110px; transform: translate(-50%, 10px); padding: 8px 14px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); color: var(--muted); font-size: 12px; opacity: 0; transition: opacity 0.5s, transform 0.5s; z-index: 5; pointer-events: none; }
.scrub-hint.show { opacity: 1; transform: translate(-50%, 0); }

.timeline { position: fixed; left: 40px; bottom: 84px; display: flex; align-items: center; gap: 12px; z-index: 5; padding: 8px 16px 8px 8px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); transition: opacity 0.6s; }
.focused .timeline { opacity: 0; pointer-events: none; }
.timeline input { width: 240px; accent-color: var(--accent); }
.tl-edge { color: var(--muted); font-size: 12px; }
.timeline b { font-size: 18px; min-width: 44px; }
#year-count { color: var(--muted); font-size: 13px; }

.chips { position: fixed; left: 40px; right: 40px; bottom: 30px; display: flex; gap: 10px; overflow-x: auto; z-index: 5; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--glass); color: var(--muted); padding: 8px 14px; border-radius: 999px; font-size: 13px; font-family: inherit; cursor: pointer; backdrop-filter: blur(8px); white-space: nowrap; transition: opacity 0.4s; }
.chip.featured { color: var(--ink); border-color: var(--accent); }
.chip.active { background: linear-gradient(135deg, #2f86ff, #36c6ff); color: #fff; border-color: transparent; }
.chip.future { opacity: 0.25; }

@media (max-width: 760px) {
  .nav { padding: 14px 16px; gap: 10px; }
  .nav nav { display: none; }
  .nav #theme-toggle { margin-left: auto; padding: 8px 12px; }
  .hero { left: 16px; right: 16px; bottom: 150px; }
  .hero p { font-size: 14px; }
  .panel { left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; padding: 18px; transform: translateY(120%); }
  .panel h2 { font-size: 22px; margin-bottom: 12px; }
  .story { display: none; }
  .timeline { left: 16px; right: 16px; bottom: 76px; }
  .timeline input { flex: 1; width: auto; min-width: 0; }
  .tl-edge { display: none; }
  .chips { left: 16px; right: 16px; bottom: 24px; }
  .focused .chips { opacity: 0; pointer-events: none; }
  .scrub-hint { bottom: auto; top: 76px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ───────── Ghim bản đồ (theo mẫu founder 06/11): giọt nước xanh + biểu tượng tòa + nhãn vàng + sóng ───────── */
.pin { position: relative; width: 34px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; pointer-events: none; transition: opacity 0.4s; }
.pin.up { pointer-events: auto; }
.pin-body { position: absolute; inset: 0; transform-origin: 50% 100%; transform: scale(0, 0); }
.pin-body svg { width: 100%; height: 100%; filter: drop-shadow(0 4px 6px rgba(11, 79, 217, 0.35)); }
.pin-label {
  position: absolute; left: 27px; top: 15px; white-space: nowrap;
  font: 700 10.5px/1 'Be Vietnam Pro', sans-serif; letter-spacing: 0.04em; text-transform: uppercase; color: #fff;
  background: linear-gradient(180deg, #d9b25f, #b38a36); padding: 5px 9px; border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); opacity: 0; transform: translateX(-8px) scale(0.9); transform-origin: left center;
  transition: opacity 0.35s 0.3s, transform 0.35s 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pin-wave { position: absolute; left: 50%; bottom: -11px; width: 64px; height: 24px; margin-left: -32px; border-radius: 50%; background: radial-gradient(ellipse, rgba(54, 198, 255, 0.6), rgba(54, 198, 255, 0) 70%); opacity: 0; pointer-events: none; }
/* Mọc như nấm: nhú lên từ mặt đất → vươn cao → bè ra → nảy về dáng chuẩn */
.pin.up .pin-body { animation: pin-mushroom 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.pin.up .pin-label { opacity: 1; transform: none; }
.pin.up .pin-wave { animation: pin-wave 2.6s ease-out 0.35s infinite; }
.pin.up .pin-wave.w2 { animation-delay: 1.65s; }
.pin:hover .pin-label, .pin:focus-visible .pin-label { background: linear-gradient(180deg, #2f86ff, #0b4fd9); }
@keyframes pin-mushroom {
  0% { transform: scale(0.3, 0); }
  40% { transform: scale(0.82, 1.24); }
  60% { transform: scale(1.14, 0.86); }
  78% { transform: scale(0.95, 1.06); }
  100% { transform: scale(1, 1); }
}
@keyframes pin-wave { 0% { transform: scale(0.3); opacity: 0.9; } 100% { transform: scale(1.7); opacity: 0; } }
/* Ghim lớn HALO */
.pin.hq { width: 58px; height: 70px; }
/* thân ghim lớn KHÔNG xoay; chỉ lớp nền giọt nước xoay -45° ⇒ chữ HALO luôn thẳng */
.pin-hq { position: absolute; isolation: isolate; left: 3px; top: 0; width: 52px; height: 52px; display: grid; place-items: center; font: 800 13px/1 'Be Vietnam Pro', sans-serif; color: #0b4fd9; letter-spacing: 0.02em; }
.pin-hq::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: #fff; border: 4px solid #0b4fd9; box-shadow: 0 6px 14px rgba(11, 79, 217, 0.35); }
.pin.hq .pin-label { left: 50px; top: 46px; font-size: 13px; padding: 7px 12px; }
.pin.hq .pin-wave { width: 110px; height: 40px; margin-left: -55px; bottom: -18px; }
/* Ghim nhường chỗ: khi đang xem một tòa, hoặc zoom sát đã thấy khối 3D */
.pins-hidden .pin, .pins-near .pin { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .pin.up .pin-body { animation: none; transform: none; } .pin.up .pin-wave { animation: none; } }

/* ───────── Khẩu hiệu trên nền kính; ẩn khi người dùng bắt đầu zoom ───────── */
.hero { max-width: 620px; background: var(--glass); border: 1px solid var(--line); border-radius: 22px; padding: 26px 30px; backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2); box-shadow: 0 18px 50px rgba(5, 20, 50, 0.18); }
.zoomed .hero { opacity: 0; transform: translateY(24px); }
@media (max-width: 760px) { .hero { padding: 18px 20px; } }

/* ───────── Hiệu năng ─────────
   backdrop-filter làm mờ LẠI nền mỗi khung khi bản đồ WebGL đang vẽ ⇒ rất nặng.
   - Nút tên tòa: bỏ hẳn kính mờ (nền đặc hơn chút, nhìn gần như nhau).
   - Khẩu hiệu / panel / thanh thời gian / nút: chỉ làm mờ khi bản đồ ĐỨNG YÊN (body:not(.moving)). */
:root, :root[data-theme='dark'] { --glass-solid: rgba(10, 20, 38, 0.86); }
:root[data-theme='light'] { --glass-solid: rgba(255, 255, 255, 0.9); }
.chip { backdrop-filter: none; background: var(--glass-solid); }
body.moving .hero, body.moving .panel, body.moving .timeline, body.moving .btn { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--glass-solid); }
.btn.primary, body.moving .btn.primary { background: linear-gradient(135deg, #2f86ff, #36c6ff); }
/* Ghim: 1 vòng sóng; dừng sóng khi bản đồ di chuyển (đỡ vẽ lại 26 phần tử mỗi khung) */
.pin { will-change: transform; }
.pin-wave.w2 { display: none; }
body.moving .pin-wave { animation-play-state: paused; opacity: 0 !important; }
/* Chế độ nhẹ (máy yếu / giảm chuyển động): không sóng, không kính mờ */
.lite .pin-wave { display: none; }
.lite .hero, .lite .panel, .lite .timeline, .lite .btn { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--glass-solid); }
.lite .btn.primary { background: linear-gradient(135deg, #2f86ff, #36c6ff); }
