/* =========================================================================
 * Careers · role detail and application form.
 *
 * Loaded on top of careers.css, and only when the careers page is showing a
 * single role from ZOUMA Recruit (?job=<slug>). The hero is the listing hero
 * with a modifier; everything below it is new. Markup is in
 * template-parts/careers-job.php, behaviour in assets/js/careers.js.
 * ====================================================================== */

/* =========================================================================
 * Hero.
 * ====================================================================== */

/* Role titles run longer than the two-line listing heading that 18ch was
 * measured for ("Senior Data Engineer, Platform" would break three times). */
.zouma-crhero--job .zouma-crhero__title {
  max-width: 26ch;
}

/* The bar holds the role's facts instead of five company badges. With two or
 * three items, the listing's space-between would fling them to the far edges
 * of the strip; a fixed gap keeps them reading as one line about one role.
 * Wrapping is on at every width so the 1024 breakpoint has nothing to undo. */
.zouma-crhero--job .zouma-crhero__bar ul {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 10px 28px;
}

/* =========================================================================
 * Body.
 *
 *   Section  #FFF · two columns: the role (back link, the full skill list,
 *            then the description in a reading-width column) with the
 *            application form pinned beside it at the inline end
 * ====================================================================== */

/* Sized to content, like every other band on the careers page. The theme's
 * `main > section` floors each band at a screenful and lays it out as a grid;
 * a class outranks that (0,0,2) selector, so the opt-out is stated here the
 * same way careers.css states it for its own bands.
 *
 * Deliberately no overflow on this section or the shell: the form column is
 * sticky, and any overflow value but visible on an ancestor would turn that
 * ancestor into its scrollport and pin the form to nothing. */
.zouma-crjob {
  min-height: 0;
  display: block;
  padding-block: clamp(2.5rem, calc(5 * var(--zouma-vw)), 4.5rem);
  background: #fff;
}

/* One track by default, so the closed and offline notes (no form, no aside)
 * fill the shell instead of sitting beside a 420px hole. The template adds
 * the split modifier only when the form renders.
 *
 * minmax(0, 1fr) rather than 1fr on the role track: a plain 1fr floors at
 * min-content, the description can carry a long unbroken URL, and the shell
 * would push past the viewport where .zouma-site clips it silently. */
.zouma-crjob__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: clamp(2rem, calc(4 * var(--zouma-vw)), 4rem);
  row-gap: clamp(2rem, calc(4 * var(--zouma-vw)), 3rem);
  /* start, not stretch: a stretched aside is as tall as its track and has
   * nowhere to travel, so sticky would never engage. */
  align-items: start;
}

.zouma-crjob__inner--split {
  grid-template-columns: minmax(0, 1fr) 420px;
}

.zouma-crjob__inner > * {
  min-width: 0;
}

.zouma-crjob__main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(1.25rem, calc(2 * var(--zouma-vw)), 1.75rem);
}

/* Flex children keep the same min-width: auto floor as grid items, and the
 * description can carry a long unbroken URL. */
.zouma-crjob__main > * {
  min-width: 0;
}

/* Where the form pins.
 *
 * Not the header's box: its frosted strip (.zouma-header::before) runs
 * 2.25rem past the box and blurs everything under it, so a column pinned at
 * header-h + 24 sat inside the frost and read as hidden — the same lesson as
 * --zouma-careers-pin on the listing. The admin bar pushes the whole header
 * down for anyone logged in, so it is counted in too. */
.zouma-crjob {
  --zouma-crjob-pin: calc(var(--zouma-header-h, 76px) + 2.25rem + 20px);
}

.admin-bar .zouma-crjob {
  --zouma-crjob-pin: calc(var(--zouma-header-h, 76px) + 32px + 2.25rem + 20px);
}

/* The hero's "Apply now" links to this aside, and the header floats over the
 * page, so the anchor clears it by the same distance the pin does — landing
 * the form exactly where it will then stay. */
.zouma-crjob__side {
  position: sticky;
  top: var(--zouma-crjob-pin);
  scroll-margin-top: var(--zouma-crjob-pin);
}

/* The card runs to ~900px. Pinned at 132 on a 900px-tall viewport, the
 * consent box and Submit sat below the fold and only surfaced once the
 * section's end released the column — so the column scrolls inside itself.
 * A scroll container on the sticky element is fine; only one on an ancestor
 * breaks sticky. A min-width query in a max-width file, on purpose: the
 * 1024 branch below sets the column static and must not inherit a cap.
 *
 * The negative inline margins and the padding widen the scroll box past the
 * card without moving the card: a scroll container clips its children's
 * box-shadow at its own edge, so the 40px blur needs room on three sides
 * (the top is already covered by the lede above the card). It doubles as the
 * scrollbar's breathing room, keeping it off the card's border, where
 * scrollbar-gutter: stable would have reserved that width on a tall viewport
 * with nothing to scroll. */
@media (min-width: 1025px) {
  .zouma-crjob__side {
    max-height: calc(100vh - var(--zouma-crjob-pin) - 1.5rem);
    max-height: calc(100svh - var(--zouma-crjob-pin) - 1.5rem);
    margin-inline: -16px;
    padding: 0 16px 56px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

.zouma-crjob__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--zouma-blue);
  font-family: var(--zouma-font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
  transition: color var(--zouma-transition);
}

.zouma-crjob__back:hover {
  color: var(--zouma-teal);
  text-decoration: underline;
}

.zouma-crjob__back:focus-visible {
  outline: 2px solid var(--zouma-blue);
  outline-offset: 3px;
  border-radius: 2px;
}

.zouma-crjob__back .zouma-icon {
  flex: 0 0 auto;
}

/* The arrow glyph is drawn pointing left; the rest of the link mirrors on
 * its own. Same hand-turn rtl.css gives the mega menu's arrows. */
[dir="rtl"] .zouma-crjob__back .zouma-icon {
  transform: scaleX(-1);
}


/* The description is the recruiter's own HTML, so the type is set on the
 * container and its children rather than trusting whatever classes arrive. */
.zouma-crjob__desc {
  width: 100%;
  max-width: 72ch;
  color: var(--zouma-color-text);
  font-family: var(--zouma-font-body);
  font-size: 0.875rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.zouma-crjob__desc > :first-child {
  margin-top: 0;
}

.zouma-crjob__desc > :last-child {
  margin-bottom: 0;
}

.zouma-crjob__desc p,
.zouma-crjob__desc ul,
.zouma-crjob__desc ol {
  margin: 0 0 1em;
}

.zouma-crjob__desc ul,
.zouma-crjob__desc ol {
  padding-inline-start: 1.4em;
}

.zouma-crjob__desc li {
  margin-bottom: 0.35em;
}

.zouma-crjob__desc li::marker {
  color: var(--zouma-blue);
}

.zouma-crjob__desc h2,
.zouma-crjob__desc h3,
.zouma-crjob__desc h4,
.zouma-crjob__desc h5 {
  margin: 1.6em 0 0.5em;
  color: var(--zouma-color-text);
  font-family: var(--zouma-font-heading);
  font-weight: 600;
  line-height: 1.3;
}

/* Whatever level the recruiter picked, headings inside the description sit
 * one step under the page's own h2. */
.zouma-crjob__desc h2,
.zouma-crjob__desc h3 {
  font-size: 1.125rem;
}

.zouma-crjob__desc h4,
.zouma-crjob__desc h5 {
  font-size: 1rem;
}

.zouma-crjob__desc strong {
  font-weight: 600;
}

.zouma-crjob__desc a {
  color: var(--zouma-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.zouma-crjob__desc a:hover {
  color: var(--zouma-teal);
}

/* The closed / offline line. Same voice as the listing's empty state. */
.zouma-crjob__note {
  max-width: 62ch;
  margin: 0;
  color: var(--zouma-color-muted);
  font-family: var(--zouma-font-body);
  font-size: 0.875rem;
  line-height: 1.7;
}

/* =========================================================================
 * Application.
 *
 *   Aside    heading and lede over the form card, in the 420px column beside
 *            the role on the section's white
 *   Card     the contact form card: white, hairline, soft shadow
 *   Fields   one across in the side column; two across from 760px once the
 *            column drops under the role at 1024
 * ====================================================================== */

.zouma-crapply__title {
  margin: 0 0 0.625rem;
  color: var(--zouma-color-text);
  font-family: var(--zouma-font-heading);
  font-size: clamp(1.5rem, 1rem + calc(1.4 * var(--zouma-vw)), 2.125rem);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.02em;
}

.zouma-crapply__lede {
  max-width: 62ch;
  margin: 0 0 1.5rem;
  color: var(--zouma-color-muted);
  font-family: var(--zouma-font-body);
  font-size: 0.8125rem;
  line-height: 1.7;
}

.zouma-apply {
  position: relative;
  padding: clamp(1.25rem, calc(2.2 * var(--zouma-vw)), 1.75rem);
  background: #fff;
  border: 1px solid var(--zouma-color-border);
  border-radius: 8px;
  box-shadow: 0 14px 40px rgba(6, 42, 66, 0.06);
}

.zouma-apply__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}

/* Two 190px inputs in a 420px card is a cramped pair; one across reads as
 * a form, and the description alongside is where the width went. */
.zouma-crjob__side .zouma-apply__grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.zouma-apply__field {
  min-width: 0;
  margin: 0 0 14px;
}

.zouma-apply__field--full {
  grid-column: 1 / -1;
}

.zouma-apply__field label {
  display: block;
  margin-bottom: 6px;
  color: var(--zouma-color-muted);
  font-family: var(--zouma-font-body);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: start;
}

.zouma-apply__req {
  color: #a4302c;
}

.zouma-apply__field input {
  width: 100%;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--zouma-color-border);
  border-radius: 4px;
  color: var(--zouma-color-text);
  font-family: var(--zouma-font-body);
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* The native file control draws its own button; the padding above would
 * push it off-centre inside the border, so it gets less. */
.zouma-apply__field input[type="file"] {
  padding: 7px 12px;
  font-size: 0.8125rem;
  cursor: pointer;
}

.zouma-apply__field input:focus-visible {
  outline: 2px solid var(--zouma-blue);
  outline-offset: 1px;
}

/* A checkbox beside its text. The label loses the uppercase treatment: it is
 * a sentence the reader is agreeing to, not a field caption. */
.zouma-apply__field--check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 10px;
  align-items: start;
}

.zouma-apply__field--check input {
  width: 16px;
  height: 16px;
  margin: 3px 0 0;
  padding: 0;
  accent-color: var(--zouma-blue);
  cursor: pointer;
}

.zouma-apply__field--check input:focus-visible {
  outline: 2px solid var(--zouma-blue);
  outline-offset: 2px;
}

.zouma-apply__field--check label {
  margin: 0;
  color: var(--zouma-color-text);
  font-size: 0.8125rem;
  letter-spacing: 0;
  line-height: 1.6;
  text-transform: none;
  cursor: pointer;
}

/* The error sits under the text, not under the box. */
.zouma-apply__field--check .zouma-apply__error {
  grid-column: 2;
}

.zouma-apply__hint,
.zouma-apply__error {
  display: block;
  margin-top: 6px;
  font-family: var(--zouma-font-body);
  font-size: 0.75rem;
  line-height: 1.5;
}

.zouma-apply__hint {
  color: var(--zouma-color-muted);
}

.zouma-apply__error {
  color: #a4302c;
}

.zouma-apply__error[hidden] {
  display: none;
}

.zouma-apply__field.is-invalid input {
  border-color: #c9403a;
}

.zouma-apply__field.is-invalid input:focus-visible {
  outline-color: #c9403a;
}

/* Off-screen rather than display:none — a hidden input is not submitted by
 * some browsers, and the trap only works if it posts. Positioned on the
 * physical left on purpose: it must be out of frame in either direction. */
.zouma-apply__pot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.zouma-apply__status {
  margin: 0 0 1rem;
  padding: 10px 14px;
  border-radius: 6px;
  font-family: var(--zouma-font-body);
  font-size: 0.75rem;
  line-height: 1.55;
}

.zouma-apply__status:focus {
  outline: none;
}

.zouma-apply__status.is-ok {
  background: var(--zouma-blue-pale);
  color: var(--zouma-blue);
}

.zouma-apply__status.is-bad {
  background: #fdecec;
  color: #a4302c;
}

.zouma-apply__status.is-busy {
  background: var(--zouma-blue-tint);
  color: var(--zouma-color-muted);
}

/* Fields fold away once the application is in; the status line stays as the
 * receipt, so it loses the margin that separated it from them. */
.zouma-apply[data-zouma-apply-state="sent"] .zouma-apply__status {
  margin-bottom: 0;
}

/* Submit.
 *
 * style.css repaints every bare `button` — a filled primary background, its
 * own padding, a radius and a hover — and that hover is `button:hover`,
 * (0,1,1). A plain `.zouma-apply__submit:hover` would only tie with it, so
 * every state here is written with the element in front of the class, and
 * every state repaints its own background: a state that inherits is a state
 * style.css can reach. */
button.zouma-apply__submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
  padding: 12px 16px;
  background: var(--zouma-dark);
  border: 1px solid var(--zouma-dark);
  border-radius: 4px;
  color: #fff;
  font-family: var(--zouma-font-body);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
  transition: background var(--zouma-transition), border-color var(--zouma-transition), opacity var(--zouma-transition);
}

button.zouma-apply__submit:hover {
  background: var(--zouma-teal);
  border-color: var(--zouma-teal);
  color: #fff;
}

button.zouma-apply__submit:focus-visible {
  outline: 2px solid var(--zouma-blue);
  outline-offset: 3px;
}

/* Disabled while the script has not run, while a request is in flight, and
 * for good once the application is in or the role has closed. Repainted in
 * full so the hover above cannot light it up. */
button.zouma-apply__submit[disabled] {
  background: var(--zouma-dark);
  border-color: var(--zouma-dark);
  color: #fff;
  opacity: 0.6;
  cursor: not-allowed;
}

/* Sent from the server for the reader with no script, where the button is
 * disabled and would otherwise sit there unexplained. */
.zouma-apply__noscript {
  margin: 12px 0 0;
  color: #a4302c;
  font-family: var(--zouma-font-body);
  font-size: 0.75rem;
  line-height: 1.55;
  text-align: center;
}

/* =========================================================================
 * Responsive.
 * ====================================================================== */

/* Under 1024 the form drops below the role: the description would be left
 * with too little to read in beside a 420px column. Sticky is released with
 * it, or the card would ride over its own copy on a phone. */
@media (max-width: 1024px) {
  .zouma-crjob__inner--split {
    grid-template-columns: minmax(0, 1fr);
  }

  .zouma-crjob__side {
    position: static;
  }
}

/* Full width under the role, the card has room for the pair again. Bounded
 * below at 761 so this (0,2,0) selector cannot outrank the 760 rule and hand
 * a phone two columns. */
@media (max-width: 1024px) and (min-width: 761px) {
  .zouma-crjob__side .zouma-apply__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px;
  }
}

@media (max-width: 760px) {
  .zouma-apply__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zouma-crjob__back,
  button.zouma-apply__submit {
    transition: none;
  }
}
