/* Person template CSS
 * Loaded on all single Person posts (single-person.php) and Region pages.
 *
 * Sections:
 *   1. Outer wrapper & stage
 *   2. Hero zone (headshot + bio)
 *   3. Section wrapper
 *   4. Location cards grid
 *   5. Bubbles (connected people)
 *   6. Responsive overrides
 */

/* ── 1. Outer wrapper ─────────────────────────────────────────────────── */

.pm-person {
	min-height: 100svh;
	padding: 1.25rem 0 2rem;
}

.pm-person__stage {
	width: min(94vw, 1100px);
	margin: 0 auto;
	display: grid;
	gap: 1.5rem;
}

/* ── 2. Hero zone: circular headshot (left) + bio (right) ─────────────── */

.pm-person__hero-zone {
	display: grid;
	grid-template-columns: 1fr 2fr;
	gap: 2rem;
	align-items: start;
}

.pm-person__hero-image {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
}

.pm-person__hero-image .pm-hero--circle {
	width: clamp(100px, 14vw, 160px);
	padding: 10px 14px; /* match map modal thumb padding — generic.css uses 10px 40px which makes the image tiny */
}

.pm-person__name {
	margin: 0 0 0.4rem;
	font-size: 1.75rem;
	font-weight: 400;
	line-height: 1.2;
}

.pm-person__meta {
	margin: 0 0 0.25rem;
	color: #555;
}

.pm-person__bio {
	margin-top: 1rem;
}

.pm-person__bio p { margin: 0 0 1rem; }

/* ── 3. Section wrapper ───────────────────────────────────────────────── */

.pm-person__section {
	display: grid;
	gap: 0.75rem;
}

/* ── 4. Location cards grid ───────────────────────────────────────────── */

.pm-location-cards {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 0.75rem;
}

.pm-location-card a {
	display: flex;
	flex-direction: column;
	height: 100%;
	text-decoration: none;
	border: 1px solid rgba(0,0,0,0.08);
	border-radius: 12px;
	overflow: hidden;
	background: #fff;
	transition: box-shadow 0.15s ease;
}

.pm-location-card a:hover {
	box-shadow: 0 4px 14px rgba(0,0,0,0.10);
}

.pm-location-card__thumb {
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: #eee;
}

.pm-location-card__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.pm-location-card__thumb-placeholder {
	width: 100%;
	height: 100%;
	background: #e8e8e8;
}

.pm-location-card__info {
	padding: 0.5rem 0.625rem;
	display: grid;
	gap: 2px;
	flex: 1;
}

.pm-location-card__name {
	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1.3;
	color: #000;
}

.pm-location-card__cat {
	font-size: 0.8rem;
	color: #666;
	line-height: 1.2;
}

/* ── 5. Accordion ─────────────────────────────────────────────────────── */

.pm-accordion {
	border: 1px solid rgba(0,0,0,0.10);
}

.pm-accordion__trigger {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	width: 100%;
	padding: 0.75rem 1rem;
	background: #fff;
	border: 0;
	cursor: pointer;
	text-align: left;
	transition: background 0.12s ease;
}

.pm-accordion__trigger:hover { background: #f5f5f5; }
.pm-accordion.is-open .pm-accordion__trigger { border-bottom: 1px solid rgba(0,0,0,0.10); }

.pm-accordion__label {
	flex: 1;
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #000;
}

.pm-accordion__count {
	font-size: 0.8rem;
	font-weight: 700;
	color: #555;
	background: rgba(0,0,0,0.06);
	padding: 2px 8px;
	border-radius: 999px;
	line-height: 1.5;
}

/* Chevron — two short bars that form a ‹ rotated to point down */
.pm-accordion__chevron {
	position: relative;
	width: 16px;
	height: 10px;
	flex-shrink: 0;
}

.pm-accordion__chevron::before,
.pm-accordion__chevron::after {
	content: '';
	position: absolute;
	top: 50%;
	width: 8px;
	height: 2px;
	background: #000;
	transition: transform 220ms ease;
}

.pm-accordion__chevron::before {
	left: 0;
	transform: translateY(-50%) rotate(45deg);
	transform-origin: right center;
}

.pm-accordion__chevron::after {
	right: 0;
	transform: translateY(-50%) rotate(-45deg);
	transform-origin: left center;
}

/* Flip chevron when open */
.pm-accordion.is-open .pm-accordion__chevron::before { transform: translateY(-50%) rotate(-45deg); }
.pm-accordion.is-open .pm-accordion__chevron::after  { transform: translateY(-50%) rotate(45deg); }

.pm-accordion__body {
	overflow: hidden;
	max-height: 0;
	transition: max-height 360ms ease;
}

.pm-accordion.is-open .pm-accordion__body {
	max-height: 4000px; /* generous ceiling — animation speed is governed by the ease curve */
	transition: max-height 480ms ease;
}

.pm-accordion__body .pm-location-cards {
	padding: 0.875rem 1rem 1rem;
}

.pm-accordion__body .pm-bubbles {
	padding: 1rem 0.5rem 1.25rem;
}

/* Bubble items fade in after the accordion opens and syncAll() has run.
 * Opacity starts at 0 (items invisible while closed / being positioned),
 * then .is-bubbles-visible is added by JS after the double-rAF handoff. */
.pm-accordion__body .pm-bubble__item {
	opacity: 0;
	transition: opacity 0.4s ease;
}

.pm-accordion__body.is-bubbles-visible .pm-bubble__item {
	opacity: 1;
}

/* ── 6. Bubbles (connected people) ────────────────────────────────────── */

.pm-bubbles { margin: 0; }

.pm-bubbles__title {
	text-align: center;
	font-size: 1.25rem;
	margin: 0.5rem 0 1.25rem;
}

.pm-bubbles__grid {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 1rem;
}

.pm-bubble {
	display: grid;
	gap: 0.5rem;
	position: relative;
	overflow: visible;
	flex: 0 0 clamp(150px, 20vw, 260px);
	max-width: 260px;
}

.pm-bubble__title { margin: 0; text-align: center; font-size: 1rem; opacity: 0.85; }

.pm-bubble__arena {
	position: relative;
	aspect-ratio: 1 / 1;
	width: 100%;
	border-radius: 999px;
	border: 1px dashed rgba(0,0,0,0.18);
	background: rgba(255,255,255,0.45);
	overflow: hidden;
}

.pm-bubble__item {
	width: 56px;
	height: 56px;
	border-radius: 999px;
	background: rgba(255,255,255,0.95);
	border: 1px solid rgba(0,0,0,0.10);
	padding: 6px;
	display: grid;
	place-items: center;
	box-shadow: 0 3px 10px rgba(0,0,0,0.08);
	will-change: transform;
}

.pm-bubble__item img { width: 100%; height: 100%; object-fit: contain; display: block; }
.pm-bubble__item a { display: grid; place-items: center; text-decoration: none; color: inherit; width: 100%; height: 100%; }

.pm-bubble__tooltip {
	display: none;
	position: fixed; /* fixed escapes overflow:hidden on accordion body */
	left: 0;
	top: 0;
	width: max-content;
	max-width: min(240px, 60vw);
	padding: 6px 10px;
	border-radius: 999px;
	background: rgba(0,0,0,0.78);
	color: #fff;
	border: 1px solid rgba(255,255,255,0.18);
	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1;
	white-space: nowrap;
	z-index: 999;
	pointer-events: none;
}

.pm-bubble.is-tooltip-open .pm-bubble__tooltip { display: block; }

/* ── 6. Responsive ────────────────────────────────────────────────────── */

@media (max-width: 720px) {
	/* Hero: stack vertically, centre the headshot */
	.pm-person__hero-zone {
		grid-template-columns: 1fr;
		gap: 1rem;
	}
	.pm-person__hero-image { justify-content: center; }

	/* Location cards: floor at 2 columns on narrow screens */
	.pm-location-cards { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

	/* Bubbles: drop the circular arena, render as a flex row of avatar circles
	 * matching the Events section .pm-avatars style. */
	.pm-bubble { flex: 0 0 100%; max-width: 100%; }
	.pm-bubble__arena {
		aspect-ratio: auto;
		border: 0;
		background: transparent;
		overflow: visible;
		display: flex;
		flex-wrap: wrap;
		gap: 0.5rem;
		padding: 0.25rem 0 0.5rem;
	}
	.pm-bubble__item {
		position: static !important;
		transform: none !important;
		width: 56px;
		height: 56px;
		border-radius: 999px;
		background: rgba(255,255,255,0.95);
		border: 1px solid rgba(0,0,0,0.10);
		padding: 6px;
		box-shadow: 0 1px 2px rgba(0,0,0,0.06);
		box-sizing: border-box;
	}
	.pm-bubble__item a { display: grid; place-items: center; width: 100%; height: 100%; }
	.pm-bubble__item img { width: 100%; height: 100%; object-fit: contain; }
	.pm-bubble__tooltip { display: none; }
}

/* ── 7. Connection preview modal ──────────────────────────────────────── */

.pm-conn-modal {
	position: fixed;
	inset: 0;
	display: grid;
	place-items: center;
	pointer-events: none;
	z-index: 200;
	opacity: 0;
	transition: opacity 200ms ease;
}

.pm-conn-modal.is-open {
	opacity: 1;
	pointer-events: auto;
}

.pm-conn-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,0.45);
	cursor: pointer;
}

.pm-conn-modal__panel {
	position: relative;
	background: #fff;
	border-radius: 14px;
	padding: 32px 24px 24px;
	max-width: min(360px, calc(100vw - 32px));
	width: 100%;
	text-align: center;
	z-index: 1;
	box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}

.pm-conn-modal__close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 28px;
	height: 28px;
	border: 1px solid rgba(0,0,0,0.15);
	background: transparent;
	border-radius: 999px;
	font-size: 1.2rem;
	line-height: 1;
	cursor: pointer;
	display: grid;
	place-items: center;
	color: #333;
}

.pm-conn-modal__close:hover { background: #f0f0f0; }

.pm-conn-modal__thumb {
	width: 100px;
	height: 100px;
	border-radius: 999px;
	overflow: hidden;
	margin: 0 auto 16px;
	border: 1px solid rgba(0,0,0,0.12);
	background: #ccc;
	padding: 8px 12px;
	box-sizing: border-box;
}

.pm-conn-modal__thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	filter: var(--pm-person-filter);
	-webkit-filter: var(--pm-person-filter);
}

.pm-conn-modal__name {
	margin: 0 0 10px;
	font-size: 1.4rem;
	font-weight: 400;
	line-height: 1.2;
}

.pm-conn-modal__note {
	margin: 0 0 4px;
	color: #555;
	font-size: 0.95rem;
	line-height: 1.55;
}

.pm-conn-modal__note[hidden] { display: none; }

.pm-conn-modal__actions { margin-top: 20px; }

.pm-conn-modal__button {
	display: inline-block;
	padding: 0.6rem 1.25rem;
	background: #111;
	color: #fff;
	border-radius: 999px;
	text-decoration: none;
	font-weight: 700;
	font-size: 0.9rem;
	border: 1px solid rgba(0,0,0,0.12);
	transition: background 120ms ease;
}

.pm-conn-modal__button:hover { background: #000; }
