/* ── Languages (plan 2026-11-06-multilingual-ui, Task 0.9, D14) ────────────
   Loaded from 'self' by the layouts only while more than one language is
   offered, so an English-only deployment never fetches it. Every typography
   rule is scoped by :lang(), so an English page renders exactly as before;
   the rest styles the language dropdown (components/language_picker.html),
   which exists only when there is a choice to make.

   :lang(zh-Hans) also matches zh-Hans-CN; :lang(ko) matches ko-KR. <html
   lang> carries the negotiated language (D15), and every element inherits it.
   ────────────────────────────────────────────────────────────────────────── */

/* Simplified Chinese and Korean: the system's own CJK fonts first (macOS,
   Windows, then Noto where it is installed). Inter stays first so digits and
   Latin data keep today's shapes; it has no CJK glyphs, so the browser takes
   those from the next family. Noto from Google Fonts is the last fallback,
   linked by base.html on a zh-Hans or ko page only; no CJK webfont is
   preloaded. */
:root:lang(zh-Hans) {
    --font-sans: 'Inter', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC',
                 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas,
                 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', monospace;
}
:root:lang(ko) {
    --font-sans: 'Inter', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR',
                 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas,
                 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', monospace;
}

/* Taller lines (+0.1 on the body's 1.5): CJK glyphs fill the em box. */
:root:lang(zh-Hans) body,
:root:lang(ko) body {
    line-height: 1.6;
}

/* No tracking and no case transform: CJK has no letter case, and tracking
   built for Latin capitals pulls ideographs apart. !important because the
   rules they undo sit in every page's own stylesheet, loaded after this one. */
:root:lang(zh-Hans) *,
:root:lang(ko) * {
    letter-spacing: normal !important;
    text-transform: none !important;
}

/* Korean breaks between words, not inside them; a word too long for its box
   still wraps rather than overflowing. */
:root:lang(ko) body {
    word-break: keep-all;
    overflow-wrap: break-word;
}

/* ── The dropdown ─────────────────────────────────────────────────────── */

.u360-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.language-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.language-picker[hidden] { display: none; }

/* The header and signed-out pages: a pill the height of the theme toggle,
   a globe for the person who cannot read the language the page is in. */
.language-picker__icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--text-secondary, #374151);
    pointer-events: none;
}
.language-picker--header .language-picker__select,
.language-picker--auth .language-picker__select,
.language-picker--landing .language-picker__select {
    appearance: none;
    -webkit-appearance: none;
    height: 36px;
    max-width: 11rem;
    padding: 0 30px 0 32px;
    border: 1px solid var(--border-default, #E5E7EB);
    border-radius: var(--radius-full, 999px);
    background-color: var(--bg-elevated, #fff);
    /* a chevron drawn in CSS (no image request, no inline SVG data) */
    background-image:
        linear-gradient(45deg, transparent 50%, currentColor 50%),
        linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    color: var(--text-secondary, #374151);
    font: inherit;
    font-size: var(--text-sm, 0.875rem);
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-fast, 150ms ease),
                color var(--transition-fast, 150ms ease),
                border-color var(--transition-fast, 150ms ease);
}
.language-picker--header .language-picker__select:hover,
.language-picker--auth .language-picker__select:hover,
.language-picker--landing .language-picker__select:hover {
    background-color: var(--bg-hover, #E5E7EB);
    color: var(--text-primary, #111827);
    border-color: var(--border-hover, #D1D5DB);
}
.language-picker__select:focus-visible {
    outline: none;
    box-shadow: var(--shadow-glow, 0 0 0 3px rgba(76, 175, 80, 0.4));
}
.language-picker__select:disabled { cursor: progress; opacity: 0.7; }
.language-picker__select option { color: var(--text-primary, #111827); background: var(--bg-primary, #fff); }

/* Settings: a row of the Appearance card, beside the theme control. */
.language-picker.language-picker--settings {
    display: flex;
    margin-top: var(--space-4, 1rem);
}
.language-picker--settings .language-picker__select {
    width: auto;
    min-width: 12rem;
    max-width: 100%;
}

/* Signed-out pages: top right of the screen, clear of the card. */
.language-picker--auth {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
}
.language-picker--landing { margin-right: 8px; }

@media (max-width: 480px) {
    .language-picker--header .language-picker__select { max-width: 8.5rem; }
}
