/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4ecdc4;
    --secondary-color: #ff6b6b;
    --accent-color: #ffe66d;
    --bg-color: #f7f7f7;
    --card-bg: #ffffff;
    --text-color: #333;
    --text-light: #666;
    --border-color: #e0e0e0;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

body.dark-mode {
    --bg-color: #1a1a1a;
    --card-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --text-light: #b0b0b0;
    --border-color: #404040;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    margin-top: 24px;
}

/* 头部样式 */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 3rem 0;
    text-align: center;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* 主内容区域 */
main {
    padding: 3rem 0;
}

.tricks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

/* 技巧卡片 */
.trick-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid var(--border-color);
}

.trick-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.trick-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.trick-header h2 {
    font-size: 1.3rem;
    color: var(--text-color);
}

.tag {
    background: var(--primary-color);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.trick-content {
    margin-bottom: 1rem;
    min-height: 150px;
}

.trick-content p {
    color: var(--text-light);
    margin-bottom: 1rem;
}

/* 演示区域 */
.demo-box {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    border: 1px dashed var(--border-color);
}

/* 按钮样式 */
.scroll-btn,
.demo-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.scroll-btn:hover,
.demo-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.scroll-btn:active,
.demo-btn:active {
    transform: translateY(0);
}

/* 代码块样式 */
.trick-code {
    background: #282c34;
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin-top: 1rem;
}

.trick-code pre {
    margin: 0;
    color: #abb2bf;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.trick-code code {
    color: #abb2bf;
}

/* 自定义文本选择 */
.custom-select {
    padding: 1rem;
    background: white;
    border-radius: 6px;
    font-size: 1.1rem;
    line-height: 1.8;
}

.custom-select::selection {
    background: #ff6b6b;
    color: white;
}

/* 玻璃态效果 */
.glass-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glass-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.glass-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

/* 打字机效果 */
.typewriter {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    min-height: 2rem;
    border-right: 2px solid var(--primary-color);
    padding-right: 0.5rem;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { border-color: var(--primary-color); }
    51%, 100% { border-color: transparent; }
}

/* 图片懒加载 */
.lazy-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

/* CSS 变量演示 */
.css-vars-demo {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.var-box {
    flex: 1;
    min-width: 100px;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.box1 {
    background: var(--primary-color);
}

.box2 {
    background: var(--secondary-color);
}

.box3 {
    background: var(--accent-color);
    color: #333;
}

/* 防抖输入 */
#debounce-input {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s;
}

#debounce-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

#debounce-result {
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 6px;
    min-height: 3rem;
    color: var(--text-color);
}

/* 渐变文字 */
.gradient-text {
    background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin: 0;
}

/* 复制功能 */
#copy-input {
    width: 70%;
    padding: 0.8rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    margin-right: 0.5rem;
}

#copy-feedback {
    display: block;
    margin-top: 0.5rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* 响应式网格 */
.responsive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
}

.grid-item {
    background: var(--primary-color);
    color: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    font-size: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.grid-item:hover {
    transform: scale(1.05);
}

/* 工具提示 */
.tooltip-btn {
    position: relative;
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
}

.tooltip-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: #333;
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    font-size: 0.9rem;
    font-weight: normal;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tooltip-btn::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    border: 6px solid transparent;
    border-top-color: #333;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.tooltip-btn:hover::after,
.tooltip-btn:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

/* 页脚 */
footer {
    background: var(--card-bg);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-light);
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
}

footer p {
    margin: 0.5rem 0;
}

.icp-info {
    margin-top: 0.8rem;
    font-size: 0.9rem;
}

.icp-info a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.3s;
}

.icp-info a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .tricks-grid {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 2rem;
    }

    header p {
        font-size: 1rem;
    }

    .trick-card {
        padding: 1rem;
    }

    .gradient-text {
        font-size: 1.5rem;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

