/* ==========================================================================
   Yixiang UI / 翊象 UI
   Design Tokens and Base Styles
   设计变量与基础样式

   Copyright (c) 2026 威海颜翊网络科技有限公司
   Licensed under the MIT License. Commercial use is permitted.
   https://www.weihaiyanyi.com  |  pinenetcn@gmail.com
   ========================================================================== */
:root {
    /* Brand Colors */
    --yx-brand-primary: #3964fe;
    --yx-brand-primary-rgb: 57, 100, 254;
    --yx-brand-primary-hover: #5686fe;
    --yx-brand-primary-active: #2f4c8f;
    --yx-brand-primary-light: #edf3fe;
    --yx-brand-dark: #283142;

    /* 供 rgba() 使用的背景色通道值，避免主题切换时写死颜色 */
    --yx-bg-paper-rgb: 255, 255, 255;
    --yx-bg-body-rgb: 245, 246, 247;

    /* Text Colors */
    --yx-text-primary: #0f1115;
    --yx-text-secondary: #61666b;
    --yx-text-tertiary: #81858c;
    --yx-text-caption: #adb2b8;
    --yx-text-inverse: #ffffff;

    /* Background Colors */
    --yx-bg-body: #f5f6f7;
    --yx-bg-paper: #ffffff;
    --yx-bg-hover: #f1f3f5;
    --yx-bg-active: #e9ecf2;
    --yx-bg-sidebar: #ffffff;

    /* Semantic Colors */
    --yx-success: #22c55e;
    --yx-success-bg: #e6faed;
    --yx-warning: #f59e0b;
    --yx-warning-bg: #fef5e7;
    --yx-danger: #ef4444;
    --yx-danger-bg: #fef2f2;
    --yx-info: #3b82f6;
    --yx-info-bg: #eff6ff;

    /* Border Colors */
    --yx-border-light: rgba(0, 0, 0, 0.04);
    --yx-border-base: rgba(0, 0, 0, 0.1);
    --yx-border-dark: rgba(0, 0, 0, 0.16);

    /* Typography */
    --yx-font-sans: "Host Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
    --yx-font-mono: "Fragment Mono", ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;

    --yx-text-xs: 12px;
    --yx-text-sm: 14px;
    --yx-text-base: 15px;
    --yx-text-lg: 18px;
    --yx-text-xl: 20px;
    --yx-text-2xl: 24px;
    --yx-text-3xl: clamp(24px, 3.2vw, 32px);
    --yx-text-hero: clamp(32px, 5.2vw, 48px);

    /* Spacing */
    --yx-space-1: 4px;
    --yx-space-2: 8px;
    --yx-space-3: 12px;
    --yx-space-4: 16px;
    --yx-space-5: 20px;
    --yx-space-6: 24px;
    --yx-space-8: 32px;
    --yx-space-10: 40px;
    --yx-space-12: 48px;
    --yx-space-16: 64px;

    /* Radius */
    --yx-radius-sm: 4px;
    --yx-radius-md: 8px;
    --yx-radius-lg: 12px;
    --yx-radius-xl: 16px;
    --yx-radius-pill: 9999px;

    /* Shadows */
    --yx-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --yx-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --yx-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --yx-shadow-float: 0 0 1px 0 rgba(0, 0, 0, 0.2), 0 0 4px 0 rgba(0, 0, 0, 0.02), 0 12px 32px 0 rgba(0, 0, 0, 0.08);

    /* Z-Index */
    --yx-z-header: 1000;
    --yx-z-sidebar: 1010;
    --yx-z-overlay: 1020;
    --yx-z-modal: 1030;
    --yx-z-toast: 1040;

    /* Transitions */
    --yx-transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --yx-transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* 焦点环 */
    --yx-focus-ring: 0 0 0 3px rgba(57, 100, 254, 0.35);
}

/* Dark Mode Configuration */
html[data-theme="dark"] {
    --yx-brand-primary: #679efe;
    --yx-brand-primary-rgb: 103, 158, 254;
    --yx-brand-primary-hover: #3964fe;
    --yx-brand-primary-active: #2f4c8f;
    --yx-brand-primary-light: #283142;
    --yx-brand-dark: #edf3fe;

    --yx-bg-paper-rgb: 27, 27, 28;
    --yx-bg-body-rgb: 15, 17, 21;

    --yx-text-primary: #f9fafb;
    --yx-text-secondary: #cfd3d6;
    --yx-text-tertiary: #adb2b8;
    --yx-text-caption: #81858c;
    --yx-text-inverse: #0f1115;

    --yx-bg-body: #0f1115;
    --yx-bg-paper: #1b1b1c;
    --yx-bg-hover: #232324;
    --yx-bg-active: #2c2c2e;
    --yx-bg-sidebar: #151517;

    --yx-border-light: hsla(0, 0%, 100%, 0.06);
    --yx-border-base: hsla(0, 0%, 100%, 0.12);
    --yx-border-dark: hsla(0, 0%, 100%, 0.2);

    --yx-success-bg: rgba(34, 197, 94, 0.15);
    --yx-warning-bg: rgba(245, 158, 11, 0.15);
    --yx-danger-bg: rgba(239, 68, 68, 0.15);
    --yx-info-bg: rgba(59, 130, 246, 0.15);

    --yx-focus-ring: 0 0 0 3px rgba(103, 158, 254, 0.35);
    color-scheme: dark;
}

/* Global Reset & Base */
*, ::before, ::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-family: var(--yx-font-sans);
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    /* 固定头部遮挡锚点的问题 */
    scroll-padding-top: 80px;
}

body {
    background-color: var(--yx-bg-body);
    color: var(--yx-text-primary);
    font-size: var(--yx-text-sm);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 弹窗 / 抽屉打开时锁定页面滚动 */
body.yx-scroll-locked,
body.yx-menu-open,
body.yx-sidebar-open {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--yx-transition-fast), opacity var(--yx-transition-fast);
}

a:active, button:active {
    opacity: 0.85;
}

img, svg {
    max-width: 100%;
}

/* 品牌 Logo 尺寸保护：避免被外部 SVG 的固有尺寸撑破布局 */
.yx-brand-logo {
    width: auto;
    max-height: 32px;
    flex-shrink: 0;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

::selection {
    background-color: rgba(var(--yx-brand-primary-rgb), 0.24);
    color: var(--yx-text-primary);
}

/* 键盘可达性：只在键盘操作时显示焦点环 */
:focus-visible {
    outline: 2px solid var(--yx-brand-primary);
    outline-offset: 2px;
}

.yx-btn:focus-visible,
.yx-input:focus-visible,
.yx-select:focus-visible,
.yx-textarea:focus-visible {
    outline: none;
    box-shadow: var(--yx-focus-ring);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background-color: var(--yx-border-dark);
    border-radius: var(--yx-radius-pill);
}
::-webkit-scrollbar-thumb:hover {
    background-color: var(--yx-text-tertiary);
}

/* 文本截断工具类 */
.yx-text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yx-text-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 仅屏幕阅读器可见 */
.yx-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Make dark mode logos readable if it's a dark logo */
html[data-theme="dark"] .yx-brand-logo {
    /* 纯白剪影，避免反相后品牌色发生色相偏移 */
    filter: brightness(0) invert(1);
}

/* Page Transition Micro-Animations */
.yx-page-fade-out {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

.yx-page-fade-in {
    animation: yxPageSlideUpFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes yxPageSlideUpFadeIn {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

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