@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/input/input.css';
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/textarea/textarea.css';
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/duration-field/duration-field.css';
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/setting-row/setting-row.css';
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/tag-input/tag-input.css';
/* A secret's key is drawn with Text (truncate="middle"). */
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/text/text.css';
/* A secret field whose keys failed to load is ErrorState's one row. */
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/error-state/error-state.css';

@layer cinder.components {
  .cinder-schema-form {
    display: grid;
    gap: var(--cinder-space-4);
    color: var(--cinder-text-default);
  }

  .cinder-schema-form__fields,
  .cinder-schema-form__fieldset,
  .cinder-schema-form__array {
    display: grid;
    gap: var(--cinder-space-3);
  }

  /* A large form puts short fields side by side; the grid collapses to one column on its own
     when the container is narrower than two columns. Wide controls take the whole row. */
  .cinder-schema-form__fields[data-cinder-columns='two'] {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    align-items: start;
  }

  .cinder-schema-form__fields > [data-cinder-span='full'] {
    grid-column: 1 / -1;
  }

  .cinder-schema-form__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: var(--cinder-space-3);
  }

  .cinder-schema-form__toolbar > :first-child {
    flex: 1 1 14rem;
  }

  .cinder-schema-form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--cinder-space-2);
  }

  .cinder-schema-form__json-panel {
    display: grid;
    gap: var(--cinder-space-3);
  }

  .cinder-schema-form__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--cinder-space-2);
  }

  .cinder-schema-form__group-label {
    display: inline-flex;
    align-items: center;
    gap: var(--cinder-space-1);
  }

  /* The closed-group summary sits after the label and gives way to it when space runs out. */
  .cinder-schema-form__summary {
    min-inline-size: 0;
    margin-inline-start: var(--cinder-space-2);
    overflow: hidden;
    color: var(--cinder-text-muted);
    font-size: var(--cinder-text-sm);
    font-weight: var(--cinder-font-normal);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .cinder-schema-form__fieldset {
    margin: 0;
    padding: var(--cinder-space-4);
    border: 1px solid var(--cinder-border-muted);
    border-radius: var(--cinder-radius-md);
  }

  .cinder-schema-form__legend {
    display: inline-flex;
    align-items: center;
    gap: var(--cinder-space-1);
    padding-inline: var(--cinder-space-1);
    color: var(--cinder-text-default);
    font-size: var(--cinder-text-sm);
    font-weight: var(--cinder-font-medium);
  }

  .cinder-schema-form__field {
    display: grid;
    gap: var(--cinder-space-2);
  }

  /* A choice between alternatives is flat: its title and its control share a line, the control at
     the inline end, and what the chosen alternative adds sits below it with no box around it. */
  .cinder-schema-form__choice {
    display: grid;
    /* The alternative's fields are the choice's own, so they sit close under it and end with the
       row's own block-end spacing, which separates the choice from whatever follows. */
    gap: var(--cinder-space-2);
    min-inline-size: 0;
  }

  /* What the chosen alternative adds ends with the spacing a row ends with, so its fields read as
     part of their choice and not as the start of the next row. A choice that adds nothing has no
     body, so it adds no space. */
  .cinder-schema-form__choice-body {
    display: grid;
    gap: var(--cinder-space-3);
    padding-block-end: var(--cinder-space-3);
  }

  /* The body that ends a settings row is the row's own tail: the list the row sits in spaces it
     from the next row, as it spaces a row with no body, so the body adds nothing of its own. */
  .cinder-setting-row > .cinder-schema-form__choice-body,
  .cinder-schema-form[data-cinder-root-row] > .cinder-schema-form__choice-body {
    padding-block-end: 0;
  }

  /* A form that is one root choice has nothing after the body but the host's own spacing (and the
     form's gap above its submit button), so the body adds none: a host that draws this form in a
     row of its own (Interborough's checkpoints) ends the row with its list's spacing. */
  .cinder-schema-form__choice[data-cinder-root-choice] > .cinder-schema-form__choice-body {
    padding-block-end: 0;
  }

  /* A form whose root is a host's own row (`rootRowHosted`) draws only that row's body where it is
     mounted. With nothing to draw there (the root's one control is in the host's control column)
     it takes no room, so the row is as tall as a row with no body. */
  .cinder-schema-form[data-cinder-root-body='none'] {
    display: none;
  }

  /* The root's one control, in the host row's control column. It is sized by that column, as any
     control the host wraps is. */
  .cinder-schema-form__root-control {
    min-inline-size: 0;
  }

  /* A plain form puts a control under its label, at the leading edge: the same place as every
     other control in it, whatever the width. A settings row puts it in the control column instead
     (`SchemaForm` draws that one itself). */
  .cinder-schema-form__choice-header {
    display: grid;
    justify-items: start;
    gap: var(--cinder-space-2);
  }

  /* The title is a plain line, not a fieldset's legend, so it starts where its siblings' labels do. */
  .cinder-schema-form__choice-header .cinder-schema-form__legend {
    padding-inline: 0;
  }

  .cinder-schema-form__choice-control {
    min-inline-size: 0;
    max-inline-size: 100%;
  }

  /* What a list that may be `null` says while it is, or the one action that returns it there. */
  .cinder-schema-form__unset {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2);
    color: var(--cinder-text-muted);
    font-size: var(--cinder-text-sm);
  }

  /* Group-level (object/array fieldset) description and error. Leaf-field
     supporting text is owned by the composed cinder controls themselves. */
  .cinder-schema-form__description {
    margin: 0;
    color: var(--cinder-text-muted);
    font-size: var(--cinder-text-sm);
  }

  .cinder-schema-form__error {
    margin: 0;
    color: var(--cinder-status-danger-text);
    font-size: var(--cinder-text-sm);
  }

  .cinder-schema-form__array-item {
    display: grid;
    gap: var(--cinder-space-2);
    padding: var(--cinder-space-3);
    border: 1px dashed var(--cinder-border-muted);
    border-radius: var(--cinder-radius-md);
  }

  /* A hosted form sits inside a surface that already has its box, so a group is a legend line over
     its fields, indented one step, and the items of an array are told apart by a hairline. */
  .cinder-schema-form[data-cinder-hosted] .cinder-schema-form__fieldset {
    padding: 0;
    padding-inline-start: var(--cinder-space-3);
    padding-block-end: var(--cinder-space-3);
    border: 0;
    border-radius: 0;
  }

  /* The browser seats a legend on the fieldset's content edge, which the indent moved to the
     fields'. Pulling it back one step keeps it on the group's outer edge, so it reads as the line
     over an indented block and not as a label of its own. */
  .cinder-schema-form[data-cinder-hosted] .cinder-schema-form__legend {
    padding-inline: 0;
    padding-block-end: var(--cinder-space-2);
    margin-inline-start: calc(-1 * var(--cinder-space-3));
  }

  .cinder-schema-form[data-cinder-hosted] .cinder-schema-form__array-item {
    padding: 0;
    padding-block-start: var(--cinder-space-3);
    border: 0;
    border-block-start: 1px solid var(--cinder-border-muted);
    border-radius: 0;
  }

  .cinder-schema-form[data-cinder-hosted] .cinder-schema-form__array-item:first-child {
    padding-block-start: 0;
    border-block-start: 0;
  }

  /* The setting rows sit flat in the surface they are put in, which is already the frame: a hairline
     between rows and no box of their own. A row is a SettingRow, which stacks its control under the
     label when its own container is narrow. */
  .cinder-schema-form__setting-rows {
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
  }

  .cinder-schema-form__setting-rows > * {
    padding-block: var(--cinder-space-3);
  }

  .cinder-schema-form__setting-rows > * + * {
    border-block-start: 1px solid var(--cinder-border-muted);
  }

  /* The edges are the host's to space: the first row has no padding above it and the last none below. */
  .cinder-schema-form__setting-rows > :first-child {
    padding-block-start: 0;
  }

  .cinder-schema-form__setting-rows > :last-child {
    padding-block-end: 0;
  }

  .cinder-schema-form__setting-body {
    display: grid;
    gap: var(--cinder-space-3);
  }

  .cinder-schema-form__bare-fieldset {
    min-inline-size: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  /* A group or an array inside a row is flat, as in a hosted form: the row's hairline is the only
     rule, so nothing is a box inside a box. */
  .cinder-schema-form[data-cinder-variant='setting-rows'] .cinder-schema-form__fieldset {
    padding: 0;
    padding-inline-start: var(--cinder-space-3);
    /* The group ends with the spacing a choice's body does, so its children sit with their parent
       and not against the next row's title. */
    padding-block-end: var(--cinder-space-3);
    border: 0;
    border-radius: 0;
  }

  .cinder-schema-form[data-cinder-variant='setting-rows'] .cinder-schema-form__legend {
    padding-inline: 0;
    padding-block-end: var(--cinder-space-2);
    margin-inline-start: calc(-1 * var(--cinder-space-3));
  }

  .cinder-schema-form[data-cinder-variant='setting-rows'] .cinder-schema-form__array-item {
    padding: 0;
    padding-block-start: var(--cinder-space-3);
    border: 0;
    border-block-start: 1px solid var(--cinder-border-muted);
    border-radius: 0;
  }

  .cinder-schema-form[data-cinder-variant='setting-rows']
    .cinder-schema-form__array-item:first-child {
    padding-block-start: 0;
    border-block-start: 0;
  }

  .cinder-schema-form__secondary-button:focus-visible {
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow:
      0 0 0 var(--cinder-ring-offset) var(--cinder-ring-offset-color),
      0 0 0 calc(var(--cinder-ring-offset) + var(--cinder-ring-width)) var(--cinder-ring-color);
  }

  .cinder-schema-form__secondary-button {
    justify-self: start;
    border: 1px solid var(--cinder-border-muted);
    border-radius: var(--cinder-radius-md);
    font-size: var(--cinder-text-sm);
    font-weight: var(--cinder-font-medium);
    cursor: pointer;
    padding: var(--cinder-space-2) var(--cinder-space-3);
    background: var(--cinder-surface);
    color: var(--cinder-text-default);
  }

  /* The submit is a primary Button, which draws its own face, states and focus ring; the form only
   * places it at the start of its row. */
  .cinder-schema-form__submit {
    justify-self: start;
  }

  /* A secret field is a Select of saved keys. A key is an identifier, so it is monospace wherever
   * the field shows one, and only there: the trigger and the options draw it through Select's
   * `code` option, and the warning and a read-only value through Text. The field's label, help and
   * placeholder are words, set in the form's face.
   * The one column is `minmax(0, 1fr)`, never the implicit `auto`: an auto track takes the Select's
   * min-content, which is a chosen key's whole width, so a long key would widen the column past the
   * screen instead of being cut in its middle (R10-13). */
  .cinder-schema-form__secret {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--cinder-space-2);
    min-width: 0;
  }

  .cinder-schema-form__secret-key {
    font-family: var(--cinder-font-mono);
  }

  /* A key is cut in its middle (Text truncate="middle"), never wrapped. In the warning's sentence its
   * tooltip wrapper stays in the line on the sentence's baseline and shrinks to the line's width,
   * so a long key gives way. */
  .cinder-schema-form__secret-warning .cinder-tooltip-wrapper.cinder-text__tooltip {
    display: inline-flex;
    max-inline-size: 100%;
    vertical-align: baseline;
  }

  /* A read-only secret: its key and its Set or Missing dot on one line, the key giving way first. */
  .cinder-schema-form__secret-value {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2);
    min-inline-size: 0;
  }

  .cinder-schema-form__secret-value > .cinder-tooltip-wrapper {
    flex: 0 1 auto;
  }

  /* The label of a field whose keys failed to load: a field label (form-field.css) in a paragraph. */
  .cinder-schema-form__secret-label {
    margin: 0;
  }

  /* The keys failed to load: ErrorState's one row, flush with the label above it, as the field's
   * control would be. */
  .cinder-schema-form__secret-failed.cinder-error-state[data-cinder-variant='row']
    .cinder-error-state-body {
    padding: 0;
  }

  .cinder-schema-form__secret-help,
  .cinder-schema-form__secret-warning {
    margin: 0;
    font-size: var(--cinder-text-sm);
    color: var(--cinder-text-muted);
  }

  /* The help reads like every other field's help (FormField's): extra small, normal leading. The
   * missing-key warning stays small, a status rather than help. */
  .cinder-schema-form__secret-help {
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-normal);
  }

  .cinder-schema-form__secret-warning {
    color: var(--cinder-status-warning-text);
  }

  /* A read-only form is label and value pairs. A value wraps anywhere and never widens the column. */
  .cinder-schema-form__read-only {
    display: grid;
    gap: var(--cinder-space-3);
    margin: 0;
    min-width: 0;
  }

  .cinder-schema-form__read-only-entry {
    display: grid;
    gap: var(--cinder-space-1);
    min-width: 0;
  }

  .cinder-schema-form__read-only-entry > dt {
    color: var(--cinder-text-muted);
    font-size: var(--cinder-text-sm);
  }

  .cinder-schema-form__read-only-entry > dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .cinder-schema-form__read-only-entry > dd .cinder-schema-form__read-only {
    padding-inline-start: var(--cinder-space-3);
    border-inline-start: 1px solid var(--cinder-border-muted);
  }

  .cinder-schema-form__read-only-list {
    display: grid;
    gap: var(--cinder-space-2);
    margin: 0;
    padding-inline-start: var(--cinder-space-4);
  }

  .cinder-schema-form__read-only-empty {
    color: var(--cinder-text-muted);
  }

  @media (forced-colors: active) {
    .cinder-schema-form__secondary-button {
      border-color: CanvasText;
    }

    .cinder-schema-form__secondary-button:focus-visible {
      outline: var(--cinder-ring-width) solid Highlight;
      outline-offset: 3px;
      box-shadow: none;
    }
  }
}
