/**
 * Gia phả họ Nguyễn Văn — CSS cho Focus View + Hồ sơ cá nhân (Phase B).
 *
 * Mobile-first: danh sách quan hệ xếp dọc, nút/link đủ lớn để bấm
 * bằng ngón tay (tối thiểu ~44px chiều cao chạm). Card hồ sơ co lại
 * vừa màn hình hẹp; trên màn hình rộng (>= 720px) ảnh hồ sơ nằm cạnh
 * thông tin thay vì chiếm cả chiều ngang.
 * File này chỉ style phần gia phả (.giapha-*), không đụng theme.
 */

.giapha-focus,
.giapha-profile {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
    box-sizing: border-box;
    line-height: 1.6;
    font-size: 16px;
}

.giapha-focus h2,
.giapha-profile-name {
    font-size: 1.5rem;
    line-height: 1.3;
    margin: 0 0 8px;
}

.giapha-focus h3,
.giapha-profile h3 {
    font-size: 1.15rem;
    margin: 24px 0 8px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 4px;
}

.giapha-focus h4,
.giapha-profile h4 {
    font-size: 1rem;
    margin: 16px 0 4px;
}

/* Danh sách quan hệ: mỗi dòng 1 người, xếp dọc, dễ bấm trên mobile. */
.giapha-relations {
    list-style: none;
    margin: 0;
    padding: 0;
}

.giapha-relations li {
    padding: 10px 4px;
    border-bottom: 1px solid #eee;
    min-height: 44px;
    box-sizing: border-box;
}

.giapha-relations a {
    font-weight: 600;
    text-decoration: none;
    padding: 6px 2px;
    display: inline-block;
}

.giapha-relations a:hover,
.giapha-relations a:focus {
    text-decoration: underline;
}

/* Hồ sơ cá nhân: card + bảng thông tin. */
.giapha-profile {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
}

.giapha-profile-photo {
    display: block;
    width: 100%;
    max-width: 220px;
    height: auto;
    border-radius: 8px;
    margin: 0 auto 16px;
}

.giapha-profile-facts {
    margin: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px 12px;
}

.giapha-profile-facts dt {
    font-weight: 700;
    margin-top: 8px;
}

.giapha-profile-facts dd {
    margin: 0;
}

/* Bản chỉ-tên cho khách chưa đăng nhập (cây công khai bật). */
.giapha-focus-public {
    border: 1px dashed #c00;
    border-radius: 8px;
    background: #fff;
}

/* Màn hình rộng: ảnh hồ sơ nằm trái, tên + thông tin nằm phải. */
@media (min-width: 720px) {
    .giapha-profile-photo {
        float: left;
        margin: 0 20px 12px 0;
    }

    .giapha-profile-facts {
        grid-template-columns: 140px 1fr;
    }

    .giapha-profile-facts dt {
        margin-top: 0;
    }
}

/* ---------- Hiệu ứng + tổng thể (Phase B2) ---------- */

/* Màu chủ đạo: vàng đồng trầm (hợp tông Flatsome trên site demo). */
.giapha-focus,
.giapha-profile,
.giapha-overview {
    --giapha-accent: #9a7b1e;
    --giapha-accent-soft: #f7f0d8;
    --giapha-card: #fff;
    --giapha-line: #e8e0c8;
    --giapha-muted: #6b6552;
}

/* Đầu trang Focus/Profile: dải nền ấm + tên lớn + huy hiệu. */
.giapha-focus-head,
.giapha-profile-name {
    background: linear-gradient(135deg, #fdf6dd 0%, #f7f0d8 100%);
    border: 1px solid var(--giapha-line);
    border-left: 5px solid var(--giapha-accent);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 8px;
}

.giapha-profile-name {
    margin: 0 0 8px;
}

.giapha-focus-head h2 {
    margin: 0 0 4px;
}

.giapha-focus-sub,
.giapha-profile-sub {
    margin: 0;
    color: var(--giapha-muted);
}

/* Huy hiệu đời + nội tộc. */
.giapha-gen-pill {
    display: inline-block;
    background: var(--giapha-accent);
    color: #fff;
    border-radius: 999px;
    padding: 1px 10px;
    font-size: 0.85rem;
    font-weight: 700;
    vertical-align: middle;
}

.giapha-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 1px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    vertical-align: middle;
    white-space: nowrap;
}

.giapha-badge--blood { background: #e2f0da; color: #2e6b1e; }
.giapha-badge--adopted_recognized { background: #ddebf7; color: #1d4f91; }
.giapha-badge--in_law { background: #efe3f5; color: #6b2d8f; }
.giapha-badge--external { background: #eee; color: #555; }

/* Khối quan hệ: nền card, dòng người có hiệu ứng nâng khi rê chuột. */
.giapha-rel-block {
    background: var(--giapha-card);
    border: 1px solid var(--giapha-line);
    border-radius: 10px;
    padding: 4px 16px 12px;
    margin: 16px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.giapha-rel-block h3 {
    border-bottom: 2px solid var(--giapha-accent-soft);
}

.giapha-relations li {
    background: #fffdf6;
    border: 1px solid #f0e9cf;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 6px 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.giapha-relations li:hover {
    transform: translateY(-1px);
    border-color: var(--giapha-accent);
    box-shadow: 0 3px 10px rgba(154, 123, 30, 0.18);
}

.giapha-relations a {
    color: #7a5c0e;
}

.giapha-relations a:hover,
.giapha-relations a:focus-visible {
    color: #5c460a;
}

.giapha-family {
    border-left: 3px solid var(--giapha-accent-soft);
    padding-left: 12px;
    margin: 8px 0;
}

.giapha-family h4 {
    margin: 12px 0 4px;
}

/* Lời mời chọn người (focus không id). */
.giapha-focus-empty {
    background: var(--giapha-accent-soft);
    border: 1px dashed var(--giapha-accent);
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
}

/* ---------- Tổng thể dòng họ ---------- */
.giapha-overview {
    max-width: 860px;
    margin: 24px auto 0;
    padding: 16px;
    box-sizing: border-box;
    line-height: 1.6;
    font-size: 16px;
}

.giapha-overview-title {
    font-size: 1.5rem;
    margin: 0 0 4px;
}

.giapha-overview-count {
    background: var(--giapha-accent);
    color: #fff;
    border-radius: 999px;
    padding: 2px 12px;
    font-size: 0.9rem;
    vertical-align: middle;
}

.giapha-overview-hint {
    color: var(--giapha-muted);
    margin: 0 0 16px;
}

.giapha-ov-generation {
    border-left: 4px solid var(--giapha-accent);
    background: #fffdf6;
    border-radius: 0 10px 10px 0;
    padding: 4px 14px 14px;
    margin: 16px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.giapha-ov-generation h3 {
    font-size: 1.15rem;
    margin: 12px 0 10px;
}

.giapha-ov-count {
    background: var(--giapha-accent-soft);
    border: 1px solid var(--giapha-line);
    color: #7a5c0e;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 0.85rem;
}

.giapha-ov-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.giapha-ov-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #fff;
    border: 1px solid var(--giapha-line);
    border-radius: 10px;
    padding: 12px;
    text-decoration: none;
    color: inherit;
    min-height: 44px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.giapha-ov-card:hover,
.giapha-ov-card:focus-visible {
    transform: translateY(-2px);
    border-color: var(--giapha-accent);
    box-shadow: 0 4px 14px rgba(154, 123, 30, 0.22);
    text-decoration: none;
}

.giapha-ov-card.is-active {
    border: 2px solid var(--giapha-accent);
    background: var(--giapha-accent-soft);
}

.giapha-ov-name {
    font-weight: 700;
    color: #2b2620;
    line-height: 1.35;
}

.giapha-ov-meta {
    font-size: 0.85rem;
    color: var(--giapha-muted);
}

.giapha-ov-card .giapha-badge {
    align-self: flex-start;
    margin-top: 6px;
}

@media (max-width: 480px) {
    .giapha-ov-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ---------- Cây gia phả ngang (MVP 2, FamilyChart) ---------- */
.giapha-tree-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 8px 0 16px;
    box-sizing: border-box;
}

.giapha-tree-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 8px 0 12px;
}

.giapha-tree-btn {
    background: var(--giapha-accent, #9a7b1e);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    transition: filter 0.15s ease, transform 0.15s ease;
}

.giapha-tree-btn:hover,
.giapha-tree-btn:focus-visible {
    filter: brightness(1.12);
    transform: translateY(-1px);
}

.giapha-tree-hint {
    color: var(--giapha-muted, #6b6552);
    font-size: 0.9rem;
}

.giapha-tree-zoom {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.giapha-tree-btn--zoom {
    min-width: 44px;
    padding: 8px 10px;
    font-size: 1.1rem;
    line-height: 1;
}

.giapha-tree-chart {
    width: 100%;
    height: 70vh;
    min-height: 480px;
    border: 1px solid var(--giapha-line, #e8e0c8);
    border-radius: 12px;
    background: #fffdf6;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.giapha-tree-chart .card {
    cursor: pointer;
}

.giapha-tree-error {
    padding: 24px;
    text-align: center;
    color: #8b2e2e;
}

.giapha-tree-debug {
    background: #fff3cd;
    border: 1px solid #d9a400;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    word-break: break-all;
}

@media (max-width: 720px) {
    .giapha-tree-chart {
        height: 60vh;
        min-height: 420px;
    }
}
