/**
 * Phả đồ – default styles (overridable via the element's Bricks controls).
 * Colors use the Bricks palette variables (--gp-*).
 */

.gp-tree {
	width: 100%; /* Bricks containers align children to flex-start: don't shrink to content */
	min-width: 0;
}

.gp-tree__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* ---------- Status + tools ---------- */

.gp-tree__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 12px 24px;
	margin-bottom: 16px;
}

.gp-tree__status {
	margin: 0;
	font-size: 14px;
	line-height: 20px;
	color: var(--gp-muted-foreground);
}

.gp-tree__reset {
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	font-weight: 500;
	color: var(--gp-primary);
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.gp-tree__tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.gp-tree__search {
	position: relative;
}

.gp-tree__search-icon {
	position: absolute;
	top: 50%;
	left: 12px;
	width: 16px;
	height: 16px;
	transform: translateY(-50%);
	color: var(--gp-muted-foreground);
	pointer-events: none;
}

.gp-tree__search-input,
.gp-tree__branch,
.gp-tree__gen-select {
	height: 40px;
	border: 1px solid var(--gp-border);
	border-radius: 2px;
	background-color: var(--gp-card);
	font-size: 14px;
	color: var(--gp-foreground);
}

.gp-tree__search-input {
	width: 256px;
	padding: 0 32px 0 36px;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.gp-tree__search-input::-webkit-search-cancel-button {
	display: none;
}

.gp-tree__search-input:focus {
	border-color: var(--gp-gold);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--gp-gold) 30%, transparent);
}

.gp-tree__search-clear {
	position: absolute;
	top: 50%;
	right: 8px;
	display: flex;
	padding: 2px;
	border: 0;
	background: none;
	color: var(--gp-muted-foreground);
	transform: translateY(-50%);
	cursor: pointer;
}

.gp-tree__search-clear[hidden],
.gp-tree__results[hidden] {
	display: none;
}

.gp-tree__search-clear svg {
	width: 16px;
	height: 16px;
}

.gp-tree__results {
	position: absolute;
	z-index: 30;
	top: calc(100% + 4px);
	left: 0;
	width: 320px;
	max-width: calc(100vw - 40px);
	max-height: 320px;
	margin: 0;
	padding: 4px;
	overflow: auto;
	list-style: none;
	border: 1px solid var(--gp-border);
	border-radius: 2px;
	background-color: var(--gp-card);
	box-shadow: var(--gp-shadow-card);
}

.gp-tree__results-count {
	padding: 4px 12px;
	font-size: 12px;
	color: var(--gp-muted-foreground);
}

.gp-tree__result {
	display: block;
	width: 100%;
	padding: 8px 12px;
	border: 0;
	border-radius: 2px;
	background: none;
	text-align: left;
	cursor: pointer;
}

.gp-tree__result:hover,
.gp-tree__result.is-active {
	background-color: var(--gp-parchment);
}

.gp-tree__result-name {
	display: block;
	font-size: 14px;
	font-weight: 500;
	color: var(--gp-foreground);
}

.gp-tree__result-meta {
	display: block;
	font-size: 12px;
	color: var(--gp-muted-foreground);
}

/* Room for Bricks' select arrow (drawn ~16–24px from the right edge) */
.gp-tree__branch {
	width: auto;
	padding: 0 36px 0 12px;
}

/* ---------- Body: generation nav + viewport ---------- */

.gp-tree__body {
	display: flex;
	gap: 12px;
}

.gp-tree__gens {
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
	gap: 4px;
	width: 64px;
}

.gp-tree__gen {
	padding: 4px 0;
	border: 1px solid var(--gp-border);
	border-radius: 2px;
	background-color: var(--gp-card);
	font-size: 12px;
	line-height: 16px;
	text-align: center;
	color: var(--gp-muted-foreground);
	cursor: pointer;
	transition: border-color .15s, background-color .15s;
}

.gp-tree__gen:hover {
	border-color: var(--gp-gold);
}

.gp-tree__gen[aria-current="true"] {
	border-color: var(--gp-gold);
	background: var(--gp-gradient-lacquer);
	color: var(--gp-gold-soft);
}

.gp-tree__main {
	position: relative;
	flex: 1;
	min-width: 0;
}

.gp-tree__gen-select {
	display: none;
	width: 100%;
	height: 36px;
	margin-bottom: 8px;
	padding: 0 36px 0 12px;
}

.gp-tree__viewport {
	position: relative;
	height: 72vh;
	min-height: 420px;
	overflow: hidden;
	border: 1px solid var(--gp-gold-40);
	border-radius: 2px;
	background-color: var(--gp-card);
	box-shadow: var(--gp-shadow-card);
	cursor: grab;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	outline: none;
}

.gp-tree__viewport:focus-visible {
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--gp-gold) 40%, transparent), var(--gp-shadow-card);
}

.gp-tree__viewport.is-dragging {
	cursor: grabbing;
}

.gp-tree__stage {
	position: absolute;
	top: 0;
	left: 0;
	transform-origin: 0 0;
}

.gp-tree__lines {
	position: absolute;
	top: 0;
	left: 0;
	overflow: visible;
	color: var(--gp-gold);
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
}

.gp-tree__nodes {
	position: absolute;
	top: 0;
	left: 0;
}

.gp-tree__node {
	position: absolute;
}

/* Generation labels (left edge, follow the vertical pan/zoom) */
.gp-tree__labels {
	position: absolute;
	z-index: 10;
	top: 0;
	left: 8px;
	pointer-events: none;
}

.gp-tree__label {
	position: absolute;
	top: 0;
	left: 0;
	padding: 2px 8px;
	border-radius: 2px;
	background-color: color-mix(in srgb, var(--gp-wood) 80%, transparent);
	font-size: 10px;
	font-weight: 500;
	line-height: 15px;
	color: var(--gp-gold-soft);
	white-space: nowrap;
}

/* ---------- Member card ---------- */

.gp-tree__card {
	display: flex;
	align-items: center;
	width: 100%;
	height: 100%;
	padding: 0 8px;
	border: 1px solid color-mix(in srgb, var(--gp-primary) 40%, transparent);
	border-radius: 2px;
	background-color: var(--gp-card);
	text-align: left;
	color: var(--gp-foreground);
	cursor: pointer;
	transition: border-color .15s, background-color .15s, box-shadow .15s;
}

.gp-tree__card.is-f {
	border-color: var(--gp-gold-50);
	background-color: var(--gp-parchment);
}

.gp-tree__card:hover {
	border-color: var(--gp-gold);
}

.gp-tree__card:focus-visible {
	outline: 2px solid var(--gp-gold);
	outline-offset: 2px;
}

.gp-tree__card[aria-pressed="true"] {
	border-color: var(--gp-gold);
	background: var(--gp-gradient-lacquer);
	box-shadow: var(--gp-shadow-gold);
	color: var(--gp-gold-soft);
}

.gp-tree__accent {
	display: block;
	min-width: 0;
	padding-left: 8px;
	border-left: 2px solid var(--gp-primary);
}

/* Avatar: featured image or initial on the gender color */
.gp-tree__avatar {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	overflow: hidden;
	border: 1px solid var(--gp-gold-40);
	border-radius: 50%;
	background-color: var(--gp-primary);
	font-family: "Playfair Display", serif;
	font-size: 17px;
	line-height: 1;
	color: var(--gp-gold-soft);
}

.gp-tree__avatar.is-f {
	background-color: var(--gp-gold);
	color: var(--gp-wood);
}

.gp-tree__avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.gp-tree__card .gp-tree__avatar + .gp-tree__accent {
	margin-left: 8px;
}

.gp-tree__card[aria-pressed="true"] .gp-tree__avatar {
	border-color: var(--gp-gold);
}

.gp-tree__panel-head {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 8px;
}

.gp-tree__panel-head .gp-tree__avatar {
	width: 56px;
	height: 56px;
	font-size: 24px;
}

.gp-tree__panel-who {
	min-width: 0;
}

.gp-tree__panel-who .gp-tree__panel-title {
	margin-top: 0;
}

.gp-tree__card.is-f .gp-tree__accent {
	border-left-color: var(--gp-gold);
}

.gp-tree__card[aria-pressed="true"] .gp-tree__accent {
	border-left-color: var(--gp-gold);
}

.gp-tree__name {
	display: block;
	overflow: hidden;
	font-size: 13px;
	font-weight: 600;
	line-height: 18px;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.gp-tree__years {
	display: block;
	font-size: 11px;
	line-height: 16px;
	color: var(--gp-muted-foreground);
}

.gp-tree__card[aria-pressed="true"] .gp-tree__years {
	color: var(--gp-gold-soft-80);
}

/* "Next generations" pill under a card */
.gp-tree__more {
	position: absolute;
	bottom: -12px;
	left: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 2px;
	min-width: 24px;
	height: 24px;
	padding: 0 6px;
	border: 1px solid var(--gp-gold);
	border-radius: 9999px;
	background-color: var(--gp-wood);
	font-size: 10px;
	line-height: 1;
	color: var(--gp-gold-soft);
	transform: translateX(-50%);
	cursor: pointer;
	transition: background-color .15s;
}

.gp-tree__more:hover {
	background-color: var(--gp-primary);
}

.gp-tree__more svg {
	width: 12px;
	height: 12px;
	transform: rotate(90deg);
}

/* ---------- Overlays: zoom, legend, panel ---------- */

.gp-tree__zoom {
	position: absolute;
	z-index: 10;
	right: 12px;
	bottom: 12px;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--gp-border);
	border-radius: 2px;
	background-color: var(--gp-card);
	box-shadow: var(--gp-shadow-card);
	cursor: default;
}

.gp-tree__zoom button {
	display: flex;
	padding: 8px;
	border: 0;
	background: none;
	color: var(--gp-foreground);
	cursor: pointer;
}

.gp-tree__zoom button + button {
	border-top: 1px solid var(--gp-border);
}

.gp-tree__zoom button:hover {
	background-color: var(--gp-parchment);
}

.gp-tree__zoom svg {
	width: 16px;
	height: 16px;
}

.gp-tree__legend {
	position: absolute;
	z-index: 10;
	bottom: 12px;
	left: 12px;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 6px 12px;
	border-radius: 2px;
	background-color: color-mix(in srgb, var(--gp-card) 90%, transparent);
	font-size: 12px;
	line-height: 16px;
	color: var(--gp-muted-foreground);
	pointer-events: none;
}

.gp-tree__legend span {
	display: flex;
	align-items: center;
	gap: 4px;
}

.gp-tree__legend i {
	width: 10px;
	height: 10px;
	border-radius: 9999px;
	background-color: var(--gp-primary);
}

.gp-tree__legend i.is-f {
	background-color: var(--gp-gold);
}

.gp-tree__panel {
	position: absolute;
	z-index: 20;
	top: 12px;
	right: 12px;
	width: min(320px, calc(100% - 24px));
	max-height: calc(100% - 24px);
	padding: 20px;
	overflow: auto;
	border: 1px solid var(--gp-gold-60);
	border-radius: 2px;
	background-color: var(--gp-card);
	box-shadow: var(--gp-shadow-card);
	cursor: auto;
	user-select: text;
	-webkit-user-select: text;
	animation: gp-tree-panel-in .2s ease-out;
}

.gp-tree__panel[hidden] {
	display: none;
}

@keyframes gp-tree-panel-in {
	from {
		opacity: 0;
		transform: translateX(16px);
	}
}

.gp-tree__panel-close {
	position: absolute;
	top: 12px;
	right: 12px;
	display: flex;
	padding: 2px;
	border: 0;
	background: none;
	color: var(--gp-foreground);
	cursor: pointer;
}

.gp-tree__panel-close svg {
	width: 16px;
	height: 16px;
}

.gp-tree__panel-eyebrow {
	margin: 0;
	padding-right: 24px;
	font-size: 12px;
	line-height: 16px;
	letter-spacing: .1em;
	text-transform: uppercase;
	color: var(--gp-primary);
}

.gp-tree__panel-title {
	margin: 4px 0 0;
	font-size: 24px;
	font-weight: 600;
	line-height: 32px;
}

.gp-tree__panel-alias {
	margin: 2px 0 0;
	font-family: "Playfair Display", serif;
	font-size: 15px;
	font-style: italic;
	line-height: 22px;
	color: var(--gp-muted-foreground);
}

.gp-tree__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 4px !important;
}

.gp-tree__chip {
	padding: 2px 8px;
	border: 0;
	border-radius: 2px;
	background-color: var(--gp-parchment);
	font: inherit;
	font-size: 13px;
	line-height: 20px;
	color: var(--gp-foreground);
	cursor: pointer;
	transition: background-color .15s, color .15s;
}

.gp-tree__chip:hover {
	background-color: var(--gp-gold-40);
	color: var(--gp-primary);
}

.gp-tree__panel-years {
	margin: 4px 0 0;
	font-size: 14px;
	line-height: 20px;
}

.gp-tree__panel-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 16px 0 0;
	font-size: 14px;
	line-height: 20px;
}

.gp-tree__panel-list dt {
	font-size: 12px;
	line-height: 16px;
	color: var(--gp-muted-foreground);
}

.gp-tree__panel-list dd {
	margin: 0;
}

.gp-tree__link {
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	color: var(--gp-primary);
	cursor: pointer;
}

.gp-tree__link:hover {
	text-decoration: underline;
}

.gp-tree__panel-bio {
	margin: 16px 0 0;
	font-size: 14px;
	line-height: 1.625;
	color: var(--gp-muted-foreground);
}

.gp-tree__panel-link {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-top: 16px;
	font-size: 14px;
	font-weight: 500;
	color: var(--gp-primary);
}

.gp-tree__panel-link:hover {
	text-decoration: underline;
}

.gp-tree__panel-link svg {
	width: 14px;
	height: 14px;
}

/* No-JS fallback list */
.gp-tree__fallback ul {
	margin: 0;
	padding-left: 20px;
	list-style: disc;
}

.gp-tree__fallback li {
	margin-top: 4px;
}

/* ---------- Responsive (Bricks breakpoints: 991 / 767 / 478) ---------- */

@media (max-width: 767px) {
	.gp-tree__gens {
		display: none;
	}

	.gp-tree__gen-select {
		display: block;
	}

	.gp-tree__tools,
	.gp-tree__search {
		width: 100%;
	}

	.gp-tree__search-input {
		width: 100%;
	}

	.gp-tree__branch {
		flex: 1;
	}

	.gp-tree__viewport {
		height: 65vh;
		min-height: 380px;
	}
}
