// ---------------------------------------------------------------------------
// Shared header of single reports (V2-D): breadcrumb, short title, facts line; filters on the right.
// PHP: views/components/objects/page-header.php, built by Service/Admin/PageHeader/PageHeader.php,
// rendered by includes/admin/templates/layout/title.php (.wps-wrap__top--single).
// ---------------------------------------------------------------------------

.wps-wrap__top.wps-wrap__top--single {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px 16px;

  // Filters and export sit beside the header (they were absolutely positioned before).
  .wps-head-filters.wps-head-filters--single {
    position: static;
    inset: auto;
    margin: 0 0 0 auto;
    flex: 0 1 auto;
    transform: none;

    .rtl & {
      margin: 0 auto 0 0;
    }

    @media (max-width: 782px) {
      margin: 0;
      width: 100%;
      justify-content: flex-start;
    }
  }

  // Real-time button and add-on hooks keep their own row on small screens.
  > .wps-realtime-btn {
    margin-inline-start: auto;
  }
}

.wps-page-header {
  flex: 1 1 320px;
  min-width: 0;
  display: grid;
  gap: 4px;
  color: $wps-text-strong;

  &__crumbs {
    ol {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 2px 0;
      margin: 0;
      padding: 0;
      list-style: none;
      font-size: 12px;
      line-height: 18px;
      color: $wps-text-subtle;
    }

    li {
      display: inline-flex;
      align-items: center;
      margin: 0;
      min-width: 0;

      & + li::before {
        content: "/";
        margin: 0 6px;
        color: $wps-icon-muted;
      }
    }

    a {
      color: $wps-brand;
      text-decoration: none;

      &:hover {
        text-decoration: underline;
      }

      &:focus {
        box-shadow: none;
      }

      &:focus-visible {
        outline: 2px solid $wps-brand;
        outline-offset: 1px;
        border-radius: 2px;
      }
    }
  }

  &__heading {
    display: flex;
    align-items: center;
    gap: 8px 10px;
    min-width: 0;
  }

  // Beats the old `.wps-wrap__top .wps_title` max-width / size rules.
  .wps-wrap__top &__title.wps_title,
  &__title.wps_title {
    margin: 0;
    padding: 0;
    min-width: 0;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 20px;
    font-weight: 500;
    line-height: 28px;
    color: $wps-text-strong;

    @media (max-width: 600px) {
      font-size: 18px;
      line-height: 26px;
      white-space: normal;
      overflow-wrap: anywhere;
    }
  }

  &__icon {
    flex: none;
    display: block;

    &--flag {
      width: 24px;
      height: 18px;
      border-radius: 2px;
      object-fit: cover;
      box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
    }

    &--logo {
      width: 22px;
      height: 22px;
      object-fit: contain;
    }

    &--avatar {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      object-fit: cover;
      background: $wps-brand-tint;
    }

    // Anonymous visitor: the incognito icon of the Logged-in Users widget in a grey circle.
    &--anonymous {
      width: 40px;
      height: 40px;
      box-sizing: border-box;
      padding: 11px 9px;
      border-radius: 50%;
      object-fit: contain;
      background: #EEEFF1;
    }
  }

  &__facts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    margin: 2px 0 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    line-height: 20px;
    color: $wps-text-muted;
  }

  &__fact {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    min-width: 0;
    max-width: 100%;

    > a,
    > span {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    > a:not(.wps-pill) {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      color: $wps-brand;
      text-decoration: none;

      &:hover {
        text-decoration: underline;
      }

      &:focus {
        box-shadow: none;
      }

      &:focus-visible {
        outline: 2px solid $wps-brand;
        outline-offset: 1px;
        border-radius: 2px;
      }
    }
  }

  &__fact-icon {
    flex: none;
    display: block;

    &--flag {
      width: 16px;
      height: 12px;
      border-radius: 2px;
      object-fit: cover;
    }

    &--logo {
      width: 14px;
      height: 14px;
      object-fit: contain;
    }
  }

  &__fact-svg {
    flex: none;
    color: $wps-text-subtle;
  }
}

// PDF export (Advanced Reporting): the crumbs and ↗ links mean nothing on paper.
.wps-pdf-export {
  .wps-page-header__crumbs,
  .wps-page-header .wps-new-tab-link {
    display: none !important;
  }
}

// RTL: a fact such as "Last seen Nov 22, 1:22 pm" or "Chrome on Windows" keeps its own word order.
.wps-page-header__fact > span,
.wps-page-header__fact > a > span {
  unicode-bidi: plaintext;
}
