/* The page's header is a navy card (the brand's navy, WI-12455) in the page's column, on the canvas: the title in white,
   extra bold and tight, as large on a phone as on a desktop (the mockup's 26px, at the nearest size token). Its page's
   nav icon is drawn large behind the title (`__icon`), tilted, near the right and cut off by the card's top edge, so
   the card clips (`overflow`) and what is written on it is lifted above the icon. A header's desktop-only actions
   (`--desktop`) are hidden on a phone, which reaches them another way. What is on the card takes its colours from
   here: the facts, the count, the accent action, the quiet buttons and the focus rings (below). */
.wi-page-header {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding: var(--space-8);
  overflow: clip; /* not hidden: that can still be scrolled by focus or a click, moving the card's content */
  border-radius: var(--radius-2xl);
  background-color: var(--brand-primary);
  box-shadow: var(--shadow-md);
  color: var(--text-on-brand);
  font-family: var(--font-family-sans);
  text-align: start;
}

.wi-page-header > :not(.wi-page-header__icon) {
  position: relative;
}

/* The tabs follow the card on the canvas, so the card is closer to them than to a page's content. */
.wi-page-header--with-tabs {
  margin-bottom: var(--space-5);
}

.wi-page-header__icon {
  position: absolute;
  top: calc(-1 * var(--space-10));
  right: 10%;
  width: 13.75rem;
  height: 13.75rem;
  color: var(--turquoise-400);
  opacity: 0.22; /* on the svg, so strokes that cross don't darken */
  stroke-width: 1; /* half of Tabler's 2, which grows with the icon: a thin line on a desktop and a phone alike (WI-12468) */
  transform: rotate(-12deg);
  pointer-events: none;
}

.wi-page-header__title-row {
  align-items: center;
  gap: var(--space-2);
  flex: auto;
  min-width: 0;
  display: flex;
}

.wi-page-header__title {
  font-size: var(--font-size-2xl);
  line-height: var(--font-line-height-2xl);
  font-weight: var(--font-weight-extrabold);
  letter-spacing: var(--font-letter-spacing-tighter);
  color: var(--text-on-brand);
  margin: 0;
}

/* The count is the accent on navy, with navy text. */
.wi-page-header__badge {
  --wi-badge-min-size: var(--size-icon-md);
  --wi-badge-padding-y: var(--space-0);
  --wi-badge-padding-x: var(--space-2);
  --wi-badge-font-size: var(--font-size-xs);
  --wi-badge-line-height: var(--font-line-height-xs);
  flex: none;
  align-items: center;
  display: flex;
}

.wi-page-header__badge .wi-badge--count {
  background-color: var(--turquoise-400);
  color: var(--brand-primary);
}

.wi-page-header__banner {
  flex: 0 0 100%;
  order: -1;
}

.wi-page-header__actions {
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  flex: 0 auto;
  margin-inline-start: auto;
  display: flex;
}

@media (max-width: 767.98px) {
  /* On a phone the card is as wide as the column, rounder corners kept smaller; its rows hold no padding of their own:
     the card's is the gutter, and the gap spaces the rows. */
  .wi-page-header {
    flex-flow: column;
    align-items: stretch;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-5) var(--space-4) var(--space-4);
    border-radius: var(--radius-xl);
  }

  .wi-page-header--with-tabs {
    margin-bottom: var(--space-3);
  }

  .wi-page-header__icon {
    top: calc(-1 * var(--space-4));
    right: var(--space-2);
    width: 7.5rem;
    height: 7.5rem;
  }

  .wi-page-header__title-row {
    box-sizing: border-box;
    min-height: var(--size-avatar-md);
    flex: none;
  }

  .wi-page-header__badge {
    --wi-badge-min-size: var(--size-icon-sm);
  }

  .wi-page-header__banner,
  .wi-page-header__actions {
    flex: none;
    order: 0;
    margin: 0;
  }

  /* Its actions keep their words, side by side on one row, each as wide as the others (WI-12430: Preview and New
     chapter the same size); one action alone takes the row. */
  .wi-page-header__actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  /* A long label wraps onto a second line rather than being cut ("Preview as an advisor"); a lesson's header keeps its
     own small Preview (application.css). */
  .wi-page-header:not(.academy__lesson-header) > .wi-page-header__actions .wi-btn {
    height: auto;
    min-height: var(--wi-btn-height-md, var(--size-control-md));
    padding-block: var(--space-2);
    white-space: normal;
    text-align: center;
  }

  /* A menu's trigger (Invite) keeps its label and its chevron on one line: the wrap above is for a long label alone. */
  .wi-page-header:not(.academy__lesson-header) > .wi-page-header__actions .wi-action-menu > .wi-btn {
    white-space: nowrap;
  }
}

/* The app's own variants: the page's facts on a line below the title ("Lesson 2 of 3 · 4 min read"). There is no
   breadcrumb: the sidebar and a phone's bottom bar lead back. */
.wi-page-header__byline {
  flex: 0 0 100%;
}

/* One line of text, its facts joined as in a sentence ("Lesson 2 of 3 · 1 min read"); the dot belongs to the fact
   before it, and a fact still empty (a lesson with nothing written) takes none. */
.wi-page-header__meta {
  flex: 0 0 100%;
  color: var(--gray-200);
  font-size: var(--font-size-sm);
  line-height: var(--font-line-height-sm);
}

.wi-page-header__meta > span:not(:last-child)::after {
  content: "\00a0·\00a0";
}

.wi-page-header__meta > span:has(+ span:empty)::after {
  content: none;
}

/* A quiet button in a header (Edit agency, Preview) is white on the navy with navy words, flat (its shadow stays for the
   same button in a page's content; a record's header lifts its own, RecordHeader.css), a light grey under the pointer. */
.wi-page-header .wi-btn--tertiary-light {
  border-color: transparent;
  background-color: var(--background-surface);
  color: var(--brand-primary);
}

.wi-page-header .wi-btn--tertiary-light:hover,
.wi-page-header .wi-btn--tertiary-light[data-hovered] {
  background-color: var(--gray-100);
}

.wi-page-header__actions .wi-btn--tertiary-light:not(:focus-visible),
.wi-page-header__actions .wi-btn--destructive-outline:not(:focus-visible) {
  box-shadow: none;
}

/* A button on the card: its focus ring is the inverse one, which shows on navy (3:1), and the `secondary` action (the
   turquoise one) is the accent: turquoise-400 with navy text, a step darker under the pointer and the press. */
.wi-page-header .wi-btn:focus-visible {
  box-shadow: var(--focus-ring-inverse);
}

.wi-page-header .wi-btn--destructive:focus-visible {
  box-shadow: var(--focus-ring-danger-inverse);
}

.wi-page-header .wi-btn--secondary {
  --brand-secondary-bg: var(--turquoise-400);
  --brand-secondary-fg: var(--brand-primary);
  --brand-secondary-bg-hover: var(--turquoise-500);
  --brand-secondary-bg-pressed: var(--turquoise-600);
}

.wi-page-header .wi-btn--ghost {
  color: var(--text-on-brand);
}

.wi-page-header .wi-btn--ghost:active {
  color: var(--gray-200);
}

/* A tile before the title (a lesson's number). */
.wi-page-header__lead {
  flex: none;
  display: flex;
}

/* A line that belongs with the title (`subtitle`), right under it, beside the lead: the two read as one. */
.wi-page-header__title-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.wi-page-header__title-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

/* An action that changes something without a page of its own is a form's button (the Academy's Preview as an
   advisor): its form lays out as if the button were the header's own action. */
.wi-page-header__actions > form {
  display: contents;
}

/* An action wrapped in its form or its menu fills the row on a phone as a link does (a campaign's Restore). */
@media (max-width: 767.98px) {
  .wi-page-header__actions > * > .wi-btn {
    width: 100%;
  }
}

/* A page's own tabs (a record's sections) are not on the card: they follow it, on the canvas, right above the content they
   switch, as wide as the content. Their line is the canvas's edge, and the current tab's bar sits on it: the tabs are as
   tall as the row, so the bar covers the line. Each tab keeps a little room for its focus ring, which the first one gives
   back to the row's padding, so the words line up with the card's edge. */
.wi-page-header__tabs {
  margin-bottom: var(--space-4);
}

.wi-page-header__tabs .wi-tabs {
  padding-inline: var(--space-2);
}

.wi-page-header__tabs .wi-tabs__tab {
  color: var(--text-secondary);
}

.wi-page-header__tabs .wi-tabs__tab[data-hovered],
.wi-page-header__tabs .wi-tabs__tab[aria-current="page"] {
  color: var(--text-primary);
}

.wi-page-header__tabs .wi-tabs__tab .wi-badge--count {
  background-color: var(--blue-gray-100);
  color: var(--text-primary);
}

.wi-page-header__tabs .wi-tabs__tab[aria-current="page"] .wi-badge--count {
  background-color: var(--brand-secondary-bg);
  color: var(--text-on-brand);
}

/* The academy's lesson title written in place, and whether it is saved: on navy, its frame and its status light. */
.wi-page-header .academy__title-field .wi-text-field__input:hover {
  border-color: var(--blue-gray-600);
}

.wi-page-header .academy__title-field .wi-text-field__input:focus-within {
  border-color: var(--turquoise-400);
}

.wi-page-header .academy__status {
  color: var(--turquoise-400);
}

.wi-page-header .academy__status[data-state="failed"] {
  color: var(--red-200);
}

/* A lesson's number is a navy tile, which would vanish on the navy card: one step lighter there. */
.wi-page-header__lead .academy__number {
  background: var(--blue-gray-700);
}

/* The chapter editor's summary (written count, length) sits in the header's actions: on the navy card, light. */
.wi-page-header .academy__summary {
  color: var(--gray-200);
}
.wi-page-header .academy__summary strong {
  color: var(--text-on-brand, var(--base-white));
}

/* The brand (navy) button would vanish on the navy card: there it takes the accent, turquoise with navy words. */
.wi-page-header .wi-btn--brand {
  background-color: var(--turquoise-400);
  color: var(--blue-gray-900);
}
.wi-page-header .wi-btn--brand:hover,
.wi-page-header .wi-btn--brand[data-hovered] {
  background-color: var(--turquoise-500);
}
