/* =============================================================================
   FOOX BRICKS: LANGUAGE SWITCHER (header icons)
   A <details> dropdown: it works without JS, and keyboard and screen readers
   get it for free. A few lines of JS (lang.js) close it on an outside click or Esc.
   ============================================================================= */
.lang-switch {
  position: relative;
  margin: 0;
}

/* the trigger looks like the other icon buttons */
.lang-switch > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-btn-size);
  height: var(--icon-btn-size);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-white);
  font-family: var(--pico-font-family);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  list-style: none;
  cursor: pointer;
}

/* The code sits exactly in the middle of the button, like the icons. Capitals
   have no descenders, so nudge them 1px down to the icons' optical centre line. */
.lang-switch > summary > span {
  display: block;
  transform: translateY(1px);
}

.lang-switch > summary::-webkit-details-marker {
  display: none;
}

/* no chevron: it pushed the code off-centre. Pico's own marker off too. */
.lang-switch > summary::after {
  display: none;
}

.lang-switch > summary:hover,
.lang-switch[open] > summary {
  background: var(--color-black-soft);
}

.lang-switch > summary:focus-visible {
  outline: 2px solid var(--color-yellow);
  outline-offset: -2px;
}

/* the menu: black header chrome, like the dark search suggestions */
body > header .lang-switch > ul {
  position: absolute;
  z-index: 120;
  top: calc(100% + (var(--header-height) - var(--icon-btn-size)) / 2 + 1px); /* flush with the header's bottom edge */
  right: 0;
  display: block;
  min-width: 14rem;
  margin: 0;
  padding: var(--space-2) 0;
  list-style: none;
  background: var(--color-black);
  border: 1px solid var(--color-black-muted);
  border-top: 2px solid var(--color-yellow);
  box-shadow: 0 24px 48px rgb(0 0 0 / 40%);
}

body > header .lang-switch > ul > li {
  display: block;
  margin: 0;
  padding: 0;
  list-style: none;
}

body > header .lang-switch > ul a {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  align-items: center;
  min-height: 44px;
  margin: 0;
  padding: 0 var(--space-4);
  color: var(--color-gray-200);
  font-size: var(--text-sm);
  text-decoration: none;
}

.lang-switch .lang-code {
  font-family: var(--pico-font-family-monospace);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--color-gray-400);
}

body > header .lang-switch > ul a:hover {
  background: var(--color-black-soft);
  color: var(--color-white);
}

body > header .lang-switch > ul a[aria-current="true"] {
  color: var(--color-white);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--color-yellow);
}

body > header .lang-switch > ul a[aria-current="true"] .lang-code {
  color: var(--color-yellow);
}

body > header .lang-switch > ul a[aria-current="true"]::after {
  color: var(--color-yellow);
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: var(--text-xs);
}

/* phones: the trigger is a 44px tap target like the other icons */
@media (max-width: 767px) {
  .lang-switch > summary {
    width: var(--tap-target);
    height: var(--tap-target);
  }

  body > header .lang-switch > ul {
    top: calc(100% + 6px);
    right: calc(-2 * var(--tap-target));
    min-width: 13rem;
  }
}

/* Pico greys out an open <details> summary and gives it a bottom margin (which
   made the button jump up when opened); keep it white and in place */
body > header details.lang-switch > summary,
body > header details.lang-switch > summary:not([role]):not(:focus),
body > header details.lang-switch[open] > summary:not([role]):not(:focus) {
  margin: 0;
  color: var(--color-white);
}
