/*
 * The site header.
 *
 * Two bars, as on the French site: a quiet utility strip for the things people
 * go looking for, and the navigation proper below it. The only colour in the
 * whole header is the call to action, which is what makes it the thing your eye
 * lands on.
 *
 * It is written against its own class names rather than Divi's, so none of the
 * theme's header rules apply and nothing here has to fight them.
 */

/*
 * The bar follows you down the page; the utility strip does not.
 *
 * One sticky element rather than two: the header sticks at minus the strip's
 * own height, so the strip scrolls up out of sight and the navigation proper
 * comes to rest against the top of the window. Sticking the bar on its own
 * would need the header to be as tall as the page for it to have anywhere to
 * travel.
 *
 * The strip is hidden below 1024px, where the offset therefore goes to zero.
 */
.site-header {
  --site-header-strip: 39px;

  position: sticky;
  top: calc(-1 * var(--site-header-strip));
  z-index: 100;
  background: var(--ds-surface);
  border-bottom: 1px solid var(--ds-line);
}

/*
 * The sales pages keep their own product bar pinned instead — two bars stacked
 * at the top of the screen is one too many, and theirs is the one carrying the
 * page's own navigation and its buy button.
 */
body:has(#pdv_product_nav) .site-header {
  position: relative;
  top: 0;
}

/* Utility strip ------------------------------------------------------- */

.site-header__utility {
  background: var(--ds-surface-sunk);
  border-bottom: 1px solid var(--ds-line);
}

.site-header__utility-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 38px;
}

/*
 * `--ds-muted` clears 4.5:1 on white but only manages 4.39:1 on the sunk grey
 * this strip sits on, so it steps down to the body colour here.
 */
.site-header__lang,
.site-header__utility-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ds-body);
  font-size: var(--ds-text-label);
  text-decoration: none;
  padding-block: 0.35rem;
}

.site-header__lang svg {
  width: 14px;
  height: 14px;
}

.site-header__lang-swap {
  display: grid;
}

.site-header__lang-swap > span {
  grid-area: 1 / 1;
  transition: opacity 0.15s ease;
}

.site-header__lang-hover {
  opacity: 0;
}

.site-header__lang:hover .site-header__lang-rest,
.site-header__lang:focus-visible .site-header__lang-rest {
  opacity: 0;
}

.site-header__lang:hover .site-header__lang-hover,
.site-header__lang:focus-visible .site-header__lang-hover {
  opacity: 1;
}

.site-header__lang:hover,
.site-header__utility-link:hover,
.site-header__lang:focus-visible,
.site-header__utility-link:focus-visible {
  color: var(--ds-ink);
}

/* Main bar ------------------------------------------------------------ */

.site-header__bar-inner {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2.5rem);
  min-height: 68px;
}

.site-header__logo {
  display: inline-flex;
  align-items: center;
  flex: none;
}

.site-header__logo img {
  display: block;
  width: 148px;
  height: auto;
}

.site-header__nav {
  flex: 1;
}

.site-header__list {
  display: flex;
  align-items: center;
  gap: clamp(0.25rem, 1.4vw, 1.1rem);
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-header__link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.55rem;
  border: 0;
  border-radius: var(--ds-radius-sm);
  background: transparent;
  color: var(--ds-ink);
  font-family: var(--ds-font);
  font-size: var(--ds-text-small);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.site-header__link:hover,
.site-header__link:focus-visible {
  background: var(--ds-surface-sunk);
}

.site-header__link[aria-current] {
  color: var(--ds-ink-strong);
}

.site-header__caret {
  width: 12px;
  height: 12px;
  flex: none;
  transition: transform 0.18s ease;
}

.site-header__caret.is-open {
  transform: rotate(180deg);
}

/* Menu icons ---------------------------------------------------------- */

/*
 * The brand's own icon set, cropped to the glyph in data/header.json: the
 * programme icons are drawn on a 48-unit plate the artwork floats in the middle
 * of, which at menu size left them reading half the weight of the rest.
 */
.site-header__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin-top: 1px;
}

.site-header__icon svg {
  width: 100%;
  height: 100%;
}

/* Dropdown ------------------------------------------------------------ */

.site-header__group {
  position: relative;
}

/*
 * A tray rather than a plain box: the items sit on a white card inside it and
 * the "view all" row sits on the tray itself, which is what separates a
 * destination you browse from the one that lists them all.
 */
.site-header__panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  width: 360px;
  padding: 0.3rem;
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface-sunk);
  box-shadow: 0 12px 32px oklch(0.21 0.006 285.885 / 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
}

/* Bare labels, so the tray only needs the width they take — and less height
   than a row carrying an icon and a description. */
.site-header__panel--compact {
  width: max-content;
  min-width: 200px;
}

.site-header__panel--compact .site-header__panel-card a {
  padding-block: 0.5rem;
}

.site-header__panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.site-header__panel-card {
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--ds-line);
  border-radius: 10px;
  background: var(--ds-surface);
}

.site-header__panel-card a,
.site-header__drawer-sub a {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.6rem 0.65rem;
  border-radius: var(--ds-radius-sm);
  text-decoration: none;
}

.site-header__panel-card a:hover,
.site-header__panel-card a:focus-visible {
  background: var(--ds-surface-sunk);
}

.site-header__panel-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.site-header__panel-title {
  color: var(--ds-ink);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
}

.site-header__panel-desc {
  color: var(--ds-muted);
  font-size: var(--ds-text-label);
  line-height: 1.4;
}

/* The row on the tray: same shape, quieter, and it turns into a card on hover. */
.site-header__panel-foot {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.3rem;
  padding: 0.6rem 0.65rem;
  border: 1px solid transparent;
  border-radius: var(--ds-radius-sm);
  color: var(--ds-body);
  font-size: var(--ds-text-small);
  font-weight: 500;
  text-decoration: none;
}

.site-header__panel-foot:hover,
.site-header__panel-foot:focus-visible {
  border-color: var(--ds-line);
  background: var(--ds-surface);
  color: var(--ds-ink);
}

.site-header__panel-foot .site-header__icon {
  width: 20px;
  height: 20px;
  margin: 0;
}

/* Actions ------------------------------------------------------------- */

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
  flex: none;
}

.site-header__burger,
.site-header__close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-surface);
  color: var(--ds-ink);
  cursor: pointer;
}

.site-header__burger {
  flex-direction: column;
  gap: 4px;
  padding: 0 9px;
}

.site-header__burger span {
  display: block;
  width: 100%;
  height: 1.5px;
  background: var(--ds-ink);
  border-radius: 2px;
}

.site-header__close svg {
  width: 20px;
  height: 20px;
}

/* Drawer -------------------------------------------------------------- */

/*
 * Full screen, with its own logo and close button. Anchoring it below the
 * header would leave a band of the page showing above it whenever the drawer is
 * opened part-way down a page.
 */
.site-header__drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--ds-surface);
}

.site-header__drawer-bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 68px;
  padding-inline: var(--ds-gutter);
  border-bottom: 1px solid var(--ds-line);
  background: var(--ds-surface);
}

.site-header__drawer-inner {
  padding: 0.5rem var(--ds-gutter) 3rem;
}

.site-header__drawer-list,
.site-header__drawer-sub {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-header__drawer-list > li + li {
  border-top: 1px solid var(--ds-line);
}

.site-header__drawer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 56px;
  padding: 0.5rem 0;
  border: 0;
  background: transparent;
  color: var(--ds-ink);
  font-family: var(--ds-font);
  font-size: 1.0625rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.site-header__drawer-row .site-header__caret {
  width: 14px;
  height: 14px;
  color: var(--ds-muted);
}

.site-header__drawer-list > li.is-open .site-header__drawer-row {
  color: var(--ds-ink-strong);
}

/* The expanded section repeats the dropdown's rows, on their own card. */
.site-header__drawer-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 0.85rem;
  padding: 0.3rem;
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-md);
  background: var(--ds-surface-sunk);
}

/*
 * The same step-down as the utility strip: `--ds-muted` clears 4.5:1 on white
 * but only 4.39:1 on the sunk grey this card is drawn on, and axe is right to
 * call it. Measured at 7.02:1 after.
 */
.site-header__drawer-sub .site-header__panel-desc {
  color: var(--ds-body);
}

/* The "view all" row is not a peer of the courses above it. */
.site-header__drawer-all {
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px solid var(--ds-line);
}

.site-header__drawer-sub a:hover,
.site-header__drawer-sub a:focus-visible {
  background: var(--ds-surface);
}

.site-header__drawer-foot {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ds-line);
}

.site-header__drawer-quiet {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ds-body);
  font-size: var(--ds-text-small);
  text-decoration: none;
}

.site-header__drawer-quiet svg {
  width: 14px;
  height: 14px;
}

.site-header__drawer-quiet:hover,
.site-header__drawer-quiet:focus-visible {
  color: var(--ds-ink);
}

/* Below the point where the row stops fitting, the drawer takes over. */
@media (max-width: 1023px) {
  .site-header {
    --site-header-strip: 0px;
  }

  .site-header__nav,
  .site-header__utility {
    display: none;
  }

  .site-header__burger,
  .site-header__close {
    display: flex;
  }

  .site-header__drawer {
    display: block;
  }

  .site-header__drawer[hidden] {
    display: none;
  }
}

@media (max-width: 380px) {
  .site-header__logo img {
    width: 124px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-header__caret,
  .site-header__panel,
  .site-header__lang-swap > span {
    transition: none;
  }
}
