/* =========================================================
   GIA PHẢ ĐẠI VIỆT — Template5: ĐEN SƠN MÀI - VÀNG KIM
   Style dùng chung: màu sắc, font, hoa văn trang trọng —
   hoành phi câu đối chữ vàng trên nền sơn mài đen, tối giản màu,
   hạn chế tối đa sắc đỏ.
   ========================================================= */

:root {
  --ivory: #f3ead2;
  --ivory-soft: #f8f1e0;
  --paper: #faf3e2;
  --ink: #241a0f;
  --ink-soft: #55432c;
  --lacquer-900: #120e0a;
  --lacquer-800: #1a130d;
  --lacquer-700: #221a11;
  --lacquer-600: #2b2118;
  --lacquer-500: #382b1c;
  --gold-800: #5c4718;
  --gold-700: #7c611f;
  --gold-600: #b3922f;
  --gold-500: #d4af37;
  --gold-400: #e3c878;
  --gold-300: #f1e3b0;
  --cinnabar: #6b2318;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--ivory);
  color: var(--ink);
  font-family: "Be Vietnam Pro", "Noto Sans", sans-serif;
  overflow-x: hidden;
}

.font-serif-display {
  font-family: "Noto Serif", "Noto Serif Display", serif;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ivory); }
::-webkit-scrollbar-thumb { background: var(--gold-600); border-radius: 999px; border: 2px solid var(--ivory); }

/* ---------- Selection ---------- */
::selection { background: var(--gold-500); color: var(--lacquer-900); }

/* ---------- Texture nền giấy cổ ---------- */
.bg-paper-texture {
  background-color: var(--ivory);
  background-image:
    radial-gradient(rgba(92, 71, 24, 0.06) 1px, transparent 1px),
    radial-gradient(rgba(92, 71, 24, 0.05) 1px, transparent 1px);
  background-size: 26px 26px, 26px 26px;
  background-position: 0 0, 13px 13px;
}

/* Nền sơn mài đen ấm — dùng cho hero, footer, các khối CTA trang trọng */
.bg-lacquer-texture {
  background-color: var(--lacquer-800);
  background-image:
    linear-gradient(135deg, rgba(212, 175, 55, 0.035) 1px, transparent 1px),
    linear-gradient(-135deg, rgba(212, 175, 55, 0.035) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* ---------- Diềm trang trí (đã tắt theo yêu cầu) ---------- */
.pattern-strip,
.pattern-strip-thin {
  display: none;
}

/* ---------- Khung viền kép kiểu sắc phong / bằng chứng nhận ---------- */
.frame-double {
  border: 1.5px solid var(--gold-600);
  outline: 1px solid var(--gold-600);
  outline-offset: 6px;
}

/* ---------- Khung góc chữ L (trang trí ảnh, thẻ) ---------- */
.corner-frame {
  position: relative;
}
.corner-frame::before,
.corner-frame::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--gold-500);
  border-style: solid;
  border-width: 0;
  z-index: 10;
  pointer-events: none;
}
.corner-frame::before {
  top: -8px;
  left: -8px;
  border-top-width: 2px;
  border-left-width: 2px;
}
.corner-frame::after {
  bottom: -8px;
  right: -8px;
  border-bottom-width: 2px;
  border-right-width: 2px;
}

/* ---------- Triện dấu — điểm nhấn ấm duy nhất ngoài đen/vàng/kem ---------- */
.seal {
  width: 64px;
  height: 64px;
  background: var(--cinnabar);
  border: 2px solid var(--gold-500);
  color: var(--gold-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Noto Serif", serif;
  font-weight: 700;
  font-size: 22px;
  transform: rotate(-6deg);
  box-shadow: 0 6px 16px rgba(18, 14, 10, 0.5);
  border-radius: 4px;
}

/* ---------- Tiêu đề mục: gạch + thoi hai bên ---------- */
.title-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}
.title-ornament .line {
  height: 1px;
  width: 48px;
  background: linear-gradient(90deg, transparent, var(--gold-600));
}
.title-ornament .line.reverse {
  background: linear-gradient(90deg, var(--gold-600), transparent);
}
.title-ornament .diamond {
  width: 8px;
  height: 8px;
  background: var(--gold-600);
  transform: rotate(45deg);
}

/* ---------- Ánh vàng lấp lánh nhẹ cho các chi tiết quan trọng ---------- */
.gold-shimmer {
  background: linear-gradient(100deg, var(--gold-600) 0%, var(--gold-300) 22%, var(--gold-500) 45%, var(--gold-300) 68%, var(--gold-600) 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gold-shimmer-move 7s linear infinite;
}
@keyframes gold-shimmer-move {
  to { background-position: 220% center; }
}
@media (prefers-reduced-motion: reduce) {
  .gold-shimmer { animation: none; }
}

/* ---------- Ảnh tông màu hoài cổ, trầm — duotone đen sơn mài ---------- */
.duotone {
  position: relative;
  overflow: hidden;
}
.duotone img {
  filter: sepia(30%) saturate(115%) hue-rotate(8deg) brightness(0.86) contrast(1.08);
  transition: transform 0.6s ease;
}
.duotone:hover img {
  transform: scale(1.06);
}
.duotone::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(26, 19, 13, 0.18), rgba(12, 9, 6, 0.5));
  mix-blend-mode: multiply;
}

/* ---------- Header shadow khi scroll ---------- */
header.is-scrolled {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ---------- Card hover nâng nhẹ ---------- */
.rise-on-hover {
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.rise-on-hover:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 40px rgba(18, 14, 10, 0.22);
}

/* ---------- Nút viền vàng ---------- */
.btn-gold-outline {
  border: 1.5px solid var(--gold-500);
  color: var(--gold-300);
  transition: all 0.3s ease;
}
.btn-gold-outline:hover {
  background: var(--gold-500);
  color: var(--lacquer-900);
}

/* ---------- Cây phả hệ (CSS org-chart) ---------- */
.tree, .tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
}
.tree ul {
  padding-top: 28px;
  position: relative;
}
.tree li {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  padding: 28px 14px 0 14px;
}
.tree li::before,
.tree li::after {
  content: "";
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 2px solid var(--gold-500);
  width: 50%;
  height: 28px;
}
.tree li::after {
  right: auto;
  left: 50%;
  border-left: 2px solid var(--gold-500);
}
.tree li:only-child::before,
.tree li:only-child::after {
  display: none;
}
.tree li:only-child { padding-top: 0; }
.tree li:first-child::before { border: 0 none; }
.tree li:last-child::after { border: 0 none; }
.tree li:last-child::before {
  border-right: 2px solid var(--gold-500);
  border-radius: 0 6px 0 0;
}
.tree li:first-child::after {
  border-radius: 6px 0 0 0;
}
.tree ul ul::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 2px solid var(--gold-500);
  width: 0;
  height: 28px;
}
.tree li .node {
  border: 1.5px solid var(--gold-500);
  background: var(--paper);
  padding: 10px 16px;
  border-radius: 6px;
  min-width: 132px;
  box-shadow: 0 6px 14px rgba(18, 14, 10, 0.15);
}

/* ---------- Accordion đời (details/summary) ---------- */
details.gen-accordion summary { cursor: pointer; list-style: none; }
details.gen-accordion summary::-webkit-details-marker { display: none; }
details.gen-accordion[open] .chevron { transform: rotate(180deg); }
.chevron { transition: transform 0.3s ease; }

/* ---------- Mobile nav (off-canvas drawer) ---------- */
#mobile-menu {
  position: fixed; top: 0; left: 0; height: 100vh; width: 82%; max-width: 320px;
  transform: translateX(-100%); transition: transform 0.35s ease; z-index: 60; overflow-y: auto;
}
#mobile-menu.open { transform: translateX(0); }
#mobile-menu-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 55;
  opacity: 0; pointer-events: none; transition: opacity 0.35s ease;
}
#mobile-menu-backdrop.open { opacity: 1; pointer-events: auto; }

/* ---------- Huy hiệu dòng họ — hào quang toả sáng (hero) ---------- */
.hero-emblem-rays {
  background: repeating-conic-gradient(
    from 0deg,
    rgba(212, 175, 55, 0.65) 0deg 1.4deg,
    transparent 1.4deg 10deg
  );
  animation: hero-emblem-spin 60s linear infinite;
}
@keyframes hero-emblem-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-emblem-rays { animation: none; }
}

/* ---------- Fade-in nhẹ khi cuộn tới ---------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Ẩn thanh cuộn (chuyên mục trượt ngang, v.v.) ---------- */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }

/* =========================================================
   Sơ đồ phả hệ tương tác (D3.js) — "gian thờ" sơn mài đen:
   khung viền vàng kim trên nền tối, thẻ thành viên nền kem ấm
   ========================================================= */
#tree-chart {
  cursor: grab;
}
#tree-chart svg { display: block; }
#tree-chart .node { transition: opacity 0.3s ease; }
#tree-chart .node:hover rect.tree-node-rect {
  stroke: var(--gold-300);
  filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.55));
}
.tree-node-dim { opacity: 0.22; }
.tree-node-match {
  stroke: var(--gold-300) !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 9px rgba(241, 227, 176, 0.9)) !important;
}

/* Khung sơ đồ phả hệ — như hoành phi sơn mài đen viền vàng kim kép */
.tree-frame {
  border: 3px solid var(--gold-600);
  box-shadow: inset 0 0 0 3px var(--lacquer-900), inset 0 0 0 4px var(--gold-500), 0 20px 45px rgba(0, 0, 0, 0.55);
  background: var(--lacquer-900);
}

.tree-frame-ribbon {
  background: linear-gradient(90deg, var(--lacquer-900), var(--lacquer-700) 50%, var(--lacquer-900));
}

/* Bộ lọc phả đồ trên mobile: thu gọn thành 1 nút, bấm mới mở */
#tree-filter-panel {
  animation: tree-filter-in 0.2s ease;
}
#tree-filter-panel.is-open {
  display: block !important;
}
@keyframes tree-filter-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Nền khung cây — như tường gian thờ, ánh sáng vàng toả nhẹ từ tâm ra viền tối */
.tree-canvas-bg {
  position: relative;
  background:
    radial-gradient(ellipse at center, rgba(212, 175, 55, 0.11), transparent 55%),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.4) 100%),
    var(--lacquer-900);
}

.tree-zoom-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--gold-500);
  background: var(--lacquer-800);
  color: var(--gold-400);
  border-radius: 9999px;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  transition: all 0.25s ease;
}
.tree-zoom-btn:hover {
  background: var(--gold-500);
  color: var(--lacquer-900);
}

/* ---------- Thẻ thành viên (lưới danh sách) ---------- */
.member-card { text-align: center; }
.member-card .avatar-ring {
  box-shadow: 0 6px 14px rgba(18, 14, 10, 0.2);
}

/* ---------- Album ---------- */
.album-card { cursor: pointer; }
.album-card:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

/* ---------- Fancybox: chỉnh tông màu cho khớp theme đen sơn mài ---------- */
.fancybox__backdrop {
  background: rgba(12, 9, 6, 0.96);
}
.fancybox__caption {
  font-family: "Be Vietnam Pro", sans-serif;
  color: var(--gold-300);
}
.fancybox__toolbar,
.fancybox__nav {
  --f-button-color: var(--gold-300);
}
.fancybox__thumbs {
  --f-thumb-selected-outline-color: var(--gold-500);
}
