/**
 * Family Tree — public stylesheet
 * Heirloom / archival aesthetic: parchment ground, mounted-photograph cards,
 * engraved connector lines. Colors are driven by CSS custom properties so
 * the admin Settings screen can override them per-site without editing CSS.
 */

.mstc-ft-wrap {
	--mstc-bg: #efe7d8;
	--mstc-line: #8c7b65;
	--mstc-card-bg: #fffdf8;
	--mstc-card-text: #2b2118;
	--mstc-card-border: #d8cba9;
	--mstc-male: #4a6d8c;
	--mstc-female: #b5657a;
	--mstc-other: #8c7b65;

	position: relative;
	width: 100%;
	max-width: 100%;
	overflow: hidden;
	background: var( --mstc-bg );
	border-radius: 10px;
	padding: 40px 24px;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.mstc-ft-wrap * {
	box-sizing: border-box;
}

.mstc-ft-viewport {
	position: relative;
	width: 100%;
	max-width: 100%;
	overflow: hidden;
}

.mstc-ft-canvas {
	position: relative;
	margin: 0;
	transform-origin: top left;
}


.mstc-ft-connectors {
	position: absolute;
	top: 0;
	left: 0;
	pointer-events: none;
}

.mstc-ft-connectors line {
	stroke: var( --mstc-line );
	stroke-width: 2;
	stroke-linecap: round;
}

.mstc-ft-connectors circle.mstc-joint {
	fill: var( --mstc-bg );
	stroke: var( --mstc-line );
	stroke-width: 2;
}

.mstc-ft-node {
	position: absolute;
	display: flex;
	align-items: center;
	gap: 10px;
	background: var( --mstc-card-bg );
	border: 1px solid var( --mstc-card-border );
	border-radius: 8px;
	padding: 10px 14px 10px 10px;
	box-shadow: 0 2px 6px rgba( 43, 33, 24, 0.12 ), 0 0 0 1px rgba( 43, 33, 24, 0.02 );
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mstc-ft-node:hover {
	transform: translateY( -2px );
	box-shadow: 0 6px 14px rgba( 43, 33, 24, 0.16 );
}

.mstc-ft-extra-spouse-chip {
	position: absolute;
	box-sizing: border-box;
	height: 22px;
	line-height: 20px;
	padding: 0 8px;
	margin: 0;
	border: 1px solid var( --mstc-card-border );
	border-radius: 999px;
	background: var( --mstc-bg );
	color: var( --mstc-card-text );
	font-size: 11px;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	cursor: pointer;
	opacity: 0.85;
}

.mstc-ft-extra-spouse-chip:hover {
	opacity: 1;
	box-shadow: 0 2px 6px rgba( 43, 33, 24, 0.12 );
}

.mstc-ft-node.is-hidden-person {	background: repeating-linear-gradient(
		135deg,
		var( --mstc-card-bg ),
		var( --mstc-card-bg ) 8px,
		rgba( 140, 123, 101, 0.08 ) 8px,
		rgba( 140, 123, 101, 0.08 ) 16px
	);
	justify-content: center;
	text-align: center;
}

.mstc-ft-photo {
	flex: 0 0 auto;
	width: 46px;
	height: 46px;
	overflow: hidden;
	background: var( --mstc-card-border );
	display: flex;
	align-items: center;
	justify-content: center;
	color: var( --mstc-card-bg );
	font-family: Georgia, 'Times New Roman', serif;
	font-weight: 600;
	font-size: 16px;
	border: 2px solid;
	flex-shrink: 0;
}

.mstc-ft-wrap[data-photo-shape='circle'] .mstc-ft-photo {
	border-radius: 50%;
}

.mstc-ft-wrap[data-photo-shape='rounded'] .mstc-ft-photo {
	border-radius: 8px;
}

.mstc-ft-wrap[data-photo-shape='square'] .mstc-ft-photo {
	border-radius: 2px;
}

.mstc-ft-photo img {
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	object-fit: cover;
	display: block;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	box-shadow: none !important;
	vertical-align: top !important;
	float: none !important;
}

.mstc-ft-node.gender-male .mstc-ft-photo {
	border-color: var( --mstc-male );
}

.mstc-ft-node.gender-female .mstc-ft-photo {
	border-color: var( --mstc-female );
}

.mstc-ft-node.gender-unknown .mstc-ft-photo {
	border-color: var( --mstc-other );
}

/* Root / starting person: a gold ring plus a small star badge, independent
   of the user's chosen color palette so it always reads as "special". */
.mstc-ft-node.is-root-person {
	box-shadow: 0 0 0 3px #d4a017, 0 3px 10px rgba( 43, 33, 24, 0.18 );
}

.mstc-ft-node.is-root-person::before {
	content: '\2605';
	position: absolute;
	top: -11px;
	left: -11px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #d4a017;
	color: #fffdf8;
	font-size: 12px;
	line-height: 22px;
	text-align: center;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.3 );
}

.mstc-ft-info {
	min-width: 0;
}

.mstc-ft-name {
	font-family: Georgia, 'Times New Roman', serif;
	font-weight: 600;
	font-size: 14px;
	line-height: 1.25;
	color: var( --mstc-card-text );
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mstc-ft-dates {
	font-size: 11.5px;
	color: var( --mstc-card-text );
	opacity: 0.65;
	margin-top: 2px;
	white-space: nowrap;
}

.mstc-ft-hidden-label {
	font-family: Georgia, 'Times New Roman', serif;
	font-style: italic;
	font-size: 13px;
	color: var( --mstc-card-text );
	opacity: 0.55;
	letter-spacing: 0.02em;
}

/* Personal-info detail modal, shown on click for anyone with something to
   show beyond what's already on the card face (photo, bio, dates, spouse,
   children, More link, etc). Clicking a spouse or child inside the modal
   slides across to their own info instead of closing it. */
.mstc-ft-node.has-detail {
	cursor: pointer;
}

.mstc-ft-detail-overlay {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba( 20, 16, 12, 0.55 );
	padding: 20px;
}

.mstc-ft-detail-overlay.is-open {
	display: flex;
}

.mstc-ft-detail-modal {
	position: relative;
	width: 100%;
	max-width: 420px;
	max-height: 86vh;
	overflow-y: auto;
	background: var( --mstc-card-bg );
	color: var( --mstc-card-text );
	border: 1px solid var( --mstc-card-border );
	border-radius: 12px;
	padding: 26px 24px;
	box-shadow: 0 20px 50px rgba( 0, 0, 0, 0.3 );
	font-family: Georgia, 'Times New Roman', serif;
}

.mstc-ft-detail-close {
	position: absolute;
	top: 10px;
	right: 12px;
	background: none;
	border: none;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	color: var( --mstc-card-text );
	opacity: 0.55;
}

.mstc-ft-detail-close:hover {
	opacity: 1;
}

.mstc-ft-detail-content {
	transition: opacity 0.18s ease, transform 0.18s ease;
	opacity: 1;
	transform: translateX( 0 );
}

.mstc-ft-detail-content.is-sliding-out {
	opacity: 0;
	transform: translateX( -18px );
}

.mstc-ft-detail-content.is-sliding-in {
	opacity: 0;
	transform: translateX( 18px );
}

.mstc-ft-detail-photo {
	display: block;
	width: 100%;
	max-height: 240px;
	object-fit: cover;
	border-radius: 8px;
	margin-bottom: 12px;
}

.mstc-ft-detail-name {
	margin: 0 0 2px;
	font-size: 19px;
}

.mstc-ft-detail-dates {
	font-size: 13px;
	opacity: 0.65;
	margin-bottom: 14px;
}

.mstc-ft-detail-rows {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13.5px;
	margin-bottom: 12px;
}

.mstc-ft-detail-row {
	display: flex;
	gap: 8px;
	padding: 6px 0;
	border-bottom: 1px solid rgba( 0, 0, 0, 0.08 );
}

.mstc-ft-detail-row:last-child {
	border-bottom: none;
}

.mstc-ft-detail-label {
	flex: 0 0 84px;
	opacity: 0.6;
	font-weight: 600;
}

.mstc-ft-detail-value {
	flex: 1;
}

.mstc-ft-detail-link {
	background: none;
	border: none;
	padding: 0;
	margin: 0 2px 0 0;
	font: inherit;
	font-weight: 600;
	color: var( --mstc-card-text );
	text-decoration: underline;
	cursor: pointer;
}

.mstc-ft-detail-link:hover {
	opacity: 0.75;
}

.mstc-ft-detail-hidden {
	opacity: 0.6;
	font-style: italic;
}

.mstc-ft-detail-bio {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13.5px;
	line-height: 1.55;
	margin: 0 0 14px;
}

.mstc-ft-detail-more {
	display: inline-block;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	color: var( --mstc-card-bg );
	background: var( --mstc-card-text );
	padding: 7px 16px;
	border-radius: 999px;
}

.mstc-ft-detail-more:hover {
	opacity: 0.85;
}

.mstc-ft-empty {
	text-align: center;
	padding: 40px 20px;
	font-family: Georgia, 'Times New Roman', serif;
	font-style: italic;
	color: var( --mstc-card-text );
	opacity: 0.6;
}

@media ( max-width: 600px ) {
	.mstc-ft-wrap {
		padding: 24px 8px;
	}
}

/* ------------------------------------------------------------------ */
/* Print / export */
/* ------------------------------------------------------------------ */

.mstc-ft-print-btn {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 10;
	background: var( --mstc-card-bg );
	color: var( --mstc-card-text );
	border: 1px solid var( --mstc-card-border );
	border-radius: 6px;
	padding: 7px 14px;
	font-size: 12.5px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	cursor: pointer;
	box-shadow: 0 1px 4px rgba( 43, 33, 24, 0.12 );
}

.mstc-ft-print-btn:hover {
	background: var( --mstc-card-border );
}

@media print {
	/* Family trees are usually wide — default the printed page to landscape.
	   Not every browser honors this, but it's a helpful hint where supported. */
	@page {
		size: landscape;
		margin: 12mm;
	}

	.mstc-ft-print-btn,
	.mstc-ft-detail-overlay {
		display: none !important;
	}

	.mstc-ft-wrap {
		overflow: visible !important;
		background: #fff !important;
		padding: 0 !important;
		border-radius: 0 !important;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.mstc-ft-canvas {
		transform: none !important;
	}

	.mstc-ft-node {
		box-shadow: none !important;
		break-inside: avoid;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}
}

@media ( max-width: 480px ) {
	.mstc-ft-wrap {
		padding: 20px 6px;
		border-radius: 6px;
	}

	.mstc-ft-print-btn {
		position: relative;
		top: auto;
		right: auto;
		display: block;
		margin: 0 0 12px auto;
	}
}
