/*
 * BentoSort: the language menu in the header, and type for every script.
 *
 * Loaded after base.css by every page that has the language menu: the home, support and privacy
 * pages in all 59 languages (i18n/build.mjs adds the <link>). Not loaded by the Impressum and the
 * coming-soon page. Logical properties only, so right-to-left pages need no extra rules.
 */

/* =========================================================================
   Language menu: a <details> list, no JavaScript
   ========================================================================= */

.lang-switch { position: relative; }
.lang-switch summary {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.25rem 0; cursor: pointer; list-style: none; color: var(--ink);
}
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch summary::after {
    content: ""; inline-size: 0.4em; block-size: 0.4em; margin-inline-start: 0.1rem;
    border-inline-end: 2px solid currentColor; border-block-end: 2px solid currentColor;
    rotate: 45deg; translate: 0 -0.15em;
}
.lang-switch details[open] summary::after { rotate: 225deg; translate: 0 0.1em; }
.lang-switch summary:hover { color: var(--indigo); }
.lang-switch .globe { inline-size: 1.1em; block-size: 1.1em; fill: none; stroke: currentColor; stroke-width: 1.6; }

.site-nav .lang-switch ul {
    position: absolute; inset-inline-end: 0; inset-block-start: calc(100% + 0.4rem); z-index: 20;
    inline-size: min(34rem, calc(100vw - 2rem)); max-block-size: min(70vh, 30rem); overflow-y: auto;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.1rem 0.5rem;
    margin: 0; padding: 0.6rem; list-style: none;
    background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius);
    box-shadow: var(--card-shadow);
}
.site-nav .lang-switch li a { display: block; padding: 0.3rem 0.55rem; border-radius: 6px; color: var(--ink); text-decoration: none; }
.site-nav .lang-switch li a:hover { background: var(--rule); color: var(--indigo); text-decoration: none; }
.site-nav .lang-switch li a[aria-current] { font-weight: 700; color: var(--indigo); }

/* Narrow screens: the list opens across the whole header instead of beside the menu. */
@media (max-width: 48rem) {
    .site-header { position: relative; }
    .lang-switch { position: static; }
    .site-nav .lang-switch ul { inset-inline: 0; inline-size: auto; }
}

/* =========================================================================
   Type per script
   The Latin faces stay first, so "BentoSort", "macOS" and the like keep the site's look; the
   script's own face follows, so the browser does not pick a random fallback for the rest.
   ========================================================================= */

html:lang(ja) {
    --serif: ui-serif, "New York", Georgia, "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "Noto Serif JP", "Noto Serif CJK JP", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", "Noto Sans CJK JP", sans-serif;
}
html:lang(zh-Hans) {
    --serif: ui-serif, "New York", Georgia, "Songti SC", STSong, "Noto Serif SC", "Noto Serif CJK SC", SimSun, serif;
    --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif;
}
html:lang(zh-Hant) {
    --serif: ui-serif, "New York", Georgia, "Songti TC", "Noto Serif TC", "Noto Serif CJK TC", PMingLiU, serif;
    --sans: system-ui, -apple-system, "Segoe UI", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Noto Sans CJK TC", sans-serif;
}
html:lang(ko) {
    --serif: ui-serif, "New York", Georgia, AppleMyungjo, "Nanum Myeongjo", "Noto Serif KR", "Noto Serif CJK KR", Batang, serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", sans-serif;
}
html:lang(ar), html:lang(fa), html:lang(ur) {
    --serif: ui-serif, "New York", Georgia, "Noto Naskh Arabic", "Geeza Pro", "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
}
html:lang(he) {
    --serif: ui-serif, "New York", Georgia, "New Peninim MT", "Noto Serif Hebrew", "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Arial Hebrew", "Noto Sans Hebrew", Arial, sans-serif;
}
html:lang(hi), html:lang(mr) {
    --serif: ui-serif, "New York", Georgia, "ITF Devanagari", "Devanagari Sangam MN", "Noto Serif Devanagari", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Kohinoor Devanagari", "Noto Sans Devanagari", "Nirmala UI", sans-serif;
}
html:lang(bn) {
    --serif: ui-serif, "New York", Georgia, "Bangla MN", "Noto Serif Bengali", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Kohinoor Bangla", "Bangla Sangam MN", "Noto Sans Bengali", "Nirmala UI", sans-serif;
}
html:lang(pa) {
    --serif: ui-serif, "New York", Georgia, "Gurmukhi MN", "Noto Serif Gurmukhi", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Gurmukhi Sangam MN", "Mukta Mahee", "Noto Sans Gurmukhi", "Nirmala UI", sans-serif;
}
html:lang(gu) {
    --serif: ui-serif, "New York", Georgia, "Gujarati MT", "Noto Serif Gujarati", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Kohinoor Gujarati", "Gujarati Sangam MN", "Noto Sans Gujarati", "Nirmala UI", sans-serif;
}
html:lang(or) {
    --serif: ui-serif, "New York", Georgia, "Oriya MN", "Noto Serif Oriya", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Oriya Sangam MN", "Noto Sans Oriya", Kalinga, "Nirmala UI", sans-serif;
}
html:lang(ta) {
    --serif: ui-serif, "New York", Georgia, "Tamil MN", "Noto Serif Tamil", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Tamil Sangam MN", InaiMathi, "Noto Sans Tamil", "Nirmala UI", sans-serif;
}
html:lang(te) {
    --serif: ui-serif, "New York", Georgia, "Telugu MN", "Noto Serif Telugu", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Kohinoor Telugu", "Telugu Sangam MN", "Noto Sans Telugu", "Nirmala UI", sans-serif;
}
html:lang(kn) {
    --serif: ui-serif, "New York", Georgia, "Kannada MN", "Noto Serif Kannada", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Kannada Sangam MN", "Noto Sans Kannada", Tunga, "Nirmala UI", sans-serif;
}
html:lang(ml) {
    --serif: ui-serif, "New York", Georgia, "Malayalam MN", "Noto Serif Malayalam", serif;
    --sans: system-ui, -apple-system, "Segoe UI", "Malayalam Sangam MN", "Noto Sans Malayalam", Kartika, "Nirmala UI", sans-serif;
}
html:lang(th) {
    --serif: ui-serif, "New York", Georgia, "Noto Serif Thai", Thonburi, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Thonburi, "Sukhumvit Set", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
}

/* Scripts without italics or letter case: no slanted kicker or emphasis (a browser would fake the
   slant), no tightened headings (tracking breaks joined Arabic letters). */
html:is(:lang(ja), :lang(zh), :lang(ko), :lang(ar), :lang(fa), :lang(ur), :lang(he), :lang(hi), :lang(mr), :lang(bn),
        :lang(pa), :lang(gu), :lang(or), :lang(ta), :lang(te), :lang(kn), :lang(ml), :lang(th)) :is(.kicker, em) {
    font-style: normal;
}
html:is(:lang(ja), :lang(zh), :lang(ko), :lang(ar), :lang(fa), :lang(ur), :lang(he), :lang(hi), :lang(mr), :lang(bn),
        :lang(pa), :lang(gu), :lang(or), :lang(ta), :lang(te), :lang(kn), :lang(ml), :lang(th)) em {
    font-weight: 600;
}
html:is(:lang(ja), :lang(zh), :lang(ko), :lang(ar), :lang(fa), :lang(ur), :lang(he), :lang(hi), :lang(mr), :lang(bn),
        :lang(pa), :lang(gu), :lang(or), :lang(ta), :lang(te), :lang(kn), :lang(ml), :lang(th)) h1 {
    letter-spacing: normal;
}

/* Tall scripts and stacked marks need more room between lines. */
html:is(:lang(hi), :lang(mr), :lang(bn), :lang(pa), :lang(gu), :lang(or), :lang(ta), :lang(te), :lang(kn),
        :lang(ml), :lang(th), :lang(ar), :lang(fa), :lang(ur), :lang(vi)) body {
    line-height: 1.75;
}
html:is(:lang(hi), :lang(mr), :lang(bn), :lang(pa), :lang(gu), :lang(or), :lang(ta), :lang(te), :lang(kn),
        :lang(ml), :lang(th), :lang(ar), :lang(fa), :lang(ur), :lang(vi)) :is(h1, h2, h3) {
    line-height: 1.35;
}
html:lang(ur) body { line-height: 1.9; }

/* Japanese headings break between phrases where the browser can (Chrome), not inside words. */
html:lang(ja) :is(h1, h2, h3) { word-break: auto-phrase; }

/* Long words (Russian "конфиденциальности", German compounds) break or hyphenate in narrow
   headings instead of running off the page. */
:is(h1, h2, h3) { overflow-wrap: break-word; hyphens: auto; }

/* Right-to-left pages: file and folder names (<code>) and the build's left-to-right runs (keys,
   date folders with their path, i18n/lib/render.mjs) read left to right as one piece and never
   break inside; without this "2026-10-14" wrapped as "–2026-10" and "14". */
[dir="rtl"] code { direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
[dir="rtl"] span[dir="ltr"] { white-space: nowrap; }
