/* Hefzul Family Tree – front end. Scoped to .hft so the theme stays in charge elsewhere.
   Colours use translucent tints so they sit on light and dark themes alike. */

.hft {
	--hft-line: rgba(127, 127, 127, 0.28);
	--hft-soft: rgba(127, 127, 127, 0.07);
	--hft-softer: rgba(127, 127, 127, 0.04);
	--hft-muted: rgba(127, 127, 127, 0.95);
	--hft-accent: #8a5a2b;
	--hft-m: rgba(52, 120, 196, 0.16);
	--hft-m-line: rgba(52, 120, 196, 0.55);
	--hft-f: rgba(201, 72, 118, 0.15);
	--hft-f-line: rgba(201, 72, 118, 0.55);
	--hft-u: rgba(127, 127, 127, 0.12);
	--hft-u-line: rgba(127, 127, 127, 0.45);
	--hft-radius: 10px;
	font-size: 1rem;
	line-height: 1.5;
	max-width: 100%;
}
.hft *, .hft *::before, .hft *::after { box-sizing: border-box; }
.hft h2 { margin: 0.4em 0 0.5em; line-height: 1.2; }
.hft h3 { margin: 0 0 0.6em; font-size: 1.1em; line-height: 1.3; }
.hft h4 { margin: 0.9em 0 0.3em; font-size: 0.95em; }
.hft a { text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* Navigation */
.hft-nav {
	display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; align-items: center;
	padding: 0.5rem 0; margin-bottom: 1.25rem; border-bottom: 1px solid var(--hft-line);
}
.hft-nav a { padding: 0.3rem 0.65rem; border-radius: 999px; text-decoration: none; font-size: 0.95em; }
.hft-nav a:hover, .hft-nav a:focus-visible { background: var(--hft-soft); }
.hft-nav a.is-current { background: var(--hft-soft); font-weight: 600; }
.hft-nav .hft-nav-edit { margin-left: auto; border: 1px solid var(--hft-line); }

.hft-tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 1.25rem; }
.hft-tabs a {
	padding: 0.3rem 0.75rem; border: 1px solid var(--hft-line); border-radius: 6px;
	text-decoration: none; font-size: 0.92em;
}
.hft-tabs a.is-current { background: var(--hft-soft); font-weight: 600; }
.hft-tabs .hft-edit-link { margin-left: auto; }

/* Panels and layout */
.hft-panel {
	background: var(--hft-softer); border: 1px solid var(--hft-line);
	border-radius: var(--hft-radius); padding: 1rem 1.15rem; margin-bottom: 1rem;
}
.hft-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
.hft-grid .hft-panel { margin: 0; }
.hft-cols { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 800px) { .hft-cols { grid-template-columns: 1fr; } }
.hft-muted, .hft-dates, .hft-small { color: var(--hft-muted); opacity: 0.85; }
.hft-small { font-size: 0.82em; font-weight: normal; }
.hft-badge {
	display: inline-block; font-size: 0.75em; padding: 0.05em 0.5em; border-radius: 999px;
	border: 1px solid var(--hft-line); background: var(--hft-soft); vertical-align: middle;
}
.hft-private, .hft-unknown { font-style: italic; opacity: 0.75; }

.hft-list { list-style: none; margin: 0; padding: 0; }
.hft-list li { padding: 0.25rem 0; border-bottom: 1px dashed var(--hft-line); }
.hft-list li:last-child { border-bottom: 0; }
.hft-columns { columns: 18rem; column-gap: 2rem; }
.hft-columns li { break-inside: avoid; }

/* Home */
.hft-hero { margin-bottom: 1.25rem; }
.hft-search {
	display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end;
	padding: 0.85rem; border: 1px solid var(--hft-line); border-radius: var(--hft-radius); background: var(--hft-soft);
}
.hft-search label, .hft-rel-form label { display: flex; flex-direction: column; font-size: 0.85em; gap: 0.15rem; flex: 1 1 9rem; }
.hft-search label:first-of-type { flex: 2 1 14rem; }
.hft-search input, .hft-rel-form select, .hft-gens select { padding: 0.4rem 0.55rem; font-size: 1rem; max-width: 100%; }
.hft-search button, .hft-rel-form button { padding: 0.5rem 1.1rem; cursor: pointer; }
.hft-stats dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; margin: 0 0 0.75rem; }
.hft-stats dt { font-size: 0.8em; opacity: 0.75; }
.hft-stats dd { margin: 0; font-size: 1.6em; font-weight: 600; line-height: 1.1; }
.hft-card-row { display: flex; gap: 0.75rem; align-items: center; }
.hft-quick a { margin-right: 0.6rem; white-space: nowrap; }

/* Avatars */
.hft-avatar { flex: none; display: inline-flex; width: 48px; height: 48px; border-radius: 50%; overflow: hidden; }
.hft-avatar img { width: 100%; height: 100%; object-fit: cover; margin: 0; }
.hft-avatar-initials {
	align-items: center; justify-content: center; font-weight: 600; font-size: 0.95em;
	background: var(--hft-u); border: 1px solid var(--hft-u-line);
}
.hft-avatar-initials.hft-sex-m { background: var(--hft-m); border-color: var(--hft-m-line); }
.hft-avatar-initials.hft-sex-f { background: var(--hft-f); border-color: var(--hft-f-line); }

/* Person */
.hft-person-head { display: flex; gap: 1.25rem; align-items: center; margin-bottom: 1rem; }
.hft-person-head .hft-avatar { width: 112px; height: 112px; font-size: 1.8em; }
.hft-person-head h2 { margin: 0 0 0.2em; }
.hft-meta { margin: 0; }
.hft-you { margin: 0.4em 0 0; padding: 0.3em 0.7em; border-left: 3px solid var(--hft-accent); background: var(--hft-soft); border-radius: 0 6px 6px 0; }
@media (max-width: 520px) {
	.hft-person-head { flex-direction: column; align-items: flex-start; }
}
.hft-facts { width: 100%; border-collapse: collapse; margin: 0; }
.hft-facts th, .hft-facts td { text-align: left; vertical-align: top; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--hft-line); }
.hft-facts tr:last-child th, .hft-facts tr:last-child td { border-bottom: 0; }
.hft-facts th { width: 34%; font-weight: 600; }
.hft-age { display: block; font-size: 0.78em; font-weight: normal; opacity: 0.75; }
.hft-ev-place { font-style: italic; }
.hft-ev-desc, .hft-ev-cite { font-size: 0.9em; }
.hft-ev-cite { opacity: 0.8; }
.hft-story { font-size: 1.02em; }
.hft-story p:last-child { margin-bottom: 0; }
.hft-family-box h3 { display: flex; justify-content: space-between; align-items: baseline; }
.hft-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
.hft-gallery figure { margin: 0; }
.hft-gallery img { width: 100%; height: 140px; object-fit: cover; border-radius: 6px; display: block; }
.hft-gallery figcaption { font-size: 0.82em; margin-top: 0.25rem; }
.hft-also { display: block; opacity: 0.85; }
.hft-doc { display: flex; align-items: center; justify-content: center; height: 140px; padding: 0.5rem; border: 1px dashed var(--hft-line); border-radius: 6px; text-align: center; font-size: 0.85em; }
.hft-notes { border-style: dashed; }

.hft-family-head { display: flex; flex-wrap: wrap; gap: 1rem 2.5rem; margin-bottom: 1rem; }

/* Charts */
.hft-chart-title { margin-bottom: 0.3em; }
.hft-gens { margin: 0 0 0.75rem; }
.hft-chart-wrap { overflow-x: auto; padding-bottom: 0.5rem; -webkit-overflow-scrolling: touch; }

.hft-box {
	position: relative; display: flex; gap: 0.5rem; align-items: center;
	padding: 0.4rem 0.55rem; border-radius: 8px; min-height: 3.2rem; width: 100%;
	background: var(--hft-u); border: 1px solid var(--hft-u-line); font-size: 0.88em; line-height: 1.25;
}
.hft-box.hft-sex-m { background: var(--hft-m); border-color: var(--hft-m-line); }
.hft-box.hft-sex-f { background: var(--hft-f); border-color: var(--hft-f-line); }
.hft-box .hft-avatar { width: 34px; height: 34px; font-size: 0.75em; }
.hft-box-text { min-width: 0; display: flex; flex-direction: column; }
.hft-box-text a { font-weight: 600; overflow-wrap: anywhere; }
.hft-box .hft-dates { font-size: 0.85em; }
.hft-box-empty, .hft-box-private { justify-content: center; background: transparent; border-style: dashed; opacity: 0.65; font-style: italic; }
.hft-more {
	position: absolute; right: -0.85rem; top: 50%; transform: translateY(-50%);
	width: 1.6rem; height: 1.6rem; border-radius: 50%; display: flex; align-items: center; justify-content: center;
	background: var(--hft-accent); color: #fff !important; text-decoration: none; font-weight: 700;
}

.hft-pedigree {
	display: grid; gap: 0.5rem 1.6rem; align-items: center;
	grid-template-columns: repeat(var(--hft-gens), minmax(170px, 1fr));
	grid-template-rows: repeat(var(--hft-rows), minmax(3.6rem, auto));
	min-width: calc(var(--hft-gens) * 190px);
}
.hft-ped-cell { display: flex; align-items: center; position: relative; }
.hft-ped-cell:not(:first-child)::before {
	content: ""; position: absolute; left: -0.8rem; top: 50%; width: 0.8rem; border-top: 1px solid var(--hft-line);
}

.hft-desc ul { list-style: none; margin: 0; padding-left: 1.4rem; position: relative; }
.hft-desc > ul { padding-left: 0; }
.hft-desc li { position: relative; margin: 0.45rem 0; }
.hft-desc ul ul > li::before {
	content: ""; position: absolute; left: -1rem; top: 1.6rem; width: 0.9rem; border-top: 1px solid var(--hft-line);
}
.hft-desc ul ul { border-left: 1px solid var(--hft-line); margin-left: 0.6rem; }
.hft-desc .hft-box { max-width: 22rem; }
.hft-desc-fams { border-left: 0 !important; }
.hft-desc-fam > .hft-desc-spouse { padding: 0.15rem 0 0.15rem 0.2rem; font-size: 0.92em; }
.hft-amp { opacity: 0.6; margin-right: 0.35rem; }

.hft-fan { width: 100%; max-width: 980px; height: auto; display: block; margin: 0 auto; }
.hft-fan-cell { fill: var(--hft-u); stroke: var(--hft-u-line); stroke-width: 1; }
.hft-fan-cell.hft-sex-m { fill: var(--hft-m); stroke: var(--hft-m-line); }
.hft-fan-cell.hft-sex-f { fill: var(--hft-f); stroke: var(--hft-f-line); }
.hft-fan-empty { fill: none; stroke-dasharray: 3 3; }
.hft-fan a:hover .hft-fan-cell, .hft-fan a:focus .hft-fan-cell { stroke-width: 2.5; }
.hft-fan a { text-decoration: none; }
.hft-fan-text { fill: currentColor; text-decoration: none; font-size: 12px; pointer-events: none; }
.hft-fan-strong { font-weight: 700; font-size: 13px; }
.hft-fan-small { font-size: 10.5px; }
.hft-fan-tiny { font-size: 9px; opacity: 0.8; }

/* Timeline */
.hft-timeline { list-style: none; margin: 0; padding: 0 0 0 0.5rem; border-left: 2px solid var(--hft-line); }
.hft-timeline li { display: grid; grid-template-columns: 5.5rem 1fr; gap: 0.75rem; padding: 0.6rem 0 0.6rem 1rem; position: relative; }
.hft-timeline li::before {
	content: ""; position: absolute; left: -0.45rem; top: 0.95rem; width: 0.8rem; height: 0.8rem; border-radius: 50%;
	background: var(--hft-accent); border: 2px solid var(--hft-softer);
}
.hft-timeline li:not(.hft-tl-self)::before { background: transparent; border: 2px solid var(--hft-line); }
.hft-timeline li:not(.hft-tl-self) .hft-tl-body { opacity: 0.85; font-size: 0.95em; }
.hft-tl-year { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Maps */
.hft-map { width: 100%; border-radius: var(--hft-radius); border: 1px solid var(--hft-line); z-index: 0; }
.hft-map-large { height: 520px; }
.hft-map-small { height: 280px; }
@media (max-width: 600px) { .hft-map-large { height: 380px; } }
.hft-place-list { font-size: 0.88em; margin: 0.75rem 0 0; padding-left: 1.1rem; }
.hft-popup-list { margin: 0.35rem 0 0; padding-left: 1rem; max-height: 220px; overflow: auto; }

/* Surnames, search, sources, relationship */
.hft-surname-cloud { line-height: 2.1; }
.hft-surname-cloud a { margin-right: 0.9rem; text-decoration: none; white-space: nowrap; }
.hft-surname-cloud span { font-size: 0.6em; opacity: 0.7; vertical-align: super; }
.hft-results { width: 100%; border-collapse: collapse; margin-top: 0.75rem; }
.hft-results th, .hft-results td { text-align: left; padding: 0.45rem; border-bottom: 1px solid var(--hft-line); }
.hft-rel-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; margin-bottom: 1rem; }
.hft-rel-form label { flex: 1 1 16rem; }
.hft-rel-answer > p:first-child { font-size: 1.15em; }
.hft-path { margin: 0.5rem 0 0; padding-left: 1.4rem; }
.hft-path li { padding: 0.2rem 0; }
.hft-dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; }
.hft-dl dt { font-weight: 600; }
.hft-dl dd { margin: 0; overflow-wrap: anywhere; }

@media print {
	.hft-nav, .hft-tabs, .hft-gens, .hft-search { display: none; }
	.hft-chart-wrap { overflow: visible; }
}

/* ------------------------------------------------------------------ */
/* Interactive tree                                                     */
/* ------------------------------------------------------------------ */
.hftv {
	position: relative; display: flex; flex-direction: column; overflow: hidden;
	border: 1px solid var(--hft-line); border-radius: var(--hft-radius);
	background: var(--hft-softer); margin: 0 0 1.25rem;
}
.hftv [hidden] { display: none !important; }
.hftv-embed { height: clamp(440px, 70vh, 780px); }
.hftv-page { height: clamp(500px, 82vh, 1200px); }
.hftv.is-max {
	position: fixed; inset: 0; height: auto; z-index: 100000; margin: 0; border-radius: 0; border: 0;
	background: Canvas; color: CanvasText;
}
html.hftv-noscroll, html.hftv-noscroll body { overflow: hidden !important; }
.hftv-loading { margin: auto; padding: 1rem; text-align: center; opacity: 0.8; }
.hftv-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.hftv-bar {
	display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; align-items: center; justify-content: space-between;
	padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--hft-line); background: var(--hft-soft); position: relative; z-index: 3;
}
.hftv-find { flex: 1 1 13rem; max-width: 26rem; }
.hftv-find input { width: 100%; padding: 0.4rem 0.65rem; font-size: 1rem; border-radius: 6px; }
.hftv-tools { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.hftv-btn {
	display: inline-flex; align-items: center; justify-content: center; min-width: 2.3rem; height: 2.3rem; padding: 0 0.7rem;
	border: 1px solid var(--hft-line); border-radius: 6px; background: transparent; color: inherit;
	font: inherit; font-size: 0.9rem; line-height: 1; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.hftv-btn:hover, .hftv-btn:focus-visible { background: var(--hft-soft); }
.hftv-btn[aria-pressed="true"] { background: var(--hft-soft); font-weight: 600; box-shadow: inset 0 -2px 0 var(--hft-accent); }
.hftv-primary { background: var(--hft-accent); border-color: var(--hft-accent); color: #fff !important; }
.hftv-primary:hover, .hftv-primary:focus-visible { background: var(--hft-accent); filter: brightness(1.1); }
.hftv-caption { padding: 0.3rem 0.7rem; font-size: 0.85em; opacity: 0.8; border-bottom: 1px solid var(--hft-line); }
.hftv-help { margin: 0; padding: 0.35rem 0.7rem; font-size: 0.78em; opacity: 0.7; border-top: 1px solid var(--hft-line); }

.hftv-vp { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; cursor: grab; outline: none; touch-action: pan-y; }
.hftv-page .hftv-vp, .hftv.is-max .hftv-vp { touch-action: none; }
.hftv.is-dragging .hftv-vp { cursor: grabbing; }
.hftv-vp:focus-visible { box-shadow: inset 0 0 0 2px var(--hft-accent); }
.hftv-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.hftv-stage.is-anim { transition: transform 0.4s ease; }
@media (prefers-reduced-motion: reduce) { .hftv-stage.is-anim { transition: none; } }
.hftv-stage svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.hftv-lines { fill: none; stroke: rgba(127, 127, 127, 0.7); stroke-width: 1.5; }
.hftv-empty { padding: 2rem; text-align: center; }

.hftv-node {
	position: absolute; box-sizing: border-box; display: flex; align-items: center; gap: 0.5rem;
	padding: 0.35rem 0.55rem; border-radius: 10px; font-size: 13px; line-height: 1.2;
	background: var(--hft-u); border: 1px solid var(--hft-u-line); cursor: pointer;
	user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.hftv-node.hft-sex-m { background: var(--hft-m); border-color: var(--hft-m-line); }
.hftv-node.hft-sex-f { background: var(--hft-f); border-color: var(--hft-f-line); }
.hftv-node.is-private { background: transparent; border-style: dashed; font-style: italic; opacity: 0.75; }
.hftv-node.is-focus { box-shadow: 0 0 0 3px var(--hft-accent); border-color: var(--hft-accent); }
.hftv-node:focus-visible { outline: 3px solid var(--hft-accent); outline-offset: 2px; }
.hftv-node:hover { filter: brightness(1.04); }
.hftv-ph {
	flex: none; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center;
	font-weight: 700; font-size: 13px; background: rgba(127, 127, 127, 0.14);
}
.hftv-ph img { width: 100%; height: 100%; object-fit: cover; margin: 0; }
.hftv-txt { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hftv-name { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.hftv-dates { font-size: 11.5px; opacity: 0.8; }
.hftv-you {
	position: absolute; top: -9px; right: 8px; font-size: 10px; font-weight: 700; line-height: 1;
	padding: 3px 6px; border-radius: 999px; background: var(--hft-accent); color: #fff;
}
.hftv-tog {
	position: absolute; left: 50%; width: 24px; height: 24px; margin-left: -12px; padding: 0;
	border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 50%; background: var(--hft-accent); color: #fff;
	font: 700 16px/1 system-ui, sans-serif; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 1;
}
.hftv-tog::after { content: ""; position: absolute; inset: -9px; }
.hftv-tog:focus-visible { outline: 3px solid var(--hft-accent); outline-offset: 2px; }
.hftv-up { top: -13px; }
.hftv-down { bottom: -13px; }
.hftv-tog[aria-expanded="true"] { opacity: 0.85; }

.hftv-card {
	position: absolute; left: 0.6rem; bottom: 0.6rem; z-index: 4; width: min(22rem, calc(100% - 1.2rem));
	padding: 0.8rem 0.9rem; border-radius: 10px; border: 1px solid var(--hft-line);
	background: Canvas; color: CanvasText; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18); font-size: 0.92rem;
}
.hftv-card p { margin: 0.35rem 0 0; }
.hftv-card-head { display: flex; gap: 0.7rem; align-items: center; }
.hftv-card-head img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; margin: 0; }
.hftv-card-head strong { display: block; font-size: 1.05em; }
.hftv-card-dates { font-size: 0.85em; opacity: 0.8; }
.hftv-card-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.hftv-hint {
	position: absolute; left: 50%; top: 0.8rem; transform: translateX(-50%); z-index: 4; pointer-events: none;
	padding: 0.35rem 0.75rem; border-radius: 999px; background: rgba(0, 0, 0, 0.72); color: #fff; font-size: 0.82rem;
	opacity: 0; transition: opacity 0.25s;
}
.hftv-hint.is-on { opacity: 1; }
.hftv-more { margin: -0.75rem 0 1.25rem; font-size: 0.9em; text-align: right; }
@media (max-width: 600px) {
	.hftv-embed { height: 64vh; }
	.hftv-help { display: none; }
	.hftv-btn { min-width: 2.6rem; height: 2.6rem; }
}
@media print { .hftv { display: none; } }
