/*
 * nexus-forms estate look (1.9.1), loaded after the block stylesheet. The file name carries the version because the
 * Deflect edge keeps assets for years: a new look ships under a new name. Tokens only (the kit scope `.nxn`: --nx-*),
 * so light and dark come from the kit; the institution gradient (--nxi-grad) comes from the estate theme when the page
 * has one. 5px radius on every field, box and button; 44px controls; 24px minimum targets; a 2px focus ring; logical
 * properties only, so right-to-left pages mirror.
 */
.nxn.nxf-root.nxf-form {
  --nxf-r: var(--nx-radius-md, 5px);
  --nxf-control: 2.75rem;
  --nxf-pad: var(--nx-space-6, 1.5rem);
  position: relative;
  max-inline-size: 48rem;
  margin-inline: auto;
  padding: var(--nxf-pad);
  border: 1px solid var(--nx-border-hairline);
  border-radius: var(--nxf-r);
  background: var(--nx-bg-surface);
  color: var(--nx-text-secondary);
  font-size: var(--nx-text-sm, 0.9375rem);
  overflow-wrap: anywhere;
}
.nxn.nxf-root.nxf-form::before {
  content: "";
  position: absolute;
  inset-block-start: -1px;
  inset-inline: -1px;
  block-size: 3px;
  border-start-start-radius: var(--nxf-r);
  border-start-end-radius: var(--nxf-r);
  background: var(--nxi-grad, var(--nx-accent));
}
.nxf-form .nxf-form__title {
  color: var(--nx-text-primary);
  font-size: var(--nx-text-lg, 1.25rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.nxf-form .nxf-form__page,
.nxf-form .nxf-field__group,
.nxf-form .nxf-repeater__row {
  padding: 0;
  border: 0;
  border-radius: 0;
}
.nxf-form .nxf-form__page + .nxf-form__page,
.nxf-form .nxf-form__page-title {
  padding-block-start: var(--nx-space-2, 0.5rem);
}
.nxf-form .nxf-form__page-title {
  padding-inline: 0;
  inline-size: 100%;
  border-block-end: 1px solid var(--nx-border-hairline);
  padding-block-end: var(--nx-space-2, 0.5rem);
  color: var(--nx-text-primary);
  font-size: var(--nx-text-md, 1rem);
  font-weight: 600;
}
.nxf-form .nxf-field__label {
  color: var(--nx-text-primary);
}

/* fields: one height, one radius, one border, one focus */
.nxf-form .nxf-field__input,
.nxf-form .nxf-address__part,
.nxf-form input[type="file"] {
  box-sizing: border-box;
  max-inline-size: 100%;
  min-block-size: var(--nxf-control);
  padding-inline: var(--nx-space-3, 0.75rem);
  border: 1px solid var(--nx-border-hairline-strong);
  border-radius: var(--nxf-r);
  background: var(--nx-bg-canvas);
  color: var(--nx-text-primary);
  font: 400 1rem/1.4 var(--nx-font-sans);
}
.nxf-form textarea.nxf-field__input {
  min-block-size: 8rem;
  padding-block: var(--nx-space-3, 0.75rem);
  resize: vertical;
}
.nxf-form select.nxf-field__input {
  appearance: none;
  padding-inline-end: 2.5rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 1.125rem center, right 0.8125rem center;
  background-size: 0.3125rem 0.3125rem, 0.3125rem 0.3125rem;
  background-repeat: no-repeat;
}
.nxf-form:dir(rtl) select.nxf-field__input {
  background-position: left 0.8125rem center, left 1.125rem center;
}
.nxf-form .nxf-field__input:hover,
.nxf-form input[type="file"]:hover {
  border-color: var(--nx-border-strong);
}
.nxf-form .nxf-field__input:focus,
.nxf-form .nxf-address__part:focus {
  outline: 2px solid var(--nx-focus);
  outline-offset: 1px;
  border-color: var(--nx-focus);
  box-shadow: none;
}
.nxf-form :focus-visible {
  outline: 2px solid var(--nx-focus);
  outline-offset: 2px;
}

/* file inputs: the picker button is a kit secondary button */
.nxf-form input[type="file"] {
  inline-size: 100%;
  padding: var(--nx-space-1, 0.25rem);
  border-style: dashed;
  cursor: pointer;
}
.nxf-form input[type="file"]::file-selector-button {
  min-block-size: calc(var(--nxf-control) - 0.625rem);
  margin-inline-end: var(--nx-space-3, 0.75rem);
  padding-inline: var(--nx-space-4, 1rem);
  border: 1px solid var(--nx-border-hairline-strong);
  border-radius: var(--nxf-r);
  background: var(--nx-bg-surface);
  color: var(--nx-text-primary);
  font: 500 0.875rem/1 var(--nx-font-sans);
  cursor: pointer;
}

/* checkboxes and radios: drawn from tokens, a 5px box, a 24px floor inside a 44px row */
.nxf-form .nxf-field__choice {
  align-items: center;
  min-block-size: var(--nxf-control);
}
.nxf-form .nxf-field__choice input[type="checkbox"],
.nxf-form .nxf-field__choice input[type="radio"],
.nxf-form input.nxf-field__check {
  appearance: none;
  display: inline-grid;
  place-content: center;
  flex: none;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  margin: 0;
  border: 1.5px solid var(--nx-border-strong);
  border-radius: var(--nxf-r);
  background: var(--nx-bg-canvas);
  cursor: pointer;
}
.nxf-form .nxf-field__choice input[type="radio"] {
  border-radius: 50%;
}
.nxf-form .nxf-field__choice input[type="checkbox"]::before,
.nxf-form input.nxf-field__check::before {
  content: "";
  inline-size: 0.875rem;
  block-size: 0.875rem;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  background: var(--nx-primary-ink);
  transform: scale(0);
}
.nxf-form .nxf-field__choice input[type="radio"]::before {
  content: "";
  inline-size: 0.625rem;
  block-size: 0.625rem;
  border-radius: 50%;
  background: var(--nx-primary-ink);
  transform: scale(0);
}
.nxf-form .nxf-field__choice input:checked,
.nxf-form input.nxf-field__check:checked {
  border-color: var(--nx-primary-bg);
  background: var(--nx-primary-bg);
}
.nxf-form .nxf-field__choice input:checked::before,
.nxf-form input.nxf-field__check:checked::before {
  transform: scale(1);
}
.nxf-form .nxf-field__choice label {
  cursor: pointer;
}

/* validation: invalid shows a critical edge and the message; a fixed answer turns quiet again */
.nxf-form .nxf-field__input[aria-invalid="true"],
.nxf-form input[aria-invalid="true"] {
  border-color: var(--nx-critical);
  border-inline-start-width: 3px;
}
.nxf-form .nxf-field__error:not(:empty) {
  display: flex;
  gap: var(--nx-space-2, 0.5rem);
  align-items: baseline;
  color: var(--nx-critical);
  font-size: var(--nx-text-xs, 0.8125rem);
  font-weight: 500;
}
.nxf-form .nxf-field__error:not(:empty)::before {
  content: "!";
  display: inline-grid;
  place-content: center;
  flex: none;
  inline-size: 1rem;
  block-size: 1rem;
  border-radius: 50%;
  background: var(--nx-critical);
  color: var(--nx-bg-canvas);
  font-size: 0.6875rem;
  font-weight: 700;
}
.nxf-form [data-nxf-dirty="1"] .nxf-field__input:valid:not([aria-invalid="true"]) {
  border-color: color-mix(in srgb, var(--nx-positive) 60%, var(--nx-border-hairline-strong));
}
.nxf-form .nxf-form__summary {
  border: 1px solid var(--nx-critical);
  border-inline-start-width: 3px;
  border-radius: var(--nxf-r);
  background: var(--nx-critical-soft, transparent);
  color: var(--nx-text-primary);
}

/* buttons: kit primary and secondary, 44px, 5px */
.nxf-form .nxf-form__nav {
  gap: var(--nx-space-3, 0.75rem);
  padding-block-start: var(--nx-space-2, 0.5rem);
}
.nxf-form .nf-ui-btn,
.nxf-form .nxf-form__button {
  min-block-size: var(--nxf-control);
  padding-inline: var(--nx-space-5, 1.25rem);
  border-radius: var(--nxf-r);
  font-size: 0.9375rem;
}

/* received: the reference reads as a record */
.nxf-form .nxf-form__outcome,
.nxf-form .nxf-form__result {
  padding: var(--nx-space-4, 1rem);
  border: 1px solid var(--nx-border-hairline);
  border-inline-start: 3px solid var(--nx-positive);
  border-radius: var(--nxf-r);
  background: var(--nx-bg-elevated, var(--nx-bg-surface));
}
.nxf-form .nxf-form__outcome-ref {
  font-family: var(--nx-font-mono);
  color: var(--nx-text-primary);
}

/* a page served from a cache older than the form */
.nxf-form .nxf-form__stale {
  margin: 0;
  padding: var(--nx-space-3, 0.75rem) var(--nx-space-4, 1rem);
  border: 1px solid var(--nx-border-hairline-strong);
  border-inline-start: 3px solid var(--nx-caution);
  border-radius: var(--nxf-r);
}
.nxf-form .nxf-form__stale a {
  color: var(--nx-text-primary);
  text-decoration: underline;
}

/* phones (390px): tighter card, full-width actions */
@media (max-width: 30rem) {
  .nxn.nxf-root.nxf-form {
    --nxf-pad: var(--nx-space-4, 1rem);
  }
  .nxf-form .nxf-form__nav {
    flex-direction: column-reverse;
  }
  .nxf-form .nxf-form__nav .nf-ui-btn,
  .nxf-form .nxf-form__nav .nxf-form__button {
    inline-size: 100%;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .nxf-form .nxf-field__choice input::before,
  .nxf-form input.nxf-field__check::before {
    transition: transform var(--nx-motion-fast, 120ms) ease-out;
  }
}
@media (forced-colors: active) {
  .nxf-form .nxf-field__choice input:checked::before,
  .nxf-form input.nxf-field__check:checked::before {
    background: CanvasText;
  }
}
