/* JJ Shim Site-Wide Bilingual (EN / KO) Toggle & Korean Typography */

/* Zero-FOUC reveal guard while Korean text swaps synchronously on boot */
html[data-jj-i18n-pending="1"] body {
  opacity: 0;
  animation: jj-i18n-failsafe 0s 1.2s forwards;
}
@keyframes jj-i18n-failsafe {
  to { opacity: 1; }
}

/* Keep nav links, theme icon, and E/K capsule aligned on one horizontal midline */
.nav ul,
.jj-site-header .jj-nav ul,
.jj-nav ul {
  align-items: center !important;
}

/* Capsule E/K language switcher */
.jj-lang {
  display: inline-flex !important;
  align-items: center !important;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

@media (min-width: 641px) {
  .theme + .jj-lang {
    margin-inline-start: -10px !important;
  }
}

.jj-lang-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-block-size: 26px;
  padding: 2px;
  border: 1px solid var(--line, var(--jj-line, #dcdcdc));
  border-radius: 999px;
  background: transparent;
  color: var(--mute, var(--muted, var(--jj-mute, #6b6b6b)));
  font-family: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.jj-lang-pill:hover {
  border-color: var(--ink, var(--jj-ink, #111111));
}

.jj-lang-pill:focus-visible {
  outline: 2px solid var(--signal, var(--jj-signal, #ff4a1c));
  outline-offset: 2px;
}

.jj-lang-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 21px;
  block-size: 20px;
  padding-inline: 5px;
  border-radius: 999px;
  color: var(--mute, var(--muted, var(--jj-mute, #6b6b6b)));
  background: transparent;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.jj-lang-opt.is-active {
  background: var(--ink, var(--jj-ink, #111111));
  color: var(--paper, var(--bg, #ffffff));
}

/* Dark theme explicit polish for pages that use dark prefers-color-scheme or data-theme */
html[data-theme="dark"] .jj-lang-pill {
  border-color: var(--line, #2a2a2a);
}
html[data-theme="dark"] .jj-lang-opt.is-active {
  background: #ffffff;
  color: #000000;
}
html[data-theme="light"] .jj-lang-opt.is-active {
  background: #111111;
  color: #ffffff;
}

/* Touch devices: larger accessible hit target */
@media (pointer: coarse) {
  .jj-lang-pill {
    min-block-size: 30px;
    padding: 3px;
  }
  .jj-lang-opt {
    min-inline-size: 24px;
    block-size: 22px;
    font-size: 11.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .jj-lang-pill,
  .jj-lang-opt {
    transition: none;
  }
}

@media (forced-colors: active) {
  .jj-lang-pill {
    border: 1px solid ButtonText;
  }
  .jj-lang-opt.is-active {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
}

/* Korean typography refinement when Korean mode is active */
html[data-lang="ko"] body {
  font-family: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", sans-serif;
  word-break: keep-all;
  overflow-wrap: break-word;
}

html[data-lang="ko"] .nav ul a,
html[data-lang="ko"] .jj-site-header ul a,
html[data-lang="ko"] .jj-nav ul a {
  word-break: keep-all;
  white-space: nowrap;
}

html[data-lang="ko"] .lede p {
  max-width: 30ch;
  line-height: 1.38;
}
