/* =============================================================================
   global-header.css — 全站设计 Token、基础字体与页头（含语言切换）的唯一样式来源（手工维护）

   使用者：全站所有页面（内容页、导航首页、分类目录、反馈页、根页 /、404 / 50x），并且是每页加载的
   第一张样式表：内容页 global-header → site → [form] → global-footer；导航首页 global-header →
   navigation → home-directory → global-footer → …；分类目录 global-header → navigation →
   navigation-category → global-footer；反馈页 … → feedback。

   规则（2026-11-22 统一，站主决定全站页头统一为导航页头）：
   1. 设计 Token 只在本文件定义一次；其他样式表只用 var(--…) 引用，不得再定义同类颜色变量，
      组件确需别名时写成 var(--全站 Token)。
   2. 页头只有一种结构，所有页面类型、所有语言相同：
        header.topbar > .topbar-inner > .brand（导航首页为 div，其余页面为指向 / 的 a）
                                                > .brand-mark + .brand-text > .brand-name + .brand-tagline
                                      > .top-links > 语言切换 [data-language-switcher]
                      [> nav.topbar-nav > a …]   内容页的栏目链接（导航页没有这一行）
      其他样式表不得再写 .topbar / .brand / .ls-* 规则（assets:check 检查）。
   3. 页头文字继承页面基础字体（下面第 2 节），其余文字属性显式声明，不受正文排版影响。
   4. 品牌色 #A61E4D（--accent-dark）用于 Logo 描述文字与搜索按钮默认文字，不得恢复旧颜色。
   ============================================================================= */

/* ---------------------------------------------------------------- 1. 设计 Token */
:root {
    /* 品牌色 */
    --accent: #d6336c;          /* 主色：主按钮、强调、选中 */
    --accent-dark: #a61e4d;     /* 品牌深色 #A61E4D：Logo 描述文字、搜索按钮文字、强调文字 */
    --accent-strong: #c0265a;   /* 表单主按钮、语言菜单选中、焦点描边 */
    --accent-deep: #8f1642;     /* 表单链接与按钮的深色、悬停 */
    --accent-bright: #ff4081;   /* 渐变按钮的亮端 */
    --hot: #ff1744;             /* 悬停与选中的高亮红 */
    --soft-hot: #fff1f6;        /* 高亮浅底 */
    /* 中性色 */
    --page: #f6f7fb;            /* 页面底色 */
    --surface: #ffffff;         /* 卡片、面板底色 */
    --surface-muted: #fff4f8;   /* 粉色浅底：提示、答案框、表头 */
    --ink: #17212b;             /* 正文主色 */
    --text: #4b5563;            /* 次级正文 */
    --muted: #5b6876;           /* 辅助文字 */
    --border: #e5e7eb;          /* 中性边框 */
    --line: #dddddd;            /* 导航首页分隔线与输入框边框 */
    --line-soft: #f2dbe3;       /* 粉色细边框：卡片、目录、正文块 */
    --focus: #2563eb;           /* 表单输入焦点 */
    --success: #176b45;
    --success-bg: #ecfdf3;
    --error: #9f1d2f;
    --error-bg: #fff1f2;
    /* 形状与布局 */
    --shadow: 0 10px 24px rgba(214, 51, 108, 0.12);
    --max: 1160px;              /* 页头、导航页与页脚的内容宽度 */
}

/* ---------------------------------------------------------------- 2. 基础字体
   以简中导航首页为基准。system-ui 解析成什么取决于访客的系统语言而不是页面语言（中文 Windows 上会用
   微软雅黑画西里尔字母和日文汉字），所以俄、日、韩、繁中逐平台点名字体（2026-09-30 导航首页实测结论）。
   内容页的文字系统补充（印度系文字、繁中网络字体等）在 content.css 第 4 节，同特异性、后加载。 */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, "Microsoft YaHei", sans-serif;
}
body:lang(ru) {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
}
body:lang(ja) {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial,
        "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo,
        "Noto Sans JP", sans-serif;
}
body:lang(ko) {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial,
        "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}
body:lang(zh-Hant) {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial,
        "PingFang TC", "Microsoft JhengHei UI", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
}

/* ---------------------------------------------------------------- 3. 页头 header.topbar */
.topbar {
    background: var(--page);
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    box-sizing: border-box;
    width: min(var(--max), calc(100% - 40px));
    min-height: 64px;
    margin: 0 auto;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: max-content;
    color: #3a2f2a;
    text-decoration: none;
}
.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: transparent;
    font-size: 0;
    font-weight: 800;
    border-radius: 10px;
    background: url("/assets/images/logo.png") center / contain no-repeat;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .18);
}
.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.brand-name {
    font-size: 18px;
    font-weight: 545;
    line-height: 1.1;
    letter-spacing: normal;
}
.brand-tagline {
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 545;
    line-height: 1.1;
    letter-spacing: normal;
}
.top-links {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
}
/* 内容页的栏目链接：页头下方居中一行；手机上改为一行横向滚动。 */
.topbar-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 28px;
    box-sizing: border-box;
    width: min(var(--max), calc(100% - 40px));
    margin: 0 auto;
    padding: 4px 0 14px;
}
.topbar .topbar-nav a {
    padding: .2rem .5rem;
    border: 1px solid #aca4ac;
    border-radius: 5px;
    background: #fff;
    color: #222;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.7;
    letter-spacing: normal;
    text-decoration: none;
}
.topbar .topbar-nav a:hover,
.topbar .topbar-nav a.active,
.topbar .topbar-nav a[aria-current="page"] {
    border-color: var(--hot);
    box-shadow: 0 4px 10px rgba(214, 51, 108, .18), 0 1px 2px rgba(0, 0, 0, .06);
    color: var(--hot);
}
.topbar a:focus-visible,
.topbar button:focus-visible {
    outline: 3px solid rgba(214, 51, 108, .28);
    outline-offset: 3px;
}
@media (max-width: 640px) {
    .topbar-inner {
        width: min(100% - 28px, var(--max));
        min-height: 58px;
    }
    .brand {
        gap: 8px;
        min-width: 0;
    }
    .brand-text {
        min-width: 0;
    }
    .brand-mark {
        flex-shrink: 0;
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }
    .brand-name {
        font-size: 16px;
    }
    .brand-tagline {
        font-size: 11px;
    }
    .top-links {
        flex-shrink: 0;
        gap: 6px;
        font-size: 12px;
    }
    .topbar-nav {
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 8px;
        width: 100%;
        padding: 2px 14px 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .topbar .topbar-nav a {
        flex-shrink: 0;
        padding: .25rem .45rem;
        font-size: .75rem;
        white-space: nowrap;
    }
}

/* ---------------------------------------------------------------- 4. 语言切换 [data-language-switcher]
   原 language-switcher.css（2026-11-22 并入）。菜单与每一行固定为 LTR，只有 .ls-label 可以按语言改为 rtl，
   靠 unicode-bidi: isolate 隔离双向文字。 */
[data-language-switcher] {
    position: relative;
    min-width: max-content;
    font-family: inherit;
}
[data-language-switcher].is-busy .ls-button {
    opacity: 0.6;
    cursor: wait;
}
.ls-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 5px 10px;
    border: 1px solid rgba(150, 150, 150, 0.45);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.6);
    color: #1f2633;
    font: inherit;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    /* 按钮本身固定 LTR：当前语言是阿拉伯语时下拉箭头仍在右侧。 */
    direction: ltr;
}
/* 原生 details 让静态导航在脚本加载前也能用；隐藏浏览器自带的三角标记。 */
summary.ls-button {
    list-style: none;
}
summary.ls-button::-webkit-details-marker {
    display: none;
}
.ls-button:hover,
.ls-button:focus-visible {
    border-color: #1f2633;
    color: #1f2633;
    outline: none;
}
.ls-button:focus-visible {
    box-shadow: 0 0 0 2px rgba(192, 38, 90, 0.35);
}
.ls-current {
    font-weight: 400;
    unicode-bidi: isolate;
}
.ls-caret {
    font-size: 22px;
    line-height: 0.8;
    opacity: 0.7;
}
[data-language-switcher].is-open .ls-caret,
details[data-language-switcher][open] .ls-caret {
    transform: rotate(180deg);
}
.ls-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-end: 0;
    z-index: 50;
    min-width: 200px;
    max-width: min(280px, calc(100vw - 24px));
    max-height: min(420px, 60vh);
    margin: 0;
    padding: 6px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    list-style: none;
    border: 1px solid rgba(150, 150, 150, 0.45);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(16, 24, 40, 0.16);
    direction: ltr;
    text-align: left;
}
[data-language-switcher].is-open .ls-menu,
details[data-language-switcher][open] .ls-menu {
    display: block;
}
.ls-menu li {
    margin: 0;
    list-style: none;
}
.ls-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    padding: 8px 10px;
    border-radius: 4px;
    color: #1f2633;
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
    text-decoration: none;
    direction: ltr;
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
}
.ls-link:hover,
.ls-link:focus-visible {
    background: #fdeaf1;
    color: var(--accent-strong);
    outline: none;
}
.ls-menu li[aria-current="true"] .ls-link {
    background: #fdeaf1;
    color: var(--accent-strong);
    font-weight: 600;
}
.ls-label {
    display: inline-block;
    max-width: 100%;
    unicode-bidi: isolate;
}
.ls-label[dir="rtl"] {
    direction: rtl;
}
@media (max-width: 768px) {
    /* 窄屏上语言切换先让位：最小 72px，过长的当前语言名省略，品牌副标题保持一行。
       flex-shrink 取极大值，让按权重收缩时品牌几乎不分担（详见 2026-11-21 前 language-switcher.css 注释）。 */
    [data-language-switcher] {
        min-width: 72px;
        flex-shrink: 1000000;
    }
    .ls-button {
        max-width: 100%;
        min-height: 30px;
        padding: 4px 8px;
        font-size: 12px;
    }
    .ls-current {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .ls-caret {
        flex-shrink: 0;
    }
    .ls-menu {
        inset-inline-end: 0;
        inset-inline-start: auto;
        max-height: min(70vh, 480px);
    }
    .ls-link {
        min-height: 40px;
        padding: 10px 12px;
        font-size: 14px;
        line-height: 1.4;
    }
}
/* RTL 页面：菜单改从另一侧展开，避免超出屏幕；菜单内部仍是 LTR。 */
html[dir="rtl"] .ls-menu {
    inset-inline-end: auto;
    inset-inline-start: 0;
}

/* ---------------------------------------------------------------- 5. 跳转到正文
   原 skip-link / es-skip / pt-skip / business-skip-link 与表单页自带的四套实现合一，获得焦点前隐藏。 */
.skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1000;
    padding: 10px 14px;
    border: 2px solid var(--accent-dark);
    border-radius: 8px;
    background: #fff;
    color: var(--accent-dark);
    text-decoration: none;
    transform: translateY(-200%);
}
.skip-link:focus {
    transform: none;
}

/* ---------------------------------------------------------------- 6. hidden 属性
   HTML 的 hidden 属性必须始终隐藏元素：组件规则给元素设了 display 时，单靠浏览器默认样式会失效。
   这是全站唯一的 [hidden] 兜底（原 form.css、home-directory.css、navigation-category.css、feedback.css、
   site.css 各有一份），也是 !important 的少数例外之一（其余见 form.css 的减少动效、home-directory.css 的快捷入口标签）。 */
[hidden] {
    display: none !important;
}
