@use '../../theme/styles' as theme;

.wr-page-header {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  // Always claim the full row even when nested in a flex-row demo wrapper.
  flex: 1 1 100%;
  width: 100%;
  min-width: 0;
  padding: 1.5rem 0 1.25rem;
  border-bottom: 1px solid var(--wr-color-light);
  font-family: var(--wr-font-family-base);

  // Opt-in (`responsive`): query the box's own width so the title + actions row
  // stacks when the header is too narrow to sit them side by side. The host is
  // already full-width, so containment is safe here.
  &--responsive {
    container: wr-page-header / inline-size;
  }

  &__breadcrumbs {
    font-size: var(--wr-text-sm);
    color: var(--wr-color-medium);

    &:empty {
      display: none;
    }
  }

  &__main {
    display: flex;
    align-items: flex-end;
    gap: 1rem 1.5rem;
    flex-wrap: wrap;
  }

  &__heading {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1 1 auto;
    min-width: 0;
  }

  &__title {
    margin: 0;
    font-size: var(--wr-text-3xl);
    font-weight: var(--wr-font-weight-bold);
    line-height: var(--wr-leading-tight);
    letter-spacing: -0.015em;
    color: var(--wr-color-dark);
  }

  &__subtitle {
    margin: 0;
    font-size: var(--wr-text-base);
    line-height: var(--wr-leading-normal);
    color: var(--wr-color-medium);
  }

  &__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 0 0 auto;

    &:empty {
      display: none;
    }
  }

  &__extra {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 0.25rem;

    &:empty {
      display: none;
    }
  }
}

// Responsive headers stack the title above the actions when their own box is
// too narrow to sit them side by side (regardless of viewport).
@container wr-page-header (max-width: 32rem) {
  .wr-page-header--responsive .wr-page-header__main {
    flex-direction: column;
    align-items: flex-start;
  }
}
