@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@layer cinder.components {
  .cinder-section-heading {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-3);
  }

  .cinder-section-heading__row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--cinder-space-4);
    flex-wrap: wrap;
  }

  .cinder-section-heading__primary {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-1);
    min-width: 0;
  }

  .cinder-section-heading__hgroup {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-1);
    margin: 0;
  }

  /* Label contrast: --cinder-text-muted at --cinder-text-xs (12px) against
   cinder surface tokens passes WCAG AA (4.5:1). Placing this on non-token
   backgrounds (custom colored surfaces) is the consumer's responsibility. */
  .cinder-section-heading__label {
    margin: 0;
    font-size: var(--cinder-text-xs);
    font-weight: var(--cinder-font-semibold);
    color: var(--cinder-text-muted);
  }

  .cinder-section-heading__title {
    font-size: var(--cinder-text-lg);
    font-weight: var(--cinder-font-semibold);
    color: var(--cinder-text-default);
    margin: 0;
    line-height: var(--cinder-leading-tight);
  }

  h3.cinder-section-heading__title {
    font-size: var(--cinder-text-base);
  }

  h4.cinder-section-heading__title {
    font-size: var(--cinder-text-sm);
  }

  .cinder-section-heading__description {
    font-size: var(--cinder-text-sm);
    color: var(--cinder-text-muted);
    margin: 0;
    max-width: 60ch;
  }

  .cinder-section-heading__actions {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2);
    flex-shrink: 0;
    /* Actions are xs controls centered on the title's line box, so they never make the heading
       taller than its title. */
    font-size: var(--cinder-text-lg);
    line-height: var(--cinder-leading-tight);
    margin-block: calc((1lh - var(--_cinder-compact-control-height)) / 2);
  }

  /* Keep the button's invisible touch extension above the surface that follows the heading. */
  @media (any-pointer: coarse) {
    .cinder-section-heading__actions:has(
      > :is(
        .cinder-button[data-cinder-hit-target='44'],
        .cinder-disclosure-trigger[data-cinder-hit-target='overlay']
      )
    ) {
      position: relative;
      z-index: 1;
    }
  }

  .cinder-section-heading__tabs {
    display: block;
    min-width: 0;
  }

  .cinder-section-heading[data-cinder-variant='actions-and-tabs'] > .cinder-section-heading__tabs {
    margin-top: calc(var(--cinder-space-2) * -1);
  }
}
