/* Language switcher, loaded on every page. Sits outside the nav pill so it never moves it. */
.lang-switch {
  position: fixed;
  top: 22px;
  right: var(--pad-x);
  z-index: 60;
}
.lang-switch-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 14px 0 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  color: rgba(242, 240, 230, 0.8);
  background: rgba(31, 31, 31, 0.34);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid #333;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.lang-switch-toggle:hover,
.lang-switch[data-open="true"] .lang-switch-toggle { color: var(--text); border-color: #4a4a4a; }
.lang-switch-toggle:focus-visible,
.lang-switch-menu a:focus-visible,
.lang-suggest a:focus-visible,
.lang-suggest button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lang-switch-toggle svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}
.lang-switch-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 164px;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: rgba(19, 19, 19, 0.94);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid #333;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0.2s;
}
.lang-switch[data-open="true"] .lang-switch-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.lang-switch-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  color: rgba(242, 240, 230, 0.8);
  border-radius: 12px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.lang-switch-menu a:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.lang-switch-menu a[aria-current="true"] { color: var(--accent); }
.lang-switch-menu a[aria-current="true"]::after { content: '✓'; font-size: 13px; }

/* First-visit suggestion, anchored to the switcher and floating over the page. */
.lang-suggest {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 4px 4px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  color: #121212;
  background: var(--text);
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
}
.lang-suggest a::after { content: ' →'; }
.lang-suggest button {
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
  color: rgba(18, 18, 18, 0.6);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.lang-suggest button:hover { color: #121212; }

@media (max-width: 880px) {
  /* Lines up inside the mobile nav pill, immediately left of the burger. */
  .lang-switch {
    top: 23px;
    right: calc(var(--pad-x) + 49px);
  }
  .lang-switch-toggle {
    height: 36px;
    padding: 0 8px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-color: transparent;
  }
  .lang-switch[data-open="true"] .lang-switch-toggle { border-color: transparent; }
  .lang-switch-menu,
  .lang-suggest { right: -41px; }
}

/* Legal pages have a plain header row, so the switcher sits in it. */
.legal-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.legal-page .lang-switch {
  position: relative;
  top: auto;
  right: auto;
  z-index: 5;
}
.legal-page .lang-switch-toggle {
  height: 40px;
  padding: 0 14px 0 12px;
  background: rgba(31, 31, 31, 0.34);
  border-color: #333;
}
.legal-page .lang-switch-menu,
.legal-page .lang-suggest { right: 0; }

@media (prefers-reduced-motion: reduce) {
  .lang-switch-menu,
  .lang-switch-toggle { transition: none; }
}

/* ---------- Fonts per language ---------- */
/* Inter, Caprasimo and Caveat stay first, so "Golfr", numbers and any Latin words keep the brand
   look. The Noto fonts only supply the characters those fonts don't have. */
html:lang(zh-Hant) {
  --font-accent: 'Caprasimo', 'Noto Serif TC', 'Songti TC', serif;
  --font-hand: 'Caveat', 'LXGW WenKai TC', 'Noto Sans TC', cursive;
}
html:lang(ja) {
  --font-accent: 'Caprasimo', 'Noto Serif JP', 'Hiragino Mincho ProN', serif;
  --font-hand: 'Caveat', 'Klee One', 'Noto Sans JP', cursive;
}
html:lang(ko) {
  --font-accent: 'Caprasimo', 'Noto Serif KR', 'AppleMyungjo', serif;
  --font-hand: 'Caveat', 'Gaegu', 'Noto Sans KR', cursive;
}
html:lang(zh-Hant), html:lang(zh-Hant) body {
  font-family: 'Inter', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', -apple-system, BlinkMacSystemFont, sans-serif;
}
html:lang(ja), html:lang(ja) body {
  font-family: 'Inter', 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', -apple-system, BlinkMacSystemFont, sans-serif;
}
html:lang(ko), html:lang(ko) body {
  font-family: 'Inter', 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, sans-serif;
}
html:is(:lang(zh-Hant), :lang(ja), :lang(ko)) :is(.scorecard-pencil, .scorecard-rules-label) {
  font-family: var(--font-hand);
}

/* ---------- Chinese, Japanese and Korean text ---------- */
html:is(:lang(zh-Hant), :lang(ja), :lang(ko)) { font-synthesis: none; }
/* Wide tracking and tight line-height are tuned for Latin capitals and clip or scatter these scripts. */
html:is(:lang(zh-Hant), :lang(ja), :lang(ko)) body * { letter-spacing: normal; }
html:is(:lang(zh-Hant), :lang(ja), :lang(ko)) em { font-style: normal; }
html:is(:lang(zh-Hant), :lang(ja)) body { line-break: strict; }
html:lang(ko) body { word-break: keep-all; }

/* Longer translated labels must not wrap inside a pill button. */
html:not(:lang(en)) :is(.mini-navbar-cta, .btn-label) { white-space: nowrap; }

/* No lone word or character left on a line. */
html:not(:lang(en)) :is(.story-headline, .proof-title, .proof-label, .tripod-links-title, .scorecard-stamp) { text-wrap: balance; }
html:not(:lang(en)) :is(.proof-sub, .waitlist-sub, .scorecard-rules p, .legal-intro) { text-wrap: pretty; }

/* An accent phrase stays whole: it moves to the next line instead of splitting in the middle. */
html:not(:lang(en)) :is(.tripod-links-title em, .site-footer-tagline em) { display: inline-block; }

/* A stat word must not split inside a word, as ツアー or 巡迴賽 would. Chinese marks its one
   allowed break with a zero-width space (&#8203;) in the translation. */
html:not(:lang(en)) .proof-stat--text { word-break: keep-all; }
html:is(:lang(zh-Hant), :lang(ja)) .proof-stat--text { --stat-size: clamp(34px, 4.6vw, 60px); --stat-word: 4.1; line-height: 1.24; }
html:lang(es) .proof-stat--text { --stat-word: 2.6; }

/* These Chinese lines wrap only at spaces and the zero-width spaces placed after their
   punctuation, so a phrase like 說不傳就不傳 never splits. A phrase too long for the
   line can still break anywhere rather than overflow. Plain wrapping keeps 裡。 with
   iPhone, which text-wrap: pretty would move down to lengthen the last line. */
html:lang(zh-Hant) :is(.story-points li, .scorecard-rules p) { word-break: keep-all; overflow-wrap: anywhere; text-wrap: wrap; }

/* The signup headline's first line has to fit on one row. */
html:is(:lang(zh-Hant), :lang(ja), :lang(ko)) .waitlist-title { font-size: min(10.8vw, max(44px, 5.8vw), 72px); line-height: 1.16; }
html:lang(es) .waitlist-title { font-size: min(10.6vw, max(44px, 6.4vw), 80px); }

/* ---------- Hero headline ---------- */
/* The characters animate one by one and each is its own box, so a wrapped line could split inside
   a word. Each line stays on one row and is sized to fit the screen. */
html:not(:lang(en)) .hero-title {
  max-width: none;
}
html:not(:lang(en)) .hero-title-main {
  display: block;
  white-space: nowrap;
}
html:lang(zh-Hant) .hero-title { font-size: min(11.8vw, max(54px, 8vw), 104px); line-height: 1.12; }
html:lang(zh-Hant) .hero-title-italic { font-size: min(11.2vw, max(50px, 7.2vw), 92px); margin-top: 6px; }
html:lang(ja) .hero-title { font-size: min(7.2vw, 84px); line-height: 1.16; }
html:lang(ja) .hero-title-italic { font-size: min(11.4vw, max(52px, 7.6vw), 96px); margin-top: 8px; }
html:lang(ko) .hero-title { font-size: min(10.2vw, max(54px, 8vw), 96px); line-height: 1.14; }
html:lang(ko) .hero-title-italic { font-size: min(11vw, max(50px, 7.2vw), 92px); margin-top: 6px; }
html:lang(es) .hero-title { font-size: min(8.6vw, 92px); line-height: 1.02; }
html:lang(es) .hero-title-italic { font-size: min(8.2vw, 84px); }
