@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@layer cinder.components {
  .cinder-access-gate {
    color: var(--cinder-text-default);
  }

  .cinder-access-gate__passthrough {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    max-inline-size: 100%;
    vertical-align: baseline;
  }

  .cinder-access-gate__passthrough:has(> [data-cinder-full-width]) {
    display: flex;
    inline-size: 100%;
  }

  .cinder-access-gate__passthrough:has(> .cinder-form-field > [data-cinder-full-width]) {
    display: flex;
    inline-size: 100%;
  }

  .cinder-access-gate__passthrough:where(
    :has(> [data-cinder-icon-only]):has(> :nth-child(2)):not(:has(> :not([data-cinder-icon-only])))
  ) {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--cinder-space-2);
    inline-size: auto;
  }

  .cinder-access-gate__passthrough[data-cinder-variant='section'] {
    display: contents;
    inline-size: auto;
  }

  .cinder-access-gate[data-cinder-variant='inline'] {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--cinder-space-2);
    max-inline-size: 100%;
    vertical-align: baseline;
  }

  .cinder-access-gate__inline-content {
    display: inline-flex;
    gap: var(--cinder-space-2);
    min-inline-size: 0;
  }

  .cinder-access-gate__inline-content:has(> [data-cinder-full-width]) {
    display: flex;
    inline-size: 100%;
  }

  .cinder-access-gate__inline-content:has(> .cinder-form-field > [data-cinder-full-width]) {
    display: flex;
    inline-size: 100%;
  }

  .cinder-access-gate[data-cinder-variant='inline']:has(
      .cinder-access-gate__inline-content > [data-cinder-icon-only]
    ) {
    align-items: center;
  }

  .cinder-access-gate__inline-content [data-cinder-access-gate-control] {
    color: var(--cinder-text-disabled);
    cursor: not-allowed;
  }

  .cinder-access-gate__inline-reason {
    position: relative;
    display: inline-block;
    align-self: first baseline;
    flex: 1 1 auto;
    min-inline-size: 0;
    padding-inline-start: calc(0.875rem + var(--cinder-space-1));
    color: var(--cinder-text-muted);
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-snug);
  }

  .cinder-access-gate__inline-reason > svg {
    position: absolute;
    inset-block-start: 0.1em;
  }

  .cinder-access-gate__inline-reason
    > svg:where(
      :not([dir='rtl'], [dir='rtl'] *),
      [dir='rtl'] [dir='ltr'],
      [dir='rtl'] [dir='ltr'] *
    ) {
    left: 0;
  }

  .cinder-access-gate__inline-reason
    > svg:where(
      :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
    ) {
    right: 0;
  }

  .cinder-access-gate__inline-reason > span {
    overflow-wrap: anywhere;
  }

  /* A denied section is a neutral disc, a title, the reason, the missing scope and its actions,
   * centred. The inline layout is a compact bordered card for one region of a readable page. */
  .cinder-access-gate[data-cinder-variant='section'] {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    inline-size: 100%;
    box-sizing: border-box;
    padding-block: var(--cinder-space-5);
    padding-inline: var(--cinder-space-6);
    border: var(--cinder-border-width) solid var(--cinder-border);
    border-radius: var(--cinder-radius-lg);
    background: var(--cinder-surface-raised);
  }

  .cinder-access-gate__section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    inline-size: var(--cinder-space-10);
    block-size: var(--cinder-space-10);
    border-radius: var(--cinder-radius-full);
    background: var(--cinder-surface-inset);
    color: var(--cinder-text-muted);
  }

  .cinder-access-gate__section-icon > svg {
    inline-size: 1.125rem;
    block-size: 1.125rem;
  }

  .cinder-access-gate__section-title {
    margin: 0;
    margin-block-start: var(--cinder-space-2);
  }

  .cinder-access-gate__section-reason {
    margin: 0;
    margin-block-start: var(--cinder-space-0-5);
    max-inline-size: 23.75rem;
  }

  .cinder-access-gate__requirement {
    margin: 0;
    margin-block-start: var(--cinder-space-1-5);
  }

  .cinder-access-gate__requirement-value {
    font-family: var(--cinder-font-mono);
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-normal);
    color: var(--cinder-text-subtle);
    overflow-wrap: anywhere;
  }

  .cinder-access-gate__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--cinder-space-2);
    margin-block-start: var(--cinder-space-2-5);
  }

  /* The full-page layout has no card: it is centred both ways in the region it fills, as an empty
   * state is (`min-block-size: 100%` makes it fill a region of known height; in an auto-height
   * parent it is ignored), with a 48px disc and 8px of extra bottom padding for optical centre. */
  .cinder-access-gate[data-cinder-variant='section'][data-cinder-layout='page'] {
    justify-content: center;
    min-block-size: 100%;
    padding-block: var(--cinder-space-2) var(--cinder-space-4);
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .cinder-access-gate[data-cinder-layout='page'] .cinder-access-gate__section-icon {
    inline-size: var(--cinder-space-12);
    block-size: var(--cinder-space-12);
  }

  .cinder-access-gate[data-cinder-layout='page'] .cinder-access-gate__section-icon > svg {
    inline-size: 1.25rem;
    block-size: 1.25rem;
  }

  .cinder-access-gate[data-cinder-layout='page'] .cinder-access-gate__section-title {
    margin-block-start: var(--cinder-space-3-5);
    font-size: var(--cinder-text-lg);
  }

  .cinder-access-gate[data-cinder-layout='page'] .cinder-access-gate__actions {
    margin-block-start: var(--cinder-space-4);
  }

  @media (forced-colors: active) {
    .cinder-access-gate[data-cinder-variant='section'] {
      border-color: CanvasText;
    }

    .cinder-access-gate__section-icon {
      border: 1px solid CanvasText;
    }
  }
}
