/* ============================================================
   ui.css — 全站共享 UI 增强（响应式 / 可访问性 / 交互动效）
   适用：p3 / pl5 / bd / ssq / dlt / 3d 等子页面
   说明：本文件只补充通用能力，不覆盖各页面独立 css 的布局规则
   ============================================================ */

/* 基础盒模型与移动端文字缩放保护 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, svg, video, canvas { max-width: 100%; height: auto; }
html { scroll-behavior: smooth; }

/* 全局键盘焦点环（可访问性，仅键盘聚焦时显示） */
:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
    border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

/* 跳转到主内容的链接（屏幕阅读器 / 键盘用户） */
.skip-link {
    position: fixed;
    top: -120px;
    left: 12px;
    z-index: 3000;
    background: #1f2937;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    text-decoration: none;
    transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; }

/* 回到顶部悬浮按钮 */
.back-to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    z-index: 1500;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: none; }
.back-to-top:hover { background: #1d4ed8; }

/* 滚动入场动画（仅 JS 启用时隐藏；无 JS 优雅降级为正常显示） */
.js .reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.6s ease, transform 0.6s ease; }
.js .reveal.in { opacity: 1; transform: none; }

/* 文档型子页面（p3 / pl5 / bd）精简吸顶导航 */
.mini-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px clamp(12px, 4vw, 24px);
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.mini-nav a { text-decoration: none; color: inherit; }
.mini-nav .mini-nav-brand {
    font-weight: 700;
    font-size: 0.98rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mini-nav .mini-nav-home {
    font-size: 0.9rem;
    padding: 6px 14px;
    border-radius: 999px;
    background: #2563eb;
    color: #fff !important;
    white-space: nowrap;
    flex-shrink: 0;
}
.mini-nav .mini-nav-home:hover { background: #1d4ed8; }

/* 通用 CTA 链接（替代子页面内联样式，统一且移动端友好） */
.cta-link {
    display: inline-block;
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    color: #fff !important;
    font-size: 1em;
    font-weight: 600;
    padding: 12px 28px;
    border-radius: 25px;
    text-decoration: none !important;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    letter-spacing: 1px;
}
.cta-link:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(39, 174, 96, 0.5); }

/* 复制按钮 */
.copy-btn {
    margin-top: 10px;
    border: 1px solid #2563eb;
    background: #fff;
    color: #2563eb;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.copy-btn:hover { background: #2563eb; color: #fff; }
.copy-btn.copied { background: #16a34a; border-color: #16a34a; color: #fff; }

/* ===== 移动端通用优化 ===== */
@media (max-width: 768px) {
    .back-to-top { right: 14px; bottom: 14px; width: 42px; height: 42px; }
    .mini-nav { padding: 8px 14px; }
    .mini-nav .mini-nav-brand { font-size: 0.9rem; }
}

@media (max-width: 600px) {
    /* 文档型页面：定宽双列网格在手机上回流为单列 */
    .grid { grid-template-columns: 1fr !important; }
    /* CTA 在手机上占满宽度，提升点按区域 */
    .cta-link,
    .nav-link { display: block !important; width: 100%; text-align: center; box-sizing: border-box; }
    .copy-btn { width: 100%; }
}

/* 尊重用户的“减少动效”偏好 */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .js .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
    .back-to-top,
    .skip-link,
    .cta-link,
    .copy-btn,
    .mini-nav { transition: none !important; }
}

/* ===== 移动端触控与渲染优化（全局） ===== */
/* 去除移动端点击时的灰色高亮，改用统一焦点环 */
* { -webkit-tap-highlight-color: transparent; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* 触控设备：保证最小点按区域 44x44，避免误触 */
@media (pointer: coarse) {
    .btn, .nav-link, .mini-nav-home, .cta-link, .copy-btn, .back-to-top, button, .mini-nav a {
        min-height: 44px;
    }
    .mini-nav a { display: inline-flex; align-items: center; }
    .back-to-top { width: 48px; height: 48px; }
}

/* 适配刘海屏 / 底部安全区（iPhone 等全面屏） */
.back-to-top {
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
}
.skip-link {
    left: calc(12px + env(safe-area-inset-left, 0px));
}
