/* The language picker (components/layout/language-picker.php).
   A bottom sheet under 1024px, a centred dialog from 1024px up.

   Every default is written as html body :where(...): two element selectors
   and no class weight (0,0,2). That is enough to beat the compiled
   Tailwind's resets for button, input and * (0,0,1 at most), which a cascade
   layer could not (they are unlayered), and any rule of a theme's that names
   one of these classes (0,1,0 or more) wins whatever the order, with no
   !important. Colours come from the theme's tokens. A theme adds a band or a
   frame with .px-lang-picker__panel::before / ::after, left free here. The
   one !important rule, at the end, keeps a closed picker and filtered rows
   hidden whatever display a theme gives them.

   On a pick the root has .is-leaving and data-lang, the row .is-chosen, and
   --px-pick-x / --px-pick-y hold the row's centre. Nothing here moves on
   them: a theme that animates something then gets its exit waited for
   (up to 700ms, language-picker.js) before the language changes. */
html body :where(.px-lang-picker) {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-sizing: border-box;
  color: var(--ink, #15131a);
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
html body :where(.px-lang-picker *),
html body :where(.px-lang-picker *)::before,
html body :where(.px-lang-picker *)::after { box-sizing: border-box; }

html body :where(.px-lang-picker__backdrop) {
  position: absolute;
  inset: 0;
  background: rgba(21, 19, 26, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

html body :where(.px-lang-picker__panel) {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(88dvh, 40rem);
  background: var(--paper, #fff);
  color: var(--ink, #15131a);
  border: 0 solid var(--rule, rgba(0, 0, 0, 0.1));
  border-top-width: 1px;
  border-radius: 1.5rem 1.5rem 0 0;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  box-shadow: 0 -20px 50px -24px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  touch-action: pan-y;
}

html body :where(.px-lang-picker.is-open .px-lang-picker__backdrop) { opacity: 1; }
html body :where(.px-lang-picker.is-open .px-lang-picker__panel) { transform: none; }
html body :where(.px-lang-picker.is-dragging .px-lang-picker__panel) { transition: none; }

html body :where(.px-lang-picker__handle) {
  flex: none;
  width: 2.5rem;
  height: 0.25rem;
  margin: 0.75rem auto 0.25rem;
  border-radius: 999px;
  background: var(--rule, rgba(0, 0, 0, 0.15));
}

html body :where(.px-lang-picker__head) {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem 1rem;
  border: 0 solid var(--rule, rgba(0, 0, 0, 0.1));
  border-bottom-width: 1px;
}
html body :where(.px-lang-picker__heading) { min-width: 0; text-align: start; }
html body :where(.px-lang-picker__eyebrow) {
  margin: 0 0 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft, #6b6b76);
}
html body :where(.px-lang-picker__title) {
  margin: 0;
  font-family: var(--font-display, inherit);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink, #15131a);
  overflow-wrap: anywhere;
}

html body :where(.px-lang-picker__close) {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--paper-2, rgba(0, 0, 0, 0.05));
  color: var(--ink-soft, #6b6b76);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
html body :where(.px-lang-picker__close:hover) { color: var(--ink, #15131a); }
html body :where(.px-lang-picker__close svg) { width: 1rem; height: 1rem; }

html body :where(.px-lang-picker__search) {
  position: relative;
  flex: none;
  padding: 0.875rem 1.25rem 0.25rem;
}
html body :where(.px-lang-picker__search-label) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
html body :where(.px-lang-picker__search-icon) {
  position: absolute;
  inset-inline-start: 2rem;
  top: calc(0.875rem + 1.375rem);
  width: 1rem;
  height: 1rem;
  transform: translateY(-50%);
  color: var(--ink-soft, #6b6b76);
  pointer-events: none;
}
html body :where(.px-lang-picker__search-input) {
  display: block;
  width: 100%;
  height: 2.75rem;
  margin: 0;
  padding: 0 1rem;
  padding-inline-start: 2.5rem;
  border: 1px solid var(--rule, rgba(0, 0, 0, 0.12));
  border-radius: 0.75rem;
  background: var(--paper-2, rgba(0, 0, 0, 0.03));
  color: var(--ink, #15131a);
  font: inherit;
  font-size: 1rem;
  line-height: 1.25;
  text-align: start;
  -webkit-appearance: none;
  appearance: none;
}
html body :where(.px-lang-picker__search-input)::placeholder { color: var(--ink-soft, #6b6b76); opacity: 1; }
html body :where(.px-lang-picker__search-input:focus) { outline: 2px solid var(--theme-500, currentColor); outline-offset: 1px; }

html body :where(.px-lang-picker__list) {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0.75rem;
}

html body :where(.px-lang-picker__item) {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin: 0 0 0.125rem;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 0.75rem;
  background: transparent;
  color: var(--ink, #15131a);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: start;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
html body :where(.px-lang-picker__item:hover) { background: var(--paper-2, rgba(0, 0, 0, 0.04)); }
html body :where(.px-lang-picker__item:active) { background: color-mix(in srgb, var(--theme-500, #888) 10%, transparent); }
html body :where(.px-lang-picker__item.is-current) {
  background: var(--paper-2, rgba(0, 0, 0, 0.05));
  font-weight: 600;
}
/* A name sits where the page's reading direction starts, even one written
   the other way (Arabic in an English list); long names wrap, nothing is
   cut off. */
html body :where(.px-lang-picker__name) {
  flex: 0 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
html body :where(.px-lang-picker__check) {
  flex: none;
  width: 1rem;
  height: 1rem;
  margin-inline-start: auto;
  color: var(--theme-500, currentColor);
  visibility: hidden;
}
html body :where(.px-lang-picker__item.is-current .px-lang-picker__check) { visibility: visible; }

html body :where(.px-lang-picker__empty) {
  margin: 0;
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--ink-soft, #6b6b76);
  font-size: 0.9375rem;
}

@media (min-width: 1024px) {
  html body :where(.px-lang-picker) { align-items: center; padding: 2rem; }
  html body :where(.px-lang-picker__panel) {
    width: min(28rem, 100%);
    max-height: min(36rem, calc(100dvh - 4rem));
    border-width: 1px;
    border-radius: 1rem;
    padding-bottom: 0.5rem;
    box-shadow: 0 30px 70px -24px rgba(0, 0, 0, 0.45);
    opacity: 0;
    transform: translateY(0.75rem) scale(0.98);
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.18s ease;
  }
  html body :where(.px-lang-picker.is-open .px-lang-picker__panel) { opacity: 1; transform: none; }
  html body :where(.px-lang-picker__handle) { display: none; }
  html body :where(.px-lang-picker__head) { padding-top: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  html body :where(.px-lang-picker__backdrop),
  html body :where(.px-lang-picker__panel) { transition: none; }
  html body :where(.px-lang-picker__panel) { transform: none; }
}

.px-lang-picker[hidden],
.px-lang-picker__empty[hidden],
.px-lang-picker__item[hidden] { display: none !important; }
