/**
 * Narrative Team Stack: frontend styles
 *
 * Everything animatable hangs off CSS custom properties so the Elementor
 * Style tab can drive it without any extra CSS from you.
 *
 * The whole fan is driven by one variable: --f (the "fan factor").
 * At rest it is 1; on hover / when open it becomes --nts-spread.
 */

.nts-root {
	position: relative;
}

.nts-member {
	/* ---- tweakables (all overridden by the Elementor Style tab) ---- */
	--nts-photo-w: 220px;
	--nts-ratio: 3 / 4;
	--nts-tilt: 3deg;   /* rotation applied per photo, at rest */
	--nts-shift: 4%;  /* sideways offset applied per photo, at rest */
	--nts-spread: 5;    /* multiplier applied when fanned */
	--nts-dir: -1;      /* -1 fans left, 1 fans right */
	--nts-speed: 450ms;
	--nts-ease: cubic-bezier(0.2, 0.8, 0.25, 1);
	--nts-photo-bg: #ffffff;
	--nts-photo-pad: 0px;
	--nts-note-w: 260px;
	--nts-note-rot: -2deg;
	--nts-note-x: 0px;
	--nts-note-y: 0px;

	/* ---- state ---- */
	--f: 1;

	position: relative;   /* NB: no z-index here on purpose. See the stacking note below. */
	display: inline-block;
	cursor: pointer;      /* the whole member toggles; the note opts out below */
	max-width: 100%;
	vertical-align: top;
}

.nts-member--dir-left  { --nts-dir: -1; }
.nts-member--dir-right { --nts-dir: 1; }

/*
 * Both ways: photo 1 (the front portrait) swings right, photo 2 holds the
 * centre, photo 3 swings left. --i is the travel multiplier per photo, so the
 * middle photo gets 0 and the outer two get 1 in opposite directions.
 * Specificity (0,2,0) beats the .nts-photo--n defaults below.
 */
.nts-member--dir-split .nts-photo--1 { --i: 1; --nts-dir:  1; }
.nts-member--dir-split .nts-photo--2 { --i: 0; --nts-dir:  1; }
.nts-member--dir-split .nts-photo--3 { --i: 1; --nts-dir: -1; }

/* ------------------------------------------------------------------ */
/* The stack                                                           */
/* ------------------------------------------------------------------ */

.nts-stack {
	position: relative;
	display: block;
	box-sizing: border-box;
	width: var(--nts-photo-w);
	max-width: 100%;
	aspect-ratio: var(--nts-ratio);
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	color: inherit;
	text-align: inherit;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.nts-member--no-note,
.nts-member--no-note .nts-stack,
.nts-stack--static {
	cursor: default;
}

.nts-stack:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 8px;
}

.nts-photo {
	position: absolute;
	inset: 0;
	display: block;
	box-sizing: border-box;
	padding: var(--nts-photo-pad);
	background-color: var(--nts-photo-bg);
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
	transform:
		translateX(calc(var(--nts-shift) * var(--i) * var(--nts-dir) * var(--f)))
		rotate(calc(var(--nts-tilt) * var(--i) * var(--nts-dir) * var(--f)));
	transform-origin: 50% 100%;
	transition:
		transform var(--nts-speed) var(--nts-ease),
		box-shadow var(--nts-speed) var(--nts-ease);
	will-change: transform;
	backface-visibility: hidden;
}

.nts-photo--1 { --i: 0; z-index: 3; }
.nts-photo--2 { --i: 1; z-index: 2; }
.nts-photo--3 { --i: 2; z-index: 1; }

/*
 * Stacking, deliberately flat.
 *
 * .nts-member is position:relative with z-index:auto, so it does NOT open a
 * stacking context. That lets every widget on the page compete on one z axis:
 *
 *   resting photos   1-3
 *   fanned photos    11-13   (a fanned stack lifts over its calm neighbours)
 *   caption          20      (the name stays readable under a fanned photo)
 *   open note        50      (always clears every photo on the page)
 *
 * If .nts-member carried its own z-index instead, an open note would be
 * trapped inside its widget and the next member's fanned photos would cover it.
 */

.nts-photo img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: inherit;
}

/* ---- what actually triggers the fan ---- */

.nts-member.is-open {
	--f: var(--nts-spread);
}

.nts-member.is-open .nts-photo--1 { z-index: 13; }
.nts-member.is-open .nts-photo--2 { z-index: 12; }
.nts-member.is-open .nts-photo--3 { z-index: 11; }

@media (hover: hover) and (pointer: fine) {
	.nts-member--hover:hover,
	.nts-member--hover:focus-within {
		--f: var(--nts-spread);
	}

	.nts-member--hover:hover .nts-photo--1,
	.nts-member--hover:focus-within .nts-photo--1 { z-index: 13; }
	.nts-member--hover:hover .nts-photo--2,
	.nts-member--hover:focus-within .nts-photo--2 { z-index: 12; }
	.nts-member--hover:hover .nts-photo--3,
	.nts-member--hover:focus-within .nts-photo--3 { z-index: 11; }
}

/* ------------------------------------------------------------------ */
/* Optional caption under the stack                                    */
/* ------------------------------------------------------------------ */

/*
 * The caption is a sibling of the stack in normal flow, so it stays put while
 * the photos fan over it. z-index 20 keeps it legible above a fanned photo
 * that dips below the stack box (rotation pivots on the bottom edge), and
 * --nts-caption-gap buys clearance so that rarely happens in the first place.
 */
.nts-caption {
	position: relative;
	z-index: 20;
	margin-top: var(--nts-caption-gap, 16px);
	max-width: var(--nts-photo-w);
}

.nts-caption__name,
.nts-caption__role {
	display: block;
}

.nts-caption__role {
	opacity: 0.75;
}

/* ------------------------------------------------------------------ */
/* The note: overlay mode (default)                                   */
/* ------------------------------------------------------------------ */

/*
 * The slot keeps its size while the note is hidden, so without this it would
 * sit over the bottom of the stack as an invisible box and swallow clicks
 * meant for the photos and the name. Only the open note takes pointer events.
 */
.nts-note-slot {
	position: absolute;
	z-index: 50;
	width: var(--nts-note-w);
	max-width: min(92vw, 460px);
	margin-left: var(--nts-note-x);
	margin-top: var(--nts-note-y);
	pointer-events: none;
}

.nts-member.is-open .nts-note-slot {
	pointer-events: auto;
}

.nts-note-clip {
	display: contents;
}

.nts-member--pos-bottom-right .nts-note-slot { top: 52%;  left: 48%; }
.nts-member--pos-bottom-left  .nts-note-slot { top: 52%;  right: 48%; }
.nts-member--pos-top-right    .nts-note-slot { bottom: 52%; left: 48%; }
.nts-member--pos-top-left     .nts-note-slot { bottom: 52%; right: 48%; }
.nts-member--pos-right        .nts-note-slot { top: 6%;   left: calc(100% - 8px); }
.nts-member--pos-below        .nts-note-slot { top: calc(100% + 12px); left: 0; }

.nts-note {
	position: relative;
	box-sizing: border-box;
	padding: 22px 22px 30px;
	background-color: #fdf16b;
	background-repeat: no-repeat;
	background-position: center center;
	background-size: 100% 100%;
	color: #1c1c1c;
	box-shadow: 3px 6px 14px rgba(0, 0, 0, 0.28);
	cursor: default;   /* clicks inside the note do nothing, so text stays selectable */
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: rotate(var(--nts-note-rot)) translateY(10px) scale(0.97);
	transform-origin: 50% 0;
	transition:
		opacity 260ms ease,
		transform 260ms var(--nts-ease),
		visibility 0s linear 260ms;
}

.nts-member.is-open .nts-note {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: rotate(var(--nts-note-rot)) translateY(0) scale(1);
	transition-delay: 0s;
}

.nts-note__close {
	position: absolute;
	top: 7px;
	right: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: inherit;
	opacity: 0.5;
	cursor: pointer;
	transition: opacity 150ms ease;
	-webkit-appearance: none;
	appearance: none;
}

.nts-note__close:hover,
.nts-note__close:focus-visible {
	opacity: 1;
}

.nts-note__close svg {
	width: 12px;
	height: 12px;
	display: block;
}

.nts-note__name {
	margin: 0 0 0.15em;
	font-size: 1.05em;
	line-height: 1.2;
	color: inherit;
}

.nts-note__role {
	margin: 0 0 0.7em;
	font-size: 0.85em;
	opacity: 0.75;
}

.nts-note__bio {
	font-size: 0.92em;
	line-height: 1.5;
}

.nts-note__bio > :first-child { margin-top: 0; }
.nts-note__bio > :last-child  { margin-bottom: 0; }

/* ------------------------------------------------------------------ */
/* The note: flow mode (accordion, pushes the page down)              */
/* ------------------------------------------------------------------ */

.nts-member--flow .nts-note-slot {
	position: static;
	width: 100%;
	max-width: none;
	margin: 0;
	display: grid;
	grid-template-rows: minmax(0, 0fr);
	transition: grid-template-rows 320ms var(--nts-ease);
}

.nts-member--flow.is-open .nts-note-slot {
	grid-template-rows: minmax(0, 1fr);
}

/* Padding + negative margin gives the box-shadow room to breathe
   without the clip box affecting layout. */
/*
 * The clip exists to hide the note while the accordion is collapsed, which is
 * a vertical job only. Plain `overflow: hidden` also clipped sideways, so a
 * note made wider than its column, or nudged out of it, lost its edge.
 * `overflow-y: clip` is the one value that lets the other axis stay visible:
 * next to `hidden`, `visible` would be forced to `auto` and add a scrollbar.
 * Older browsers keep the shorthand below and simply clip as before.
 */
.nts-member--flow .nts-note-clip {
	display: flow-root;
	min-height: 0;
	overflow: hidden;
	padding: 0 18px;
	margin: 0 -18px;
}

@supports (overflow: clip) {
	.nts-member--flow .nts-note-clip {
		overflow-x: visible;
		overflow-y: clip;
	}
}

/*
 * Stacked (accordion) notes honour the same width and nudge controls as
 * overlay ones. They are applied to the note itself rather than the slot:
 * the slot is the animation container whose height goes 0fr -> 1fr, so a
 * margin there would leave a permanent gap below the photos while closed.
 * The note sits inside the overflow-clip, so its margins cost nothing until
 * the note opens.
 */
.nts-member--flow .nts-note {
	visibility: visible;
	pointer-events: auto;
	width: var(--nts-note-w);
	max-width: none;
	margin: calc(14px + var(--nts-note-y)) 0 16px var(--nts-note-x);
	transform: rotate(var(--nts-note-rot));
	transition: opacity 260ms ease;
}

.nts-member--flow.is-open .nts-note {
	opacity: 1;
	transform: rotate(var(--nts-note-rot));
}

/* Same treatment, applied only on small screens, for overlay widgets
   that opted into "push content down on mobile". */
@media (max-width: 767px) {
	.nts-member--mobile-flow {
		display: block;
	}

	.nts-member--mobile-flow .nts-note-slot {
		position: static;
		width: 100%;
		max-width: none;
		margin: 0;
		display: grid;
		grid-template-rows: minmax(0, 0fr);
		transition: grid-template-rows 320ms var(--nts-ease);
	}

	.nts-member--mobile-flow.is-open .nts-note-slot {
		grid-template-rows: minmax(0, 1fr);
	}

	.nts-member--mobile-flow .nts-note-clip {
		display: flow-root;
		min-height: 0;
		overflow: hidden;
		padding: 0 18px;
		margin: 0 -18px;
	}

	@supports (overflow: clip) {
		.nts-member--mobile-flow .nts-note-clip {
			overflow-x: visible;
			overflow-y: clip;
		}
	}

	.nts-member--mobile-flow .nts-note {
		visibility: visible;
		pointer-events: auto;
		width: var(--nts-note-w);
		max-width: none;
		margin: calc(14px + var(--nts-note-y)) 0 16px var(--nts-note-x);
		transform: rotate(var(--nts-note-rot));
		transition: opacity 260ms ease;
	}

	/*
	 * No mobile note width has been set, so keep the long-standing behaviour
	 * of filling the column rather than inheriting the desktop width. PHP adds
	 * this class only while that control is empty, so setting a mobile width
	 * removes it and the rule above takes over. Must stay after that rule:
	 * same specificity, source order decides.
	 */
	.nts-member--stacked-auto-mobile .nts-note {
		width: auto;
	}

	.nts-member--mobile-flow.is-open .nts-note {
		opacity: 1;
		transform: rotate(var(--nts-note-rot));
	}
}

/* ------------------------------------------------------------------ */
/* Utilities                                                           */
/* ------------------------------------------------------------------ */

.nts-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

@media (prefers-reduced-motion: reduce) {
	.nts-photo,
	.nts-note,
	.nts-note-slot {
		transition-duration: 1ms !important;
	}
}

@media print {
	.nts-note {
		opacity: 1 !important;
		visibility: visible !important;
		position: static !important;
		transform: none !important;
	}
	.nts-note-slot {
		position: static !important;
		grid-template-rows: 1fr !important;
	}
}
