/* =========================================================
   GIA PHẢ ĐẠI VIỆT — Template2 (Hiện đại — Ấm áp, gần gũi)
   Bảng màu: kem be + nâu cà phê (espresso) + đất nung (terracotta) + vàng mật ong (honey)
   ========================================================= */

:root {
  --cream: #faf6ef;
  --cream-soft: #f4ead9;
  --cream-card: #fffbf3;
  --espresso-900: #241a12;
  --espresso-800: #3d2b1f;
  --espresso-700: #4a3426;
  --espresso-600: #5c4331;
  --espresso-500: #6f5340;
  --terracotta-800: #7a2f17;
  --terracotta-700: #9a3a1f;
  --terracotta-600: #bc4b2f;
  --terracotta-500: #c2410c;
  --terracotta-400: #dd6b3f;
  --espresso-400: #8a6b54;
  --honey-800: #6e4c17;
  --honey-700: #8a5f1e;
  --honey-600: #ab7827;
  --honey-500: #c68a32;
  --honey-400: #d4a24e;
  --honey-300: #e6c184;
  --honey-200: #f2dcb3;
  --honey-100: #faeed7;
  --terracotta-300: #eb9772;
  --terracotta-100: #fbe3d4;
  --olive-600: #5b6b2b;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--cream);
  color: var(--espresso-800);
  font-family: "Be Vietnam Pro", "Inter", "Noto Sans", sans-serif;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--cream-soft); }
::-webkit-scrollbar-thumb { background: var(--terracotta-500); border-radius: 999px; border: 2px solid var(--cream-soft); }

::selection { background: var(--honey-400); color: var(--espresso-900); }

/* ---------- Texture nền ấm nhẹ (kiểu giấy cổ mờ) ---------- */
.bg-warm-texture {
  background-color: var(--cream);
  background-image:
    radial-gradient(rgba(188, 75, 47, 0.05) 1.5px, transparent 1.5px),
    radial-gradient(rgba(198, 138, 50, 0.06) 1.5px, transparent 1.5px);
  background-size: 30px 30px, 30px 30px;
  background-position: 0 0, 15px 15px;
}
/* Biến thể cho các khối nền kem đậm hơn (cream-soft) — vẫn giữ texture giấy mờ */
.bg-warm-texture-soft {
  background-color: var(--cream-soft);
  background-image:
    radial-gradient(rgba(122, 47, 23, 0.05) 1.5px, transparent 1.5px),
    radial-gradient(rgba(138, 95, 30, 0.06) 1.5px, transparent 1.5px);
  background-size: 30px 30px, 30px 30px;
  background-position: 0 0, 15px 15px;
}

/* ---------- Hero: gradient ấm + blob hữu cơ ---------- */
.bg-hero-warm {
  background: radial-gradient(120% 140% at 15% 0%, #eb9772 0%, #dd6b3f 28%, #bc4b2f 55%, #9a3a1f 100%);
}

.blob {
  position: absolute;
  border-radius: 62% 38% 55% 45% / 48% 42% 58% 52%;
  filter: blur(0px);
}
.blob-soft {
  filter: blur(2px);
}

@keyframes blob-float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-8px, 10px) rotate(3deg); }
}
.blob-animate {
  animation: blob-float 18s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .blob-animate { animation: none; }
}

/* ---------- Monogram / huy hiệu dòng họ hiện đại ---------- */
.monogram {
  background: linear-gradient(145deg, var(--honey-400), var(--terracotta-500));
  color: var(--cream);
  box-shadow: 0 8px 20px rgba(154, 58, 31, 0.35);
}

/* ---------- Ảnh tông ấm (duotone sepia hiện đại) ---------- */
.duotone-warm {
  position: relative;
  overflow: hidden;
}
.duotone-warm img {
  filter: sepia(38%) saturate(150%) hue-rotate(-8deg) brightness(0.97) contrast(1.04);
  transition: transform 0.6s ease;
}
.duotone-warm:hover img {
  transform: scale(1.06);
}
.duotone-warm::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(154, 58, 31, 0.08), rgba(74, 52, 38, 0.35));
  mix-blend-mode: multiply;
}

/* ---------- Header shadow khi cuộn ---------- */
header.is-scrolled {
  box-shadow: 0 10px 30px rgba(74, 52, 38, 0.12);
}

/* ---------- Card ấm, bo lớn, đổ bóng ấm ---------- */
.card-warm {
  background: var(--cream-card);
  border: 1.5px solid transparent;
  box-shadow: 0 10px 28px rgba(74, 52, 38, 0.08);
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}
.card-warm:hover {
  transform: translateY(-6px);
  box-shadow: 0 22px 44px rgba(154, 58, 31, 0.16);
  border-color: var(--honey-400);
}

/* ---------- Nút chính / phụ ---------- */
.btn-primary {
  background: var(--terracotta-600);
  color: var(--cream);
  box-shadow: 0 10px 22px rgba(188, 75, 47, 0.35);
  transition: all 0.3s ease;
}
.btn-primary:hover {
  background: var(--terracotta-700);
  box-shadow: 0 14px 28px rgba(188, 75, 47, 0.45);
  transform: translateY(-2px);
}
.btn-outline-warm {
  border: 1.5px solid var(--honey-400);
  color: var(--espresso-800);
  transition: all 0.3s ease;
}
.btn-outline-warm:hover {
  background: var(--honey-400);
  color: var(--espresso-900);
}

/* ---------- Chip / badge pill màu đầy ---------- */
.pill-terracotta {
  background: var(--terracotta-500);
  color: var(--cream);
}
.pill-honey {
  background: var(--honey-400);
  color: var(--espresso-900);
}

/* ---------- Tiêu đề mục: chấm + gạch ấm ---------- */
.title-ornament-warm {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}
.title-ornament-warm .line {
  height: 3px;
  width: 36px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--honey-400), var(--terracotta-500));
}
.title-ornament-warm .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--terracotta-500);
}
.title-ornament-warm.ornament-left {
  justify-content: flex-start;
}

/* ---------- Khung viền kép trang trọng (thư ngỏ, khung phả đồ, stat nổi bật) ---------- */
.frame-heritage {
  position: relative;
  border: 1.5px solid var(--honey-400);
}
.frame-heritage::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid var(--honey-300);
  border-radius: inherit;
  pointer-events: none;
}

/* ---------- Triện / con dấu cách điệu tối giản (thư ngỏ trưởng tộc) ---------- */
.seal-badge {
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  border: 2px solid var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.seal-badge::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(250, 246, 239, 0.55);
  border-radius: 9999px;
}
.seal-badge span {
  font-family: "Noto Serif", serif;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.01em;
  color: var(--honey-200);
}

/* ---------- 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 khi cuộn ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Ẩn thanh cuộn ---------- */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }

/* ---------- Cây phả hệ thu nhỏ trang trí (trang chủ) ---------- */
.tree-mini, .tree-mini ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
}
.tree-mini ul {
  padding-top: 26px;
  position: relative;
}
.tree-mini li {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  padding: 26px 12px 0 12px;
}
.tree-mini li::before,
.tree-mini li::after {
  content: "";
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 2px solid var(--honey-400);
  width: 50%;
  height: 26px;
}
.tree-mini li::after {
  right: auto;
  left: 50%;
  border-left: 2px solid var(--honey-400);
}
.tree-mini li:only-child::before,
.tree-mini li:only-child::after { display: none; }
.tree-mini li:only-child { padding-top: 0; }
.tree-mini li:first-child::before { border: 0 none; }
.tree-mini li:last-child::after { border: 0 none; }
.tree-mini li:last-child::before {
  border-right: 2px solid var(--honey-400);
  border-radius: 0 8px 0 0;
}
.tree-mini li:first-child::after { border-radius: 8px 0 0 0; }
.tree-mini ul ul::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 2px solid var(--honey-400);
  width: 0;
  height: 26px;
}
.tree-mini li .node {
  border: 1.5px solid var(--honey-400);
  background: var(--cream-card);
  padding: 10px 16px;
  border-radius: 14px;
  min-width: 132px;
  box-shadow: 0 8px 18px rgba(74, 52, 38, 0.1);
}

/* ---------- Sơ đồ phả hệ tương tác (D3.js) — tông ấ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(--terracotta-600);
  filter: drop-shadow(0 6px 12px rgba(74, 52, 38, 0.3));
}
.tree-node-dim { opacity: 0.22; }
.tree-node-match {
  stroke: var(--honey-400) !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 9px rgba(212, 162, 78, 0.9)) !important;
}

.tree-frame {
  border: 3px solid var(--honey-500);
  box-shadow: inset 0 0 0 3px var(--cream-card), inset 0 0 0 4px var(--terracotta-400), 0 22px 48px rgba(74, 52, 38, 0.22);
  background: var(--espresso-800);
}
.tree-frame-ribbon {
  background: linear-gradient(90deg, var(--terracotta-700), var(--terracotta-600) 50%, var(--terracotta-700));
}

.tree-canvas-bg {
  position: relative;
  background:
    radial-gradient(ellipse at center, rgba(212, 162, 78, 0.16), transparent 55%),
    radial-gradient(ellipse at center, transparent 55%, rgba(122, 47, 23, 0.14) 100%),
    var(--cream);
}

/* 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: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--cream-card);
  color: var(--terracotta-700);
  border-radius: 9999px;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(74, 52, 38, 0.22);
  transition: all 0.25s ease;
}
.tree-zoom-btn:hover {
  background: var(--terracotta-600);
  color: var(--cream);
  transform: translateY(-2px);
}

/* ---------- Thẻ thành viên (lưới danh sách) ---------- */
.member-card { text-align: center; }
.member-card .avatar-ring {
  box-shadow: 0 8px 18px rgba(74, 52, 38, 0.14);
}

/* ---------- 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; }

/* ---------- Album ---------- */
.album-card { cursor: pointer; }
.album-card:focus-visible {
  outline: 2px solid var(--honey-400);
  outline-offset: 2px;
}

/* ---------- Fancybox: tông ấm ---------- */
.fancybox__backdrop {
  background: rgba(36, 26, 18, 0.94);
}
.fancybox__caption {
  font-family: "Be Vietnam Pro", sans-serif;
  color: var(--honey-300);
}
.fancybox__toolbar,
.fancybox__nav {
  --f-button-color: var(--honey-300);
}
.fancybox__thumbs {
  --f-thumb-selected-outline-color: var(--honey-400);
}
