@layer components {
  /* The account's people, found by typing: one wide field over the companies, each with its people under its name. */
  .people {
    .filter-bar {
      --filter-input-width: 100%;

      margin-block: var(--control-gap) 0;               /* 16px under the page's button */
    }

    .filter-box {
      flex: 1 1 100%;
    }

    .filter-bar__terms:is(.input) {
      --input-padding: 0 2.7em 0 0.75em;

      block-size: 2.625rem;                             /* 42px */
      font-size: 1rem;                                  /* 16px */

      @media (min-width: 100ch) {
        block-size: 2.21rem;
        font-size: var(--text-note);
      }
    }
  }

  /* A company goes with its people when a filter leaves none of them. */
  .people__group:not(:has(.person__link:not([hidden]))) {
    display: none;
  }

  .people__heading {
    font-size: var(--text-note);                        /* 16px */
    font-weight: 700;
    line-height: 1.5;
    margin: 2em 0 0.25em;

    a {
      color: inherit;
      text-decoration: none;

      &:hover {
        text-decoration: underline;
      }
    }
  }

  .people__kind {
    color: var(--color-meta);
    font-weight: 400;
  }

  .people__list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .people__note,
  .people__more {
    font-size: var(--text-note);
    margin: 1.5em 0 0;
  }

  .people__note {
    color: var(--color-meta);
    font-size: var(--text-control);
    margin-block-start: 1.7em;

    a {
      color: inherit;
    }
  }

  /* A person on a row: a 40px avatar, the name in bold over a quiet line, and a menu at the row's end. The row
     shades a little past its text on both sides, under the pointer and while its menu is open. */
  .person {
    --avatar-size: 2.5rem;                              /* 40px */

    align-items: center;
    border-radius: var(--radius-md);
    display: flex;
    font-size: var(--text-note);                        /* 16px */
    gap: 0.75em;
    margin-inline: -0.5em;
    outline: none;
    padding: 0.5em;

    /* A filter matches the name and the line under it, never the words of the menu, so it hides the link and the row goes with it. */
    &:has(> .person__link[hidden]) {
      display: none;
    }

    &:has(dialog[open]) {
      background-color: var(--tint-ink-5);
    }

    @media (min-width: 100ch) {
      --avatar-size: 2.105rem;                          /* 40px */
    }

    @media (any-hover: hover) {
      &:has(> .person__link:hover) {
        background-color: var(--tint-ink-5);
      }
    }

    .avatar {
      font-size: 0.9375em;                              /* 15px */
    }

    > .popup-anchor > .btn--circle {
      --btn-background: transparent;
      --btn-border-size: 0;
      --btn-size: var(--control-size);

      font-size: var(--text-control);
    }

    .popup {
      font-size: var(--text-control);
    }
  }

  .person__link {
    align-items: center;
    color: inherit;
    display: flex;
    flex: 1 1 auto;
    gap: 0.75em;
    min-inline-size: 0;
    text-decoration: none;

    &:focus-visible {
      border-radius: var(--radius-sm);
      outline: var(--focus-ring-size) solid var(--focus-ring-color);
      outline-offset: var(--focus-ring-offset);
    }
  }

  .person__body {
    display: grid;
    min-inline-size: 0;
  }

  .person__name {
    font-weight: 700;
    line-height: 1.375;                                 /* 22px */
    overflow-wrap: anywhere;
  }

  .person__meta {
    color: var(--color-meta);
    font-size: 0.875em;                                 /* 14px */
    line-height: 1.43;                                  /* 20px */
    overflow-wrap: anywhere;
  }

  /* Someone new: the name and the email side by side while there is room for both. */
  .invite__fields {
    display: grid;
    gap: var(--control-gap);
    grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
  }

  .invite__note {
    color: var(--color-meta);
    font-size: var(--text-control);
    margin: 1.7em 0 0;

    a {
      color: inherit;
    }
  }

  /* What a person can do beyond being on the team: a switch each, its name in bold over a line that says what it gives. */
  .powers {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .power {
    align-items: start;
    column-gap: 0.75rem;
    display: grid;
    font-size: var(--text-note);                        /* 16px */
    grid-template-columns: auto minmax(0, 1fr);

    &:is(label) {
      cursor: pointer;
    }

    .switch {
      margin-block-start: 0.125em;
    }
  }

  .power__words {
    display: grid;
  }

  .power__title {
    font-size: var(--text-row);                         /* 18px, 16px on a phone */
    font-weight: 700;
    line-height: 1.45;
  }

  .power__hint {
    color: var(--color-meta);
    font-size: var(--text-control);                     /* 14px */
    line-height: 1.5;
    text-wrap: pretty;
  }

  /* Said in words to whoever cannot change it. */
  p.power {
    grid-template-columns: minmax(0, 1fr);
    margin: 0;
  }

  /* Among a person's facts the name of what they can do reads at the size of a fact. */
  @media (min-width: 100ch) {
    .details__value .power__title {
      font-size: var(--text-section);                   /* 20px */
      line-height: 1.5;
    }
  }

  /* A person's page: what they can do, where, and what they set up, as a record's facts; then their own settings, each under its heading. */
  .profile > .details {
    margin-block: 0;
  }

  .profile .details__values {
    gap: 0.15em;
  }

  .details__aside {
    color: var(--color-meta);
  }

  /* The sites a person is on: each a pill with its name and, for whoever places people, a cross that takes them off it. */
  .site-chips {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.22em 0.11em;                                 /* 4px and 2px */
  }

  /* A pill a face high, the face inset by a hair and the name by more, with the cross in its own room at the end. */
  .site-chip {
    --avatar-size: 1.5rem;                              /* 24px */
    --site-chip-inset: 3px;
    --site-chip-start: 12px;
    --site-chip-end: 30px;

    align-items: center;
    background-color: var(--color-chip-fill);
    block-size: calc(var(--avatar-size) + var(--site-chip-inset) * 2 + 2px);
    border: 1px solid var(--tint-ink-10);
    border-radius: 99rem;
    column-gap: 0.25em;
    display: inline-flex;
    font-size: 0.9em;                                   /* 18px, 14.4px on a phone */
    line-height: var(--avatar-size);
    max-inline-size: 100%;
    padding: var(--site-chip-inset) var(--site-chip-start);
    position: relative;
    white-space: nowrap;

    @media (min-width: 640px) {
      --site-chip-inset: 0.18em;
      --site-chip-start: 0.76em;
      --site-chip-end: 1.5em;
    }

    @media (min-width: 100ch) {
      --avatar-size: 1.29rem;                           /* 24.5px */
    }

    /* A person's pill starts with their face. */
    &:has(.avatar) {
      padding-inline-start: var(--site-chip-inset);
    }

    &:has(.site-chip__remove) {
      padding-inline-end: var(--site-chip-end);
    }

    .avatar {
      font-size: var(--text-xx-small);
    }

    /* A name longer than the line ends in an ellipsis inside the pill. */
    .site-chip__name {
      min-inline-size: 0;
      overflow-x: clip;
      text-overflow: ellipsis;
    }

    a {
      color: inherit;
      text-decoration: none;

      &:hover {
        text-decoration: underline;
      }
    }
  }

  /* The cross is the pill's own ink, half strength until it is pointed at. */
  .site-chip__remove {
    --icon-size: 0.5em;

    appearance: none;
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    display: grid;
    font: inherit;
    inline-size: var(--site-chip-end);
    inset-block: 0;
    inset-inline-end: 0;
    opacity: 0.5;
    padding: 0;
    place-content: center;
    position: absolute;

    &:is(:hover, :focus-visible) {
      opacity: 1;
    }
  }

  /* A field that asks for one more: no box, a dashed line under what is typed, and what matches listed under it. */
  .input--prompt:is(.input) {
    --input-background: transparent;
    --input-border-radius: 0;
    --input-border-size: 0;
    --input-padding: 0.1em 0;

    border-block-end: 1px dashed var(--color-ink-medium);
    font-size: max(16px, var(--text-row));

    &:focus {
      border-block-end-style: solid;
      outline: none;
    }
  }

  .site-chips__add {
    display: inline-block;
    inline-size: min(100%, 11.5em);

    .suggestions__list {
      inline-size: max-content;
      max-inline-size: min(90vw, 24em);
      min-inline-size: 100%;
    }

    .row__body {
      background: none;
      border: 0;
      color: inherit;
      cursor: pointer;
      font: inherit;
      inline-size: 100%;
      padding: 0;
      text-align: start;
    }
  }

  /* What a person set up: the newest few, and the rest behind a button. */
  .made:not(.made--all *) .made__rest,
  .made--all .made__more {
    display: none;
  }

  .made__more {
    font-size: var(--text-control);
    margin-block-start: 0.4em;
  }

  /* Two lists of one place's people as folder tabs on a rule that runs to the sheet's edges, the open one joined to what is under it. */
  .folder-tabs {
    border-block-end: var(--border);
    display: flex;
    font-size: var(--text-note);                        /* 16px */
    gap: 0.25em;
    margin: 0 calc(var(--sheet-padding) * -1) 1.5em;
    padding-inline: var(--sheet-padding);
  }

  .folder-tabs__tab {
    border: 1px solid transparent;
    border-block-end: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    color: var(--color-ink);
    line-height: 1.5;
    margin-block-end: -1px;
    padding: 0.5em 1em;
    text-decoration: none;

    &[aria-current] {
      background-color: var(--color-canvas);
      border-color: var(--color-ink-lighter);
      font-weight: 700;
    }

    @media (any-hover: hover) {
      &:hover:not([aria-current]) {
        text-decoration: underline;
      }
    }
  }

  /* Who is on a site or answers for a firm: a note of how it works, the people on one side and the way to add one on the other. They stack below 800. */
  .roster__notice {
    background-color: var(--tint-ink-5);
    border-radius: var(--radius-lg);
    font-size: var(--text-note);                        /* 16px */
    line-height: 1.5;
    padding: 0.75em 1em;

    .btn {
      display: inline;
      font-size: inherit;
      white-space: normal;
    }
  }

  /* A firm at a site, with who answers for it under its name. */
  .roster__firm .person {
    margin-inline: 0;
    padding-inline: 0;

    a {
      color: inherit;
      text-decoration: none;

      &:hover {
        text-decoration: underline;
      }
    }
  }

  .roster__switch {
    display: inline;
  }

  .roster {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: minmax(0, 1fr);
    margin-block-start: 1.5rem;

    @media (min-width: 100ch) {
      column-gap: 2.5rem;                               /* 48px */
      grid-template-columns: repeat(2, minmax(0, 1fr));
      margin-block-start: 1.263rem;                     /* 24px */
    }
  }

  .roster__add {
    border-block-start: var(--border);
    padding-block-start: 1.5rem;

    @media (min-width: 100ch) {
      border-block-start: 0;
      border-inline-start: var(--border);
      padding-block-start: 0;
      padding-inline-start: 1.263rem;                   /* 24px */
    }
  }

  .roster__heading {
    font-size: var(--text-section);                     /* 20px */
    font-weight: 700;
    line-height: 1.4;
    margin: 0 0 0.25em;
  }

  /* A firm's Equipo adds people two ways, one under the other: as Responsables, and as an admin who answers for it. */
  .roster__section + .roster__section {
    border-block-start: var(--border);
    margin-block-start: 1.5rem;
    padding-block-start: 1.5rem;
  }

  .roster__prompt .input--prompt {
    inline-size: 100%;
    min-block-size: 2.2em;
  }

  .roster__prompt .suggestions__list {
    inline-size: 100%;

    .row > form {
      flex: 1;
    }

    .row__body {
      align-items: center;
      background: none;
      border: 0;
      color: inherit;
      cursor: pointer;
      display: flex;
      flex-flow: row wrap;
      font: inherit;
      gap: 0 0.5em;
      inline-size: 100%;
      padding: 0;
      text-align: start;
    }
  }

  /* While the people who could be added are on their way, nothing says yet that nobody matches. */
  .roster__prompt:has(.suggestions__skeleton) .suggestions__fallback {
    display: none;
  }

  /* An address nobody has is offered as an invitation; anything else is said not to be one. */
  .roster__prompt:has(.input:invalid) .roster__invite,
  .roster__prompt:not(:has(.input:invalid)) .roster__not-address {
    display: none;
  }

  /* What was typed matches nobody: the way to invite that address, where the matches would have been. */
  .roster__invite:is(.btn) {
    font-size: var(--text-note);
    margin-block-start: 0.25rem;
    overflow-wrap: anywhere;
    text-align: start;
    white-space: normal;
  }

  .roster__hint,
  .roster__also,
  .roster__empty {
    color: var(--color-meta);
    font-size: var(--text-control);                     /* 14px */
    line-height: 1.5;
    margin: 0.75rem 0 0;

    a {
      color: inherit;
    }
  }

  .roster__empty {
    font-size: var(--text-note);
    margin-block-start: 0;
  }

  .roster__also {
    border-block-start: var(--border);
    margin-block-start: 1rem;
    padding-block-start: 1rem;
  }

  .roster__avatars {
    --avatar-size: 1.5rem;

    display: inline-flex;
    gap: 0.15rem;
    margin-inline-end: 0.35rem;
    vertical-align: middle;

    .avatar {
      font-size: var(--text-xx-small);
    }
  }

  /* On a roster a person stands larger: a 48px avatar, the name at 20px, and under it what can be done about them. */
  .person--roster {
    --avatar-size: 2.5rem;                              /* 40px on a phone */

    font-size: 1.125rem;                                /* 18px */
    margin-inline: 0;
    padding: 0.5rem 0;

    @media (min-width: 100ch) {
      --avatar-size: 2.526rem;                          /* 48px */

      font-size: var(--text-section);                   /* 20px */
    }

    .avatar {
      font-size: 0.85em;
    }

    .person__name {
      line-height: 1.4;

      a {
        color: inherit;
        text-decoration: none;

        &:hover {
          text-decoration: underline;
        }
      }
    }

    .person__meta {
      font-size: var(--text-control);                   /* 14px */

      a {
        color: inherit;
        text-decoration-color: color-mix(in oklch, currentColor 40%, transparent);
        text-underline-offset: 0.15em;
      }
    }
  }

  .person__action:is(.btn) {
    color: inherit;
    font-size: inherit;
    text-decoration: underline;
    text-decoration-color: color-mix(in oklch, currentColor 40%, transparent);
    text-underline-offset: 0.15em;

    &:hover {
      color: var(--color-ink);
    }
  }

  .person__pill {
    background-color: var(--tint-ink-10);
    border-radius: 1em;
    font-size: 0.75rem;                                 /* 12px */
    font-weight: 700;
    line-height: 1.67;
    margin-inline-start: 0.4em;
    padding: 0.15em 0.65em;
    vertical-align: 0.2em;
    white-space: nowrap;

    @media (min-width: 100ch) {
      font-size: 0.632rem;
    }
  }
}
