/* OAIT Design System 2.1.0 · reference/css/inputs.css
   Text fields and the field family (unit c-inputs).

   Components
   - Text field (.oa-field): label above, optional marker, the 56px box, helper, error and lock lines;
     textarea, select (--select), one-time code (--code) and read-only (--readonly) members.
   - Phone number (.oa-phone): one fieldset, a country select defaulting to +961 and a tel input.
   - File and photo upload (.oa-file): a button-styled label around the native file input, its hint
     and error, the file name and a 4:5 photo preview.
   - Search (.oa-search): the role="search" region with its leading icon and Clear search button, and
     the Jobs search panel (--panel).
   - Field group (.oa-fieldset): fieldset, legend, hint and group error, shared with selection.css.

   Implements canonical §10.0, §10.4, §2.7, §3.5, §3.8, §6.2, §6.3, §8.4, §12.4, §13, §14.2 and
   D-CAI-01, D-CAI-09, D-CAI-10, D-CAI-11, D-CAI-20, D-SEM-03, D-SEM-10, D-COL-05, D-COL-11, D-ARC-02,
   D-ARC-04, D-ARC-05, D-ARC-21, D-ARC-25, D-BCP-30, D-BCP-34; CLIENT CALL D-CAI-09 = D-SEM-03 (label
   above, 12px radius) is the default applied here.

   Tokens read: --color-on-surface, --color-on-surface-variant, --color-outline, --color-outline-variant,
   --color-surface-container-lowest, --color-surface-container-high, --color-primary-ink, --color-error,
   --color-focus-ring; --size-field, --size-icon-xs, --size-icon-md, --size-icon-lg, --size-focus-ring,
   --size-focus-offset; --space-1, --space-1-5, --space-2, --space-3, --space-4, --space-12,
   --space-14, --space-28; --radius-field, --radius-card; --text-label-md, --text-body-lg,
   --text-body-md, --text-code-lg (each with its --line-height, --letter-spacing and --font-weight
   companions); --font-mono, --font-weight-medium; --opacity-state-disabled-container,
   --opacity-state-disabled-content; --duration-short-3; --ease-standard.
   Context property read: --oa-state (the state layer of .oa-btn, switched off on a disabled picker).
   Component-local property: --oa-field-line (the height of one message line, registered below).

   Classes: .oa-field (+ --select, --code, --readonly; __label, __optional, __control, __input,
   __leading, __trailing, __message, __error), .oa-phone (+ __row), .oa-file (+ __picker, __input,
   __hint, __error, __name, __preview), .oa-search (+ --panel; __clear), .oa-fieldset (+ __legend, __hint, __error).

   Relies on base.css for .oa-icon, the global :focus-visible ring, [data-demo-focus], [hidden] and the
   reduced-motion switch; on button.css for .oa-btn and .oa-icon-btn (the file picker and the trailing
   icon buttons); on card.css for .oa-card (the search panel). Breakpoint: sm 40rem (640px). */


/* ---------------------------------------------------------------------------------------------
   1. The field. One anatomy for every member: a label row above (label-md, wraps, never
   truncated), the 56px box, then one message row (helper, error or lock) 4px below
   (D-CAI-09, D-ARC-21; CLIENT CALL D-CAI-09 = D-SEM-03, default label above).
   --------------------------------------------------------------------------------------------- */

/* The height of one message line, measured where the message is set (1lh), so a 16px icon centers
   on the first line in English and in Arabic, whose body-md line is taller (D-TYP-14). */
@property --oa-field-line {
  syntax: "<length>";
  inherits: true;
  initial-value: 20px;
}

.oa-field {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
}

.oa-field__label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--space-2);
  margin-block-end: var(--space-1-5);
  color: var(--color-on-surface);
  font-size: var(--text-label-md);
  line-height: var(--text-label-md--line-height);
  letter-spacing: var(--text-label-md--letter-spacing);
  font-weight: var(--text-label-md--font-weight);
}

/* "(optional)" after the label; required fields carry no marker and no asterisk (D-CAI-10). */
.oa-field__optional {
  color: var(--color-on-surface-variant);
  font-size: var(--text-body-md);
  line-height: var(--text-body-md--line-height);
  letter-spacing: var(--text-body-md--letter-spacing);
  font-weight: var(--text-body-md--font-weight);
}

/* The control box holds the input and its icons. Latin-only values (email, phone, password, codes,
   Global ID numbers) set dir="ltr" here, never on the label or the messages (D-BCP-30). */
.oa-field__control {
  position: relative;
  display: block;
  min-inline-size: 0;
}

/* The box: 56px, 12px radius, white fill (a well in dark), a 1px outline edge, 16px text so phones
   do not zoom (D-CAI-09, D-COL-11, canonical §3.8). No hover state (D-CAI-10). */
.oa-field__input {
  box-sizing: border-box;
  display: block;
  inline-size: 100%;
  min-inline-size: 0;
  min-block-size: var(--size-field); /* a minimum, so scaled text grows the box instead of clipping (canonical §4.6) */
  margin: 0;
  padding-block: 0;
  padding-inline: var(--space-4);
  border: 1px solid var(--color-outline);
  border-radius: var(--radius-field);
  background-color: var(--color-surface-container-lowest);
  color: var(--color-on-surface);
  font-family: inherit;
  font-size: var(--text-body-lg);
  line-height: var(--text-body-lg--line-height);
  letter-spacing: var(--text-body-lg--letter-spacing);
  font-weight: var(--text-body-lg--font-weight);
  text-overflow: ellipsis;
  transition:
    border-color var(--duration-short-3) var(--ease-standard),
    background-color var(--duration-short-3) var(--ease-standard),
    color var(--duration-short-3) var(--ease-standard);
}

/* Placeholders are only "For example: …", at the full strength of on-surface-variant (D-CAI-10). */
.oa-field__input::placeholder {
  color: var(--color-on-surface-variant);
}

/* Leading icon: a 20px icon 16px from the inline start, centered; the value moves to 48px
   (D-CAI-11). __leading is a span around the .oa-icon: the icon box is always left to right, so the
   wrapper places it by the control's own direction and the icon follows it in Arabic (D-BCP-30). */
.oa-field__leading {
  position: absolute;
  inset-block: 0;
  inset-inline-start: var(--space-4);
  display: flex;
  align-items: center;
  color: var(--color-on-surface-variant);
  pointer-events: none;
}

.oa-field__leading > .oa-icon {
  font-size: var(--size-icon-md);
}

.oa-field__leading ~ .oa-field__input {
  padding-inline-start: var(--space-12);
}

/* Trailing action: a 48px standard icon button (.oa-icon-btn) 4px from the top and the inline end;
   the value keeps 56px clear of it (canonical §10.2, §10.4). */
.oa-field__control > .oa-field__trailing {
  position: absolute;
  inset-block-start: var(--space-1);
  inset-inline-end: var(--space-1);
}

.oa-field__control:has(> .oa-field__trailing:not([hidden])) > .oa-field__input {
  padding-inline-end: var(--space-14);
}

/* Read-only: a hairline edge, no fill, still focusable and selectable, with a lock line that says
   where the value comes from ("From the Registrar") (D-CAI-10). Written before focus so focus wins. */
.oa-field--readonly .oa-field__input,
.oa-field__input[readonly] {
  border-color: var(--color-outline-variant);
  background-color: transparent;
}

/* Focus: the base ring (3px, 2px outside, following the 12px radius) plus a primary-ink edge
   (D-CAI-10, D-SEM-11). [data-demo-focus] shows it on documentation pages. */
.oa-field__input:is(:focus, [data-demo-focus]) {
  border-color: var(--color-primary-ink);
}

/* Error: an error edge (written after focus, so a focused invalid field keeps it), 2px while focused
   with no shift: the border plus a 1px inset line, as the selected choice card draws its edge
   (canonical §6.2, §10.7). The label stays on-surface; the message carries the error. */
.oa-field__input[aria-invalid="true"] {
  border-color: var(--color-error);
}

.oa-field__input[aria-invalid="true"]:is(:focus, [data-demo-focus]) {
  box-shadow: inset 0 0 0 1px var(--color-error);
}

/* Disabled: the edge at 12% of on-surface, no fill, content at 38%; never used to signal invalid
   input (D-CAI-06, D-ARC-33, canonical §2.7). */
.oa-field__input:disabled {
  border-color: color-mix(in srgb, var(--color-on-surface) calc(var(--opacity-state-disabled-container) * 100%), transparent);
  background-color: transparent;
  color: color-mix(in srgb, var(--color-on-surface) calc(var(--opacity-state-disabled-content) * 100%), transparent);
  cursor: default;
}

.oa-field__input:disabled::placeholder {
  color: color-mix(in srgb, var(--color-on-surface) calc(var(--opacity-state-disabled-content) * 100%), transparent);
}

.oa-field:has(.oa-field__input:disabled) :is(.oa-field__label, .oa-field__optional, .oa-field__message, .oa-field__leading, .oa-field__trailing) {
  color: color-mix(in srgb, var(--color-on-surface) calc(var(--opacity-state-disabled-content) * 100%), transparent);
}

/* Messages: helper, error or lock, 4px under the box, body-md; an icon is 16px and centers on the
   first line. Errors replace the helper: a filled error icon and words at font-medium (D-CAI-10,
   D-ARC-21). Messages are tied with aria-describedby and are never live regions. */
.oa-field__message,
.oa-field__error,
.oa-file__hint,
.oa-file__error {
  --oa-field-line: 1lh;
  display: flex;
  align-items: flex-start;
  gap: var(--space-1-5);
  margin-block: var(--space-1) 0;
  margin-inline: 0;
  font-size: var(--text-body-md);
  line-height: var(--text-body-md--line-height);
  letter-spacing: var(--text-body-md--letter-spacing);
  font-weight: var(--text-body-md--font-weight);
  overflow-wrap: anywhere;
}

.oa-field__message,
.oa-file__hint {
  color: var(--color-on-surface-variant);
}

.oa-field__error,
.oa-file__error {
  color: var(--color-error);
  font-weight: var(--font-weight-medium);
}

.oa-field__message > .oa-icon,
.oa-field__error > .oa-icon,
.oa-file__hint > .oa-icon,
.oa-file__error > .oa-icon {
  font-size: var(--size-icon-xs);
  margin-block-start: max(0px, calc((var(--oa-field-line) - var(--size-icon-xs)) / 2));
}

/* The lock line of a read-only field is a message at font-medium (D-CAI-10). */
.oa-field--readonly .oa-field__message:has(> .oa-icon) {
  font-weight: var(--font-weight-medium);
}


/* ---------------------------------------------------------------------------------------------
   2. Field family members (D-CAI-11).
   --------------------------------------------------------------------------------------------- */

/* Textarea: from 112px, 12px × 16px padding, resized vertically only (canonical §10.4). */
textarea.oa-field__input {
  block-size: auto;
  min-block-size: var(--space-28);
  padding-block: var(--space-3);
  resize: vertical;
  text-overflow: clip;
}

/* Select: the native select drawn as a field, its own arrow removed and a 24px arrow_drop_down
   12px from the inline end, in a span like the leading icon; a select whose control box is
   dir="ltr" keeps the arrow on the physical right in Arabic (D-CAI-11, D-BCP-34). The value keeps
   48px clear of it. Phones open their own picker. */
.oa-field.oa-field--select .oa-field__control > .oa-field__input {
  appearance: none;
  padding-inline-end: var(--space-12);
  cursor: pointer;
}

.oa-field.oa-field--select .oa-field__control > .oa-field__trailing {
  inset-block: 0;
  inset-inline-end: var(--space-3);
  display: flex;
  align-items: center;
  color: var(--color-on-surface-variant);
  pointer-events: none;
}

.oa-field--select .oa-field__trailing > .oa-icon {
  font-size: var(--size-icon-lg);
}

.oa-field.oa-field--select .oa-field__control > .oa-field__input:disabled {
  cursor: default;
}

/* One-time code: one field, never split boxes; the value in mono code-lg, tracked +0.12em
   (canonical §3.5, §10.4, D-TYP-13). The control box is dir="ltr". */
.oa-field--code .oa-field__input {
  font-family: var(--font-mono);
  font-size: var(--text-code-lg);
  line-height: var(--text-code-lg--line-height);
  letter-spacing: var(--text-code-lg--letter-spacing);
  font-weight: var(--text-code-lg--font-weight);
}

/* Search: drawn as a plain field; WebKit's own clear button is hidden, as the field shows its
   "Clear search" button instead (D-CAI-11). */
.oa-field__input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}

.oa-field__input[type="search"]::-webkit-search-cancel-button,
.oa-field__input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}


/* ---------------------------------------------------------------------------------------------
   3. Field groups. A fieldset with a legend in the field-label style; a group's hint or error sits
   right under the legend (D-CAI-12). The phone fieldset puts its hint under the controls, as a
   field does (D-CAI-11).
   --------------------------------------------------------------------------------------------- */

.oa-fieldset {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.oa-fieldset__legend {
  margin-block-end: var(--space-1-5);
  padding: 0;
  color: var(--color-on-surface);
  font-size: var(--text-label-md);
  line-height: var(--text-label-md--line-height);
  letter-spacing: var(--text-label-md--letter-spacing);
  font-weight: var(--text-label-md--font-weight);
}

.oa-fieldset__hint,
.oa-fieldset__error {
  --oa-field-line: 1lh;
  display: flex;
  align-items: flex-start;
  gap: var(--space-1-5);
  margin-block: 0 var(--space-1);
  margin-inline: 0;
  font-size: var(--text-body-md);
  line-height: var(--text-body-md--line-height);
  letter-spacing: var(--text-body-md--letter-spacing);
  font-weight: var(--text-body-md--font-weight);
  overflow-wrap: anywhere;
}

.oa-fieldset__hint {
  color: var(--color-on-surface-variant);
}

.oa-fieldset__error {
  color: var(--color-error);
  font-weight: var(--font-weight-medium);
}

.oa-fieldset__error > .oa-icon {
  font-size: var(--size-icon-xs);
  margin-block-start: max(0px, calc((var(--oa-field-line) - var(--size-icon-xs)) / 2));
}

.oa-fieldset:disabled :is(.oa-fieldset__legend, .oa-fieldset__hint) {
  color: color-mix(in srgb, var(--color-on-surface) calc(var(--opacity-state-disabled-content) * 100%), transparent);
}


/* ---------------------------------------------------------------------------------------------
   4. Phone number. The legend "Phone number" names the group and the tel input; the select is
   named "Country code" and defaults to +961 Lebanon. Both control boxes are dir="ltr"; the pair
   follows the page direction, country at the inline start, in Global ID's 0.95fr / 1.35fr grid with
   a 12px gap. The country column never gets narrower than two field heights and a 16px gap (128px),
   so the closed select may cut the country name at 390px but always shows the whole calling code,
   "+961" apart from "+962", down to a 320px window (D-CAI-11, canonical §14.3).
   --------------------------------------------------------------------------------------------- */

.oa-phone__row {
  display: grid;
  grid-template-columns: minmax(calc(2 * var(--size-field) + var(--space-4)), 0.95fr) minmax(0, 1.35fr);
  column-gap: var(--space-3);
}

.oa-phone__row + :is(.oa-fieldset__hint, .oa-fieldset__error) {
  margin-block: var(--space-1) 0;
}


/* ---------------------------------------------------------------------------------------------
   5. File and photo upload. The picker is a <label> drawn as a button (.oa-btn: outlined md, or
   filled lg when choosing the file is the view's main action) around the native file input, which
   covers the whole label, transparent, so the label's own box is the target. The label draws the
   ring while the input has keyboard focus. After choosing: the file name, or a 4:5 photo preview
   (D-CAI-11). No drag-and-drop zone in 1.0.
   --------------------------------------------------------------------------------------------- */

.oa-file {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-inline-size: 0;
}

/* The picker keeps its own width; the rows (name, hint, actions) take the full width. */
.oa-file > .oa-file__picker {
  align-self: flex-start;
}

/* 12px between the parts; the hint or error sits 4px under the picker, like a field's message. */
.oa-file > * + * {
  margin-block-start: var(--space-3);
}

.oa-file > * + :is(.oa-file__hint, .oa-file__error) {
  margin-block-start: var(--space-1);
}

.oa-file__picker {
  cursor: pointer;
}

.oa-file__input {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

.oa-file__picker:has(.oa-file__input:focus-visible) {
  outline: var(--size-focus-ring) solid var(--color-focus-ring);
  outline-offset: var(--size-focus-offset);
}

/* Disabled, as button.css draws a disabled button (a label cannot be :disabled itself): the label at
   38%, a filled or tonal fill at 12%, an outlined edge at 12%, no state layer (D-ARC-33). */
.oa-file__picker:has(.oa-file__input:disabled) {
  --oa-state: 0;
  color: color-mix(in srgb, var(--color-on-surface) calc(var(--opacity-state-disabled-content) * 100%), transparent);
  cursor: default;
}

.oa-file__picker:is(.oa-btn--filled, .oa-btn--tonal):has(.oa-file__input:disabled) {
  background-color: color-mix(in srgb, var(--color-on-surface) calc(var(--opacity-state-disabled-container) * 100%), transparent);
}

.oa-file__picker.oa-btn--outlined:has(.oa-file__input:disabled) {
  border-color: color-mix(in srgb, var(--color-on-surface) calc(var(--opacity-state-disabled-container) * 100%), transparent);
}

.oa-file__picker:has(.oa-file__input:disabled) .oa-file__input {
  cursor: default;
}

@media (forced-colors: active) {
  .oa-file__picker:has(.oa-file__input:disabled) {
    border-color: GrayText;
    color: GrayText;
  }
}

/* The chosen file's name: body-md at font-medium; long names wrap anywhere (canonical §3.8). */
.oa-file__name {
  color: var(--color-on-surface);
  font-size: var(--text-body-md);
  line-height: var(--text-body-md--line-height);
  letter-spacing: var(--text-body-md--letter-spacing);
  font-weight: var(--font-weight-medium);
  overflow-wrap: anywhere;
}

/* The photo preview: portrait 4:5, up to 240px, on the card radius; the fill shows while the image
   decodes (D-BCP-36, D-CAI-11). */
.oa-file__preview {
  display: block;
  inline-size: 100%;
  max-inline-size: 240px; /* component constant: the photo preview (D-CAI-11) */
  block-size: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius-card);
  background-color: var(--color-surface-container-high);
}


/* ---------------------------------------------------------------------------------------------
   6. Search. A role="search" region named for what it searches ("Search jobs"); the field has a
   leading search icon, type="search", enterkeyhint="search" and, once it holds text, a trailing
   48px "Clear search" button (.oa-search__clear with the hidden attribute while empty) that empties
   it and returns focus to the input (D-CAI-11, D-BCP-34).
   --panel is the Jobs search panel on an outlined card (.oa-card): keyword, location and a filled
   lg "Search" in one row from 640px (minmax(0, 1fr) 13rem auto, aligned to the bottom), stacked
   with a full-width button below (canonical §11 template 4, §15).
   --------------------------------------------------------------------------------------------- */

.oa-search {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-inline-size: 0;
  margin: 0;
}

.oa-search.oa-search--panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.oa-search--panel > .oa-btn {
  inline-size: 100%;
}

@media (width >= 40rem) {
  .oa-search.oa-search--panel {
    grid-template-columns: minmax(0, 1fr) 13rem auto; /* component constant: the location column (D-CAI-11) */
    align-items: end;
  }

  .oa-search--panel > .oa-btn {
    inline-size: auto;
    min-inline-size: 112px; /* component constant: the panel's Search button (D-CAI-11) */
  }
}
