/* ============================================================
   界面精致化层（design.css）
   ------------------------------------------------------------
   定位：在「主题变量 → 布局基础样式 → components.css」之后加载，
        只做视觉打磨，不改变任何结构与交互，因此可以安全地整体
        回退（删掉这一个 <link> 即还原）。

   打磨内容：
     1.  全局排版与阅读质感      7.  徽章 / 角标
     2.  主题化滚动条与选中色    8.  下拉 / 模态
     3.  卡片浮起层次            9.  分页 / 表格 / 面包屑
     4.  按钮系统               10.  页脚 / 返回顶部
     5.  表单控件               11.  入场动效
     6.  导航栏细化             12.  后台专用细化
   ============================================================ */

/* ============================================================
   1. 全局排版与阅读质感
   ============================================================ */
html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: 88px;
}

body {
    letter-spacing: 0.01em;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1, "liga" 1;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.012em;
    font-weight: 700;
}

p { letter-spacing: 0.006em; }

/* 数字统一等宽，列表里的计数不再跳到下一行 */
.tabular-nums,
.link-clicks,
.article-clicks,
.stat-number,
.page-info {
    font-variant-numeric: tabular-nums;
}

/* 键盘可访问的焦点环：只在键盘操作时出现，鼠标点击不打扰 */
:focus-visible {
    outline: 2px solid var(--theme-ring, var(--theme-primary, #4f46e5));
    outline-offset: 2px;
}

/* 正文链接：下划线随悬浮淡入，比直接变色更含蓄 */
.article-content a,
.text-content a {
    text-decoration-color: var(--theme-hairline, var(--theme-border));
    text-underline-offset: 3px;
    transition: text-decoration-color .2s ease;
}
.article-content a:hover,
.text-content a:hover {
    text-decoration-color: currentColor;
}

/* ============================================================
   2. 主题化滚动条与选中色
   ============================================================ */
::selection {
    background: var(--theme-primary, #4f46e5);
    color: #fff;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--theme-border, #d8dce5) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--theme-border, #d8dce5);
    border: 3px solid transparent;
    background-clip: content-box;
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--theme-text-weak, #9aa1ad);
    background-clip: content-box;
}
::-webkit-scrollbar-corner { background: transparent; }

/* 左侧分类栏的滚动条更纤细 */
.nav-sidebar::-webkit-scrollbar { width: 6px; }

/* ============================================================
   3. 卡片浮起层次
   ------------------------------------------------------------
   统一「静止 = 极轻投影 + 细描边，悬浮 = 抬升一档 + 主色描边」，
   让所有卡片有同一套物理规则。
   ============================================================ */
.category-card,
.url-card,
.article-card,
.article-item,
.cat-block,
.notebook-item,
.admin-card,
.stat-card {
    box-shadow: var(--theme-shadow-sm);
    transition: box-shadow .28s cubic-bezier(.4, 0, .2, 1),
                transform .28s cubic-bezier(.4, 0, .2, 1),
                border-color .28s ease;
}

.category-card:hover,
.url-card:hover,
.article-card:hover,
.article-item:hover,
.cat-block:hover,
.notebook-item:hover {
    box-shadow: var(--theme-shadow-md);
}

/* 分类卡片：顶部一条极淡的主题色高光，暗示"这是一块内容" */
.category-card {
    position: relative;
}
.category-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity .28s ease;
    pointer-events: none;
}
.category-card:hover::before { opacity: 1; }

/* 分类头部：图标与标题之间的节奏 */
.category-header h5 { letter-spacing: -0.01em; }
.category-icon {
    box-shadow: 0 4px 12px -6px var(--theme-nav-shadow, rgba(0, 0, 0, .25));
}

/* 网址卡：图标容器改用方圆角，视觉更"应用化" */
.url-img {
    border-radius: 12px;
    background: var(--theme-bg-secondary, #f1f5f9);
}
.url-img img { border-radius: 8px; }
.url-img .fallback-icon { border-radius: 12px; }

.item-card {
    border-radius: 12px;
    transition: background .22s ease, border-color .22s ease,
                transform .22s cubic-bezier(.4, 0, .2, 1),
                box-shadow .22s ease;
}
.item-card:hover {
    transform: translateX(3px) translateY(-1px);
    box-shadow: var(--theme-shadow-sm);
}

/* 文章卡：标题与时间之间加一道呼吸 */
.article-card-title { letter-spacing: -0.008em; }
.article-card-time { opacity: .92; }

/* ============================================================
   4. 按钮系统
   ============================================================ */
.btn {
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: transform .2s cubic-bezier(.4, 0, .2, 1),
                box-shadow .2s ease,
                background-color .2s ease,
                border-color .2s ease,
                color .2s ease;
}
.btn:active { transform: translateY(0) scale(.985); }

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: #fff;
    box-shadow: 0 6px 16px -10px var(--theme-nav-shadow, rgba(79, 70, 229, .5));
}
.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-gradient);
    filter: brightness(1.06);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 10px 22px -12px var(--theme-nav-shadow, rgba(79, 70, 229, .6));
}

.btn-outline-primary {
    border-color: var(--theme-nav-border-soft, var(--theme-primary));
    color: var(--theme-primary);
}
.btn-outline-primary:hover {
    background: var(--theme-primary);
    border-color: var(--theme-primary);
    color: #fff;
}

.btn-outline-secondary,
.btn-outline-danger,
.btn-outline-warning,
.btn-outline-info {
    border-color: var(--theme-border);
    color: var(--theme-text-secondary);
}
.btn-outline-secondary:hover {
    background: var(--theme-bg-tertiary);
    border-color: var(--theme-border);
    color: var(--theme-text-primary);
}

.btn-light {
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-border);
    color: var(--theme-text-secondary);
}
.btn-light:hover {
    background: var(--theme-bg-secondary);
    color: var(--theme-text-primary);
}

.btn-sm { border-radius: 8px; }

/* ============================================================
   5. 表单控件
   ============================================================ */
.form-control,
.form-select {
    border-radius: 10px;
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-border);
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.form-control:hover:not(:focus),
.form-select:hover:not(:focus) {
    border-color: var(--theme-text-weak);
}
.form-control:focus,
.form-select:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 4px var(--theme-ring, var(--theme-primary-light));
    background: var(--theme-card-bg);
}
.form-label {
    font-weight: 600;
    font-size: .88rem;
    color: var(--theme-text-secondary);
}
.form-check-input:checked {
    background-color: var(--theme-primary);
    border-color: var(--theme-primary);
}
.form-check-input:focus {
    box-shadow: 0 0 0 4px var(--theme-ring, var(--theme-primary-light));
}

/* ============================================================
   6. 导航栏细化
   ============================================================ */
.navbar .nav-link {
    position: relative;
    border-radius: 10px;
}
/* 当前菜单：底部一条主题色短线，比整块底色更克制（仅桌面端横排菜单） */
@media (min-width: 992px) {
    .navbar .nav-link.active::after {
        content: "";
        position: absolute;
        left: 50%;
        bottom: 2px;
        width: 18px;
        height: 2px;
        margin-left: -9px;
        border-radius: 2px;
        background: var(--primary-gradient);
    }
}
.navbar-brand { letter-spacing: -0.02em; }

/* 主题切换 / 语言 / 主页模式按钮统一为"胶囊"手感 */
.theme-toggle {
    border: 1px solid var(--theme-border);
    box-shadow: var(--theme-shadow-sm);
}
.theme-toggle:hover {
    border-color: var(--theme-nav-border-soft, var(--theme-primary));
    box-shadow: 0 6px 16px -10px var(--theme-nav-shadow, rgba(0, 0, 0, .4));
}
.home-mode-toggle,
.lang-selector .form-select {
    box-shadow: var(--theme-shadow-sm);
}

/* 推荐位：小胶囊，悬浮时轻微上浮 */
.recommend-item {
    transition: background-color .2s ease, border-color .2s ease,
                color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.recommend-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px -10px var(--theme-nav-shadow, rgba(0, 0, 0, .4));
}

/* ============================================================
   7. 徽章 / 角标
   ============================================================ */
.badge {
    font-weight: 600;
    letter-spacing: 0.01em;
    border-radius: 7px;
    padding: .34em .6em;
}
.badge-rec {
    border-radius: 6px;
    box-shadow: 0 2px 6px -3px rgba(0, 0, 0, .45);
}
.vip-badge {
    background: var(--primary-gradient);
    box-shadow: 0 3px 10px -6px var(--theme-nav-shadow, rgba(0, 0, 0, .5));
    letter-spacing: .02em;
}
.badge-vip {
    background: var(--primary-gradient);
    color: #fff;
}
.badge-normal {
    background: var(--theme-bg-tertiary);
    color: var(--theme-text-secondary);
}

/* ============================================================
   8. 下拉 / 模态
   ============================================================ */
.dropdown-menu {
    border-radius: 14px;
    border: 1px solid var(--theme-border);
    box-shadow: var(--theme-shadow-lg);
    padding: 6px;
}
.dropdown-item {
    border-radius: 9px;
    padding: 8px 12px;
    font-size: .9rem;
    transition: background-color .16s ease, color .16s ease;
}
.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--theme-primary-light);
    color: var(--theme-primary);
}
.dropdown-divider { border-color: var(--theme-border-light); }

.modal-content {
    border-radius: 18px;
    border: 1px solid var(--theme-border);
    box-shadow: var(--theme-shadow-xl);
    overflow: hidden;
}
.modal-header {
    background: linear-gradient(180deg, var(--theme-bg-secondary) 0%, var(--theme-card-bg) 100%);
    border-bottom: 1px solid var(--theme-border-light);
}
.modal-title { font-size: 1.02rem; font-weight: 700; }
.modal-footer { border-top: 1px solid var(--theme-border-light); }
.modal-backdrop.show { opacity: .5; }

/* ============================================================
   9. 分页 / 表格 / 面包屑
   ============================================================ */
.pagination { gap: 6px; }
.page-link {
    border-radius: 10px !important;
    border: 1px solid var(--theme-border);
    color: var(--theme-text-secondary);
    font-weight: 600;
    min-width: 38px;
    text-align: center;
    transition: all .2s ease;
}
.page-link:hover {
    background: var(--theme-primary-light);
    border-color: var(--theme-nav-border-soft, var(--theme-primary));
    color: var(--theme-primary);
}
.page-item.active .page-link {
    background: var(--primary-gradient);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 6px 16px -10px var(--theme-nav-shadow, rgba(0, 0, 0, .5));
}
.page-item.disabled .page-link {
    background: var(--theme-bg-secondary);
    color: var(--theme-text-weak);
    opacity: .7;
}

.table {
    --bs-table-bg: transparent;
    border-color: var(--theme-border-light);
}
.table > thead th {
    background: var(--theme-bg-secondary);
    color: var(--theme-text-secondary);
    font-weight: 600;
    font-size: .86rem;
    letter-spacing: .02em;
    border-bottom: 1px solid var(--theme-border);
    white-space: nowrap;
}
.table > tbody > tr {
    transition: background-color .16s ease;
}
.table > tbody > tr:hover > * {
    background: var(--theme-primary-light) !important;
}
.table > :not(caption) > * > * {
    border-color: var(--theme-border-light);
    padding: .7rem .75rem;
}

.breadcrumb { font-size: .85rem; margin-bottom: 1rem; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--theme-text-weak); }
.breadcrumb-item a {
    color: var(--theme-text-muted);
    text-decoration: none;
    transition: color .2s ease;
}
.breadcrumb-item a:hover { color: var(--theme-primary); }
.breadcrumb-item.active { color: var(--theme-text-primary); font-weight: 600; }

/* ============================================================
   10. 页脚 / 返回顶部
   ============================================================ */
footer {
    line-height: 1.9;
}
footer a {
    text-decoration: none;
    transition: color .2s ease;
}
footer a:hover { color: var(--theme-primary); text-decoration: underline; }

.back-to-top-btn,
.back-to-bottom-btn {
    box-shadow: 0 8px 24px -10px var(--theme-nav-shadow, rgba(0, 0, 0, .55));
    border: 1px solid rgba(255, 255, 255, .18);
}
.back-to-top-btn:hover,
.back-to-bottom-btn:hover {
    box-shadow: 0 14px 30px -12px var(--theme-nav-shadow, rgba(0, 0, 0, .6));
}

/* ============================================================
   11. 入场动效（轻量、可关闭）
   ============================================================ */
@keyframes wbRise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.nav-content > .cat-block,
.category-section > .category-card,
.nav-content > .article-grid {
    animation: wbRise .42s cubic-bezier(.22, 1, .36, 1) both;
}
.nav-content > .cat-block:nth-child(2),
.category-section > .category-card:nth-child(2) { animation-delay: .04s; }
.nav-content > .cat-block:nth-child(3),
.category-section > .category-card:nth-child(3) { animation-delay: .08s; }
.nav-content > .cat-block:nth-child(4),
.category-section > .category-card:nth-child(4) { animation-delay: .12s; }
.nav-content > .cat-block:nth-child(n+5),
.category-section > .category-card:nth-child(n+5) { animation-delay: .16s; }

/* 尊重系统"减弱动态效果"设置 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   12. 后台专用细化
   ============================================================ */
.admin-card {
    border-radius: 16px;
    border: 1px solid var(--theme-border);
}
.admin-card-header {
    border-bottom: 1px solid var(--theme-border-light);
    font-weight: 600;
    letter-spacing: -0.005em;
}

.stat-card {
    border-radius: 16px;
    border: 1px solid var(--theme-border);
    transition: box-shadow .28s ease, transform .28s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--theme-shadow-md);
}
.stat-number { letter-spacing: -0.02em; }
.stat-icon {
    border-radius: 12px;
}

/* 后台侧边菜单：当前项用主题渐变 + 左侧指示条 */
.sidebar-link {
    border-radius: 10px;
    transition: background-color .2s ease, color .2s ease, transform .2s ease;
}
.sidebar-link:hover { transform: translateX(2px); }
.nav-section-title {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--theme-text-weak);
    text-transform: uppercase;
}

.admin-topbar {
    border-bottom: 1px solid var(--theme-border);
    box-shadow: 0 10px 30px -28px rgba(0, 0, 0, .6);
}

/* ============================================================
   13. 移动端微调
   ============================================================ */
@media (max-width: 768px) {
    .modal-content { border-radius: 16px 16px 0 0; }
    .dropdown-menu { border-radius: 12px; }
    .btn { border-radius: 9px; }
}

/* ============================================================
   14. 分类图标（后台 / 用户中心分类管理卡）
   ------------------------------------------------------------
   分类管理卡里分类名后统一跟一枚图标：设置了就用自定义图标类名，
   未设置则由 catIconBiClass() 回退（一级 bi-folder / 二级 bi-folder2-open）。
   这里限定 i.cat-icon，避免影响前台区块头的 .cat-icon 方块。
   ============================================================ */
i.cat-icon {
    font-size: .9rem;
    line-height: 1;
    color: var(--theme-text-muted);
    flex-shrink: 0;
}
