/* Lumore i18n: language switcher, fonts per script and right-to-left fixes.
   Added by scripts/i18n_core.py to every page that exists in more than one language (and to every non-English page).
   Base styles use logical properties (margin-inline-start, text-align:start...), so most of the layout mirrors by itself. */

/* ---------- Fonts per script ----------
   M PLUS Rounded 1c (headings) covers Latin, Cyrillic, Hebrew and Japanese. Inter (body) covers Latin and Cyrillic.
   Other scripts fall back to a Noto font that the page loads only for that language (see "fonts" in i18n/<lang>.json). */
html:lang(ja) { --head: "M PLUS Rounded 1c", "Noto Sans JP", system-ui, sans-serif; --body: Inter, "Noto Sans JP", system-ui, sans-serif; }
html:lang(ko) { --head: "M PLUS Rounded 1c", "Noto Sans KR", system-ui, sans-serif; --body: Inter, "Noto Sans KR", system-ui, sans-serif; }
html:lang(he) { --head: "M PLUS Rounded 1c", "Noto Sans Hebrew", system-ui, sans-serif; --body: "Noto Sans Hebrew", Inter, system-ui, sans-serif; }
html:lang(ja) body { line-break: strict; }
html:lang(ko) body { word-break: keep-all; overflow-wrap: anywhere; }
/* Hebrew and CJK are not letter-spaced or upper-cased. */
html:lang(he) body *, html:lang(ja) body *, html:lang(ko) body * { letter-spacing: normal !important; }

/* ---------- Language switcher (header) ---------- */
.lang-switch { position: relative; display: inline-block; flex: none; margin-inline-start: 6px; font: 500 14px/1 var(--body); }
.lang-switch summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px;
  border-radius: 999px; color: var(--muted, #B8A9C4); border: 1px solid rgba(255, 255, 255, .12); background: rgba(20, 15, 28, .35); }
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch svg, .lang-foot svg { flex: none; width: 18px; height: 18px; }
.lang-switch summary:hover, .lang-switch[open] summary { color: var(--text, #F6F0F4); background: rgba(255, 255, 255, .08); }
.lang-switch summary:focus-visible { outline: 2px solid var(--sakura, #F2A7C3); outline-offset: 2px; }
.lang-switch ul { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); z-index: 200; min-width: 168px; margin: 0; padding: 6px; list-style: none;
  background: #271F33; border: 1px solid rgba(255, 255, 255, .14); border-radius: 16px; box-shadow: 0 18px 40px rgba(0, 0, 0, .45); }
.lang-switch li { margin: 0; padding: 0; }
.lang-switch li::before { content: none !important; }
.lang-switch a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--text, #F6F0F4); text-decoration: none; font-size: 15px; text-align: start; }
.lang-switch a:hover, .lang-switch a:focus-visible { background: rgba(255, 255, 255, .08); }
.lang-switch a[aria-current] { color: var(--sakura, #F2A7C3); }
@media (max-width: 560px) {
  .lang-switch summary span { display: none; }
  .lang-switch summary { padding: 0 8px; min-height: 36px; }
  .lang-switch { margin-inline-start: 0; }
  .nav:has(.lang-switch), .t-nav:has(.lang-switch), .site-nav:has(.lang-switch) { gap: 10px; }
  html:lang(en) .nav .btn, html:lang(en) .site-nav .btn { white-space: nowrap; }
}

/* ---------- Language list (footer) ---------- */
.lang-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; width: 100%; color: var(--muted, #B8A9C4); font-size: 14px; }
.lang-foot ul { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; }
.lang-foot li { margin: 0; padding: 0; }
.lang-foot li::before { content: none !important; }
.lang-foot a { color: inherit; text-decoration: none; }
.lang-foot a:hover { color: var(--text, #F6F0F4); }
.lang-foot a[aria-current] { color: var(--text, #F6F0F4); font-weight: 600; }

/* ---------- Right-to-left ---------- */
/* Times, clocks and scores read left to right inside RTL text ("3:00 / 3:00" must not flip). */
[dir=rtl] .tm-digits, [dir=rtl] .clock, [dir=rtl] #t-clock, [dir=rtl] .hud .time, [dir=rtl] .bd-clock, [dir=rtl] .r-big,
[dir=rtl] .res-big strong, [dir=rtl] #wp-dims, [dir=rtl] .cd-tile b, [dir=rtl] .tm-code, [dir=rtl] .kbd { direction: ltr; unicode-bidi: isolate; }
/* App screen mock-ups, dials, rings and the fake lock screen keep their own layout (they picture real devices). */
[dir=rtl] .parade, [dir=rtl] .feature-media .iphone, [dir=rtl] .tm-dial, [dir=rtl] .ring, [dir=rtl] .lock, [dir=rtl] .desk-ui, [dir=rtl] .guides { direction: ltr; }
/* Controls that show a direction */
[dir=rtl] .select { background-position: left 14px center; }
[dir=rtl] .toggle-ui::after { left: auto; right: 3px; }
[dir=rtl] .toggle input:checked + .toggle-ui::after { transform: translateX(-18px); }
[dir=rtl] .range::-webkit-slider-runnable-track { background: linear-gradient(270deg, var(--sakura) var(--v), rgba(255, 255, 255, .12) var(--v)); }
[dir=rtl] .bar, [dir=rtl] .tm-bar i { transform-origin: 100% 50%; }
[dir=rtl] .faq summary { padding-left: 40px; padding-right: 0; }
[dir=rtl] .prose blockquote { padding: 4px 20px 4px 0; }
[dir=rtl] .sticky-cta { padding: 10px 12px 10px 10px; }
[dir=rtl] .chip small { margin-left: 0; margin-right: 4px; }
/* User-typed text keeps its own direction (also set with dir="auto" on inputs). */
[dir=rtl] input[type=date], [dir=rtl] input[type=time], [dir=rtl] input[type=number] { direction: ltr; text-align: end; }

/* ---------- Longer translations ----------
   Other languages often run 20–40% longer than English: let single-column tool layouts shrink to the screen
   and let buttons wrap instead of pushing cards past the edge on phones. */
@media (max-width: 959.98px) {
  html:not(:lang(en)) .timer-wrap, html:not(:lang(en)) .noise-wrap, html:not(:lang(en)) .daruma-wrap,
  html:not(:lang(en)) .bd-layout, html:not(:lang(en)) .game-layout, html:not(:lang(en)) .wp-layout { grid-template-columns: minmax(0, 1fr); }
}
html:not(:lang(en)) .btn, html:not(:lang(en)) .chip { white-space: normal; text-align: center; }
html:not(:lang(en)) .sumi { width: auto; }
/* In right-to-left pages, decorative overflow (glows, the off-screen skip link) would otherwise make phones zoom out. */
html[dir=rtl] { overflow-x: hidden; }
@supports (overflow: clip) { html[dir=rtl] { overflow-x: clip; } }

/* CJK scripts have no true italics: show emphasis with weight instead of a fake slant. */
:lang(ja) em, :lang(ko) em, :lang(ja) i, :lang(ko) i { font-style: normal; font-weight: 700; }
