/*
 * Job detail page.
 *
 * Ships from the mu-plugin, not the theme, so there is no theme edit anywhere in
 * this feature. Every colour comes from the theme's own custom properties, which
 * each board's style variation remaps, so the structure is shared across the
 * network and the branding stays per board.
 *
 * Everything is scoped under .jbf-job-detail (a body class added only on single
 * job listings) so nothing here can reach another page.
 */

/* The theme does not set box-sizing globally, so every component here opts in.
   Without this, min-height on the CTA adds to its padding (a 75px button) and
   a width:100% button on mobile grows past the viewport by its own padding. */
.jbf-job-detail [class^="jbf-job-"],
.jbf-job-detail [class*=" jbf-job-"],
.jbf-job-detail .jbf-job-hero *,
.jbf-job-detail .jbf-job-summary *,
.jbf-job-detail .jbf-job-employer *,
.jbf-job-detail .jbf-job-sticky-apply * {
	box-sizing: border-box;
}

.jbf-job-detail .jbf-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Long job titles and company names must wrap rather than widen the page. */
.jbf-job-detail .jbf-article__head .wp-block-post-title,
.jbf-job-detail .jbf-job-hero__company-name,
.jbf-job-detail .jbf-job-employer__name {
	overflow-wrap: anywhere;
}

/* --- Fuse with the theme's title block ------------------------------------
   The theme renders the H1 inside .jbf-article__head on a canvas-grey band and
   the content inside .jbf-article__body on white. Left alone, the hero would be
   a grey card under a grey band with a white gap between them: an old heading
   sitting above a separate modern component, which is exactly wrong.

   On job pages only: the band goes white so title and hero share a background,
   the theme's date row is hidden because the hero's freshness line duplicates
   it (and the category row is empty for a listing anyway), and the gap between
   the two blocks closes. Title, company, facts and CTA then read as one header
   that ends in a rule before the description begins.

   Scoped to body.jbf-job-detail, so no other page changes, and no theme file is
   touched. The one !important is needed because single.html sets the title
   block's padding-bottom as an inline style, which nothing else can override. */

.jbf-job-detail .jbf-article__head {
	background: var(--wp--preset--color--base);
	padding-bottom: 0 !important;
}

.jbf-job-detail .jbf-article__meta {
	display: none;
}

.jbf-job-detail .jbf-article__body .wp-block-post-content > *:first-child {
	margin-top: 0;
}

/* The theme's flow layout puts its block gap (24px) between the title block and
   the body. On job pages the hero carries its own spacing, so the gap goes. */
.jbf-job-detail .jbf-article__body {
	margin-block-start: 0;
}

/* --- Hero ---------------------------------------------------------------- */

.jbf-job-detail .jbf-job-hero {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--30, 1rem);
	align-items: flex-start;
	justify-content: space-between;
	margin: 0 0 var(--wp--preset--spacing--40, 1.5rem);
	padding: 1rem 0 var(--wp--preset--spacing--40, 1.5rem);
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.jbf-job-detail .jbf-job-hero__body {
	flex: 1 1 18rem;
	min-width: 0;
}

.jbf-job-detail .jbf-job-hero__company {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin: 0 0 0.75rem;
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--wp--preset--color--primary);
}

/* The company logo: a standalone visual in the right column, under the Apply
   button, capped at 200 x 150 and never cropped or stretched. width/height
   attributes carry the intrinsic size, so both are reset to auto here and the
   max-* rules do the fitting. No card, no reserved space when there is none
   (the element is simply not rendered). */
.jbf-job-detail .jbf-job-hero__logo {
	display: block;
	width: auto;
	height: auto;
	max-width: 200px;
	max-height: 150px;
	margin: 1rem 0 0 auto;
	object-fit: contain;
	background: transparent;
}

.jbf-job-detail .jbf-job-hero__facts {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.jbf-job-detail .jbf-job-hero__fact {
	margin: 0;
	padding: 0.35rem 0.75rem;
	font-size: 0.9rem;
	line-height: 1.4;
	color: var(--wp--preset--color--contrast);
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 999px;
}

.jbf-job-detail .jbf-job-hero__fact--salary {
	font-weight: 700;
	color: var(--wp--preset--color--primary);
	border-color: var(--wp--preset--color--primary);
}

.jbf-job-detail .jbf-job-hero__posted,
.jbf-job-detail .jbf-job-hero__closed {
	margin: 0.75rem 0 0;
	font-size: 0.85rem;
	color: var(--wp--preset--color--muted);
}

.jbf-job-detail .jbf-job-hero__actions {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	max-width: 100%;
}

/* The hero CTA and the one after the description share the theme's button, so
   each board's accent colour carries straight through. */
.jbf-job-detail .jbf-job-cta__button {
	min-height: 44px;
}

/* --- Summary panel ------------------------------------------------------- */

.jbf-job-detail .jbf-job-summary {
	margin: 0 0 var(--wp--preset--spacing--40, 1.5rem);
}

.jbf-job-detail .jbf-job-summary__title,
.jbf-job-detail .jbf-job-employer__title {
	margin: 0 0 var(--wp--preset--spacing--30, 1rem);
	font-size: 1.15rem;
	line-height: 1.3;
}

.jbf-job-detail .jbf-job-summary__list {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0;
	margin: 0;
	padding: 0;
	list-style: none;
	border-top: 1px solid var(--wp--preset--color--border);
}

/* An empty list can still exist when a third-party add-on hooks the meta area
   and outputs nothing. Never show its border. */
.jbf-job-detail .jbf-job-summary__list:empty {
	display: none;
}

.jbf-job-detail .jbf-job-summary__row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1rem;
	margin: 0;
	padding: 0.7rem 0;
	border-bottom: 1px solid var(--wp--preset--color--border);
}

.jbf-job-detail .jbf-job-summary__label {
	flex: 0 0 12rem;
	font-weight: 700;
	color: var(--wp--preset--color--muted);
	font-size: 0.9rem;
}

.jbf-job-detail .jbf-job-summary__value {
	flex: 1 1 12rem;
	min-width: 0;
	overflow-wrap: anywhere;
}

.jbf-job-detail .jbf-job-summary__row--notice {
	font-weight: 700;
	color: var(--wp--preset--color--primary);
}

/* --- Description --------------------------------------------------------- */

.jbf-job-detail .job_description {
	margin: 0 0 var(--wp--preset--spacing--50, 2rem);
	line-height: 1.7;
}

.jbf-job-detail .job_description > *:first-child {
	margin-top: 0;
}

.jbf-job-detail .jbf-job-desc__heading {
	margin: var(--wp--preset--spacing--50, 2rem) 0 var(--wp--preset--spacing--20, 0.5rem);
	font-size: 1.15rem;
	line-height: 1.3;
	color: var(--wp--preset--color--primary);
}

.jbf-job-detail .jbf-job-desc__list {
	margin: 0 0 var(--wp--preset--spacing--30, 1rem);
	padding-left: 1.25rem;
}

.jbf-job-detail .jbf-job-desc__list li {
	margin: 0 0 0.35rem;
	padding-left: 0.15rem;
}

/* --- Apply box ----------------------------------------------------------- */

.jbf-job-detail .jbf-job-apply-anchor {
	display: block;
	height: 0;
	scroll-margin-top: 1.5rem;
}

.jbf-job-detail .job_application {
	margin: 0 0 var(--wp--preset--spacing--40, 1.5rem);
	padding: var(--wp--preset--spacing--40, 1.5rem);
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--jbf-radius, 10px);
}

.jbf-job-detail .job_application .application_button {
	min-height: 44px;
	padding: 0.85rem 1.6rem;
	font-weight: 700;
	color: var(--jbf-accent-text, var(--wp--preset--color--contrast));
	background: var(--wp--preset--color--accent);
	border: 2px solid var(--wp--preset--color--accent);
	border-radius: 8px;
	cursor: pointer;
}

.jbf-job-detail .job_application .application_button:hover,
.jbf-job-detail .job_application .application_button:focus {
	background: var(--wp--preset--color--accent-dark);
	border-color: var(--wp--preset--color--accent-dark);
}

/* --- Employer card ------------------------------------------------------- */

.jbf-job-detail .jbf-job-employer {
	margin: var(--wp--preset--spacing--50, 2rem) 0 0;
	padding: var(--wp--preset--spacing--40, 1.5rem);
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--jbf-radius, 10px);
}

.jbf-job-detail .jbf-job-employer__body {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--30, 1rem);
	align-items: flex-start;
}

.jbf-job-detail .jbf-job-employer__logo {
	/* WP Job Manager's stylesheet absolutely positions any img under .company.
	   The card no longer carries that class, and this pins it regardless. */
	position: static;
	float: none;
	flex: 0 0 auto;
	width: 64px;
	height: 64px;
	object-fit: contain;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 6px;
}

.jbf-job-detail .jbf-job-employer__text {
	flex: 1 1 14rem;
	min-width: 0;
}

.jbf-job-detail .jbf-job-employer__name {
	margin: 0 0 0.25rem;
}

.jbf-job-detail .jbf-job-employer__tagline {
	margin: 0 0 0.5rem;
	color: var(--wp--preset--color--muted);
}

.jbf-job-detail .jbf-job-employer__links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.25rem;
	margin: 0;
}

.jbf-job-detail .jbf-job-employer__link {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	font-weight: 700;
	color: var(--wp--preset--color--primary);
}

/* --- Focus ---------------------------------------------------------------
   Visible on every interactive element, including the anchor target, so
   keyboard users always know where they are. */

.jbf-job-detail a:focus-visible,
.jbf-job-detail button:focus-visible,
.jbf-job-detail input:focus-visible,
.jbf-job-detail select:focus-visible,
.jbf-job-detail textarea:focus-visible {
	outline: 3px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

/* --- Mobile --------------------------------------------------------------
   A single sticky Apply bar, phone widths only, restrained: solid surface, one
   button, no animation, no overlay. Desktop keeps the two in-page CTAs and no
   sticky UI at all.

   Hidden by default, shown only inside the media query below, so display:none
   also keeps it out of the accessibility tree on desktop rather than leaving a
   third duplicate Apply link for screen-reader users. */

.jbf-job-detail .jbf-job-sticky-apply {
	display: none;
}

@media (max-width: 781px) {
	.jbf-job-detail .jbf-job-hero {
		flex-direction: column;
		align-items: stretch;
	}

	.jbf-job-detail .jbf-job-hero__actions {
		align-items: stretch;
	}

	.jbf-job-detail .jbf-job-hero__actions .jbf-job-cta__button {
		width: 100%;
	}

	/* In the single-column stack the logo sits under the company/meta block
	   and above the Apply button, smaller, left-aligned with the text. */
	.jbf-job-detail .jbf-job-hero__logo {
		order: -1;
		max-width: 140px;
		max-height: 110px;
		margin: 0 auto 1rem 0;
	}

	.jbf-job-detail .jbf-job-summary__label {
		flex: 1 1 100%;
	}

	body.jbf-job-detail {
		padding-bottom: 5rem;
	}

	.jbf-job-detail .jbf-job-sticky-apply {
		position: fixed;
		z-index: 20;
		right: 0;
		bottom: 0;
		left: 0;
		display: block;
		padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
		background: var(--wp--preset--color--base);
		border-top: 1px solid var(--wp--preset--color--border);
	}

	.jbf-job-detail .jbf-job-sticky-apply .jbf-job-cta__button {
		width: 100%;
	}

	/* Parked while the hero's own Apply button is on screen (set by
	   job-detail.js). Without JavaScript the class never appears and the bar is
	   simply always visible, which is the safe fallback. */
	.jbf-job-detail .jbf-job-sticky-apply--parked {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jbf-job-detail * {
		transition: none !important;
		animation: none !important;
	}
}

/* --- Hero CTA note (email and external methods) ---------------------------- */

.jbf-job-detail .jbf-job-hero__cta-note {
	margin: 0.5rem 0 0;
	max-width: 16rem;
	font-size: 0.8rem;
	line-height: 1.4;
	color: var(--wp--preset--color--muted);
}

/* --- Candidate application form (WP Job Manager Applications) -------------
   The add-on's own template and field keys are untouched; this is presentation
   for what it renders inside the apply box. */

.jbf-job-detail .job-manager-application-form {
	margin-top: var(--wp--preset--spacing--30, 1rem);
}

.jbf-job-detail .job-manager-application-form fieldset {
	margin: 0 0 1.1rem;
	padding: 0;
	border: 0;
}

.jbf-job-detail .job-manager-application-form label {
	display: block;
	margin: 0 0 0.35rem;
	font-weight: 700;
	line-height: 1.3;
}

.jbf-job-detail .job-manager-application-form label small {
	font-weight: 400;
	color: var(--wp--preset--color--muted);
}

.jbf-job-detail .job-manager-application-form input[type="text"],
.jbf-job-detail .job-manager-application-form input[type="email"],
.jbf-job-detail .job-manager-application-form textarea,
.jbf-job-detail .job-manager-application-form select {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	min-height: 44px;
	padding: 0.6rem 0.75rem;
	font: inherit;
	color: var(--wp--preset--color--contrast);
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 8px;
}

.jbf-job-detail .job-manager-application-form textarea {
	min-height: 7rem;
}

.jbf-job-detail .job-manager-application-form .description {
	display: block;
	margin: 0.35rem 0 0;
	font-size: 0.85rem;
	color: var(--wp--preset--color--muted);
}

/* The required marker: the add-on prints "(optional)" on optional fields, so
   a required one is the one without it. Make the required ones visibly so. */
.jbf-job-detail .job-manager-application-form .required-field input,
.jbf-job-detail .job-manager-application-form .required-field textarea {
	border-left: 3px solid var(--wp--preset--color--accent);
}

.jbf-job-detail .job-manager-application-form input[type="file"] {
	width: 100%;
	max-width: 100%;
	padding: 0.5rem 0;
}

.jbf-job-detail .job-manager-application-form .job-manager-uploaded-file {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0.4rem 0.5rem 0 0;
	padding: 0.35rem 0.7rem;
	font-size: 0.85rem;
	background: var(--wp--preset--color--base);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 999px;
}

.jbf-job-detail .job-manager-application-form .wp_job_manager_send_application_button {
	min-height: 44px;
	padding: 0.85rem 1.6rem;
	font-weight: 700;
	color: var(--jbf-accent-text, var(--wp--preset--color--contrast));
	background: var(--wp--preset--color--accent);
	border: 2px solid var(--wp--preset--color--accent);
	border-radius: 8px;
	cursor: pointer;
}

.jbf-job-detail .job-manager-error,
.jbf-job-detail .job-manager-message,
.jbf-job-detail .job-manager-info {
	margin: 0 0 1rem;
	padding: 0.85rem 1rem;
	border-radius: 8px;
	border: 1px solid var(--wp--preset--color--border);
	background: var(--wp--preset--color--base);
}

.jbf-job-detail .job-manager-error {
	border-color: #c9302c;
	color: #7a1f1c;
	background: #fbeeed;
}

.jbf-job-detail .job-manager-message {
	border-color: #2e7d32;
	color: #1b5e20;
	background: #edf7ee;
}

@media (max-width: 781px) {
	.jbf-job-detail .job-manager-application-form .wp_job_manager_send_application_button {
		width: 100%;
	}
}
