/* ============================================================
   SoftCare — CareGiver application form (/apply, 4 locales)
   Loaded only by apply.html, ar/apply.html, fr/apply.html,
   es/apply.html, after styles.css (and rtl.css on /ar).
   Every class is prefixed ap-. Logical properties only, so the
   same rules serve RTL.
   ============================================================ */

.ap-section [hidden] { display: none !important; }
.ap-sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Banner ---------- */
.ap-banner { padding-bottom: 40px; }
.ap-banner .breadcrumb { flex-wrap: wrap; }
[dir="rtl"] .ap-banner .breadcrumb svg { transform: scaleX(-1); }
.ap-banner .ap-lead { font-size: 1.0625rem; line-height: 1.6; max-width: 40em; margin-top: 14px; }

/* ---------- Layout ---------- */
.ap-section { padding: 48px 0 96px; }
.ap-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 290px;
  gap: clamp(40px, 6vw, 80px); align-items: start;
}
.ap-main { min-width: 0; max-width: 720px; }
.ap-aside { position: sticky; top: 96px; font-size: .9375rem; }
.ap-form :is(input, select, textarea, button, h2, fieldset),
.ap-flow, .ap-done-h { scroll-margin-top: 104px; }

/* ---------- Step indicator ---------- */
.ap-steps-nav { margin-bottom: 36px; }
.ap-steps-count { display: none; margin: 0 0 10px; font-size: .875rem; font-weight: 600; color: var(--green-deep); }
.ap-steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
}
.ap-steps-btn {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; min-height: 44px;
  padding: 14px 0 4px; margin: 0; background: none; border: 0; border-top: 3px solid var(--hair);
  font: inherit; color: var(--text-muted); text-align: start; cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.ap-steps-btn:disabled { cursor: default; }
.ap-steps-btn:not(:disabled):hover { color: var(--text); }
.ap-steps-btn.is-done { border-top-color: var(--mint); color: var(--text-secondary); }
.ap-steps-btn[aria-current="step"] { border-top-color: var(--green-solid); color: var(--text); }
.ap-steps-btn:focus-visible { outline: 2px solid var(--green-deep); outline-offset: 4px; border-radius: 4px; }
.ap-steps-num {
  flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--border); color: var(--text-muted); background: #fff;
}
.ap-steps-btn.is-done .ap-steps-num { border-color: var(--mint); background: var(--mist); color: var(--green-deep); }
.ap-steps-btn[aria-current="step"] .ap-steps-num { border-color: var(--green-solid); background: var(--green-solid); color: #fff; }
.ap-steps-label { font-size: .875rem; font-weight: 600; line-height: 1.35; padding-top: 2px; }

/* ---------- Step ---------- */
.ap-step-h { font-size: clamp(1.5rem, 3vw, 1.875rem); letter-spacing: -.02em; line-height: 1.15; margin-bottom: 8px; }
[dir="rtl"] .ap-step-h { letter-spacing: 0; }
.ap-step-h:focus { outline: none; }
.ap-step-sub { margin: 0 0 28px; max-width: 36em; color: var(--text-secondary); }

/* ---------- Fields ---------- */
.ap-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.ap-grid-rate { grid-template-columns: minmax(0, 1fr) minmax(0, 10em); }
.ap-field { margin: 0 0 22px; min-width: 0; }
.ap-label { display: block; margin-bottom: 6px; font-size: .9375rem; font-weight: 600; line-height: 1.4; color: var(--text); }
.ap-opt { font-weight: 400; color: var(--text-muted); }
.ap-hint { margin: -2px 0 8px; font-size: .875rem; line-height: 1.5; color: var(--text-muted); }
.ap-hint.is-after { margin: 7px 0 0; }
.ap-hint bdi { white-space: nowrap; }
.ap-input {
  display: block; width: 100%; min-height: 48px; padding: 11px 14px;
  font: inherit; font-size: 1rem; line-height: 1.4; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.ap-input::placeholder { color: var(--text-muted); opacity: 1; }
.ap-input:hover { border-color: var(--text-muted); }
.ap-input:focus { outline: 2px solid var(--green-deep); outline-offset: 1px; border-color: var(--green-deep); }
.ap-input[aria-invalid="true"] { border-color: var(--error); box-shadow: inset 0 0 0 1px var(--error); }
.ap-input[aria-invalid="true"]:focus { outline-color: var(--error); }
.ap-input[type="number"] { -moz-appearance: textfield; }
.ap-input[type="date"] { min-width: 0; }
/* In the Arabic form every value sits on the right edge, even Latin text (email, phone, licence numbers) */
[dir="rtl"] .ap-input { text-align: right; }
.ap-select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  padding-inline-end: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6E63' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 18px; background-position: right 14px center;
}
[dir="rtl"] .ap-select { background-position: left 14px center; }
.ap-textarea { min-height: 132px; resize: vertical; line-height: 1.55; }
.ap-count { margin: 6px 0 0; font-size: .8125rem; color: var(--text-muted); text-align: end; font-variant-numeric: tabular-nums; }
.ap-count.is-near { color: var(--warning); font-weight: 600; }

.ap-error {
  display: flex; gap: 6px; align-items: flex-start;
  margin: 7px 0 0; font-size: .875rem; font-weight: 500; line-height: 1.45; color: var(--error);
}
.ap-error::before {
  content: ""; flex: 0 0 16px; height: 16px; margin-top: 2px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='7.5' x2='12' y2='13'/%3E%3Cline x1='12' y1='16.5' x2='12.01' y2='16.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='7.5' x2='12' y2='13'/%3E%3Cline x1='12' y1='16.5' x2='12.01' y2='16.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- Chip groups (specialties, languages) ---------- */
.ap-group { border: 0; padding: 0; margin: 4px 0 26px; min-width: 0; }
.ap-group legend { padding: 0; }
.ap-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-chip { position: relative; display: inline-flex; max-width: 100%; }
.ap-chip-input { position: absolute; inset-inline-start: 0; top: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.ap-chip-text {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; max-width: 100%;
  padding: 9px 16px; border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: #fff; color: var(--text); font-size: .9375rem; font-weight: 500; line-height: 1.3;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: background var(--transition), border-color var(--transition);
}
.ap-chip-text:hover { border-color: var(--green-deep); }
.ap-chip-input:checked + .ap-chip-text { background: var(--mist); border-color: var(--green-deep); }
.ap-chip-input:checked + .ap-chip-text::before {
  content: ""; flex: 0 0 16px; height: 16px; background: var(--green-deep);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ap-chip-input:focus-visible + .ap-chip-text { outline: 2px solid var(--green-deep); outline-offset: 2px; }
.ap-group.is-invalid .ap-chip-text { border-color: #E5A3A6; }

/* ---------- Documents ---------- */
.ap-docs { margin: 10px 0 8px; padding-top: 28px; border-top: 1px solid var(--hair); }
.ap-docs-h { font-size: 1.25rem; margin-bottom: 8px; }
.ap-docs-sub { margin: 0 0 18px; max-width: 38em; }
.ap-docs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ap-doc {
  position: relative; display: flex; flex-direction: column; gap: 8px; min-width: 0;
  padding: 18px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md);
  transition: border-color var(--transition), background var(--transition);
}
.ap-doc.is-filled { background: var(--foam); border-color: var(--hair); }
.ap-doc.is-invalid { border-color: var(--error); box-shadow: inset 0 0 0 1px var(--error); }
.ap-doc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ap-doc-title { font-size: 1rem; font-weight: 700; line-height: 1.3; }
.ap-tag { flex: 0 0 auto; font-size: .75rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.ap-tag.is-req { color: var(--green-deep); }
.ap-doc-desc { margin: 0; font-size: .875rem; line-height: 1.5; color: var(--text-secondary); }
.ap-doc-note { margin: 0; }
.ap-file {
  position: absolute; inset-inline-start: 0; top: 0; width: 1px; height: 1px;
  opacity: 0; overflow: hidden; clip: rect(0 0 0 0);
}
.ap-doc-pick {
  margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 16px; text-align: center;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  background: var(--foam); color: var(--green-deep); font-size: .9375rem; font-weight: 600; line-height: 1.3;
  cursor: pointer; transition: background var(--transition), border-color var(--transition);
}
.ap-doc-pick:hover { background: var(--mist); border-color: var(--green-deep); }
.ap-file:focus-visible + .ap-doc-pick { outline: 2px solid var(--green-deep); outline-offset: 2px; }
.ap-doc-pick-icon { flex: 0 0 20px; width: 20px; height: 20px; }
.ap-doc.is-invalid .ap-doc-pick { border-color: var(--error); }
.ap-doc-filled {
  margin-top: auto; display: grid; grid-template-columns: 64px minmax(0, 1fr);
  grid-template-areas: "thumb meta" "thumb btns"; gap: 2px 14px; align-items: center;
}
.ap-doc-thumb {
  grid-area: thumb; width: 64px; height: 64px; border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--mist); border: 1px solid var(--hair);
}
.ap-doc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ap-doc-thumb.is-pdf::before {
  content: "PDF"; display: flex; align-items: flex-end; justify-content: center;
  width: 32px; height: 40px; padding-bottom: 5px; border: 1.5px solid var(--green-deep); border-radius: 4px 10px 4px 4px;
  background: #fff; color: var(--green-deep); font-size: .625rem; font-weight: 700; letter-spacing: .04em;
}
.ap-doc-meta { grid-area: meta; display: flex; flex-direction: column; align-items: flex-start; min-width: 0; padding-top: 4px; }
.ap-doc-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9375rem; font-weight: 600; color: var(--text); }
.ap-doc-size { font-size: .8125rem; color: var(--text-muted); }
.ap-doc-btns { grid-area: btns; display: flex; flex-wrap: wrap; gap: 0 18px; }
.ap-link-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0; margin: 0;
  background: none; border: 0; font: inherit; font-size: .9375rem; font-weight: 600;
  color: var(--green-deep); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
  cursor: pointer;
}
.ap-link-btn:hover { color: var(--text); }
.ap-link-btn.is-danger { color: var(--error); }
.ap-link-btn:disabled { color: var(--text-muted); cursor: default; text-decoration: none; }
.ap-link-btn:focus-visible { outline: 2px solid var(--green-deep); outline-offset: 2px; border-radius: 4px; }
.ap-doc-busy { display: flex; align-items: center; gap: 10px; margin: 0; font-size: .875rem; color: var(--text-secondary); }
.ap-doc-busy::before, .ap-sending::before {
  content: ""; flex: 0 0 16px; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--mint); border-top-color: var(--green-deep); animation: ap-spin .8s linear infinite;
}
@keyframes ap-spin { to { transform: rotate(360deg); } }

/* ---------- Review ---------- */
.ap-summary { margin: 0 0 28px; }
.ap-sum-group { padding: 16px 0 8px; border-top: 1px solid var(--border); }
.ap-sum-group:last-child { border-bottom: 1px solid var(--border); }
.ap-sum-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ap-sum-head h3 { font-size: 1.0625rem; }
.ap-sum-list { margin: 2px 0 8px; font-size: .9375rem; }
.ap-sum-row { display: grid; grid-template-columns: minmax(0, 12em) minmax(0, 1fr); gap: 0 20px; padding: 5px 0; }
.ap-sum-row dt { color: var(--text-muted); }
.ap-sum-row dd { margin: 0; color: var(--text); overflow-wrap: anywhere; white-space: pre-line; }
.ap-sum-row dd.is-empty { color: var(--text-muted); }
[dir="rtl"] .ap-sum-row dd { text-align: right; }

.ap-consents { margin: 0 0 8px; }
.ap-check { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 2px 12px; align-items: start; margin-bottom: 14px; }
.ap-check-input { width: 22px; height: 22px; margin: 3px 0 0; accent-color: var(--green-solid); cursor: pointer; }
.ap-check-input:focus-visible { outline: 2px solid var(--green-deep); outline-offset: 2px; }
.ap-check-label { padding: 1px 0 4px; font-size: .9375rem; line-height: 1.55; color: var(--text); cursor: pointer; }
.ap-check-label a { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.ap-check .ap-error { grid-column: 2; margin-top: 0; }
.ap-check.is-invalid .ap-check-input { outline: 2px solid var(--error); outline-offset: 1px; }

/* Honeypot: off-screen for people, present for bots */
.ap-hp { position: absolute; inset-inline-start: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Status, progress ---------- */
.ap-status { margin: 0; }
.ap-status.is-on { margin: 8px 0 4px; padding: 14px 16px; background: var(--foam); border: 1px solid var(--hair); border-radius: var(--radius-sm); }
.ap-status.is-error { background: #FDF3F3; border-color: #EDC0C2; }
.ap-status-text { margin: 0; font-size: .9375rem; font-weight: 500; line-height: 1.5; color: var(--text); }
.ap-status.is-error .ap-status-text { color: var(--text); }
.ap-bar { height: 8px; margin-top: 12px; overflow: hidden; border-radius: var(--radius-pill); background: #fff; border: 1px solid var(--hair); }
.ap-bar-fill { height: 100%; width: 0; background: var(--green-solid); transition: width .2s ease; }

/* ---------- Actions ---------- */
.ap-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--hair);
}
.ap-actions .btn { min-height: 48px; }
.ap-actions .btn:focus-visible { outline: 2px solid var(--green-deep); outline-offset: 3px; }
.ap-actions .btn[disabled] { opacity: .7; cursor: progress; }
.ap-actions .btn-ghost[disabled] { cursor: default; }
.ap-sending { gap: 10px; }
.ap-sending::before { border-color: rgba(255,255,255,.45); border-top-color: #fff; }

.ap-noscript {
  margin: 0 0 24px; padding: 14px 16px; border: 1px solid #EDC0C2; border-radius: var(--radius-sm);
  background: #FDF3F3; color: var(--text); font-size: .9375rem;
}

/* ---------- Success ---------- */
.ap-done { max-width: 36em; padding: 4px 0 24px; }
.ap-done-mark {
  width: 56px; height: 56px; margin-bottom: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--mist); color: var(--green-deep);
}
.ap-done-mark svg { width: 30px; height: 30px; }
.ap-done-h { font-size: clamp(1.6rem, 3.4vw, 2.25rem); letter-spacing: -.02em; margin-bottom: 14px; }
[dir="rtl"] .ap-done-h { letter-spacing: 0; }
.ap-done-h:focus { outline: none; }
.ap-done p { margin: 0 0 14px; font-size: 1.0625rem; line-height: 1.6; }
.ap-done .ap-done-note { margin-bottom: 8px; font-size: .9375rem; color: var(--text-muted); }
.ap-done-email { color: var(--text); overflow-wrap: anywhere; }
.ap-done-stores { margin: 24px 0 14px; }

/* ---------- Aside ---------- */
.ap-aside-block + .ap-aside-block { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--hair); }
.ap-aside-h { font-size: 1.0625rem; line-height: 1.3; margin-bottom: 10px; }
.ap-aside p { margin: 0; font-size: .9375rem; line-height: 1.6; color: var(--text-secondary); }
.ap-aside .ap-aside-note { margin-top: 10px; color: var(--text-muted); }
.ap-aside-list { list-style: none; margin: 0; padding: 0; }
.ap-aside-list li { position: relative; margin: 0 0 9px; padding-inline-start: 30px; line-height: 1.5; color: var(--text-secondary); }
.ap-aside-list.is-check li::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 2px; width: 19px; height: 19px; background: var(--green-deep);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m8 12.5 2.8 2.8L16 9.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m8 12.5 2.8 2.8L16 9.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ap-aside-list.is-num { counter-reset: ap-next; }
.ap-aside-list.is-num li { counter-increment: ap-next; }
.ap-aside-list.is-num li::before {
  content: counter(ap-next); position: absolute; inset-inline-start: 0; top: 1px;
  width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--mist); color: var(--green-deep); font-size: .6875rem; font-weight: 700;
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .ap-layout { grid-template-columns: minmax(0, 1fr); }
  .ap-main { max-width: none; }
  .ap-aside { position: static; padding-top: 32px; border-top: 1px solid var(--border); }
}
@media (max-width: 680px) {
  .ap-docs-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .ap-section { padding: 32px 0 64px; }
  .ap-banner { padding-bottom: 28px; }
  .ap-banner .ap-lead { font-size: 1rem; }
  .ap-grid { grid-template-columns: minmax(0, 1fr); }
  .ap-grid-rate { grid-template-columns: minmax(0, 1fr) minmax(0, 8em); }
  .ap-steps-nav { margin-bottom: 28px; }
  .ap-steps-count { display: block; }
  .ap-steps { gap: 6px; }
  .ap-steps-btn { justify-content: center; padding-top: 10px; }
  .ap-steps-label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .ap-sum-row { grid-template-columns: minmax(0, 1fr); padding: 6px 0; }
  .ap-actions { gap: 10px; }
  .ap-actions .btn { white-space: normal; text-align: center; line-height: 1.25; }
  .ap-actions .btn-primary { flex: 1 1 auto; }
  .ap-actions .btn-lg { padding: 13px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .ap-doc-busy::before, .ap-sending::before { animation-duration: 2.4s; }
  .ap-bar-fill { transition: none; }
}
