/*
 * Site header: the logotype, the main navigation, the locale choice (only with
 * more than one locale) and the theme button, in one row. Not fixed: it scrolls
 * away with the page. Solid --color-bg bar: no divider line, no shadow, no blur.
 * Measures follow the approved mockup: a centered column of min(1280px, 100% - 64px),
 * 58 px of top padding (28 px on phones), the logotype 65 px high (48 px on phones).
 * Each link and button is at least 44 px high, for touch.
 * Below 780 px the links fold into a round button that opens a panel (see the
 * script in base.html). Without script the links stay in the row, and the theme
 * button stays hidden, as it always does without script.
 */

.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  padding: 58px max(32px, calc((100% - 1280px) / 2)) 20px;
  background: var(--color-bg);
  color: var(--color-text);
}

.site-header a {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
  min-inline-size: 44px;
}

/*
 * Logotype: two images in the link, the dark-background version first and the
 * light-background version second. The scheme shows one of them, with no script:
 * dark by default, light when the system asks for it, and data-theme forces either.
 * The hidden one is removed from the accessibility tree too.
 */
.site-header a img {
  display: block;
  block-size: 4.0625rem;
  inline-size: auto;
}

.site-header a img + img {
  display: none;
}

:root[data-theme="light"] .site-header a img:first-child {
  display: none;
}

:root[data-theme="light"] .site-header a img + img {
  display: block;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .site-header a img:first-child {
    display: none;
  }

  :root:not([data-theme="dark"]) .site-header a img + img {
    display: block;
  }
}

/* The panel holds the navigation. On a wide screen it sits at the right, before the theme button. */
.site-header__panel {
  display: flex;
  align-items: center;
  margin-inline: auto clamp(55px, 7vw, 105px);
}

.site-header__panel ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem clamp(42px, 5.4vw, 82px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header__panel nav p {
  margin: 0;
}

/* Links: light title font, white, no underline at rest. Hover and focus turn the text purple; no underline. */
.site-header__panel a,
.site-header__panel a:visited {
  color: var(--color-text);
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 300;
  text-decoration: none;
}

.site-header__panel a:hover,
.site-header__panel a:focus-visible {
  color: var(--color-accent-text);
}

.site-header__panel a[aria-current="page"] {
  font-weight: 700;
}

/* Round button: 46 px, thin border. Three lines, hidden on wide screens and without script. */
.site-header .site-header__toggle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: 5px;
  inline-size: 46px;
  block-size: 46px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
}

.site-header .site-header__toggle:hover {
  border-color: var(--color-text);
}

.site-header .site-header__toggle span {
  display: block;
  inline-size: 19px;
  block-size: 1px;
  background: currentColor;
}

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

/* Theme button: round, 44 px. */
.site-header button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  inline-size: 44px;
  block-size: 44px;
  margin: 0;
  padding: 0;
  border: 2px solid var(--color-border-strong);
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
}

.site-header button:hover {
  border-color: var(--color-text);
}

.site-header button:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

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

.site-header button svg {
  display: none;
  inline-size: 20px;
  block-size: 20px;
}

.site-header button[aria-pressed="false"] svg[data-icon="moon"],
.site-header button[aria-pressed="true"] svg[data-icon="sun"] {
  display: block;
}

/* Below 1020 px: smaller links and gap, as in the mockup. */
@media (max-width: 1020px) {
  .site-header {
    padding-inline: max(22px, calc((100% - 900px) / 2));
  }

  .site-header__panel {
    margin-inline: auto 38px;
  }

  .site-header__panel ul {
    gap: 0.5rem 28px;
  }

  .site-header__panel a,
  .site-header__panel a:visited {
    font-size: 17px;
  }
}

/* Below 780 px: the links fold into the panel, opened by the round button. */
@media (max-width: 780px) {
  .site-header {
    flex-wrap: wrap;
    padding-top: 28px;
    padding-inline: 20px;
  }

  .site-header a img {
    block-size: 3rem;
  }

  /* The menu button loses its ring on phones: a bare icon next to the round theme button, 20 px apart. */
  .site-header .site-header__toggle {
    display: inline-flex;
    margin-inline: auto 20px;
    border-color: transparent;
    background: transparent;
  }

  .site-header .site-header__toggle:hover {
    border-color: transparent;
  }

  .site-header .site-header__toggle span {
    inline-size: 26px;
    block-size: 2px;
  }

  .site-header__panel {
    order: 1;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    margin: 0;
  }

  .site-header__panel ul {
    flex-direction: column;
    gap: 20px;
  }

  .site-header__panel a,
  .site-header__panel a:visited {
    font-size: 20px;
  }

  /* With script (the button is shown) the panel floats over the page, in a solid card. */
  .site-header .site-header__toggle:not([hidden]) + .site-header__panel {
    position: absolute;
    inset-block-start: 100%;
    inset-inline: 20px;
    margin-block-start: 16px;
    padding: 28px;
    border: 1px solid var(--color-border);
    border-radius: 24px;
    background: var(--color-surface);
    z-index: 1;
  }

  .site-header .site-header__toggle:not([hidden]) + .site-header__panel ul {
    gap: 20px;
  }

  .site-header .site-header__toggle[aria-expanded="false"] + .site-header__panel {
    display: none;
  }
}
