/* Authorizing an app (oauth/authorizations) and the apps you've connected (my/connected_apps) */

@layer components {
  .oauth-consent {
    display: flex;
    flex-direction: column;
    gap: var(--block-space);
  }

  /* An app's name with its byline tight beneath, on consent and in Connected
     apps alike. A long name or host breaks inside itself rather than widening
     the panel */
  .oauth-client__identity,
  .connected-app__identity {
    display: flex;
    flex-direction: column;
    gap: 0.1em;
    min-inline-size: 0;
    overflow-wrap: anywhere;
  }

  /* Under the page heading, across the header's full width and closer to the
     heading than to the panel. A long email still leaves room for "Use a
     different account?": the row wraps, and the address breaks */
  .oauth-consent__identity {
    flex-wrap: wrap;
    grid-column: 1 / -1;
    margin-block-start: 0.2em;
    text-align: center;

    > span {
      min-inline-size: 0;
      overflow-wrap: anywhere;
    }
  }

  /* The unchecked-app warning, and the webhooks an app leaves running */
  .oauth-client__warning,
  .connected-app__webhooks {
    background-color: var(--color-highlight);
    border-radius: 0.5em;
    padding: var(--block-space-half) var(--inline-space);
  }

  .oauth-access {
    border: 0;
    margin: 0;
    padding: 0;
  }

  /* The note sits close under its heading, and the choices stand apart below it */
  .oauth-access__legend {
    margin-block-end: 0.2em;
    padding: 0;
  }

  /* One bordered group, as bc3's consent: the rows share a frame, and the
     chosen one is tinted and outlined so it's unmistakable */
  .oauth-access__choices {
    border: var(--border);
    border-radius: 0.5em;
    margin-block-start: var(--block-space-half);
    overflow: hidden;
  }

  .oauth-access__choice {
    align-items: start;
    cursor: pointer;
    display: flex;
    gap: var(--inline-space);
    padding: var(--block-space-half) var(--inline-space);
    position: relative;

    /* A long account name breaks inside its row rather than widening it */
    > :not(input) {
      min-inline-size: 0;
      overflow-wrap: anywhere;
    }

    & + & {
      border-block-start: var(--border);
    }

    &:has(:checked) {
      background-color: var(--color-selected-light);
      box-shadow: inset 0 0 0 1px var(--color-selected-dark);
    }

    &:first-child:has(:checked) {
      border-start-start-radius: 0.5em;
      border-start-end-radius: 0.5em;
    }

    &:last-child:has(:checked) {
      border-end-start-radius: 0.5em;
      border-end-end-radius: 0.5em;
    }

    &:has(:focus-visible) {
      outline: 2px solid var(--color-ink);
      outline-offset: -2px;
    }
  }

  /* Drawn rather than native, so it follows Fizzy's theme, not the OS's. The
     unchecked ring is the lightest ink that keeps 3:1 against the canvas in
     both themes, as a control's edge needs */
  .oauth-access__radio {
    appearance: none;
    background-color: var(--color-canvas);
    block-size: 1.15em;
    border: 2px solid var(--color-ink-medium);
    border-radius: 50%;
    flex-shrink: 0;
    inline-size: 1.15em;
    margin: 0.15em 0 0;

    &:checked {
      border: 0.35em solid var(--color-link);
    }
  }

  .oauth-consent__actions {
    flex-wrap: wrap;
  }

  .connected-apps {
    display: flex;
    flex-direction: column;
    gap: var(--block-space);
  }

  .connected-apps__group {
    display: flex;
    flex-direction: column;
  }

  .connected-apps__empty {
    padding: var(--block-space) var(--inline-space-double);
  }

  .connected-app {
    align-items: start;
    border-block-end: var(--border);
    display: flex;
    gap: var(--inline-space);
    justify-content: space-between;
    padding-block: var(--block-space-half);

    &:last-child {
      border-block-end: 0;
    }

    /* Narrow screens: the disconnect button drops under the details */
    @media (max-width: 480px) {
      flex-direction: column;
    }
  }

  .connected-app__disconnect {
    flex-shrink: 0;
  }

  /* Three blocks: the name and its byline, the access the app holds, and when
     it connected. The access lines sit together, with a paragraph's space
     between them and the grey lines either side */
  .connected-app__details {
    gap: var(--block-space-half);
    min-inline-size: 0;
    overflow-wrap: anywhere;
  }

  .connected-app__reach {
    display: flex;
    flex-direction: column;
    gap: 0.15em;
  }
}
