/* =========================================================
   GIA PHẢ ĐẠI VIỆT — Template dòng họ — "Gốm Hoa Lam" (Template4)
   Style dùng chung: bảng màu xanh lam men gốm + trắng ngà + vàng kim,
   hoạ tiết hoa văn gốm sứ cổ Việt Nam (hoa mẫu đơn, diềm hồi văn)
   ========================================================= */

:root {
  --ivory: #f6f1e2;
  --ivory-soft: #faf6ea;
  --paper: #fdfbf3;
  --ink: #1b2733;
  --ink-soft: #46596b;
  --lam-950: #0a1f30;
  --lam-900: #12324a;
  --lam-800: #1a4360;
  --lam-700: #1d4265;
  --lam-600: #2f6d92;
  --lam-500: #4685ab;
  --lam-400: #6aa0c2;
  --gold-800: #7a5c1e;
  --gold-700: #977224;
  --gold-600: #b8912f;
  --gold-500: #cda63f;
  --gold-400: #ddc06a;
  --gold-300: #ecdca0;
}

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(--lam-950); }

/* ---------- Texture nền giấy cổ ---------- */
.bg-paper-texture {
  background-color: var(--ivory);
  background-image:
    radial-gradient(rgba(26, 67, 96, 0.06) 1px, transparent 1px),
    radial-gradient(rgba(26, 67, 96, 0.05) 1px, transparent 1px);
  background-size: 26px 26px, 26px 26px;
  background-position: 0 0, 13px 13px;
}

/* =========================================================
   HOẠ TIẾT GỐM HOA LAM
   ========================================================= */

/* Hoạ tiết nền hoa mẫu đơn cách điệu rải nhẹ — nền các section lớn (hero, banner, khung phả đồ...) */
.lam-bg-pattern {
  background-color: var(--ivory, #f6f1e2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cg fill='none' stroke='%231d4265' stroke-width='1.1' opacity='0.3'%3E%3Ccircle cx='45' cy='45' r='3'/%3E%3Cpath d='M45,22 Q52,31 45,40 Q38,31 45,22 Z'/%3E%3Cpath d='M45,68 Q52,59 45,50 Q38,59 45,68 Z'/%3E%3Cpath d='M22,45 Q31,38 40,45 Q31,52 22,45 Z'/%3E%3Cpath d='M68,45 Q59,38 50,45 Q59,52 68,45 Z'/%3E%3Cpath d='M28,28 Q36,33 40,41 Q31,39 28,28 Z'/%3E%3Cpath d='M62,28 Q54,33 50,41 Q59,39 62,28 Z'/%3E%3Cpath d='M28,62 Q36,57 40,49 Q31,51 28,62 Z'/%3E%3Cpath d='M62,62 Q54,57 50,49 Q59,51 62,62 Z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 90px 90px;
}
/* Bản nhạt hơn cho dải số liệu (chữ số nằm đè lên hoạ tiết nên cần dịu) */
.lam-bg-pattern-faint {
  background-color: var(--ivory, #f6f1e2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cg fill='none' stroke='%231d4265' stroke-width='1.1' opacity='0.15'%3E%3Ccircle cx='45' cy='45' r='3'/%3E%3Cpath d='M45,22 Q52,31 45,40 Q38,31 45,22 Z'/%3E%3Cpath d='M45,68 Q52,59 45,50 Q38,59 45,68 Z'/%3E%3Cpath d='M22,45 Q31,38 40,45 Q31,52 22,45 Z'/%3E%3Cpath d='M68,45 Q59,38 50,45 Q59,52 68,45 Z'/%3E%3Cpath d='M28,28 Q36,33 40,41 Q31,39 28,28 Z'/%3E%3Cpath d='M62,28 Q54,33 50,41 Q59,39 62,28 Z'/%3E%3Cpath d='M28,62 Q36,57 40,49 Q31,51 28,62 Z'/%3E%3Cpath d='M62,62 Q54,57 50,49 Q59,51 62,62 Z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 90px 90px;
}
/* Biến thể đậm hơn dùng trên nền xanh đậm (header/hero tối) — hoa văn màu kem/vàng nhạt */
.lam-bg-pattern-dark {
  background-color: var(--lam-900, #12324a);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cg fill='none' stroke='%23ecdca0' stroke-width='1' opacity='0.16'%3E%3Ccircle cx='45' cy='45' r='3'/%3E%3Cpath d='M45,22 Q52,31 45,40 Q38,31 45,22 Z'/%3E%3Cpath d='M45,68 Q52,59 45,50 Q38,59 45,68 Z'/%3E%3Cpath d='M22,45 Q31,38 40,45 Q31,52 22,45 Z'/%3E%3Cpath d='M68,45 Q59,38 50,45 Q59,52 68,45 Z'/%3E%3Cpath d='M28,28 Q36,33 40,41 Q31,39 28,28 Z'/%3E%3Cpath d='M62,28 Q54,33 50,41 Q59,39 62,28 Z'/%3E%3Cpath d='M28,62 Q36,57 40,49 Q31,51 28,62 Z'/%3E%3Cpath d='M62,62 Q54,57 50,49 Q59,51 62,62 Z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 90px 90px;
}
/* Diềm hồi văn (Greek-key / meander) vuông góc — thay thế toàn bộ các diềm mảnh đơn điệu */
.lam-vine-strip {
  height: 16px;
  background-repeat: repeat-x;
  background-position: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 16'%3E%3Cpath d='M0 13 H9 V3 H18 V13 H27 V3 H36 V13 H40' fill='none' stroke='%231d4265' stroke-width='2' stroke-linecap='square'/%3E%3C/svg%3E");
  background-size: 40px 16px;
}
.lam-vine-strip.on-dark {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 16'%3E%3Cpath d='M0 13 H9 V3 H18 V13 H27 V3 H36 V13 H40' fill='none' stroke='%23ecdca0' stroke-width='2' stroke-linecap='square'/%3E%3C/svg%3E");
  opacity: 0.75;
}
/* Diềm hồi văn mảnh — diềm nhỏ/tinh tế hơn */
.lam-wave-strip {
  height: 9px;
  background-repeat: repeat-x;
  background-position: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 9'%3E%3Cpath d='M0 7 H5 V2 H10 V7 H15 V2 H20 V7 H24' fill='none' stroke='%231d4265' stroke-width='1.3' opacity='0.7'/%3E%3C/svg%3E");
  background-size: 24px 9px;
}
/* Khung viền kép kiểu gốm sứ cao cấp viền kim khẩu */
.lam-frame {
  border: 1.5px solid var(--gold-600);
  outline: 1px solid var(--lam-700);
  outline-offset: 5px;
}

/* ---------- 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;
}

/* ---------- Ấn triện trang trí (thư ngỏ trưởng tộc) ---------- */
.seal {
  width: 64px;
  height: 64px;
  background: var(--lam-800);
  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(10, 31, 48, 0.35);
  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 tông xanh lam hoài cổ (duotone) ---------- */
.duotone {
  position: relative;
  overflow: hidden;
}
.duotone img {
  filter: grayscale(30%) saturate(105%) brightness(0.97) contrast(1.05);
  transition: transform 0.6s ease;
}
.duotone:hover img {
  transform: scale(1.06);
}
.duotone::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(18, 50, 74, 0.15), rgba(10, 31, 48, 0.55));
  mix-blend-mode: multiply;
}

/* ---------- Header shadow khi scroll ---------- */
header.is-scrolled {
  box-shadow: 0 8px 24px rgba(27, 39, 51, 0.18);
}

/* ---------- 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(27, 39, 51, 0.16);
}

/* ---------- 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(--lam-950);
}

/* ---------- 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(27, 39, 51, 0.1);
}

/* ---------- 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 trượt từ trái) ---------- */
#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.5); z-index: 55;
  opacity: 0; pointer-events: none; transition: opacity 0.35s ease;
}
#mobile-menu-backdrop.open { opacity: 1; pointer-events: auto; }

/* ---------- 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) ---------- */
#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(--lam-700);
  filter: drop-shadow(0 6px 10px rgba(27, 39, 51, 0.28));
}
.tree-node-dim { opacity: 0.25; }
.tree-node-match {
  stroke: var(--gold-400) !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 8px rgba(205, 166, 63, 0.85)) !important;
}

/* Khung sơ đồ phả hệ — rực rỡ, kiểu bằng gia phả cổ men lam viền kim khẩu */
.tree-frame {
  border: 3px solid var(--gold-600);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--gold-500), 0 20px 45px rgba(10, 31, 48, 0.25);
  background: var(--lam-950);
}

.tree-frame-ribbon {
  background: linear-gradient(90deg, var(--lam-900), var(--lam-800) 50%, var(--lam-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); }
}

.tree-zoom-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--gold-500);
  background: var(--paper);
  color: var(--lam-800);
  border-radius: 9999px;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(27, 39, 51, 0.2);
  transition: all 0.25s ease;
}
.tree-zoom-btn:hover {
  background: var(--lam-800);
  color: var(--gold-300);
}

/* ---------- 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(27, 39, 51, 0.15);
}

/* ---------- 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 ---------- */
.fancybox__backdrop {
  background: rgba(10, 31, 48, 0.94);
}
.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);
}
