/* ========================================================================
   Refinements CSS — 跨主题共享的精致化样式层
   ------------------------------------------------------------------------
   设计目标：在保持各主题原有色彩与字体特色的前提下，统一提升以下维度：
   1. 排版层级（letter-spacing / line-height / font-feature-settings）
   2. 卡片深度（subtle shadow + gradient border）
   3. 悬停/聚焦微交互（smooth transitions + ring indicators）
   4. 按钮状态（depth + gradient + press feedback）
   5. 区块分隔（gradient dividers / soft transitions）
   6. 徽章/标签（pill style with subtle border）
   7. 表单输入（focus ring + smooth border）
   8. 滚动条美化
   9. 选中态样式
   ======================================================================== */

/* ---------- 1. 全局排版增强 ---------- */
:root {
    /* 统一圆角刻度（语义化） */
    --r-sm: 4px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 20px;
    --r-full: 9999px;

    /* 阴影刻度 */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.10), 0 8px 16px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 0 3px rgba(var(--color-accent, 0 122 255), 0.15);
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1, 'ss01' 1;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.018em;
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

/* 选中态 */
::selection {
    background: rgba(var(--color-accent, 0 122 255), 0.22);
    color: inherit;
}

/* 滚动条美化（仅 Webkit） */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(var(--color-text-main, 30 30 30), 0.18);
    border-radius: var(--r-full);
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--color-text-main, 30 30 30), 0.32);
    background-clip: padding-box;
    border: 2px solid transparent;
}

/* ---------- 2. 卡片精致化 ---------- */
.refine-card {
    background: rgb(var(--color-white, 255 255 255));
    border: 1px solid rgba(var(--color-text-main, 30 30 30), 0.08);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.32s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.32s ease;
    will-change: transform;
}
.refine-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(var(--color-accent, 0 122 255), 0.35);
}
.refine-card-flat {
    background: rgb(var(--color-white, 255 255 255));
    border: 1px solid rgba(var(--color-text-main, 30 30 30), 0.08);
    border-radius: var(--r-lg);
    transition: border-color 0.24s ease, background 0.24s ease;
}
.refine-card-flat:hover {
    border-color: rgba(var(--color-accent, 0 122 255), 0.4);
    background: rgba(var(--color-accent, 0 122 255), 0.02);
}

/* ---------- 3. 按钮精致化 ---------- */
.refine-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    font-size: 0.875rem;
    letter-spacing: 0.005em;
    border-radius: var(--r-md);
    transition: transform 0.18s ease, box-shadow 0.24s ease, background 0.24s ease, color 0.24s ease;
    cursor: pointer;
    user-select: none;
}
.refine-btn:hover {
    transform: translateY(-1px);
}
.refine-btn:active {
    transform: translateY(0);
}
.refine-btn-primary {
    background: rgb(var(--color-primary, 0 122 255));
    color: rgb(var(--color-white, 255 255 255));
    box-shadow: 0 4px 12px rgba(var(--color-primary, 0 122 255), 0.25),
                inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.refine-btn-primary:hover {
    box-shadow: 0 8px 20px rgba(var(--color-primary, 0 122 255), 0.35),
                inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.refine-btn-outline {
    background: transparent;
    border: 1.5px solid rgba(var(--color-text-main, 30 30 30), 0.18);
    color: rgb(var(--color-text-main, 30 30 30));
}
.refine-btn-outline:hover {
    border-color: rgb(var(--color-primary, 0 122 255));
    color: rgb(var(--color-primary, 0 122 255));
}
.refine-btn-ghost {
    background: transparent;
    color: rgb(var(--color-text-main, 30 30 30));
}
.refine-btn-ghost:hover {
    background: rgba(var(--color-text-main, 30 30 30), 0.05);
}

/* ---------- 4. 徽章 / Pill ---------- */
.refine-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    border-radius: var(--r-full);
    background: rgba(var(--color-accent, 0 122 255), 0.08);
    color: rgb(var(--color-accent, 0 122 255));
    border: 1px solid rgba(var(--color-accent, 0 122 255), 0.18);
}

/* ---------- 5. 链接悬浮下划线动画 ---------- */
.refine-link {
    position: relative;
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}
.refine-link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.refine-link:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* ---------- 6. 区块分隔 / 软渐变 ---------- */
.refine-divider {
    height: 1px;
    background: linear-gradient(to right,
        transparent,
        rgba(var(--color-text-main, 30 30 30), 0.12),
        transparent);
    border: 0;
}

/* 区块间过渡渐变（用于 section 顶部，避免硬切换） */
.refine-section-transition {
    position: relative;
}
.refine-section-transition::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 64px;
    height: 3px;
    background: linear-gradient(to right,
        rgb(var(--color-primary, 0 122 255)),
        rgb(var(--color-accent, 0 122 255)));
    border-radius: var(--r-full);
}

/* ---------- 7. 表单输入精致化 ---------- */
.refine-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    background: rgb(var(--color-white, 255 255 255));
    border: 1px solid rgba(var(--color-text-main, 30 30 30), 0.16);
    border-radius: var(--r-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}
.refine-input:focus {
    border-color: rgb(var(--color-accent, 0 122 255));
    box-shadow: 0 0 0 3px rgba(var(--color-accent, 0 122 255), 0.12);
}

/* ---------- 8. 焦点环（无障碍） ---------- */
.refine-focus-ring:focus-visible {
    outline: 2px solid rgb(var(--color-accent, 0 122 255));
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

/* ---------- 9. 图片悬停缩放容器 ---------- */
.refine-img-zoom {
    overflow: hidden;
}
.refine-img-zoom img {
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.refine-img-zoom:hover img {
    transform: scale(1.06);
}

/* ---------- 10. 微动画：fade-in-up ---------- */
@keyframes refine-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.refine-fade-in-up {
    animation: refine-fade-in-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.refine-fade-in-up-stagger > * {
    opacity: 0;
    animation: refine-fade-in-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.refine-fade-in-up-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.refine-fade-in-up-stagger > *:nth-child(2) { animation-delay: 0.12s; }
.refine-fade-in-up-stagger > *:nth-child(3) { animation-delay: 0.19s; }
.refine-fade-in-up-stagger > *:nth-child(4) { animation-delay: 0.26s; }
.refine-fade-in-up-stagger > *:nth-child(5) { animation-delay: 0.33s; }
.refine-fade-in-up-stagger > *:nth-child(6) { animation-delay: 0.4s; }

/* ---------- 11. 渐变文字 ---------- */
.refine-text-gradient {
    background: linear-gradient(135deg,
        rgb(var(--color-primary, 0 122 255)) 0%,
        rgb(var(--color-accent, 0 122 255)) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* ---------- 12. Hero 装饰：网格 / 光晕 ---------- */
.refine-hero-grid {
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 50%, black 40%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 50%, black 40%, transparent 100%);
}

/* ---------- 13. 分页精致化 ---------- */
.refine-pagination {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem;
    background: rgb(var(--color-white, 255 255 255));
    border: 1px solid rgba(var(--color-text-main, 30 30 30), 0.08);
    border-radius: var(--r-full);
    box-shadow: var(--shadow-sm);
}
.refine-pagination a,
.refine-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--r-full);
    transition: background 0.18s ease, color 0.18s ease;
}
.refine-pagination a:hover {
    background: rgba(var(--color-text-main, 30 30 30), 0.06);
}
.refine-pagination .active {
    background: rgb(var(--color-primary, 0 122 255));
    color: rgb(var(--color-white, 255 255 255));
}

/* ---------- 14. 静默降级：尊重 prefers-reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .refine-card:hover {
        transform: none;
    }
}
