/* ============================================================
   PWA 安装按钮 + iOS 引导弹窗
   全平台：Android / iOS / Windows / macOS
   ============================================================ */

/* ============================================================
   移动端 header（<768px 显示）
   布局：Logo | 🔍搜索 | PWA 按钮 | ☰菜单
   ============================================================ */
#m-header {
    display: none;   /* 默认隐藏，桌面不显示 */
    position: fixed;     /* 固定顶部，不随页面滚动 */
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: #0d0d1a;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    height: 54px;
}
.m-header-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 12px;
    gap: 8px;
    width: 100%;
}
/* 弹性占位元素：吃掉 logo 和右侧之间的所有空间，把右侧推到边缘 */
.m-header-spacer {
    flex: 1 1 auto;
    min-width: 0;
}
.m-header-logo {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
}
.m-header-logo img {
    height: 26px;
    display: block;
}
.m-header-ico {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 0;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    transition: background .15s ease;
}
.m-header-ico:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.m-header-ico:active { background: rgba(255, 255, 255, .2); }
.m-header-search i { font-size: 17px; line-height: 1; }
/* 汉堡三横按钮：用 span.m-header-bars 做容器，自己画三条线
   （不依赖 .nav-toggle i 已有的 ::before/::after，避免被覆盖只显示一条） */
.m-header-menu { position: relative; top:0;left:0}
.m-header-bars,
.m-header-bars::before,
.m-header-bars::after {
    position: absolute;
    left: 50%;
    width: 18px;
    height: 2px;
    background: #fff;
    transform: translateX(-50%);
    transition: all .25s ease;
    border-radius: 1px;
}
.m-header-bars { top: 50%; margin-top: -1px; }
.m-header-bars::before { content: ''; top: -7px; left: 0; transform: none; }
.m-header-bars::after  { content: ''; top:  7px; left: 0; transform: none; }

/* 打开状态（mobile.js 给 .nav-toggle 加 .cur）：横线变 X */
.nav-toggle.cur .m-header-bars { background: transparent; }
.nav-toggle.cur .m-header-bars::before { top: 0; transform: rotate(45deg); }
.nav-toggle.cur .m-header-bars::after  { top: 0; transform: rotate(-45deg); }

/* PWA 安装按钮区：在 .m-header-actions 内部，按自然宽度显示 */
.m-header-pwa {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    min-width: 0;
}
.m-header-pwa:empty { display: none; }   /* JS 未挂载时不占空间 */
.m-header-pwa .pwa-install-btn {
    width: auto;
    padding: 6px 10px;
    font-size: 12px;
    gap: 5px;
    margin: 0;
    box-shadow: 0 2px 8px rgba(59, 130, 246, .25);
    max-width: none;          /* 移动端不限制 max-width，让按钮按内容自适应 */
}
.m-header-pwa .pwa-install-btn-text { display: inline; }

/* 只在 <768px 显示移动端 header，隐藏 PC header */
@media (max-width: 767px) {
    /* 显示移动端 header */
    #m-header { display: flex; }

    /* PC header 在移动端整体隐藏（避免两份导航） */
    #pc-header { display: none !important; }

    /* 关键：直接隐藏 .sidebar 元素本身（不依赖 #m-mask 动画）
       .sidebar 在 base CSS 是 position:fixed;top:10px，会让 logo 一直显示在顶部 */
    .sidebar { display: none; }

    /* 解除桌面 .main 左侧 250px 边距 + 上方 60px 边距（桌面原本给 sidebar 留位置） */
    .main { margin: 0 !important; padding-top: 54px; }  /* 给 fixed header 留位置 */
}

/* 搜索列和 PWA 列之间的间隙收紧：去掉 pintuer 默认的列 padding */
/* 桌面：搜索列内容靠右，跟 PWA 列拼成一组
   容器 .container-layout 是 max-width:94%，居中后右侧留 3% 空白，
   所以用 margin-right:-3% 把右列拉出容器边缘，贴到视口右沿 */
.pwa-search-col {
    padding-right: 0 !important;
    float: right !important;
    margin-right: -3%;
}
.pwa-search-col .searchBar-pc {
    float: right;
}
.pwa-install-col {
    float: right !important;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-left: 0 !important;
    padding-right: 0 !important;
}
.pwa-install-col .pwa-install-slot {
    display: inline-flex;
    align-items: center;
    margin-top: 21px;
}

/* PC 顶栏右侧三个控件（搜索 / 语言 / PWA）合并到 .pc-header-tools 内，flex 排版
   DOM 顺序 = 视觉顺序（左→右）：搜索 → 语言 → PWA
   不再依赖 order / float 覆盖，浏览器开发工具里直接看到的就是最终布局 */
#pc-header .line {
    padding-top: 15px;
    display: flex;        /* nav 列和 tools 列垂直居中，避免 .pc-header-tools 贴顶 */
    align-items: center;
}
/* nav 列：外层 xm8 用 flex 居中 .nav，里层 .nav 用 flex 居中每个 <li>。
   原来靠 #pc-header .nav li a{margin-top:28px} 手动偏移，现在去掉，靠 flex 自动居中 */
#pc-header .xm8 {
    display: flex;
    align-items: center;
}
#pc-header .nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}
#pc-header .nav li a {
    margin-top: 0;
}
#pc-header .pc-header-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
}
#pc-header .pc-header-tool {
    display: flex;
    align-items: center;
}
/* 取消原 .searchBar-pc{margin:21px 0 16px 0}、.pwa-install-slot{margin-top:21px}
   的手工偏移，垂直居中由外层 flex 自动处理 */
#pc-header .pc-header-search .searchBar-pc { margin: 0; }
#pc-header .pc-header-pwa .pwa-install-slot { margin-top: 0; }

/* 默认 slot 占位（JS 未挂载时也不影响布局） */
.pwa-install-slot {
    display: inline-flex;
    pointer-events: none;
}
.pwa-install-slot > * { pointer-events: auto; }

/* ---------- 安装按钮（通用） ---------- */
.pwa-install-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: linear-gradient(135deg, rgba(59, 130, 246, .92), rgba(99, 102, 241, .92));
    color: #fff;
    font-size: 13px;
    line-height: 1;
    font-weight: 500;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease, background .18s ease;
    box-shadow: 0 4px 14px rgba(59, 130, 246, .25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    width: 100%;            /* 在 xm2 列内铺满，避免文字溢出换行 */
    box-sizing: border-box;
}
.pwa-install-btn-text {
    /* 默认显示文字 */
    display: inline;
}
.pwa-install-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(59, 130, 246, .35);
}
.pwa-install-btn:active { transform: translateY(0); }
.pwa-install-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}
.pwa-install-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}

/* 等候态：事件还没到，先变灰 */
.pwa-install-btn.is-waiting {
    opacity: .55;
    background: rgba(255, 255, 255, .12);
    cursor: default;
    box-shadow: none;
}
.pwa-install-btn.is-waiting:hover { transform: none; box-shadow: none; }

/* 原生事件已就绪 */
.pwa-install-btn.is-ready {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    animation: pwaPulse 1.6s ease-in-out infinite;
}
@keyframes pwaPulse {
    0%, 100% { box-shadow: 0 4px 14px rgba(59, 130, 246, .25); }
    50%      { box-shadow: 0 4px 22px rgba(59, 130, 246, .55); }
}

/* 已安装 */
.pwa-install-btn.is-installed {
    background: rgba(16, 185, 129, .85);
    border-color: rgba(16, 185, 129, .6);
    cursor: default;
}
.pwa-install-btn.is-installed:hover { transform: none; box-shadow: none; }

/* 不可安装 / 已关闭 */
.pwa-install-btn.is-disabled { opacity: .45; cursor: not-allowed; }

/* 抖动：提示用户操作无效 */
.pwa-install-btn.is-shake { animation: pwaShake .55s ease both; }
@keyframes pwaShake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

/* iOS 专属：始终高亮（无需等事件） */
.pwa-install-btn.pwa-install-btn--ios {
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
}

/* ============================================================
   响应式：根据屏幕宽度调整按钮形态
   关键：按钮 width: 100% 始终填满 PWA 列，消除按钮与搜索框之间的视觉空隙
   - ≥992px（xb/xl）：xm2 列（200px），按钮填满，文字居中
   - 768~991px（xm）：按钮收紧，文字保留
   - <768px（xs）：搜索 + PWA 同列同行，PWA 列固定 120px，按钮填满
   - <480px（手机超小）：PWA 列 50px，按钮仅图标
   ============================================================ */

/* ============================================================
   移动端搜索浮层（.searchBar-m）布局修复
   原有 CSS 用 float 实现输入框+按钮同行，移动端经常错位
   改用 flexbox 强制并排，且按钮内嵌 <i> 图标
   ============================================================ */
.searchBar-m .form-group form {
    display: flex !important;
    align-items: stretch;
    width: 100%;
}
.searchBar-m .form-group .input {
    flex: 1 1 auto !important;
    width: auto !important;
    float: none !important;
    border-radius: 30px 0 0 30px !important;
}
.searchBar-m .form-group .button {
    flex: 0 0 64px !important;
    width: 64px !important;
    float: none !important;
    border-radius: 0 30px 30px 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.6);
}
.searchBar-m .form-group .button i {
    font-size: 18px;
    line-height: 1;
    margin: 0;
    color: rgba(255,255,255,.7);
}

/* xb / xl：搜索框/PWA 列实际宽度够，按钮填满整列
   （不用 justify-content，留出空白让用户以为中间有 gap） */
@media (min-width: 992px) {
    .pwa-install-col { justify-content: flex-end; }
    .pwa-install-btn { width: 100%; }
}

/* xm：768~991px 之间，列窄，按钮收紧但仍带文字 */
@media (max-width: 991px) and (min-width: 768px) {
    .pwa-search-col .searchBar-pc {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .pwa-search-col .searchBar-pc .input { padding-left: 10px; font-size: 12px; }
    .pwa-install-col .pwa-install-slot { margin-top: 18px; }
    .pwa-install-btn {
        font-size: 12px;
        padding: 7px 10px;
        gap: 5px;
    }
}

/* xs：<768px — 搜索框和 PWA 按钮保持同一行
   搜索占剩余空间，PWA 按钮固定在右端 */
@media (max-width: 767px) {
    /* 覆盖 pintuer 的 xl12/xs12 强制 100% 宽，让两个列在同一行 */
    .pwa-search-col,
    .pwa-install-col {
        width: auto !important;
        float: left !important;
    }
    .pwa-search-col {
        width: calc(100% - 120px) !important;  /* 留 120px 给 PWA 按钮 */
    }
    .pwa-install-col {
        width: 120px !important;
        justify-content: stretch;              /* 按钮填满整列，无左右空白 */
    }
    .pwa-search-col .searchBar-pc {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .pwa-search-col .searchBar-pc .input { padding-left: 12px; font-size: 13px; }
    .pwa-install-col .pwa-install-slot { margin-top: 21px; }
    .pwa-install-btn {
        font-size: 13px;
        padding: 8px 12px;
        width: 100%;                           /* 填满 120px 列 */
    }
}

/* 手机超小：<480px，仅图标 */
@media (max-width: 479px) {
    /* 搜索更窄，按钮列也更窄（仅图标圆点） */
    .pwa-search-col { width: calc(100% - 50px) !important; }
    .pwa-install-col { width: 50px !important; justify-content: stretch; }
    .pwa-search-col .searchBar-pc .input { padding-left: 10px; font-size: 12px; height: 34px; }
    .pwa-search-col .searchBar-pc .button { height: 34px; width: 36px; }
    .pwa-install-col .pwa-install-slot { margin-top: 16px; }
    .pwa-install-btn-text { display: none; }
    .pwa-install-btn {
        padding: 8px;
        gap: 0;
        width: 100%;                           /* 填满 50px 列 */
    }
}

/* ---------- iOS 引导弹窗 ---------- */
.pwa-ios-hint {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(7, 7, 22, .78);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 24px;
    animation: pwaFadeIn .25s ease both;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
@keyframes pwaFadeIn { from { opacity: 0; } to { opacity: 1; } }

.pwa-ios-hint-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    background: linear-gradient(160deg, #1f1f3a, #0f0f24);
    color: #fff;
    border-radius: 22px;
    padding: 22px 20px 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .08);
    margin-bottom: 40px;
    animation: pwaSlideUp .35s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes pwaSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.pwa-ios-hint-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    border: 0;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.pwa-ios-hint-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 14px;
    text-align: center;
    letter-spacing: .5px;
}
.pwa-ios-hint-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 14px;
    line-height: 1.5;
}
.pwa-ios-hint-steps .step {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, .05);
    border-radius: 12px;
    padding: 9px 12px;
}
.pwa-ios-hint-steps .step b { color: #93c5fd; margin: 0 2px; }
.pwa-ios-hint-steps .step-num {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.pwa-ios-hint-steps .kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    margin: 0 2px;
}

.pwa-ios-hint-foot {
    margin-top: 14px;
    text-align: center;
    font-size: 12px;
    color: rgba(255, 255, 255, .65);
}

/* PC 端（≥768px）弹窗：放宽 + 居中 + 字号行高都放大
   默认 .pwa-ios-hint-card 锁死 360px、贴底，是为移动端 iOS 分享按钮引导设计的
   PC 桌面端屏幕大，文字挤得慌，重新做一套 */
@media (min-width: 768px) {
    .pwa-ios-hint {
        align-items: center;
        padding: 32px;
    }
    .pwa-ios-hint-card {
        max-width: 640px;
        width: clamp(480px, 70vw, 720px);
        padding: 32px 40px 28px;
        border-radius: 16px;
        margin-bottom: 0;
        box-shadow: 0 30px 80px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .08);
    }
    .pwa-ios-hint-title {
        font-size: 20px;
        margin-bottom: 18px;
        letter-spacing: 1px;
    }
    .pwa-ios-hint-steps {
        gap: 12px;
        font-size: 15px;
        line-height: 1.65;
    }
    .pwa-ios-hint-steps .step {
        padding: 12px 16px;
        border-radius: 10px;
        gap: 12px;
    }
    .pwa-ios-hint-steps .step-num {
        flex: 0 0 26px;
        width: 26px;
        height: 26px;
        font-size: 13px;
    }
    .pwa-ios-hint-foot {
        margin-top: 18px;
        font-size: 13px;
    }
    /* 移动端的小箭头在 PC 端没意义（不指向任何东西），隐藏 */
    .pwa-ios-hint-arrow { display: none; }
}

/* 指向屏幕底部分享按钮的小箭头 */
.pwa-ios-hint-arrow {
    position: absolute;
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-top: 14px solid #1f1f3a;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35));
}

/* ---------- 暗色模式兼容（系统暗色时按钮自动适配） ---------- */
@media (prefers-color-scheme: dark) {
    .pwa-install-btn {
        border-color: rgba(255, 255, 255, .22);
    }
}

/* ---------- 减少动画偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
    .pwa-install-btn,
    .pwa-install-btn.is-ready,
    .pwa-install-btn.is-shake,
    .pwa-ios-hint,
    .pwa-ios-hint-card { animation: none; transition: none; }
}
