* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90e2;
    --secondary-color: #50c878;
    --bg-color: #f5f7fa;
    --sidebar-bg: #2c3e50;
    --text-color: #333;
    --text-light: #666;
    --border-color: #e0e0e0;
    --code-bg: #282c34;
    --code-text: #abb2bf;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏样式 */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 20px;
    margin-bottom: 15px;
    color: white;
}

.search-box {
    display: flex;
    gap: 5px;
}

.search-box input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 14px;
}

.search-box input::placeholder {
    color: rgba(255,255,255,0.5);
}

.search-box button {
    padding: 8px 12px;
    background: var(--primary-color);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
}

.nav-menu {
    padding: 10px 0;
}

.nav-section {
    margin-bottom: 10px;
}

.nav-section h3 {
    padding: 10px 20px;
    font-size: 12px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.6);
    letter-spacing: 1px;
}

.nav-section ul {
    list-style: none;
}

.nav-section li {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.nav-section a {
    display: block;
    padding: 12px 20px 12px 30px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s;
}

.nav-section a:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    padding-left: 35px;
}

.nav-section a.active {
    background: var(--primary-color);
    color: white;
}

/* 主内容区样式 */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 40px;
    max-width: 1200px;
}

.welcome-page {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.welcome-page h1 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 32px;
}

.welcome-page > p {
    font-size: 18px;
    color: var(--text-light);
    margin-bottom: 40px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.feature-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.feature-card h3 {
    margin-bottom: 10px;
    font-size: 20px;
}

.feature-card p {
    opacity: 0.9;
    font-size: 14px;
}

.quick-start {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 2px solid var(--border-color);
}

.quick-start h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.quick-start > p {
    margin-bottom: 20px;
    color: var(--text-light);
}

.recommended {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
}

.recommended h3 {
    margin-bottom: 15px;
    color: var(--text-color);
}

.recommended ol {
    margin-left: 20px;
}

.recommended li {
    margin-bottom: 10px;
    color: var(--text-light);
}

.recommended a {
    color: var(--primary-color);
    text-decoration: none;
}

.recommended a:hover {
    text-decoration: underline;
}

/* 函数页面样式 */
.function-page {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.function-page h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 32px;
}

.function-page .subtitle {
    color: var(--text-light);
    font-size: 18px;
    margin-bottom: 30px;
}

.section {
    margin-bottom: 40px;
}

.section h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.section h3 {
    color: var(--text-color);
    margin: 20px 0 10px 0;
}

.section p {
    margin-bottom: 15px;
    color: var(--text-light);
    line-height: 1.8;
}

/* 可视化容器 */
.visualization-container {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 8px;
    margin: 20px 0;
    border: 2px solid var(--border-color);
}

.canvas-container {
    position: relative;
    margin: 20px 0;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

canvas {
    display: block;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: 4px;
}

.control-group {
    flex: 1;
    min-width: 200px;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-color);
    font-weight: 500;
}

.control-group input[type="range"] {
    width: 100%;
    margin-bottom: 5px;
}

.control-group .value-display {
    color: var(--primary-color);
    font-weight: bold;
}

/* 代码块样式 */
.code-block {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 20px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 20px 0;
    font-family: 'Consolas', 'Monaco', 'Fira Code', 'Source Code Pro', monospace;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre;
    tab-size: 4;
    position: relative;
}

/* Shader 代码块（更大的内边距） */
pre.shader-code,
.shader-code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 24px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
    font-family: 'Consolas', 'Monaco', 'Fira Code', 'Source Code Pro', monospace;
    font-size: 14px;
    line-height: 1.8;
    white-space: pre;
    tab-size: 4;
    border-left: 4px solid var(--primary-color);
}

/* 旧的样式类（兼容现有页面） */
.code-block .comment,
.shader-code .comment {
    color: #5c6370;
    font-style: italic;
}

.code-block .keyword,
.shader-code .keyword {
    color: #c678dd;
    font-weight: 500;
}

.code-block .function,
.shader-code .function {
    color: #61afef;
}

.code-block .string,
.shader-code .string {
    color: #98c379;
}

.code-block .number,
.shader-code .number {
    color: #d19a66;
}

/* 新的 HLSL 语法高亮样式 */
.hlsl-keyword {
    color: #c678dd;
    font-weight: 500;
}

.hlsl-builtin {
    color: #61afef;
}

.hlsl-comment {
    color: #5c6370;
    font-style: italic;
}

.hlsl-string {
    color: #98c379;
}

.hlsl-number {
    color: #d19a66;
}

.hlsl-semantic {
    color: #e5c07b;
    font-weight: 600;
}

.hlsl-unity-var {
    color: #56b6c2;
}

.hlsl-preprocessor {
    color: #e06c75;
}

/* 代码块标题（可选） */
.code-block-title {
    background: #21252b;
    color: #9da5b4;
    padding: 8px 20px;
    margin: -20px -20px 15px -20px;
    border-radius: 6px 6px 0 0;
    font-size: 12px;
    border-bottom: 1px solid #181a1f;
}

/* 行号支持 */
.code-block.with-line-numbers {
    padding-left: 60px;
}

.code-block .line-numbers {
    position: absolute;
    left: 0;
    top: 20px;
    width: 40px;
    text-align: right;
    color: #4b5263;
    user-select: none;
    font-size: 12px;
    line-height: 1.7;
    padding-right: 10px;
    border-right: 1px solid #3e4451;
}

/* 矩阵可视化 */
.matrix-visualization {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin: 30px 0;
}

.matrix-box {
    background: white;
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.matrix-box h4 {
    margin-bottom: 15px;
    color: var(--text-color);
    text-align: center;
}

.matrix {
    display: inline-block;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    padding: 15px;
    background: #f8f9fa;
}

.matrix-row {
    display: flex;
    gap: 10px;
    margin: 5px 0;
}

.matrix-cell {
    width: 60px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-weight: bold;
    color: var(--text-color);
}

.matrix-cell.highlight {
    background: #fff3cd;
    border-color: #ffc107;
}

/* 步骤说明 */
.steps {
    margin: 20px 0;
}

.step {
    background: #f8f9fa;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
}

.step-number {
    display: inline-block;
    width: 30px;
    height: 30px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 30px;
    font-weight: bold;
    margin-right: 10px;
}

/* 术语卡片样式 */
.term-card {
    background: white;
    padding: 25px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-left: 4px solid var(--primary-color);
}

.term-card h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 22px;
}

.term-details {
    color: var(--text-light);
}

.term-details p {
    margin-bottom: 10px;
}

.term-details ul {
    margin-left: 20px;
    margin-top: 10px;
}

.term-details li {
    margin-bottom: 5px;
}

/* 学习路径样式 */
.learning-path {
    margin: 40px 0;
}

.path-steps {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.path-step {
    display: flex;
    gap: 20px;
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.path-step .step-number {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
}

.path-step .step-content {
    flex: 1;
}

.path-step h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.path-step ul {
    margin-left: 20px;
    margin-top: 10px;
}

.path-step li {
    margin-bottom: 5px;
}

.path-step a {
    color: var(--primary-color);
    text-decoration: none;
}

.path-step a:hover {
    text-decoration: underline;
}

/* 快速链接卡片 */
.quick-links {
    margin: 40px 0;
}

.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.quick-link-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-decoration: none;
    transition: transform 0.3s, box-shadow 0.3s;
}

.quick-link-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.quick-link-card h3 {
    margin-bottom: 10px;
    font-size: 20px;
}

.quick-link-card p {
    opacity: 0.9;
    font-size: 14px;
}

/* 介绍部分样式 */
.intro-section {
    margin: 40px 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }

    .path-step {
        flex-direction: column;
    }

    .link-grid {
        grid-template-columns: 1fr;
    }
}

/* 搜索高亮 */
.highlight {
    background: yellow;
    padding: 2px 4px;
    border-radius: 2px;
}

/* --- Visual Explanations --- */

.visual-explanation {
    background: white;
    padding: 20px;
    margin: 20px 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.visual-explanation h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.diagram-container {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 4px;
    margin-bottom: 10px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    width: 100%;
}

/* SVG Styles */
.diagram-svg {
    max-width: 100%;
    height: auto;
}

.axis-line { stroke-width: 2; stroke-linecap: round; }
.axis-x { stroke: #eb5757; }
.axis-y { stroke: #50c878; }
.axis-z { stroke: #4a90e2; }

.vector-line { stroke: #333; stroke-width: 2; marker-end: url(#arrow); }
.normal-line { stroke: #9b59b6; stroke-width: 2; stroke-dasharray: 4; marker-end: url(#arrow-purple); }
.light-line { stroke: #f1c40f; stroke-width: 3; marker-end: url(#arrow-yellow); }

.diagram-text { font-family: monospace; font-size: 14px; fill: #555; }
.angle-arc { fill: none; stroke: #666; stroke-width: 1; stroke-dasharray: 2; }

/* CSS-based UV Grid */
.uv-visualizer {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.uv-box {
    text-align: center;
}

.uv-grid {
    width: 200px;
    height: 200px;
    background-image: 
        linear-gradient(rgba(0,0,0,0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.1) 1px, transparent 1px);
    background-size: 20px 20px; /* 0.1 unit per line */
    border: 2px solid #333;
    position: relative;
    background-color: #eee;
    margin: 0 auto 10px auto;
    overflow: hidden;
}

.uv-content {
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"><rect width="50%" height="50%" fill="%23eb5757" fill-opacity="0.5"/><rect x="50%" y="50%" width="50%" height="50%" fill="%234a90e2" fill-opacity="0.5"/></svg>');
    background-size: 100% 100%;
    transition: all 0.5s ease;
}

/* Image Placeholder for Screenshots */
.image-placeholder {
    width: 100%;
    min-height: 150px;
    background: #f8f9fa;
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    margin: 20px 0;
    text-align: center;
    color: #718096;
}

.image-placeholder .icon {
    font-size: 40px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.image-placeholder .desc {
    font-weight: bold;
    margin-bottom: 5px;
    color: #4a5568;
}

.image-placeholder .instruction {
    font-size: 12px;
    color: #a0aec0;
}
