/* Organisation CSS - combined from three Code Snippets, each pulled fresh from production 2026-08-24:
   "JD: Org page view-toggle CSS" (id 36), "JD: Organisation sidebar styling" (id 41),
   "JD: Related organisation page styling" (id 42). */

/* Class-based version for the manual rebuild — add these exact CSS Classes (Advanced tab) to the
   matching widgets in the Elementor editor, see organisation-page-manual-build-guide.md step 6. */

/* Always hide the 'full' paginated grids by default (overview = previews only), and hide every
   per-block "back to organisation" link by default too - each one only appears on its own
   subview (see the body.org-view-* rules below), sitting in the SAME header row as that block's
   heading (heading left / back-link right, replacing the now-hidden "View all X" link in that
   row's flex space-between layout - the row already has justify-content:space-between from the
   original heading+viewall design, so putting the visible back-link as the row's last child with
   the viewall link hidden reuses that same alignment for free).

   jd-about-full / jd-about-backlink added 5 August 2026 alongside the new About sub-view - same
   preview/full/backlink mechanics as the other four blocks. */
.jd-events-full, .jd-members-full, .jd-courses-full, .jd-news-full, .jd-about-full,
.jd-events-backlink, .jd-members-backlink, .jd-courses-backlink, .jd-news-backlink, .jd-about-backlink {
	display: none;
}

/* Visual styling only (no `display` here on purpose - display is controlled solely by the rules
   above/below; mixing a display value into this same-specificity single-class selector caused a
   bug once already where the visual rule silently won the cascade and kept the link visible
   everywhere regardless of view). */
a.jd-org-back-link {
	align-items: center;
	gap: 6px;
	font-size: 14px;
	color: var(--jd-accent);
	text-decoration: none;
}
a.jd-org-back-link:hover {
	text-decoration: underline;
}
a.jd-org-back-link::before {
	content: "←";
	margin-right: 4px;
}

/* org-view-about keeps its OWN heading visible (same row as the now-visible back-link, mirroring
   how events/members/courses/news keep their own heading on their own subview) - only its
   preview text and "Read full profile" link hide, replaced by the full text below. */
body.org-view-about .jd-about-backlink { display: inline-flex; }
body.org-view-about .jd-events-heading, body.org-view-about .jd-events-preview, body.org-view-about .jd-events-viewall,
body.org-view-about .jd-members-heading, body.org-view-about .jd-members-preview, body.org-view-about .jd-members-viewall,
body.org-view-about .jd-courses-heading, body.org-view-about .jd-courses-preview, body.org-view-about .jd-courses-viewall,
body.org-view-about .jd-news-heading, body.org-view-about .jd-news-preview, body.org-view-about .jd-news-viewall,
body.org-view-about .jd-about-preview, body.org-view-about .jd-about-viewall {
	display: none;
}
body.org-view-about .jd-about-full { display: block; }

body.org-view-events .jd-events-backlink { display: inline-flex; }
body.org-view-events .jd-about-heading, body.org-view-events .jd-about-preview, body.org-view-events .jd-about-viewall, body.org-view-events .jd-events-preview, body.org-view-events .jd-events-viewall,
body.org-view-events .jd-members-heading, body.org-view-events .jd-members-preview, body.org-view-events .jd-members-viewall,
body.org-view-events .jd-courses-heading, body.org-view-events .jd-courses-preview, body.org-view-events .jd-courses-viewall,
body.org-view-events .jd-news-heading, body.org-view-events .jd-news-preview, body.org-view-events .jd-news-viewall {
	display: none;
}
body.org-view-events .jd-events-full { display: block; }

body.org-view-members .jd-members-backlink { display: inline-flex; }
body.org-view-members .jd-about-heading, body.org-view-members .jd-about-preview, body.org-view-members .jd-about-viewall, body.org-view-members .jd-events-heading, body.org-view-members .jd-events-preview, body.org-view-members .jd-events-viewall,
body.org-view-members .jd-members-preview, body.org-view-members .jd-members-viewall,
body.org-view-members .jd-courses-heading, body.org-view-members .jd-courses-preview, body.org-view-members .jd-courses-viewall,
body.org-view-members .jd-news-heading, body.org-view-members .jd-news-preview, body.org-view-members .jd-news-viewall {
	display: none;
}
body.org-view-members .jd-members-full { display: block; }

body.org-view-courses .jd-courses-backlink { display: inline-flex; }
body.org-view-courses .jd-about-heading, body.org-view-courses .jd-about-preview, body.org-view-courses .jd-about-viewall, body.org-view-courses .jd-events-heading, body.org-view-courses .jd-events-preview, body.org-view-courses .jd-events-viewall,
body.org-view-courses .jd-members-heading, body.org-view-courses .jd-members-preview, body.org-view-courses .jd-members-viewall,
body.org-view-courses .jd-courses-preview, body.org-view-courses .jd-courses-viewall,
body.org-view-courses .jd-news-heading, body.org-view-courses .jd-news-preview, body.org-view-courses .jd-news-viewall {
	display: none;
}
body.org-view-courses .jd-courses-full { display: block; }

body.org-view-news .jd-news-backlink { display: inline-flex; }
body.org-view-news .jd-about-heading, body.org-view-news .jd-about-preview, body.org-view-news .jd-about-viewall, body.org-view-news .jd-events-heading, body.org-view-news .jd-events-preview, body.org-view-news .jd-events-viewall,
body.org-view-news .jd-members-heading, body.org-view-news .jd-members-preview, body.org-view-news .jd-members-viewall,
body.org-view-news .jd-courses-heading, body.org-view-news .jd-courses-preview, body.org-view-news .jd-courses-viewall,
body.org-view-news .jd-news-preview, body.org-view-news .jd-news-viewall {
	display: none;
}
body.org-view-news .jd-news-full { display: block; }

/* ======================================================================
   EMPTY-SECTION SUPPRESSION

   A Loop Grid whose query returns nothing emits
   <div class="e-loop-nothing-found-message"> inside its widget container.
   That marker is the only signal on the page guaranteed to agree with what
   the grid actually rendered, so we key off it rather than recounting in
   PHP - which would duplicate the elementor/query/org-* logic (and be free
   to drift from it) and cost roughly 1.4s per page load across four
   sections.

   A block's preview and full grids run the SAME query (only posts_per_page
   and pagination differ), so a block is empty iff either grid carries the
   marker. Hiding the block wrapper removes its heading and its
   "View all ... →" link along with the grids.

   These selectors target the block WRAPPERS; every rule above targets
   widgets INSIDE the blocks, so there is no cascade conflict either way.

   :has() is baseline-supported in all current browsers. Where it is absent
   the whole rule is dropped and the page degrades to the previous
   behaviour (empty headings shown), which is no worse than before.

   The About block is NOT a Loop Grid (it's a single post's own text), so it
   has no e-loop-nothing-found-message marker - its emptiness is instead
   handled by the generic empty-shortcode-widget rule in "JD: Empty rail
   suppression" (body.single-iaap-organisations .elementor-widget-shortcode
   :has(...>.elementor-shortcode:empty)), which hides the preview/full
   widgets individually. An org with no post_content shows an "About"
   heading with nothing under it rather than the whole card disappearing -
   accepted as a minor cosmetic gap since post_content is filled on the
   large majority of IAAP organisations.
   ====================================================================== */

/* IAAP Organisations - template 31228. All four block ids are hand-set as of
   Phase 1 (2026-08-04); the Events and Members containers were renamed from
   the generated ids d784799 / 022a2d3 so every selector below reads the same. */
.elementor-element-jd-events-block:has(.e-loop-nothing-found-message),
.elementor-element-jd-members-block:has(.e-loop-nothing-found-message),
.elementor-element-jd-courses-block:has(.e-loop-nothing-found-message),
.elementor-element-jd-news-block:has(.e-loop-nothing-found-message),

/* Related Organisations - template 126278. */
.elementor-element-jd-relorg-events-block:has(.e-loop-nothing-found-message),
.elementor-element-jd-relorg-courses-block:has(.e-loop-nothing-found-message),
.elementor-element-jd-relorg-news-block:has(.e-loop-nothing-found-message) {
	display: none;
}

/* ======================================================================
   SUB-VIEW: HIDE THE INACTIVE BLOCK WRAPPERS

   The rules above hide the *children* of the non-active blocks on a
   sub-view (heading, preview grid, "view all" link). That was invisible
   while block containers had no chrome of their own. Phase 1a gave them
   .jd-section - white background, 1px border, 10px radius, 22px padding -
   so a block with every child hidden now renders as an empty card.

   Seen on /iaap-organisations/iaap/association-of-jungian-analysts/courses/:
   an empty card above "Courses & Training", which is the MEMBERS block.
   The empty-section suppression does not catch it because that keys off
   the Loop Grid's nothing-found marker, and AJA genuinely has 59 members -
   the block is empty only because of the view, not because of the data.

   Fix: on each sub-view, hide the wrappers of the blocks that are not the
   subject of that view. Redundant with the child-level rules above, which
   are left in place: they still do the work of hiding the ACTIVE block's
   own preview grid and "view all" link.

   Both templates' class names are listed together. A selector naming a
   class that is not on the current page costs nothing.

   jd-about-block added 5 August 2026: it is a plain .jd-section wrapper
   like the other four (not Loop-Grid-based), so it needs the same
   wrapper-level hide on every OTHER sub-view, and the other four need
   hiding on org-view-about in turn.
   ====================================================================== */

/* viewing ABOUT - hide members, events, courses, news (both post types) */
body.org-view-about .elementor-element-jd-members-block,
body.org-view-about .elementor-element-jd-events-block,
body.org-view-about .elementor-element-jd-courses-block,
body.org-view-about .elementor-element-jd-news-block,
body.org-view-about .elementor-element-jd-relorg-events-block,
body.org-view-about .elementor-element-jd-relorg-courses-block,
body.org-view-about .elementor-element-jd-relorg-news-block,

/* viewing MEMBERS - hide about, events, courses, news */
body.org-view-members .elementor-element-jd-about-block,
body.org-view-members .elementor-element-jd-events-block,
body.org-view-members .elementor-element-jd-courses-block,
body.org-view-members .elementor-element-jd-news-block,
body.org-view-members .elementor-element-jd-relorg-events-block,
body.org-view-members .elementor-element-jd-relorg-courses-block,
body.org-view-members .elementor-element-jd-relorg-news-block,

/* viewing EVENTS - hide about, members, courses, news */
body.org-view-events .elementor-element-jd-about-block,
body.org-view-events .elementor-element-jd-relorg-about-block,
body.org-view-events .elementor-element-jd-members-block,
body.org-view-events .elementor-element-jd-courses-block,
body.org-view-events .elementor-element-jd-news-block,
body.org-view-events .elementor-element-jd-relorg-courses-block,
body.org-view-events .elementor-element-jd-relorg-news-block,

/* viewing COURSES - hide about, members, events, news */
body.org-view-courses .elementor-element-jd-about-block,
body.org-view-courses .elementor-element-jd-relorg-about-block,
body.org-view-courses .elementor-element-jd-members-block,
body.org-view-courses .elementor-element-jd-events-block,
body.org-view-courses .elementor-element-jd-news-block,
body.org-view-courses .elementor-element-jd-relorg-events-block,
body.org-view-courses .elementor-element-jd-relorg-news-block,

/* viewing NEWS - hide about, members, events, courses */
body.org-view-news .elementor-element-jd-about-block,
body.org-view-news .elementor-element-jd-relorg-about-block,
body.org-view-news .elementor-element-jd-members-block,
body.org-view-news .elementor-element-jd-events-block,
body.org-view-news .elementor-element-jd-courses-block,
body.org-view-news .elementor-element-jd-relorg-events-block,
body.org-view-news .elementor-element-jd-relorg-courses-block {
	display: none;
}


/* ---------- Organisation sidebar styling (id 41) ---------- */

.jd-sidebar-card {
	background: var(--jd-surface);
	border: 1px solid var(--jd-rule);
	border-radius: var(--jd-r-lg);
	padding: 24px;
	width: 100%;
	box-sizing: border-box;
}
.jd-sidebar-card-heading,
.jd-sidebar-card-heading .elementor-heading-title {
	font-family: var(--jd-font);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: var(--jd-ls-label);
	text-transform: uppercase;
	color: var(--jd-navy-dark);
	margin: 0 0 16px 0;
}
.jd-org-map {
	width: 100%;
	height: 140px;
	border-radius: var(--jd-r-md);
	overflow: hidden;
	margin-bottom: 16px;
}
.jd-org-map iframe {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}
.jd-org-map--placeholder {
	background: repeating-linear-gradient(45deg, var(--jd-tint), var(--jd-tint) 10px, var(--jd-tint-deep) 10px, var(--jd-tint-deep) 20px);
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 12px;
}
.jd-org-map--placeholder span {
	font-size: 12px;
	color: var(--jd-text-muted);
	background: rgba(255,255,255,0.85);
	padding: 4px 10px;
	border-radius: var(--jd-r-sm);
}
.jd-org-contact-row {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	font-size: 14px;
	color: var(--jd-text);
	margin-bottom: 14px;
	line-height: 1.5;
}
.jd-org-contact-row:last-child {
	margin-bottom: 0;
}
.jd-org-contact-row a {
	color: var(--jd-text);
	text-decoration: none;
	word-break: break-word;
}
.jd-org-contact-row a:hover {
	color: var(--jd-accent);
}
.jd-org-contact-row .jd-icon {
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--jd-accent);
	font-size: 14px;
	margin-top: 1px;
}
.jd-sidebar-social {
	margin-top: 18px;
	padding-top: 18px;
	border-top: 1px solid var(--jd-rule);
}
a.jd-org-link-row {
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 14px;
	color: var(--jd-text);
	text-decoration: none;
	padding: 10px 0;
	border-bottom: 1px solid var(--jd-rule);
}
a.jd-org-link-row:last-child {
	border-bottom: none;
	padding-bottom: 0;
}
a.jd-org-link-row:first-of-type {
	padding-top: 0;
}
a.jd-org-link-row:hover {
	color: var(--jd-accent);
}
a.jd-org-link-row .jd-icon {
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--jd-accent);
	font-size: 14px;
}
a.jd-org-iaap-listing {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 13px;
	color: var(--jd-text-muted);
	text-decoration: none;
	padding: 4px 4px;
}
a.jd-org-iaap-listing:hover {
	color: var(--jd-accent);
}
a.jd-org-iaap-listing-link {
	font-weight: 600;
	color: var(--jd-accent);
}

/* Key Personnel card (IAAP Organisations, 5 August 2026) - a row list rather than the
   Components library's .jd-person-grid (4 fixed columns, built for a wide main-column team
   wall), which would be too cramped in a ~30%-width sidebar rail. Each row: circular avatar
   (real analyst photo when set, else initials) + name (linked to the analyst's own profile) +
   role, matching the visual weight of .jd-org-contact-row immediately above without reusing
   its icon-first layout, since these rows carry a photo instead of a Font Awesome glyph. */
.jd-personnel-row {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 14px;
}
.jd-personnel-row:last-child {
	margin-bottom: 0;
}
.jd-personnel-avatar {
	width: 40px;
	height: 40px;
	flex: 0 0 40px;
	border-radius: 50%;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--jd-navy);
}
.jd-personnel-avatar--initials span {
	color: var(--jd-text-invert);
	font-weight: 700;
	font-size: 13px;
	letter-spacing: 0.02em;
}
.jd-personnel-avatar-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.jd-personnel-info {
	display: flex;
	flex-direction: column;
	min-width: 0;
}
.jd-personnel-name {
	font-size: 14px;
	font-weight: 600;
	color: var(--jd-text);
	text-decoration: none;
	line-height: 1.3;
}
.jd-personnel-name:hover {
	color: var(--jd-accent);
	text-decoration: underline;
}
.jd-personnel-role {
	font-size: 12px;
	color: var(--jd-text-muted);
}


/* ---------- Related organisation page styling (id 42) ---------- */

.jd-relorg-logo-img {
	width: 100%;
	height: auto;
	display: block;
}
.jd-relorg-logo-fallback {
	width: 100px;
	height: 100px;
	border-radius: 50%;
	background: var(--jd-navy);
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto;
}
.jd-relorg-logo-fallback span {
	color: var(--jd-text-invert);
	font-size: 28px;
	font-weight: 600;
	letter-spacing: 0.02em;
}
.jd-relorg-subtitle {
	font-style: italic;
	color: var(--jd-text-muted);
	margin: 0 0 11px 0;
	line-height: 1.3;
}
.jd-relorg-personnel-role {
	color: var(--jd-text-muted);
	font-weight: 400;
}
.jd-relorg-personnel-email {
	color: var(--jd-accent);
	margin-left: 4px;
}
.jd-relorg-social a {
	color: var(--jd-text);
	margin-right: 12px;
	font-size: 16px;
}
.jd-relorg-social a:last-child {
	margin-right: 0;
}
.jd-relorg-social a:hover {
	color: var(--jd-accent);
}
