/* Language switcher
   =========================================================================
   Styles for templates/includes/language_switcher.html.

   This lives in its own file, and not inside landing_redesign.css, because the
   switcher appears in three places that load completely different stylesheets:
   the public site, the student workspace, and the login and sign-up pages.

   Every colour and spacing value is written as var(--token, fallback). On the
   public site the tokens exist and the switcher picks up that page's palette. In
   the workspace they do not exist, and the fallback keeps it looking right.
   --primary is the exception: every page sets it from CountrySite.primary_color,
   so the switcher is the country's own colour wherever it is shown.
   ------------------------------------------------------------------------- */

.lang-switch {
  display: flex;
  align-items: center;
  gap: var(--space-1, .5rem);
  margin: 0;
}

/* The word "Langue" is announced to screen readers but hidden from view: the FR
   and PT buttons already say what they are to anyone who can see them. */
.lang-switch_label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.lang-switch_options {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border-soft, #e2e2e2);
  border-radius: var(--radius-pill, 999px);
  background: var(--card-bg, #ffffff);
}

.lang-switch_option {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-muted, #6b6357);
  font-family: inherit;
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .04em;
  line-height: 1;
  min-height: 28px;
  padding: 0 .6rem;
  border-radius: var(--radius-pill, 999px);
  cursor: pointer;
  text-transform: uppercase;
  transition: background-color .15s ease, color .15s ease;
}

.lang-switch_option:hover {
  color: var(--primary, #00923f);
  background: rgba(0, 0, 0, .05);
}

.lang-switch_option:focus-visible {
  outline: 2px solid var(--primary, #00923f);
  outline-offset: 2px;
}

.lang-switch_option.is-current {
  background: var(--primary, #00923f);
  color: #fff;
  cursor: default;
}

/* ---- Public site: header and slide-out menu ---- */

/* A narrow header only has room for the login button and the burger, so the
   switcher moves into the slide-out menu instead of wrapping onto a second row. */
@media (max-width: 991px) {
  .header-warm_actions .lang-switch { display: none; }
}

.menu-warm_lang {
  margin-top: var(--space-2, 1rem);
  padding-top: var(--space-2, 1rem);
  border-top: 1px solid var(--border-soft, #e2e2e2);
}

/* There is room for the label inside the menu, so show it there. */
.lang-switch--menu .lang-switch_label {
  position: static;
  width: auto;
  height: auto;
  margin: 0 var(--space-1, .5rem) 0 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  color: var(--ink-muted, #6b6357);
  font-size: .85rem;
}

/* ---- Student workspace: inside the profile dropdown ---- */

/* The dropdown is a list of links, so the switcher is given the same padding and
   the same divider above it that the other rows in that menu already have. */
.lang-switch--dropdown {
  padding: 10px 20px;
}

.lang-switch--dropdown .lang-switch_label {
  position: static;
  width: auto;
  height: auto;
  margin: 0 var(--space-1, .5rem) 0 0;
  overflow: visible;
  clip: auto;
  clip-path: none;
  color: var(--ink-muted, #8c8c8c);
  font-size: .8rem;
}

/* ---- Login and sign-up pages: floating in the top corner ---- */

/* These pages are a single centred card on an empty background, with no header to
   put the switcher in, so it floats clear of the card in the top right. */
.lang-switch--floating {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 20;
}

.lang-switch--floating .lang-switch_options {
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
