/* Language switcher: a quiet text control in the header (globe + language code + caret, from lg) and a row at the top of the
   menu drawer (below lg). Colours come from the header's own variables, so the overlay look (white over a hero) just works. */
.lang-switcher { position: relative; flex: none; }

.lang-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-gap-5xs);
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0 var(--space-gap-4xs);
  border: 0;
  background: none;
  color: var(--hdr-fg, inherit);
  white-space: nowrap;
  cursor: pointer;
}
.lang-switcher__btn .icon--globe { flex: none; width: calc(var(--icon-search) + var(--border-1-pixel)); height: calc(var(--icon-search) + var(--border-1-pixel)); }
.lang-switcher__btn .icon--caret { flex: none; width: var(--space-inset-2xs); height: var(--space-inset-2xs); transform: rotate(90deg); transition: transform 150ms ease; }
.lang-switcher--header .icon--globe { margin-inline-end: var(--space-gap-5xs); } /* 4px more between the globe and the code */
.lang-switcher.is-open .lang-switcher__btn .icon--caret { transform: rotate(-90deg); }
.lang-switcher__btn:hover .lang-switcher__label { text-decoration: underline; text-underline-offset: var(--space-gap-5xs); }

/* The list: closed unless open. Without JS it opens with keyboard focus, so the links are still reachable. */
.lang-switcher__list { display: none; margin: 0; padding: 0; list-style: none; }
.lang-switcher.is-open .lang-switcher__list,
.lang-switcher:not(.is-ready):focus-within .lang-switcher__list { display: block; }

.lang-switcher__link {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 var(--space-gap-xs);
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.lang-switcher__link:hover,
.lang-switcher__link:focus-visible { background: var(--color-bg-subtle); }
.lang-switcher__link:focus-visible { outline-offset: calc(-1 * var(--border-2-pixel)); }
/* The current language: a bar on the left edge and a heavier weight, so it is not marked by colour alone. */
.lang-switcher__link[aria-current="true"] { box-shadow: inset var(--border-3-pixel) 0 0 var(--color-bg-inverse); font-weight: 700; }

/* Header placement: lg and up only (below lg the drawer carries it). */
.lang-switcher--header { display: none; }

@media (min-width: 1024px) {
  .lang-switcher--header {
    display: block;
    /* Sits close to the button on its right: the actions' own gap is --space-gap-lg, pull it in to --space-gap-xs. */
    margin-inline-end: calc(var(--space-gap-xs) - var(--space-gap-lg));
  }
  .lang-switcher--header .lang-switcher__list {
    position: absolute;
    top: calc(100% + var(--space-gap-5xs));
    inset-inline-end: 0;
    z-index: 3;
    width: max-content;
    min-width: 100%;
    padding: var(--space-gap-5xs) 0;
    background: var(--color-bg-canvas);
    color: var(--color-text-primary);
    border: var(--border-1-pixel) solid var(--color-border-rule);
    box-shadow: 0 var(--space-gap-5xs) var(--space-gap-xs) color-mix(in srgb, var(--color-bg-alpha-30) 67%, transparent); /* same soft shadow as the scrolled header */
  }
}

/* Drawer placement: a full-width row like the accordions below it; the list opens in the flow. */
.lang-switcher--drawer { border-bottom: var(--border-1-pixel) solid var(--color-border-rule-subtle); }
.lang-switcher--drawer .lang-switcher__btn {
  width: 100%;
  min-height: calc(var(--tap-min) + var(--space-gap-5xs));
  padding: var(--space-gap-4xs) 0;
  gap: var(--space-gap-2xs);
  color: inherit;
  text-align: left;
}
.lang-switcher--drawer .icon--caret { margin-inline-start: auto; }
.lang-switcher--drawer .lang-switcher__list { padding-bottom: var(--space-gap-xs); }
.lang-switcher--drawer .lang-switcher__link { padding-inline: var(--space-inset-md) var(--space-gap-xs); white-space: normal; }

@media (min-width: 1024px) {
  .lang-switcher--drawer { display: none; }
}
