/**
 * AncestorPress Family Trees - Public Stylesheet
 */

/* ── Chart wrapper ─────────────────────────────────────────────────────────── */

/*
 * Break out of the theme content container to use full viewport width.
 * box-sizing: border-box ensures padding (applied via inline style from
 * chart settings) does not add to the 100vw width and cause overflow.
 * Padding defaults are applied as inline style on the wrapper element;
 * only box-sizing lives here as a structural rule.
 */
.ancp-chart-wrapper {
	width: 100vw;
	position: relative;
	left: 50%;
	right: 50%;
	margin-left: -50vw;
	margin-right: -50vw;
	box-sizing: border-box;
	background: #f8f8f8;
}

/* ── Chart viewport (the visible scrollable window) ────────────────────────── */

.ancp-chart-viewport {
	position: relative;
	border-top: 1px solid #ddd;
	border-bottom: 1px solid #ddd;
	width: 100%;
	/* Responsive height: at least 480px, up to 75% of viewport, max 900px */
	height: clamp( 480px, 75vh, 900px );
	overflow: hidden;
	cursor: grab;
	box-sizing: border-box;
}

.ancp-chart-viewport:active {
	cursor: grabbing;
}

/* ── Draggable inner element (panzoom target) ──────────────────────────────── */

.ancp-chart-drag {
	text-align: center;
	display: inline-block;
	position: absolute;
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	-webkit-transform: translateX(-50%);
	-moz-transform: translateX(-50%);
}

.ancp-chart-drag:focus {
	outline: 0;
}

/* ── Pan hint ───────────────────────────────────────────────────────────────── */

.ancp-chart-wrapper::after {
	content: attr(data-hint);
	position: absolute;
	bottom: 8px;
	right: 12px;
	font-size: 11px;
	color: #888;
	pointer-events: none;
}

/* ── Tree container ─────────────────────────────────────────────────────────── */

#tree-container {
	border: 0;
	display: inline-block;
	text-align: left;
}

#hoverimage {
	position: absolute;
	border: 1px solid gray;
	background-color: #efefef;
	z-index: 100;
}

#focusperson {
	height: 2em;
	padding: 0;
	width: 40%;
}

#toolbar-container {
	position: relative;
	z-index: 500;
}

.dynamicDiv {
	border: solid 1px #c0c0c0;
	background-color: #e1e1e1;
	font-size: 8px;
	font-family: verdana;
	color: #000;
	padding: 0;
}

/* ── SVG ────────────────────────────────────────────────────────────────────── */

.ancp-chart-wrapper svg {
	max-width: inherit;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Tree styles - type 11 (Descendant)
───────────────────────────────────────────────────────────────────────────── */

/* ─────────────────────────────────────────────────────────────────────────────
   Descendant tree (chart-type-11) - show-spouse mode
   Structure: li > .ancp-couple(.person + .person) + ul.childs > li
───────────────────────────────────────────────────────────────────────────── */

/* Each node li: inline-block so siblings flow side-by-side in their parent ul */
.tree-default > .tree-descendant.show-spouse li {
	display: inline-block;
	vertical-align: top;
	text-align: center;
	position: relative;
	padding-top: 20px;
}

/* Root li: no space above, no connectors (nothing to connect to) */
.tree-default > .tree-descendant.show-spouse .ancp-root > li {
	padding-top: 0;
}
.tree-default > .tree-descendant.show-spouse .ancp-root > li::before,
.tree-default > .tree-descendant.show-spouse .ancp-root > li::after {
	display: none;
}

/* Couple: husband + wife side by side, centred */
.tree-default > .tree-descendant.show-spouse .ancp-couple {
	display: inline-flex;
	flex-direction: row;
	align-items: stretch;
	justify-content: center;
	position: relative;
}

/* Double marriage line between husband and wife */
.tree-default > .tree-descendant.show-spouse .ancp-couple .person + .person {
	position: relative;
}
.tree-default > .tree-descendant.show-spouse .ancp-couple .person + .person::before {
	content: "";
	position: absolute;
	top: 24px;
	left: -10px;
	width: 10px;
	border-top: 1px solid;
	height: 5px;
	border-bottom: 1px solid;
	z-index: 1;
}

/* Vertical drop from centre of couple to children bar */
.tree-default > .tree-descendant.show-spouse .ancp-couple.haschill::after {
	content: "";
	position: absolute;
	bottom: -20px;
	left: 50%;
	height: 20px;
	border-left: 1px solid;
}

/* Person box (shared across both modes) */
.tree-default > .tree-descendant .person > div > div {
	border: 1px solid;
	background: #e3e5e7;
	display: inline-flex;
	margin: 0 auto;
	position: relative;
}

/* Children list: centred flex row */
.tree-default > .tree-descendant.show-spouse .childs {
	display: flex;
	flex-direction: row;
	align-items: flex-start;
	justify-content: center;
	list-style: none;
	margin-top: 20px;
	padding: 0;
	position: relative;
}

/* Horizontal bar: spans left-to-right across sibling children, trimmed at edges */
.tree-default > .tree-descendant.show-spouse .childs > li::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	border-top: 1px solid;
}
.tree-default > .tree-descendant.show-spouse .childs > li:first-child:not(:only-child)::before {
	left: 50%;
}
.tree-default > .tree-descendant.show-spouse .childs > li:last-child:not(:only-child)::before {
	right: 50%;
}
/* Single child: no horizontal bar, just the vertical from parent */
.tree-default > .tree-descendant.show-spouse .childs > li:only-child::before {
	border: none;
}

/* Vertical drop from bar down to each child's couple */
.tree-default > .tree-descendant.show-spouse .childs > li::after {
	content: "";
	position: absolute;
	top: 0;
	left: 50%;
	height: 20px;
	border-left: 1px solid;
}
/* Only-child: vertical drop but no bar - the parent couple::after provides the top half */
.tree-default > .tree-descendant.show-spouse .childs > li:only-child::after {
	content: "";
	position: absolute;
	top: 0;
	left: 50%;
	height: 20px;
	border-left: 1px solid;
}


/* ─────────────────────────────────────────────────────────────────────────────
   Tree styles - type 12 (Pedigree/Ancestor)
───────────────────────────────────────────────────────────────────────────── */

.tree-default > .tree-pedigree .childs:after {
	content: "";
	position: absolute;
	height: 10px;
	border-left: 1px solid;
	left: 50%;
	right: 50%;
	top: 0;
}

.tree-default > .tree-pedigree .childs > li {
	display: block;
	position: relative;
	text-align: center;
	padding-top: 10px;
}

.tree-default > .tree-pedigree .childs > li:before {
	content: "";
	left: 0;
	right: 0;
	display: block;
	border-top: 1px solid;
	height: 10px;
	margin-top: 10px;
	position: absolute;
	top: 0;
}

.tree-default > .tree-pedigree .childs > li:last-child:not(:only-child):before {
	left: 0;
	right: 50%;
	border-right: 1px solid;
}

.tree-default > .tree-pedigree .childs > li:first-child:before {
	left: 50%;
	right: 0;
	border-left: 1px solid;
}

.tree-default > .tree-pedigree .childs > li:only-child:before {
	left: 50%;
	right: 50%;
	border-right: 0;
}

.tree-default > .tree-pedigree .childs > li:not(:first-child):not(:last-child):after {
	content: "";
	position: absolute;
	height: 10px;
	border-left: 1px solid;
	left: 50%;
	right: 50%;
	top: 10px;
}

.tree-default > .tree-pedigree .person { display: block; }

.tree-default .chart-type-12up {
	transform: rotate(180deg);
	bottom: -20px;
}

.tree-default .chart-type-12up .person-info {
	transform: rotate(180deg);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Shared tree styles (all types)
───────────────────────────────────────────────────────────────────────────── */

.tree-default {
	white-space: nowrap;
	position: relative;
	margin: 0 !important;
	padding: 0 !important;
}

.tree-default .childs {
	width: max-content;
	display: flex;
	position: relative;
	margin: 0;
	padding: 0;
	min-width: 100%;
	justify-content: center;
}

.tree-default .person {
	margin-top: 10px;
	padding-left: 4px;
	padding-right: 4px;
}

.tree-default .person > div > div {
	border: 1px solid;
	background: #e3e5e7;
	display: inline-flex;
	margin: 0 auto;
	position: relative;
	z-index: 5000000;
}

.tree-default .person table { width: 100%; }

.tree-default .person table,
.tree-default .person table td {
	border: 0;
	display: inline-flex;
	vertical-align: top;
	padding: 0;
	margin: 0;
}

.tree-default .person table td { padding: 3px; }
.tree-default .person table td a { text-decoration: none; }

.tree-default .person .thumb {
	position: relative;
	width: 50px;
	height: 50px;
	overflow: hidden;
}

.tree-default .person .thumb img { display: block; }

.tree-default .person .thumb > .toolbar {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 20;
	opacity: 0;
	background: rgb(255 255 255 / 80%);
	display: block;
	text-align: center;
}

.tree-default .person .thumb > .toolbar > .toolbar-inner {
	width: 50px;
	height: 50px;
}

.tree-default .person .thumb > .toolbar a {
	display: inline-block;
	margin: 18px 2px;
	height: 14px;
}

.tree-default .person .thumb > .toolbar:hover { opacity: 1; }
