@layer components {
  /* The popup to add or edit a source (sources/new, edit): wide enough for its details in two columns, so they are
     seen at a glance (sources/_form) */
  #source-popup .lightbox__panel {
    width: min(90vw, 64rem);
  }

  /* Fields only some types of source have (data-source-types in sources/_form), shown for the type chosen; also when
     the DOI lookup changes it. "Other" is in every list: it shows all. */
  #source_fields:has([name="source[source_type]"] option[value="book"]:checked) [data-source-types]:not([data-source-types~="book"]),
  #source_fields:has([name="source[source_type]"] option[value="chapter"]:checked) [data-source-types]:not([data-source-types~="chapter"]),
  #source_fields:has([name="source[source_type]"] option[value="article"]:checked) [data-source-types]:not([data-source-types~="article"]),
  #source_fields:has([name="source[source_type]"] option[value="website"]:checked) [data-source-types]:not([data-source-types~="website"]),
  #source_fields:has([name="source[source_type]"] option[value="other"]:checked) [data-source-types]:not([data-source-types~="other"]) {
    display: none;
  }

  /* The reference list below the text on Write: at least a screen high, so it and the last headings before it can be
     scrolled up to where the outline marks them (outline controller) */
  .references {
    min-block-size: calc(100dvh - 100px);
  }

  /* Authors and editors in the source form (sources/_contributors_field) */
  .contributors {
    min-inline-size: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  /* Person: kind | last name | first name(s) | remove; organization: kind | name | remove */
  .contributor-row {
    display: grid;
    grid-template-columns: 9rem 1fr 1fr auto;
    gap: var(--space-1);
    align-items: center;
  }

  .contributor-row[data-kind="organization"] [data-contributor-kind="organization"] {
    grid-column: span 2;
  }

  .contributor-row[data-kind="person"] [data-contributor-kind="organization"],
  .contributor-row[data-kind="organization"] [data-contributor-kind="person"] {
    display: none;
  }

  /* Fields the DOI lookup filled (green) or where it replaced something else (orange, with what was in it before);
     doi-lookup controller */
  .input.is-fetched,
  .contributors.is-fetched .input {
    background-color: var(--color-positive-soft);
    border-color: var(--color-positive);
  }

  .input.is-replaced,
  .contributors.is-replaced .input {
    background-color: var(--color-warning-soft);
    border-color: var(--color-warning);
  }

  .field-change {
    display: block;
    color: var(--color-warning);

    button {
      padding: 0;
      font: inherit;
      font-weight: var(--font-weight-semibold);
      color: inherit;
      text-decoration: underline;
      background: none;
      border: 0;
      cursor: pointer;
    }
  }
}
