/**
 * Butterfields – People Cards
 *
 * Themes the People Cards plugin to the approved "Meet the team" card design
 * and to the site's own button / panel language.
 *
 * The card itself is built to the supplied design (example-person-card.pdf):
 * a full-bleed portrait photo, then the name and role set in Cormorant
 * Garamond directly on the page — no panel, no border, no shadow, no radius.
 *
 * The Read More button and the popup are not in that design, so they are
 * derived from the patterns already on the site: the pill CTAs in the page
 * content, and the bordered "Talk to us" panel with its dark-olive header.
 *
 * ---------------------------------------------------------------------------
 * Why every selector is prefixed with `body`
 *
 * The plugin registers its stylesheet on wp_enqueue_scripts but only enqueues
 * it when the shortcode actually renders — which happens while the_content is
 * being filtered, i.e. after wp_head has already printed. WordPress therefore
 * prints people-cards.css in the *body*, after every stylesheet this theme
 * puts in the head. Source order breaks specificity ties in the plugin's
 * favour, so a bare `.people-cards__name` here (0,1,0) would lose to the
 * plugin's identical selector.
 *
 * The `body` prefix lifts each rule to (0,1,1) and takes the tie back without
 * resorting to !important. The exception is `.people-cards-modal__close`,
 * where the plugin's own declarations are !important and have to be met in
 * kind — see that rule.
 * ---------------------------------------------------------------------------
 */

/* -------------------------------------------------------------------------
 * Component tokens
 *
 * The brand palette and font stacks come from :root in header.css. Only the
 * values the card design needs and the theme does not already name are
 * declared here.
 * ---------------------------------------------------------------------- */

:root {
	/* Page-content colours, matched to the Elementor global styles used by the
	 * body copy and section headings around the cards. */
	--pc-ink: #34403c; /* Headings + primary body copy */
	--pc-ink-muted: #65706c; /* Secondary body copy */
	--pc-cream: #faf9f4; /* Section tint, reused as the photo placeholder */
	--pc-rule: rgba(113, 116, 106, 0.55); /* Hairline, as on the "Talk to us" panel */

	/* Body copy inside the popup is set in Manrope to match the page's own
	 * body text. Manrope is loaded by Elementor's global fonts rather than by
	 * this theme, hence the full fallback stack. */
	--pc-font-body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	/* The design's photo: 335 x 464. Kept as the authored numbers rather than
	 * a rounded ratio so the crop stays exactly on the design. */
	--pc-photo-ratio: 335 / 464;

	/*
	 * The card's largest size, and the gap between columns.
	 *
	 * 320px is set by the row of four: the content column measures 1365px on a
	 * 1440px screen, and four cards plus three 24px gaps have to fit inside it
	 * (4 x 320 + 3 x 24 = 1352). It is a shade under the design's 335px card,
	 * so the type and padding below are scaled by the same 0.94 to keep the
	 * card's internal proportions on the design.
	 */
	--pc-card-max: 320px;
	--pc-column-gap: 24px;
}

/* -------------------------------------------------------------------------
 * Plugin token remap
 *
 * The plugin paints itself from its own custom properties. Repointing them at
 * the brand palette re-colours everything it styles internally — including
 * anything added to it later — and leaves only structure and type to override
 * below. Declared on the same elements the plugin declares them on, one
 * specificity step up.
 * ---------------------------------------------------------------------- */

body .people-cards,
body .people-cards-modal-overlay {
	--people-cards-accent: var(--bf-olive-dark);
	--people-cards-accent-alt: var(--bf-grey);
	--people-cards-text: var(--pc-ink);
	--people-cards-font: var(--bf-font-accent);
}

/* -------------------------------------------------------------------------
 * Grid
 * ---------------------------------------------------------------------- */

body .people-cards {
	/* The shortcode sits inside an Elementor container that already applies
	 * the section gutter, so the plugin's own 20px would push the cards in
	 * further than the body copy above them. */
	max-width: none;
	padding-inline: 0;
	font-family: var(--pc-font-body);
}

/*
 * Four across on a desktop, then three, two and one as the screen narrows.
 *
 * The column count is set explicitly at each breakpoint rather than left to
 * `auto-fill`, and the grid is capped at exactly the width of that many cards.
 * The two work together:
 *
 * - The max-width stops the cards growing past their designed size. Tracks are
 *   1fr, so without it a wide container would stretch each card, scaling the
 *   photo up and leaving the type looking small against it.
 * - Fixing the count stops them shrinking too far. `auto-fill` derives the
 *   count from the track cap, which on a 1366px laptop — a very common size —
 *   left room for only three 320px columns and a wide band of dead space. A
 *   declared count instead lets the cards give up a few pixels each and hold
 *   the row of four.
 *
 * Between them the card stays within 283–320px at every width, so the row is
 * always full and the card is always close to the design.
 */
body .people-cards__grid {
	grid-template-columns: repeat(4, minmax(0, 1fr));
	max-width: calc(4 * var(--pc-card-max) + 3 * var(--pc-column-gap));
	gap: 44px var(--pc-column-gap);
}

/* Each step drops a column just before the cards would fall below ~280px. */
@media (max-width: 1279px) {
	body .people-cards__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		max-width: calc(3 * var(--pc-card-max) + 2 * var(--pc-column-gap));
	}
}

@media (max-width: 998px) {
	body .people-cards__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		max-width: calc(2 * var(--pc-card-max) + var(--pc-column-gap));
	}
}

@media (max-width: 699px) {
	body .people-cards__grid {
		grid-template-columns: minmax(0, 1fr);
		max-width: var(--pc-card-max);
	}
}

/* -------------------------------------------------------------------------
 * Card
 * ---------------------------------------------------------------------- */

/* The design has no card container: the photo sits on the page and the text
 * runs underneath it, so everything the plugin uses to lift the card off the
 * background is removed. */
body .people-cards__item {
	background: none;
	border-radius: 0;
	box-shadow: none;
	overflow: visible;
}

body .people-cards__photo {
	aspect-ratio: var(--pc-photo-ratio);
	border-radius: 0;
	background: var(--pc-cream);
	overflow: hidden;
}

/*
 * The registered "people-card" image size is a 600x600 square crop, so the
 * portrait box above crops it. `cover` with a top-weighted origin keeps the
 * head where the design has it rather than trimming it to centre the frame.
 */
body .people-cards__photo img {
	object-fit: cover;
	object-position: center top;
}

body .people-cards__body {
	/* Text is inset from the card edge while the photo stays full-bleed —
	 * 21px against the design's 335px card. The photo's own edge is the
	 * alignment the design reads from, so this is a plain inset, not a
	 * container padding.
	 *
	 * The 15px foot is what the design leaves under the last baseline once the
	 * line box's own descent is accounted for. With no card background it is
	 * only felt as space before the next row, but it keeps the card box itself
	 * on the design. */
	padding: 18px 20px 15px;
}

/*
 * Name and role share one baseline rhythm in the design — the role continues
 * the name's line spacing rather than opening a gap after it — so both are
 * set at the same size and line-height with no margin between them. Only the
 * weight and the colour separate them.
 *
 * The size is measured off the design rather than guessed: the name occupies
 * 73.7% of the card's width there, which is 32px on the design's own 335px
 * card and 30px on this 320px one. Sizing from the ink width rather than the
 * cap height is deliberate — the width is a ~250px measurement, so a pixel of
 * antialiasing either side barely moves it, where the same pixel on a 25px cap
 * height would put the size out by 4%.
 *
 * The size also decides where the role breaks. "Managing Director and" is the
 * longest first line in the team, and at 30px it fits the 280px text column
 * with 7px to spare, so it wraps where the design wraps it. At 32px in this
 * narrower card "and" drops to the second line instead.
 *
 * 1.25 puts the baselines 37.5px apart, the design's 40px scaled by the same
 * 320/340.
 */
body .people-cards__name {
	margin: 0;
	font-family: var(--bf-font-accent);
	font-weight: 500;
	font-size: 30px;
	line-height: 1.25;
	color: var(--bf-olive-dark);
}

body .people-cards__subtitle {
	margin: 0;
	font-family: var(--bf-font-accent);
	font-weight: 400;
	font-size: 30px;
	line-height: 1.25;
	color: var(--bf-grey);
}

/* -------------------------------------------------------------------------
 * Read More button
 *
 * Not in the card design. Built as an outlined pill so it belongs to the
 * site's CTA language (the pill buttons in the page content) without
 * competing with the name it sits under — the card's own weight should stay
 * on the photograph and the name.
 *
 * Both the popup trigger (<button>) and the PDF link (<a>) carry this class,
 * so the reset below covers the button's UA styling as well as the link's.
 * ---------------------------------------------------------------------- */

body .people-cards__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: auto;
	margin-top: 22px;
	padding: 12px 26px;
	background: transparent;
	border: 1px solid var(--bf-olive);
	border-radius: 999px;
	color: var(--bf-olive-dark);
	font-family: var(--bf-font-primary);
	font-weight: 600;
	font-size: 13px;
	line-height: 1.2;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/*
 * Hello Elementor's reset.css repaints links with `a:active,a:hover{color:#336}`
 * and fills every <button> with #c36 on :hover *and* :focus, both at (0,1,1).
 * The states below sit at (0,1,2) and take the brand colours back.
 *
 * :focus is held at the resting look rather than folded in with :hover. It
 * still has to be declared — otherwise the parent's magenta shows through it —
 * but the popup returns focus to its trigger on close, so painting :focus like
 * the hover state would leave the button looking pressed after every mouse
 * click. Keyboard focus is covered by :focus-visible below, which is listed
 * after this rule so it wins where both match.
 */
body .people-cards__button:focus {
	background-color: transparent;
	border-color: var(--bf-olive);
	color: var(--bf-olive-dark);
}

body .people-cards__button:hover,
body .people-cards__button:active,
body .people-cards__button:focus-visible {
	background-color: var(--bf-olive-dark);
	border-color: var(--bf-olive-dark);
	color: var(--bf-white);
}

body .people-cards__button:focus-visible {
	outline: 2px solid var(--bf-olive-dark);
	outline-offset: 2px;
}

/* -------------------------------------------------------------------------
 * Optional shortcode heading
 * ---------------------------------------------------------------------- */

/* Matched to the section headings on the page (Cormorant Garamond 28/500). */
body .people-cards__heading {
	margin: 0 0 28px;
	font-family: var(--bf-font-accent);
	font-weight: 500;
	font-size: 28px;
	line-height: 1.2;
	color: var(--pc-ink);
}

/* -------------------------------------------------------------------------
 * Popup
 *
 * Follows the "Talk to us" panel: square corners, a hairline border and white
 * ground. The scrim is the page ink at 55% rather than a brand tint — the
 * photograph and the bio are what should hold attention once it is open.
 * ---------------------------------------------------------------------- */

body .people-cards-modal-overlay {
	background: rgba(52, 64, 60, 0.55);
}

body .people-cards-modal {
	gap: 36px;
	border: 1px solid var(--pc-rule);
	border-radius: 0;
	box-shadow: 0 24px 60px rgba(52, 64, 60, 0.22);
	font-family: var(--pc-font-body);
}

/* The plugin sets background/color/box-shadow on the close button with
 * !important — to keep its own styling clear of the parent theme's magenta
 * button reset — so recolouring it has to be !important too. */
body .people-cards-modal__close,
body .people-cards-modal__close:hover,
body .people-cards-modal__close:focus,
body .people-cards-modal__close:active {
	color: var(--bf-olive-dark) !important;
	transition: color 0.2s ease;
}

body .people-cards-modal__close:hover,
body .people-cards-modal__close:focus-visible {
	color: var(--bf-primary) !important;
}

/*
 * The plugin's media column is a 220px track, which is too narrow for a name
 * with post-nominals after it — "David P. Butterfield Dip. F.D. M.B.I.F.D"
 * broke across three lines there. At 260px the name breaks in two, the same
 * way it does on the card and in the design.
 */
body .people-cards-modal__media {
	flex: 0 0 260px;
}

body .people-cards-modal__photo {
	width: 100%;
	aspect-ratio: var(--pc-photo-ratio);
	border: 0;
	border-radius: 0;
	background: var(--pc-cream);
}

body .people-cards-modal__photo img {
	object-fit: cover;
	object-position: center top;
}

body .people-cards-modal__name {
	margin: 20px 0 2px;
	font-family: var(--bf-font-accent);
	font-weight: 500;
	font-size: 28px;
	line-height: 1.2;
	color: var(--bf-olive-dark);
}

body .people-cards-modal__subtitle {
	margin: 0 0 18px;
	font-family: var(--bf-font-accent);
	font-weight: 400;
	font-size: 24px;
	line-height: 1.18;
	color: var(--bf-grey);
}

body .people-cards-modal__email {
	font-family: var(--pc-font-body);
	font-size: 16px;
	line-height: 1.5;
	color: var(--pc-ink-muted);
}

body .people-cards-modal__email a,
body .people-cards-modal__email a:hover,
body .people-cards-modal__email a:active {
	color: var(--bf-olive-dark);
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* The popup's website link is the same pill as the card's Read More button so
 * the two read as one control. */
body .people-cards-modal__website a {
	padding: 12px 26px;
	background: transparent;
	border: 1px solid var(--bf-olive);
	border-radius: 999px;
	color: var(--bf-olive-dark);
	font-family: var(--bf-font-primary);
	font-weight: 600;
	font-size: 13px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

body .people-cards-modal__website a:hover,
body .people-cards-modal__website a:active,
body .people-cards-modal__website a:focus-visible {
	background-color: var(--bf-olive-dark);
	border-color: var(--bf-olive-dark);
	color: var(--bf-white);
}

/*
 * 18px/1.55 is the page's own body setting, so a bio reads exactly like the
 * copy on the rest of the site.
 *
 * The right inset clears the close button. It is positioned 16px in from the
 * modal's edge and is 40px square, so it reaches 24px past the modal's 32px
 * padding and into the text column — without this, the first line of a long
 * bio runs under it.
 */
body .people-cards-modal__description {
	padding-right: 28px;
	font-family: var(--pc-font-body);
	font-size: 18px;
	line-height: 1.55;
	color: var(--pc-ink);
}

body .people-cards-modal__description a,
body .people-cards-modal__description a:hover,
body .people-cards-modal__description a:active {
	color: var(--bf-olive-dark);
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* -------------------------------------------------------------------------
 * Narrow screens
 *
 * The card's type is set at absolute sizes because the column cap keeps the
 * card within a narrow band of widths (280–320px). Below that the single
 * column can go narrower still, so the name and role step down with it —
 * otherwise the longest role in the team stops fitting on one line.
 * ---------------------------------------------------------------------- */

@media (max-width: 400px) {
	body .people-cards__name,
	body .people-cards__subtitle {
		font-size: 27px;
	}
}

@media (max-width: 700px) {
	body .people-cards-modal__name {
		font-size: 26px;
	}

	body .people-cards-modal__subtitle {
		font-size: 21px;
	}

	/* The media column is a fixed track on desktop; stacked, the photo should
	 * not run the full width of the popup. */
	body .people-cards-modal__media {
		flex-basis: auto;
	}

	body .people-cards-modal__photo {
		width: 200px;
	}

	/* Stacked, the bio sits below the photo block rather than beside the close
	 * button, so it no longer needs the inset that clears it. */
	body .people-cards-modal__description {
		padding-right: 0;
	}
}
