/*
 * The two switchers' own rules: the languages and the themes. Each element
 * the head draws for them carries a class of the design. `.qs-langs` holds
 * `.qs-lang`, the summary of the folded languages and a link per language,
 * or a button where the page stands at one address in every language, as
 * the app's does, each with its `.qs-flag` and its `.qs-lang-name`. `.qs-themes` holds
 * `.qs-theme`, a button per theme with its `.qs-theme-icon` and its
 * `.qs-theme-name`. The flag and the icon are the design's own pictures in
 * `icons/`, laid whole inside their classes, so the rules reach the drawing
 * through the class that holds it.
 */

/* ---- a language, as a link or the summary ------------------------------------------- */

.qs-lang {
  display: inline-flex;
  align-items: center;
  gap: var(--nv-space-1);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
}

/* A button says a language as a link does, in the type around it. */
button.qs-lang {
  padding: 0;
  font: inherit;
  background: transparent;
  border: 0;
}

/* The summary is a block of its own, so it is as tall as its flag and stands
   on no line of text: its middle is the middle of what shares its line. */
summary.qs-lang {
  display: flex;
}

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

.qs-lang[aria-current='true'] {
  color: var(--nv-color-fg);
}

.qs-flag {
  display: inline-flex;
  flex: none;
}

/* A flag is a rectangle, not a glyph on a colourless field, so it keeps its
   own width and a hairline edge rather than the icon square. The edge is a
   border, not an outline: the outline is the focus ring's alone. */
.qs-flag svg {
  width: calc(var(--nv-icon-sm) * 1.5);
  height: var(--nv-icon-sm);
  color: var(--nv-color-fg-subtle);
  border: 1px solid var(--nv-color-border, currentColor);
  border-radius: var(--nv-radius-xs, 2px);
  box-sizing: border-box;
}

.qs-lang[aria-current='true'] .qs-flag svg {
  border-color: var(--nv-color-accent, currentColor);
}

/* The summary shows the language's own name, not a code, so it reads in
   the site's own font. */
summary.qs-lang .qs-lang-name {
  font-size: var(--nv-text-sm);
}

/* ---- the languages --------------------------------------------------- */

/* The languages fold behind one press: the current language stands for the
   rest of them, and the others open under it. */
.qs-langs {
  position: relative;
  display: inline-block;
  line-height: 1;
}

.qs-langs nav {
  position: absolute;
  inset-block-start: calc(100% + var(--nv-space-2));
  inset-inline-end: 0;
  z-index: 10;
  display: flex;
  width: max-content;
  flex-direction: column;
  gap: var(--nv-space-05);
  padding: var(--nv-space-1);
  font-size: var(--nv-text-sm);
  line-height: var(--nv-leading-normal, 1.5);
  background: var(--nv-color-bg-raised);
  border: 1px solid var(--nv-color-border, currentColor);
  border-radius: var(--nv-radius-sm, 4px);
  white-space: nowrap;
}

/* Each language in the open menu is a row of its own, in the head's type,
   with room around it and a ground under the one a pointer is on. */
.qs-langs nav .qs-lang {
  gap: var(--nv-space-2);
  padding: var(--nv-space-1) var(--nv-space-3);
  color: var(--nv-color-fg-muted);
  border-radius: var(--nv-radius-xs, 2px);
}

.qs-langs nav .qs-lang:hover {
  color: var(--nv-color-fg);
  background: var(--nv-color-bg-raised-strong);
}

.qs-langs nav .qs-lang[aria-current='true'] {
  color: var(--nv-color-fg);
}

/* ---- the themes ------------------------------------------------------ */

.qs-theme {
  display: inline-flex;
  gap: var(--nv-space-1);
  align-items: center;
  padding: var(--nv-space-1) var(--nv-space-2);
  font-size: var(--nv-text-sm);
  color: var(--nv-color-fg-muted);
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: var(--nv-radius-full);
}

.qs-theme[aria-pressed='true'],
.qs-theme[aria-current='true'] {
  color: var(--nv-color-fg);
  background: var(--nv-color-bg-raised-strong);
}

.qs-theme-icon {
  display: inline-flex;
}

.qs-theme-icon svg {
  width: var(--nv-icon-sm);
  height: var(--nv-icon-sm);
  color: var(--nv-color-fg-subtle);
}

/* The glyph carries the meaning and the word stays for a reader who is not
   looking at it. */
.qs-themes[data-compact] .qs-theme:has(.qs-theme-icon) .qs-theme-name,
.qs-themes-compact .qs-theme:has(.qs-theme-icon) .qs-theme-name {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The choices rubric draws in the organism's tree hold no element of the page's own: their themes are a group of the class
   `.qs-themes-compact`, dressed as the page's `nv-theme` is, and each language a fieldset that carries the press's one field,
   laid as if it were not there. */
.qs-themes-compact {
  display: inline-flex;
  gap: var(--nv-space-05);
  padding: var(--nv-space-05);
  background: var(--nv-color-bg-raised);
  border: 1px solid var(--nv-color-border);
  border-radius: var(--nv-radius-full);
}

.qs-lang-one {
  display: contents;
}
