/* Careers: open-roles list extras, job page, application form.
   Builds on styles.css tokens (--ink, --body, --muted, --sand, --red) and its .btn / .display / .wrap. */

:root {
  --field-h: 48px;
  --field-radius: 12px;
  --field-border: rgba(11, 11, 10, 0.14);
  --field-border-hover: rgba(11, 11, 10, 0.3);
  --ring: 0 0 0 3px rgba(11, 11, 10, 0.08);
  --ring-error: 0 0 0 3px rgba(225, 22, 35, 0.12);
  --divider: rgba(11, 11, 10, 0.08);
}

.job-page [hidden],
.role-panel[hidden] {
  display: none !important;
}

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

/* ------------------------------------------------ home: open roles (accordion) */

.role-item {
  scroll-margin-top: calc(var(--header-h) + 16px);
  border-radius: 20px;
  background: var(--sand);
  transition: background-color 0.15s;
}

.role-item:not(.is-open):hover {
  background: #eceae6;
}

.role-item > .role {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.role-item > .role:hover {
  background: transparent;
}

.role-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.role-summary {
  max-width: 620px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.role-item.is-open .role-summary {
  -webkit-line-clamp: unset;
}

.role-chevron svg {
  transition: transform 0.25s ease;
}

.role-item.is-open .role-chevron svg {
  transform: rotate(180deg);
}

.role-panel {
  overflow: hidden;
  transition: height 0.3s ease;
}

.role-panel-inner {
  margin: 0 28px;
  padding: 24px 0 28px;
  border-top: 1px solid var(--divider);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 48px;
  align-items: start;
}

.role-details {
  max-width: 640px;
}

.role-about {
  margin: 0;
  color: var(--body);
  font-size: 16px;
  line-height: 1.65;
}

.role-details .job-section {
  margin-top: 24px;
}

.role-details .job-section:first-child {
  margin-top: 0;
}

.role-details h3 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
}

.role-details .job-list li {
  font-size: 15.5px;
}

.role-side {
  padding: 20px;
  border-radius: 16px;
  background: #fff;
  display: grid;
  gap: 16px;
}

.role-facts {
  margin: 0;
  display: grid;
  gap: 12px;
}

.role-facts div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.role-facts dt {
  color: var(--muted);
  font-size: 13.5px;
}

.role-facts dd {
  margin: 0;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
  text-align: right;
}

.role-apply {
  width: 100%;
}

.roles-empty {
  margin: 0;
  padding: 28px;
  border-radius: 20px;
  background: var(--sand);
  color: var(--body);
  font-size: 16px;
  line-height: 1.6;
}

/* ------------------------------------------------ job page: details left, form right */

.job-page {
  padding: 48px 0 128px;
}

.job-loading {
  margin: 0;
  padding: 80px 0;
  color: var(--muted);
}

.job-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  color: var(--muted);
  font-size: 14.5px;
  text-decoration: none;
  transition: color 0.15s;
}

.job-back:hover {
  color: var(--ink);
}

.job-hero {
  padding: 40px 0 56px;
  border-bottom: 1px solid var(--divider);
}

.job-eyebrow {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.job-title {
  margin: 0;
  color: var(--ink);
  font-size: 44px;
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.job-meta {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  color: var(--body);
  font-size: 15px;
  line-height: 1.5;
}

.job-meta li {
  display: inline-flex;
  align-items: center;
}

.job-meta li + li::before {
  content: "";
  width: 3px;
  height: 3px;
  margin: 0 12px;
  border-radius: 50%;
  background: var(--muted);
}

.job-lede {
  max-width: 680px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.55;
}

.job-jump {
  display: none;
  margin-top: 32px;
}

.job-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 96px;
  align-items: start;
  padding-top: 56px;
}

.job-body {
  max-width: 680px;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.job-section + .job-section {
  margin-top: 48px;
}

.job-section h2 {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.job-section p {
  margin: 0;
  color: var(--body);
  font-size: 16.5px;
  line-height: 1.7;
}

.job-section p + p {
  margin-top: 16px;
}

.job-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.job-list li {
  position: relative;
  padding-left: 22px;
  color: var(--body);
  font-size: 16.5px;
  line-height: 1.6;
}

.job-list li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: calc(0.8em - 3px); /* centre of the first line */
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
}

.job-aside {
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.job-empty {
  display: grid;
  justify-items: start;
  padding: 72px 0 24px;
}

.job-empty .job-lede {
  margin-bottom: 32px;
}

/* ------------------------------------------------ application card */

.apply-card {
  padding: 32px;
  border-radius: 24px;
  background: var(--sand);
  display: grid;
  gap: 20px;
}

.apply-head h2,
.apply-card > h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.apply-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
}

.apply-card > p {
  margin: 0;
  color: var(--body);
  font-size: 15.5px;
  line-height: 1.6;
}

/* fields */

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
}

.field-optional {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.apply-card input:not([type="file"]),
.apply-card textarea {
  display: block;
  width: 100%;
  height: var(--field-h);
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 15.5px;
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.apply-card textarea {
  height: auto;
  min-height: 112px;
  padding: 12px 14px;
  resize: vertical;
}

.apply-card input::placeholder,
.apply-card textarea::placeholder {
  color: #a8a29d;
}

.apply-card input:hover,
.apply-card textarea:hover {
  border-color: var(--field-border-hover);
}

.apply-card input:focus,
.apply-card textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: var(--ring);
}

.field.has-error input,
.field.has-error textarea {
  border-color: var(--red);
}

.field.has-error input:focus,
.field.has-error textarea:focus {
  box-shadow: var(--ring-error);
}

.field-hint,
.field-error {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.field-hint {
  color: var(--muted);
}

.field-error {
  color: var(--red);
}

/* number input with a "years" suffix */
.input-suffix {
  position: relative;
}

.input-suffix input {
  padding-right: 60px !important;
  -moz-appearance: textfield;
}

.input-suffix input::-webkit-outer-spin-button,
.input-suffix input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-suffix span {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14.5px;
  pointer-events: none;
}

/* CV upload */
.drop,
.file-chip {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 14px 16px;
  border-radius: var(--field-radius);
  background: #fff;
}

.drop {
  border: 1.5px dashed rgba(11, 11, 10, 0.22);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.drop:hover,
.drop.is-over {
  border-color: var(--ink);
}

.drop.is-over {
  background: #fbfaf8;
}

.drop:focus-within {
  border-color: var(--ink);
  box-shadow: var(--ring);
}

.field.has-error .drop {
  border-color: var(--red);
}

.file-chip {
  border: 1px solid var(--field-border);
}

.drop-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sand);
  color: var(--ink);
  display: grid;
  place-items: center;
}

.drop-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

.drop-text strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-remove {
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.file-remove:hover {
  background: var(--sand);
  color: var(--ink);
}

/* footer of the form */
.apply-foot {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.apply-error {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--field-radius);
  background: rgba(225, 22, 35, 0.07);
  color: #b3121c;
  font-size: 14px;
  line-height: 1.45;
}

.apply-submit {
  width: 100%;
  height: 52px;
  gap: 10px;
  transition: background-color 0.15s, opacity 0.15s;
}

.apply-submit:disabled {
  cursor: default;
  opacity: 0.85;
}

.apply-submit.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.apply-privacy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.turnstile:empty {
  display: none;
}

/* success + closed */
.apply-done,
.apply-closed {
  justify-items: start;
  outline: none;
}

.done-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
}

.done-ref {
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--field-radius);
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14.5px;
}

.done-ref dt {
  color: var(--muted);
}

.done-ref dd {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ------------------------------------------------ responsive */

@media (max-width: 1100px) {
  .job-layout {
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 56px;
  }
}

@media (max-width: 960px) {
  .job-layout {
    grid-template-columns: 1fr;
    gap: 56px;
  }

  .job-body {
    max-width: none;
  }

  .job-jump {
    display: inline-flex;
  }

  .role-panel-inner {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .role-details {
    max-width: none;
  }
}

@media (max-width: 860px) {
  .job-page {
    padding: 28px 0 88px;
  }

  .job-hero {
    padding: 28px 0 40px;
  }

  .job-lede {
    font-size: 17px;
  }

  .job-layout {
    padding-top: 40px;
  }

  .role-panel-inner {
    margin: 0 18px;
    padding: 20px 0 18px;
  }

  .role-summary {
    -webkit-line-clamp: 3;
  }
}

@media (max-width: 560px) {
  .apply-card {
    padding: 22px 18px;
    border-radius: 20px;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .job-section h2 {
    font-size: 20px;
  }

  .job-section p,
  .job-list li {
    font-size: 16px;
  }

  .apply-card input:not([type="file"]),
  .apply-card textarea {
    font-size: 16px; /* stops iOS zooming into fields */
  }
}

@media (prefers-reduced-motion: reduce) {
  .apply-submit.is-loading::before {
    animation-duration: 2s;
  }
}

/* Dynamic application steps */
.apply-step { display: grid; gap: 20px; min-width: 0; }
.apply-card [hidden] { display: none !important; }
.apply-card { scroll-margin-top: 100px; }
.apply-card select { width: 100%; min-width: 0; box-sizing: border-box; border: 1px solid #d9d5cf; border-radius: 10px; padding: 12px 14px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; min-height: 46px; }
.apply-card select:focus { outline: 2px solid var(--ink); outline-offset: 2px; }
.apply-card .field { min-width: 0; }
.apply-card .field-label { overflow-wrap: anywhere; }
.apply-actions { display: flex; align-items: stretch; gap: 12px; }
.apply-actions .apply-submit { flex: 1; min-width: 0; }
.apply-actions .apply-back { flex: 0 0 auto; }
.apply-progress { display: grid; gap: 10px; font-size: 13px; color: var(--ink); }
.step-track { display: flex; gap: 6px; }
.step-track i { height: 3px; flex: 1; background: #ddd9d3; border-radius: 3px; }
.step-track i:first-child, .is-second .step-track i { background: var(--ink); }
.step-title { margin: 0; font-size: 20px; }
.step-description { margin: -8px 0 0; font-size: 14px; color: var(--muted); }

.resume-autofill { display: grid; gap: 10px; padding-bottom: 20px; border-bottom: 1px solid #ddd9d3; min-width: 0; }
.autofill-button { width: 100%; display: flex; justify-content: center; align-items: center; gap: 10px; white-space: normal; text-align: center; min-height: 48px; }
.autofill-button svg { flex-shrink: 0; }
.autofill-hint, .autofill-status { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.autofill-status { color: var(--ink); }
.autofill-button:disabled { opacity: .65; cursor: wait; }
