/**
 * Presentation pass: backgrounds, centred About boxes, justified prose,
 * fee-table stacking, and Judicial Office tier rows.
 */

/* Optional editor colour tokens (empty = inherit existing presentation). */
.njcms-has-custom-bg {
	--njcms-bg-heading: inherit;
	--njcms-bg-body: inherit;
	--njcms-bg-link: inherit;
	--njcms-bg-button: inherit;
}

.njcms-has-custom-bg[style*="--njcms-bg-heading"] .njcms-quick-access__title,
.njcms-has-custom-bg[style*="--njcms-bg-heading"] .njcms-ia-panel__title,
.njcms-has-custom-bg[style*="--njcms-bg-heading"] .nj-page-shell__intro-heading,
.njcms-has-custom-bg[style*="--njcms-bg-heading"] .njcms-page-chrome__heading,
.njcms-has-custom-bg[style*="--njcms-bg-heading"] .nj-page-shell__main h2,
.njcms-has-custom-bg[style*="--njcms-bg-heading"] .nj-page-shell__main h3 {
	color: var(--njcms-bg-heading) !important;
}

.njcms-has-custom-bg[style*="--njcms-bg-body"] .njcms-quick-access__card-desc,
.njcms-has-custom-bg[style*="--njcms-bg-body"] .njcms-ia-panel__body,
.njcms-has-custom-bg[style*="--njcms-bg-body"] .njcms-ia-panel__body p,
.njcms-has-custom-bg[style*="--njcms-bg-body"] .nj-page-shell__intro-text,
.njcms-has-custom-bg[style*="--njcms-bg-body"] .njcms-page-chrome__description-body,
.njcms-has-custom-bg[style*="--njcms-bg-body"] .nj-page-shell__main p {
	color: var(--njcms-bg-body) !important;
}

/* Section-band link colour must not paint navy CTAs inside nested navy cards. */
.njcms-has-custom-bg[style*="--njcms-bg-link"] a:not(.njcms-home-principles__button):not(.njcms-service-infoboxes__button) {
	color: var(--njcms-bg-link) !important;
}

.njcms-has-custom-bg[style*="--njcms-bg-link"] a:not(.njcms-home-principles__button):not(.njcms-service-infoboxes__button):hover,
.njcms-has-custom-bg[style*="--njcms-bg-link"] a:not(.njcms-home-principles__button):not(.njcms-service-infoboxes__button):focus {
	color: var(--njcms-bg-link) !important;
	text-decoration: underline;
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Do not force section-band link colour onto the navy-card CTA (brand-overrides owns it). */

.njcms-has-custom-bg[style*="--njcms-bg-button"] .button:not(.njcms-home-principles__button),
.njcms-has-custom-bg[style*="--njcms-bg-button"] .njcms-btn:not(.njcms-home-principles__button),
.njcms-has-custom-bg[style*="--njcms-bg-button"] a.button:not(.njcms-home-principles__button) {
	background-color: var(--njcms-bg-button) !important;
	border-color: var(--njcms-bg-button) !important;
}

.njcms-has-custom-bg[style*="--njcms-bg-button"] .button:hover,
.njcms-has-custom-bg[style*="--njcms-bg-button"] .button:focus,
.njcms-has-custom-bg[style*="--njcms-bg-button"] .njcms-btn:hover,
.njcms-has-custom-bg[style*="--njcms-bg-button"] .njcms-btn:focus,
.njcms-has-custom-bg[style*="--njcms-bg-button"] a.button:hover,
.njcms-has-custom-bg[style*="--njcms-bg-button"] a.button:focus {
	filter: brightness(0.92);
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Nested white/light cards on a dark section keep dark readable card text. */
.njcms-bg-tone-dark .njcms-quick-access__card,
.njcms-bg-tone-dark .njcms-ia-card:not(.njcms-has-custom-bg),
.njcms-bg-tone-dark .njcms-ia-panel:not(.njcms-has-custom-bg),
.nj-page-shell.njcms-bg-tone-dark .njcms-ia-card:not(.njcms-has-custom-bg),
.nj-page-shell.njcms-bg-tone-dark article.njcms-ia-card:not(.njcms-has-custom-bg),
body.njcms-has-main-bg.njcms-bg-tone-dark .njcms-ia-card:not(.njcms-has-custom-bg),
body.njcms-has-main-bg.njcms-bg-tone-dark article.njcms-ia-card:not(.njcms-has-custom-bg),
body.njcms-has-main-bg.njcms-bg-tone-dark .nj-card,
body.njcms-has-main-bg.njcms-bg-tone-dark .nj-panel,
body.njcms-has-main-bg.njcms-bg-tone-dark .nj-people-card,
body.njcms-has-main-bg.njcms-bg-tone-dark .nj-profile-card,
body.njcms-has-main-bg.njcms-bg-tone-dark .njcms-court-card,
body.njcms-has-main-bg.njcms-bg-tone-dark .njcms-courts__card {
	color: #142033;
}

.njcms-bg-tone-dark .njcms-quick-access__card-title,
.njcms-bg-tone-dark .njcms-quick-access__card-desc,
.njcms-bg-tone-dark .njcms-ia-card:not(.njcms-has-custom-bg) .njcms-ia-panel__title,
.njcms-bg-tone-dark .njcms-ia-card:not(.njcms-has-custom-bg) .njcms-ia-panel__body,
.njcms-bg-tone-dark .njcms-ia-card:not(.njcms-has-custom-bg) .njcms-ia-panel__body p,
body.njcms-has-main-bg.njcms-bg-tone-dark .njcms-ia-card:not(.njcms-has-custom-bg) .njcms-ia-panel__title,
body.njcms-has-main-bg.njcms-bg-tone-dark .njcms-ia-card:not(.njcms-has-custom-bg) .njcms-ia-panel__body,
body.njcms-has-main-bg.njcms-bg-tone-dark .njcms-ia-card:not(.njcms-has-custom-bg) .njcms-ia-panel__body p {
	color: #142033 !important;
}

.njcms-bg-tone-dark .njcms-quick-access__card a,
.njcms-bg-tone-dark .njcms-ia-card:not(.njcms-has-custom-bg) a,
body.njcms-has-main-bg.njcms-bg-tone-dark .njcms-ia-card:not(.njcms-has-custom-bg) a {
	color: #012169 !important;
}

/* Directory listing backgrounds paint full-width #main (not the content shell). */
body.njcms-has-main-bg #main.site-main {
	position: relative;
	background-size: cover;
	background-position: center center;
	background-repeat: no-repeat;
}

body.njcms-has-main-bg.njcms-bg-tone-dark #main.site-main {
	color: #f3f4f6;
}

body.njcms-has-main-bg.njcms-bg-tone-light #main.site-main {
	color: #1f2937;
}

/*
 * When a directory main background is active, drop opaque shell/page fills that
 * would mask the selected pattern/image/colour. Content width rules stay.
 * Individual section/card overrides (about_*, etc.) keep their own backgrounds.
 */
body.njcms-has-main-bg .nj-page-shell,
body.njcms-has-main-bg .nj-directory-page,
body.njcms-has-main-bg .nj-page.nj-page-shell,
body.njcms-has-main-bg .nj-page-shell__main > .njcms-ia:not(.njcms-has-custom-bg) {
	background-color: transparent !important;
	background-image: none !important;
}

/*
 * Optional background opacity (0–0.9): paint lives in --njcms-paint-* vars
 * so the section can lighten without fading content or the dark overlay.
 */
.njcms-has-custom-bg.njcms-has-bg-opacity {
	position: relative;
}

.njcms-has-custom-bg.njcms-has-bg-opacity::before {
	content: "";
	position: absolute;
	inset: 0;
	background-color: var(--njcms-paint-color, transparent);
	background-image: var(--njcms-paint-image, none);
	background-size: var(--njcms-paint-size, auto);
	background-position: var(--njcms-paint-position, 0 0);
	background-repeat: var(--njcms-paint-repeat, repeat);
	opacity: var(--njcms-bg-opacity, 1);
	pointer-events: none;
	z-index: 0;
}

.njcms-has-custom-bg.njcms-has-bg-opacity > * {
	position: relative;
	z-index: 1;
}

.njcms-has-custom-bg[style*="--njcms-bg-overlay"]::after {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, var(--njcms-bg-overlay));
	pointer-events: none;
	z-index: 0;
}

body.njcms-has-main-bg #main.site-main::after {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, var(--njcms-bg-overlay, 0));
	pointer-events: none;
	z-index: 0;
}

body.njcms-has-main-bg.njcms-has-bg-opacity #main.site-main::before {
	content: "";
	position: absolute;
	inset: 0;
	background-color: var(--njcms-paint-color, transparent);
	background-image: var(--njcms-paint-image, none);
	background-size: var(--njcms-paint-size, auto);
	background-position: var(--njcms-paint-position, 0 0);
	background-repeat: var(--njcms-paint-repeat, repeat);
	opacity: var(--njcms-bg-opacity, 1);
	pointer-events: none;
	z-index: 0;
}

body.njcms-has-main-bg #main.site-main > * {
	position: relative;
	z-index: 1;
}

/* Quick Access custom background replaces the fixed navy band, not the cards. */
.njcms-quick-access.njcms-has-custom-bg:not(.njcms-has-bg-opacity)::before {
	background: none;
}

.njcms-quick-access.njcms-bg-tone-light .njcms-quick-access__eyebrow,
.njcms-quick-access.njcms-bg-tone-light .njcms-quick-access__title {
	color: #012169 !important;
}

.njcms-quick-access.njcms-bg-tone-image .njcms-quick-access__eyebrow,
.njcms-quick-access.njcms-bg-tone-image .njcms-quick-access__title {
	text-shadow: 0 1px 2px rgba(1, 33, 105, 0.45);
}

.njcms-quick-access.njcms-has-custom-bg .njcms-quick-access__card,
.njcms-quick-access.njcms-has-custom-bg .njcms-quick-access__card-title,
.njcms-quick-access.njcms-has-custom-bg .njcms-quick-access__card-desc {
	text-shadow: none;
}

/* About Us boxes: centre headings and body, including the smaller value cards. */
.njcms-ia-who-we-are .njcms-ia-panel,
.njcms-ia-who-we-are .njcms-ia-panel__title,
.njcms-ia-who-we-are .njcms-ia-panel__body,
.njcms-ia-who-we-are .njcms-ia-panel__body p,
.njcms-ia-who-we-are .njcms-ia-values li,
.njcms-ia-who-we-are .njcms-ia-values strong,
.njcms-ia-who-we-are .njcms-ia-values span {
	text-align: center;
}

.njcms-ia-who-we-are .njcms-ia-panel__body {
	max-width: 40rem;
	margin-inline: auto;
	overflow-wrap: break-word;
}

.njcms-ia-who-we-are .njcms-ia-panel__body p {
	overflow-wrap: break-word;
	hyphens: auto;
}

.njcms-ia-who-we-are .njcms-ia-values li {
	display: flex;
	flex-direction: column;
	align-items: center;
	height: auto;
	min-width: 0;
}

.njcms-ia-who-we-are.njcms-has-custom-bg,
.njcms-ia-who-we-are .njcms-ia-panel.njcms-has-custom-bg {
	background-size: cover;
	background-position: center center;
	background-repeat: no-repeat;
}

.njcms-ia-who-we-are .njcms-ia-panel.njcms-bg-tone-dark,
.njcms-ia-who-we-are .njcms-ia-panel.njcms-bg-tone-dark .njcms-ia-panel__title,
.njcms-ia-who-we-are .njcms-ia-panel.njcms-bg-tone-dark .njcms-ia-panel__body,
.njcms-ia-who-we-are .njcms-ia-panel.njcms-bg-tone-dark .njcms-ia-panel__body p {
	color: #fff;
}

.njcms-ia-who-we-are .njcms-ia-panel.njcms-bg-tone-light,
.njcms-ia-who-we-are .njcms-ia-panel.njcms-bg-tone-light .njcms-ia-panel__title,
.njcms-ia-who-we-are .njcms-ia-panel.njcms-bg-tone-light .njcms-ia-panel__body,
.njcms-ia-who-we-are .njcms-ia-panel.njcms-bg-tone-light .njcms-ia-panel__body p {
	color: #142033;
}

.njcms-ia-who-we-are .njcms-ia-panel.njcms-bg-tone-image .njcms-ia-panel__title,
.njcms-ia-who-we-are .njcms-ia-panel.njcms-bg-tone-image .njcms-ia-panel__body {
	background: rgba(255, 255, 255, 0.9);
	color: #142033;
	border-radius: 0.35rem;
	padding: 0.65rem 0.75rem;
}

.njcms-ia-who-we-are .njcms-ia-panel--values .njcms-ia-values li {
	background: #f7f9fc;
	color: #243447;
}

.njcms-ia-who-we-are .njcms-ia-panel--values .njcms-ia-values strong,
.njcms-ia-who-we-are .njcms-ia-panel--values .njcms-ia-values span {
	color: #142033;
}

/*
 * Long-form prose. Last line stays natural (no text-align-last).
 * Titles, nav, breadcrumbs, buttons, forms, tables, cards, dates/case numbers,
 * and intentional centre/right alignment are excluded.
 */
.entry-content > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.wp-block-post-content > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.elementor-widget-theme-post-content > .elementor-widget-container > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.elementor-widget-text-editor .elementor-widget-container > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right):not(.elementor-heading-title),
body.home .elementor-widget-text-editor .elementor-widget-container > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.page-history .elementor-widget-text-editor .elementor-widget-container > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-about-history__prose > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-about-history__lead > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-about-history__body > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-about-history__highlight-prose > p,
.njcms-page-chrome__description-body > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.nj-page-shell__intro-text > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-home-principles__intro,
.njcms-footer-intro > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.elementor-location-footer .elementor-widget-text-editor .elementor-widget-container > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-court-guide-single__prose p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-court-prose p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-court-card__prose p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-court-intro__summary,
.njcms-court-list__body,
.njcms-tribunal-single__summary,
.njcms-tribunal-single__prose p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-staff-single__prose p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-staff-single__bio,
.nj-people-card__bio,
.nj-profile-card__bio,
.nj-practitioner-single__bio,
.nj-practitioner-single__prose p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-legal-practitioner-single__prose p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
.njcms-ia-panel__body > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right) {
	text-align: justify;
	hyphens: auto;
	overflow-wrap: break-word;
	text-align-last: auto;
	line-height: 1.7;
}

/* Narrow viewports: avoid uneven justified gaps. */
@media (max-width: 480px) {
	.entry-content > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
	.wp-block-post-content > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
	.elementor-widget-text-editor .elementor-widget-container > p:not(.has-text-align-center):not(.has-text-align-left):not(.has-text-align-right),
	.njcms-about-history__prose > p,
	.njcms-about-history__lead > p,
	.njcms-about-history__body > p,
	.njcms-about-history__highlight-prose > p,
	.njcms-page-chrome__description-body > p,
	.nj-page-shell__intro-text > p,
	.njcms-court-guide-single__prose p,
	.njcms-court-prose p,
	.njcms-court-card__prose p,
	.njcms-court-intro__summary,
	.njcms-court-list__body,
	.njcms-tribunal-single__summary,
	.njcms-tribunal-single__prose p,
	.njcms-staff-single__prose p,
	.njcms-staff-single__bio,
	.nj-people-card__bio,
	.nj-profile-card__bio,
	.nj-practitioner-single__bio,
	.nj-practitioner-single__prose p,
	.njcms-legal-practitioner-single__prose p,
	.njcms-ia-panel__body > p {
		text-align: left;
		hyphens: manual;
	}
}

/* Homepage court cards stay centred even when a general prose rule is justified. */
.njcms-home-courts__grid .njcms-home-court-card,
.njcms-home-courts--theme-strip .njcms-home-court-card--theme {
	align-items: center;
	text-align: center;
}

.njcms-home-courts__grid .njcms-home-court-card__icon-wrap,
.njcms-home-courts--theme-strip .njcms-home-court-card__icon-wrap {
	margin-left: auto;
	margin-right: auto;
}

.njcms-home-courts__grid .njcms-home-court-card__title,
.njcms-home-courts__grid .njcms-home-court-card__title a,
.njcms-home-courts__grid .njcms-home-court-card__summary,
.njcms-home-courts__grid .njcms-home-court-card__actions,
.njcms-home-courts__grid .njcms-home-court-card__button,
.njcms-home-courts--theme-strip .njcms-home-court-card__title,
.njcms-home-courts--theme-strip .njcms-home-court-card__title a,
.njcms-home-courts--theme-strip .njcms-home-court-card__summary,
.njcms-home-courts--theme-strip .njcms-home-court-card__actions,
.njcms-home-courts--theme-strip .njcms-home-court-card__button {
	text-align: center;
}

.njcms-home-courts__grid .njcms-home-court-card__actions,
.njcms-home-courts--theme-strip .njcms-home-court-card__actions {
	display: flex;
	justify-content: center;
	width: 100%;
}

/* Guide body fills its parent content area. The 52rem cap was ending the column early. */
body.njcms-court-guide-single .njcms-court-guide-single__content,
body.njcms-court-guide-single .njcms-court-guide-single__prose,
body.njcms-etiquette-page .njcms-court-guide-single__content,
body.njcms-etiquette-page .njcms-court-guide-single__prose {
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

/*
 * Judicial Office: each display tier is a full-width row.
 * Separate grids prevent a lower-tier profile from sitting beside a higher
 * tier at any breakpoint (including tablet and mobile).
 */
.nj-people-section > .nj-profile-grid.nj-profile-grid--tier {
	display: grid;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	flex: 0 0 100%;
	float: none;
	clear: both;
	grid-template-columns: repeat(auto-fit, minmax(16rem, 22rem));
	justify-content: start;
	margin-bottom: 1rem;
}

.nj-people-section > .nj-profile-grid.nj-profile-grid--tier .nj-profile-card {
	height: auto;
	max-width: 22rem;
}

@media (max-width: 639px) {
	.nj-people-section > .nj-profile-grid.nj-profile-grid--tier {
		grid-template-columns: minmax(0, 1fr);
	}

	.nj-people-section > .nj-profile-grid.nj-profile-grid--tier .nj-profile-card {
		max-width: none;
	}
}

/* Guide section download. */
.njcms-guide-section-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 0.75rem;
	margin: 0.35rem 0 1rem;
}

.njcms-guide-section-download {
	display: inline-flex;
	align-items: center;
	min-height: 2.75rem;
	padding: 0.4rem 0.9rem;
	border: 1px solid #012169;
	border-radius: 999px;
	background: #fff;
	color: #012169;
	font-weight: 700;
	text-decoration: none;
}

.njcms-guide-section-download--pdf,
.njcms-guide-section-download--pdf:link,
.njcms-guide-section-download--pdf:visited,
.njcms-guide-section-download--pdf:hover,
.njcms-guide-section-download--pdf:focus,
.njcms-guide-section-download--pdf:focus-visible,
.njcms-guide-section-download--pdf:active {
	background: #012169;
	color: #fff !important;
}

.njcms-guide-section-download:hover,
.njcms-guide-section-download:focus-visible {
	background: #012169;
	color: #fff;
}

.njcms-guide-section-download--pdf:hover,
.njcms-guide-section-download--pdf:focus,
.njcms-guide-section-download--pdf:focus-visible {
	background: #0a3a8f;
	border-color: #0a3a8f;
	color: #fff !important;
}

.njcms-guide-section-download--pdf:focus,
.njcms-guide-section-download--pdf:focus-visible {
	outline: 3px solid #c8a45d;
	outline-offset: 3px;
}

/* Fee tables: stack rows on small screens. Labels stay in the cell. */
.njcms-fee-tables__stack-label {
	display: none;
}

@media (max-width: 720px) {
	.njcms-fees__table-wrap,
	.njcms-fee-tables__table-wrap {
		overflow-x: visible;
	}

	.njcms-fees__table thead,
	.njcms-fee-tables__table thead {
		position: absolute;
		width: 1px;
		height: 1px;
		padding: 0;
		margin: -1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
		border: 0;
	}

	.njcms-fees__table,
	.njcms-fees__table tbody,
	.njcms-fees__table tr,
	.njcms-fees__table td,
	.njcms-fee-tables__table,
	.njcms-fee-tables__table tbody,
	.njcms-fee-tables__table tr,
	.njcms-fee-tables__table td {
		display: block;
		width: 100% !important;
		max-width: none !important;
		min-width: 0 !important;
		text-align: left;
		white-space: normal;
	}

	.njcms-fees__table tr,
	.njcms-fee-tables__table tr {
		margin: 0 0 0.85rem;
		border: 1px solid #d8dee6;
		border-radius: 6px;
		overflow: hidden;
	}

	.njcms-fee-tables__stack-label {
		display: block;
		margin-bottom: 0.2rem;
		font-size: 0.78rem;
		font-weight: 700;
		letter-spacing: 0.02em;
		text-transform: uppercase;
		color: #3d4a5c;
	}
}
