/**
 * Canonical public form controls.
 *
 * This layer owns the visual primitives shared by lead forms, Search,
 * Academic programs filters and the header predictive search. Component
 * styles should only define layout and intentional variants.
 */

:root {
  --jci-form-font: "DM Sans", sans-serif;
  --jci-form-text: #041c40;
  --jci-form-muted: #657082;
  --jci-form-placeholder: #7c8490;
  --jci-form-border: #d7dde6;
  --jci-form-border-hover: #aeb9c9;
  --jci-form-border-focus: #487cff;
  --jci-form-bg: #fff;
  --jci-form-bg-muted: #f6f8fb;
  --jci-form-radius: 8px;
  --jci-form-height: 46px;
  --jci-form-max-width: 760px;
  --jci-form-padding-inline: 14px;
  --jci-form-focus-ring: 0 0 0 3px rgb(72 124 255 / 0.16);
  --jci-form-transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.jci-form {
  color: var(--jci-form-text);
  font-family: var(--jci-form-font);
}

.jci-form :where(
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  input[type="number"],
  input[type="date"],
  input[type="month"],
  input[type="week"],
  input[type="time"],
  input[type="datetime-local"],
  select,
  textarea,
  .form-control
):not(.jci-form-hidden-field) {
  width: 100%;
  min-width: 0;
  min-height: var(--jci-form-height);
  margin: 0;
  padding: 10px var(--jci-form-padding-inline);
  border: 1px solid var(--jci-form-border);
  border-radius: var(--jci-form-radius);
  background-color: var(--jci-form-bg);
  color: var(--jci-form-text);
  font-family: var(--jci-form-font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.35;
  box-shadow: none;
  outline: 0;
  transition: var(--jci-form-transition);
}

.jci-form :where(
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  input[type="number"],
  input[type="date"],
  input[type="month"],
  input[type="week"],
  input[type="time"],
  input[type="datetime-local"],
  select,
  textarea,
  .form-control
):not(.jci-form-hidden-field):hover:not(:disabled):not([readonly]) {
  border-color: var(--jci-form-border-hover);
}

.jci-form :where(
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  input[type="number"],
  input[type="date"],
  input[type="month"],
  input[type="week"],
  input[type="time"],
  input[type="datetime-local"],
  select,
  textarea,
  .form-control
):not(.jci-form-hidden-field):focus {
  border-color: var(--jci-form-border-focus);
  background-color: #fff;
}

.jci-form :where(
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  input[type="number"],
  input[type="date"],
  input[type="month"],
  input[type="week"],
  input[type="time"],
  input[type="datetime-local"],
  select,
  textarea,
  .form-control
):not(.jci-form-hidden-field):focus-visible {
  border-color: var(--jci-form-border-focus);
  box-shadow: var(--jci-form-focus-ring);
  outline: 0;
}

.jci-form :where(input, textarea)::placeholder {
  color: var(--jci-form-placeholder);
  opacity: 1;
}

/* Required selects use their empty-value option as the native placeholder.
 * Match text-input placeholders while the select has no valid value, then
 * return to the canonical form text colour as soon as a real option is chosen. */
.jci-form select:required:invalid {
  color: var(--jci-form-placeholder);
}

.jci-form select option {
  color: var(--jci-form-text);
}

.jci-form select option[value=""] {
  color: var(--jci-form-placeholder);
}

.jci-form textarea {
  min-height: 118px;
  resize: vertical;
}

/* Canonical label/control pair. Components may size the field container, but
 * the label and control always participate in the same layout box. This keeps
 * translated labels from colliding with neighbouring controls. */
.jci-form-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.jci-form-field__label {
  display: block;
  min-width: 0;
  margin: 0;
  line-height: 1.25;
}

.jci-form-field > :where(input, select, textarea) {
  width: 100%;
  min-width: 0;
}

.jci-form select {
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  padding-right: 48px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.25 6 6.25 11 1.25' fill='none' stroke='%23657082' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 16px center;
  background-repeat: no-repeat;
  background-size: 12px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jci-form-select {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}

.jci-form-select > select {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding-right: 56px;
  background-image: none;
}

/*
 * Native select text rendering is not consistent across Chromium/WebKit when a
 * custom arrow is painted inside the select background. The dedicated arrow rail
 * lives above the control instead, masks the icon zone and remains pointer-transparent.
 * This guarantees a real, non-overlapping text area in every supported language.
 */
.jci-form-select::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 46px;
  border-radius: 0 calc(var(--jci-form-radius) - 1px) calc(var(--jci-form-radius) - 1px) 0;
  background-color: var(--jci-form-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.25 6 6.25 11 1.25' fill='none' stroke='%23657082' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 12px 8px;
  pointer-events: none;
}

.jci-form-select:has(> select:disabled)::after {
  background-color: var(--jci-form-bg-muted);
}

.jci-form select:disabled {
  background-color: var(--jci-form-bg-muted);
  color: #8b94a3;
}

.jci-form :where(input, select, textarea):disabled,
.jci-form :where(input, textarea)[readonly] {
  border-color: #e2e6ec;
  background-color: var(--jci-form-bg-muted);
  color: #8b94a3;
  cursor: not-allowed;
}

.jci-form :where(input, select, textarea)[aria-invalid="true"] {
  border-color: #b42318;
}

.jci-form :where(input, select, textarea)[aria-invalid="true"]:focus-visible {
  box-shadow: 0 0 0 3px rgb(180 35 24 / 0.12);
}

.jci-form :where(input[type="checkbox"], input[type="radio"]) {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1px solid #9da8b7;
  background: #fff;
  box-shadow: none;
  cursor: pointer;
  transition: var(--jci-form-transition);
}

.jci-form input[type="checkbox"] {
  border-radius: 4px;
}

.jci-form input[type="radio"] {
  border-radius: 50%;
}

.jci-form :where(input[type="checkbox"], input[type="radio"]):hover:not(:disabled) {
  border-color: var(--jci-form-border-focus);
}

.jci-form :where(input[type="checkbox"], input[type="radio"]):focus-visible {
  border-color: var(--jci-form-border-focus);
  box-shadow: var(--jci-form-focus-ring);
  outline: 0;
}

.jci-form input[type="checkbox"]:checked {
  border-color: var(--jci-form-border-focus);
  background-color: var(--jci-form-border-focus);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m4 8.2 2.4 2.4L12 5'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 14px 14px;
}

.jci-form input[type="radio"]:checked {
  border-color: var(--jci-form-border-focus);
  background: radial-gradient(circle at center, var(--jci-form-border-focus) 0 4px, #fff 4.5px);
}

.jci-form :where(input[type="checkbox"], input[type="radio"]):disabled {
  border-color: #d5dae2;
  background-color: #eef1f5;
  cursor: not-allowed;
  opacity: 0.75;
}

.jci-form :where(button[type="submit"], input[type="submit"], button.jci-form-submit) {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid #487cff;
  border-radius: var(--jci-form-radius);
  background: #487cff;
  color: #fff;
  font-family: var(--jci-form-font);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  box-shadow: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

/* Lead-form submit actions mirror the established Program-hero primary CTA:
 * same compact geometry, typography, brand state and arrow motion. */
.jci-form--lead :where(button[type="submit"], input[type="submit"], button.jci-form-submit) {
  min-height: 38px;
  padding-inline: 22px;
  border-radius: 8px;
}

.jci-form--lead button.jci-form-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: auto;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.jci-form--lead .jci-form-submit__icon {
  display: block;
  flex: 0 0 28px;
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  height: auto;
  max-height: 14px;
  margin: 0;
  object-fit: contain;
}

.jci-form--lead .jci-form-submit__label {
  min-width: 0;
}

.jci-form :where(button[type="submit"], input[type="submit"], button.jci-form-submit):hover:not(:disabled) {
  border-color: #2f68ff;
  background: #2f68ff;
}

.jci-form :where(button[type="submit"], input[type="submit"], button.jci-form-submit):focus-visible {
  border-color: #2f68ff;
  background: #2f68ff;
  box-shadow: var(--jci-form-focus-ring);
  outline: 0;
}

.jci-form :where(button[type="submit"], input[type="submit"], button.jci-form-submit):active:not(:disabled) {
  transform: translateY(1px);
}

.jci-form--lead button.jci-form-submit:active:not(:disabled) {
  transform: none;
}

.jci-form :where(button[type="submit"], input[type="submit"], button.jci-form-submit):disabled {
  border-color: #bdc8da;
  background: #bdc8da;
  color: #fff;
  cursor: not-allowed;
  opacity: 1;
}

.jci-form label {
  color: var(--jci-form-text);
  font-family: var(--jci-form-font);
}

.jci-form legend:not(.screen-reader-text) {
  width: auto;
  margin: 0 0 10px;
  color: var(--jci-form-text);
  font-family: var(--jci-form-font);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.jci-form fieldset {
  min-width: 0;
}

.jci-form .jci-form-help,
.jci-form .jci-form-status,
.jci-form small {
  color: var(--jci-form-muted);
}


/* Predictive-search visual primitive shared by the header and program finder.
 * Components own only the panel position/max-height; the result language lives
 * here so search suggestions do not drift into separate implementations. */
.jci-predictive-search[hidden] {
  display: none;
}

.jci-predictive-search__panel,
.jci-predictive-search__empty,
.jci-predictive-search__loading {
  width: 100%;
  box-sizing: border-box;
}

.jci-predictive-search__panel {
  display: grid;
  gap: 4px;
  padding: 14px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgb(18 24 38 / 0.1);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 20px 44px rgb(12 23 46 / 0.12);
  scrollbar-width: thin;
}

.jci-predictive-search__group {
  display: block;
  margin: 8px 0 4px;
  padding: 0;
  color: #6e7788;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.jci-predictive-search__group:first-child {
  margin-top: 0;
}

a.jci-predictive-search__item,
a.jci-predictive-search__all-results {
  display: grid;
  width: 100%;
  gap: 3px;
  padding: 12px 14px;
  border-radius: 14px;
  box-sizing: border-box;
  color: #132038;
  text-decoration: none;
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

a.jci-predictive-search__item:hover,
a.jci-predictive-search__item:focus-visible,
a.jci-predictive-search__item.is-active,
a.jci-predictive-search__all-results:hover,
a.jci-predictive-search__all-results:focus-visible,
a.jci-predictive-search__all-results.is-active {
  background: #eef4ff;
  color: #0f3d91;
  transform: translateY(-1px);
}

.jci-predictive-search__item-title {
  display: block;
  margin: 0;
  color: inherit;
  font-size: 14px;
  font-weight: 620;
  line-height: 1.3;
}

.jci-predictive-search__item-meta {
  display: block;
  margin: 0;
  color: #6a7589;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  text-transform: none;
}

a.jci-predictive-search__all-results {
  display: block;
  margin-top: 6px;
  padding: 10px 4px 2px;
  border-top: 1px solid rgb(18 24 38 / 0.08);
  border-radius: 0;
  color: #6a7589;
  font-size: 12px;
  font-weight: 520;
  line-height: 1.45;
}

.jci-predictive-search__empty {
  padding: 14px 16px;
  border: 1px solid rgb(18 24 38 / 0.08);
  border-radius: 18px;
  background: #fff;
  color: #556175;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 20px 44px rgb(12 23 46 / 0.12);
}

.jci-predictive-search__loading {
  height: 54px;
  border: 1px solid rgb(18 24 38 / 0.08);
  border-radius: 18px;
  background: linear-gradient(90deg, rgb(227 234 246 / 0.65) 20%, rgb(245 248 252 / 0.96) 50%, rgb(227 234 246 / 0.65) 80%) 0 0 / 220% 100%;
  box-shadow: 0 20px 44px rgb(12 23 46 / 0.12);
  animation: jciPredictiveSearchPulse 1.1s linear infinite;
}

@keyframes jciPredictiveSearchPulse {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -20% 0;
  }
}

@media (max-width: 720px) {
  :root {
    --jci-form-height: 48px;
  }

  .jci-form :where(
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="number"],
    input[type="date"],
    input[type="month"],
    input[type="week"],
    input[type="time"],
    input[type="datetime-local"],
    select,
    textarea,
    .form-control
  ):not(.jci-form-hidden-field) {
    font-size: 16px;
  }

  .jci-form :where(input[type="checkbox"], input[type="radio"]) {
    width: 20px;
    height: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .jci-form :where(input, select, textarea, button),
  a.jci-predictive-search__item,
  a.jci-predictive-search__all-results {
    transition: none !important;
  }
}
