/* The shared language selector and the text it chooses (templates/locale-select.mjs, client/i18n.js;
   Percy, October 8, 2026). A page that offers several languages carries each text in all of them
   as [data-l] elements; only the one in <html data-locale> shows, so a choice changes the page at
   once and nothing moves. A page sets the --locale-* colours to its own palette; the fallbacks are
   the site tokens. */
[data-l][hidden] {
  display: none !important;
}

/* The original reading content stays visible while the language script loads. */

.contact-locale-bar {
  --locale-ink: var(--color-ink);
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  z-index: 60;
}

.contact-locale-bar .locale-button {
  background: var(--color-paper);
}

body:has(.contact-locale-bar) .directory-qr-close {
  left: var(--card-space-md);
  right: auto;
}

:root[data-theme='light'] .contact-locale-bar {
  --locale-ink: #171717;
  --locale-muted: #55545a;
  --locale-panel: #f5f4f0;
  --locale-rule: #c4c1b9;
  --locale-surface: #e9e6df;
  --locale-sub: #25252a;
  --locale-hover: #e2dfd7;
}

:root[data-theme='light'] .contact-locale-bar .locale-button {
  background: #f5f4f0;
}

html[data-locale]:not([data-locale='en']) body main a.lp-button {
  max-width: 100%;
  min-height: 55px;
  height: auto;
  padding-block: 14px;
  white-space: normal;
  text-align: start;
}

html[data-locale]:not([data-locale='en']) .lp-hero-actions {
  flex-wrap: wrap;
  max-width: 100%;
}

html[data-locale]:not([data-locale='en']) .lp-hero-actions > .lp-button {
  flex: 0 1 auto;
}

html[data-locale]:not([data-locale='en']) body main .lp-button svg {
  flex: none;
}

.floating-header .locale-button {
  font-size: 13px;
  padding-inline: 10px;
}

.floating-header .locale-menu {
  z-index: 60;
}

body .floating-header:has(.locale-select) .floating-bar {
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: 16px;
}

body .floating-header:has(.locale-select) .glass-nav {
  gap: 16px;
}

.locale-compact {
  display: none;
}

.locale-nojs {
  position: fixed;
  inset-inline-end: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 60;
  min-width: 150px;
  padding: 8px 12px;
  border: 1px solid var(--color-rule-strong);
  background: var(--color-surface);
  color: var(--color-ink);
  font: 500 15px / 1.5 var(--font-body);
}

.locale-nojs summary,
.locale-nojs a {
  display: block;
  min-height: 44px;
  padding: 10px 4px;
  color: inherit;
  cursor: pointer;
}

.locale-nojs ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 1360px) {
  .floating-header .locale-current {
    display: none;
  }

  @media (max-width: 360px) {
    body .floating-header:has(.locale-select) .floating-bar {
      column-gap: 8px;
    }

    body .floating-header:has(.locale-select) .header-actions {
      gap: 6px;
    }

    .floating-header .locale-button {
      gap: 6px;
      padding-inline: 8px;
    }

    .floating-header .locale-globe {
      display: none;
    }
  }

  @media (min-width: 1001px) and (max-width: 1200px) {
    body .floating-header:has(.locale-select) .floating-bar {
      position: relative;
    }
    body .floating-header:has(.locale-select) .mobile-nav-toggle {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 5px;
      width: 44px;
      height: 44px;
      padding: 8px;
      border: 1px solid var(--color-rule-strong);
      border-radius: 3px;
      background: var(--color-surface);
      color: var(--color-ink);
    }
    body .floating-header:has(.locale-select) .mobile-nav-toggle span {
      width: 17px;
      height: 1px;
      background: currentColor;
    }
    body .floating-header:has(.locale-select) .glass-nav {
      display: none;
      position: absolute;
      inset: 72px 0 auto;
      width: 100%;
      justify-self: stretch;
      padding: 14px 20px 20px;
      max-height: calc(100dvh - 88px);
      overflow-y: auto;
      border: 1px solid var(--color-rule);
      background: var(--color-surface);
    }
    body .floating-header:has(.locale-select) .glass-nav.open {
      display: flex;
      align-items: stretch;
      flex-direction: column;
      gap: 0;
    }
    body .floating-header:has(.locale-select) .nav-trigger {
      display: flex;
      width: 100%;
      justify-content: space-between;
      padding: 14px 16px;
      font-size: 15px;
    }
    body .floating-header:has(.locale-select) .mega-panel {
      position: static;
      width: 100%;
      max-height: none;
      transform: none;
      border: 0;
      padding: 4px 0 12px;
      background: var(--color-paper);
    }
    body .floating-header:has(.locale-select) .mp-feature {
      grid-template-columns: minmax(0, 1fr) 24px;
      min-height: 0;
    }
    body .floating-header:has(.locale-select) :is(.mp-feature-art, .mp-feature-render) {
      display: none;
    }
    body .floating-header:has(.locale-select) :is(.mp-stages, .mp-pages) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }
  .floating-header .locale-compact {
    display: inline;
  }
}

html[lang='zh-CN'] {
  --font-body: Geist, Arial, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
}

html[lang='zh-CN'] :is(h1, h2, h3, .lp-title, .lp-eyebrow) {
  letter-spacing: normal;
}

.locale-select {
  position: relative;
  display: none;
}

html[data-locale-ready] .locale-select {
  display: inline-block;
}

.locale-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--locale-rule, var(--color-rule-strong));
  border-radius: 2px;
  background: transparent;
  color: var(--locale-ink, var(--color-ink));
  font: 500 15px / 1 var(--font-body);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-feedback) var(--ease-out);
}

.locale-button:hover,
.locale-button[aria-expanded='true'] {
  background: var(--locale-surface, var(--color-surface));
}

.locale-button:focus-visible {
  outline: 2px solid var(--locale-accent, var(--color-accent));
  outline-offset: 2px;
}

.locale-select svg {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.locale-globe {
  width: 18px;
  height: 18px;
  color: var(--locale-muted, var(--color-muted));
}

.locale-chevron {
  width: 16px;
  height: 16px;
  color: var(--locale-muted, var(--color-muted));
  transition: transform var(--dur-feedback) var(--ease-out);
}

.locale-button[aria-expanded='true'] .locale-chevron {
  transform: rotate(180deg);
}

.locale-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: max(100%, 184px);
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--locale-rule, var(--color-rule-strong));
  border-radius: 2px;
  background: var(--locale-panel, var(--color-surface));
  box-shadow: var(--locale-shadow, 0 12px 32px rgb(0 0 0 / 0.28));
}

.locale-menu[hidden] {
  display: none;
}

.locale-menu > li {
  margin: 0;
}

.locale-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 14px 0 10px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--locale-sub, var(--color-ink));
  font: 500 15px / 1 var(--font-body);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.locale-option:hover,
.locale-option:focus-visible {
  background: var(--locale-hover, var(--color-surface-raised));
  color: var(--locale-ink, var(--color-ink));
}

.locale-option:focus-visible {
  outline: 2px solid var(--locale-accent, var(--color-accent));
  outline-offset: -2px;
}

.locale-option[aria-checked='true'] {
  color: var(--locale-ink, var(--color-ink));
}

.locale-check {
  width: 16px;
  height: 16px;
  color: var(--locale-accent, var(--color-accent));
  visibility: hidden;
}

.locale-option[aria-checked='true'] .locale-check {
  visibility: visible;
}

.locale-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .locale-button,
  .locale-chevron {
    transition: none;
  }
}
