:root {
  --primary-color: #2563eb;
  --text-color: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: all 0.2s;
}

a:hover {
  color: #1d4ed8;
}

.hover-lift {
  transition: transform 0.2s, box-shadow 0.2s;
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

.post-content {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-color);
}

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2rem 0 1rem;
}

.post-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1.5rem 0;
}

.post-content blockquote {
  border-left: 4px solid var(--border-color);
  padding: 0.5rem 0 0.5rem 1rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
}

.post-content code {
  background: #f3f4f6;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

.post-content pre {
  background: #282c34;
  border-radius: 8px;
  padding: 1rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}

.post-content pre code {
  background: transparent;
  padding: 0;
  border: none;
  font-family: 'JetBrains Mono', Consolas, Monaco, 'Andale Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #abb2bf;
}

.post-content pre[data-lang]::before {
  content: attr(data-lang);
  display: block;
  background: #21252b;
  color: #abb2bf;
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  margin: -1rem -1rem 1rem -1rem;
  border-radius: 8px 8px 0 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.post-content pre {
  counter-reset: line;
}

.post-content pre > code {
  counter-increment: line;
}

.post-content pre > code::before {
  content: counter(line);
  display: inline-block;
  width: 2em;
  padding-right: 1em;
  margin-right: 1em;
  text-align: right;
  color: #5c6370;
  border-right: 1px solid #3e4451;
}

.post-content code:not(pre code) {
  background: #f3f4f6;
  color: #ef4444;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'JetBrains Mono', Consolas, Monaco, 'Andale Mono', monospace;
}

.u-narrow {
  max-width: 768px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  html {
    font-size: 15px;
  }
  
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 页面过渡动画 */
.page-enter {
    animation: fadeIn 0.3s ease;
}

/* 交互效果 */
.btn {
    transition: all 0.2s ease;
}

.btn:active {
    transform: scale(0.98);
}

.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

/* 加载状态 */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.5rem;
    height: 1.5rem;
    margin: -0.75rem 0 0 -0.75rem;
    border: 2px solid var(--primary-color);
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 工具类 */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hover-underline {
    position: relative;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width 0.2s ease;
}

.hover-underline:hover::after {
    width: 100%;
}

/* 响应式优化 */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .h1, h1 {
        font-size: 1.75rem;
    }
    
    .h2, h2 {
        font-size: 1.5rem;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #60a5fa;
        --text-color: #e5e7eb;
        --text-muted: #9ca3af;
        --border-color: #374151;
    }

    body {
        background-color: #111827;
        color: var(--text-color);
    }

    .bg-white {
        background-color: #1f2937 !important;
    }

    .text-dark {
        color: var(--text-color) !important;
    }

    .border-top {
        border-color: var(--border-color) !important;
    }

    .card {
        background-color: #1f2937;
    }

    .post-content code:not(pre code) {
        background: #374151;
        color: #f87171;
    }
}

/* 语法高亮 - One Dark 主题 */
.hljs {
    color: #abb2bf;
}

.hljs-comment,
.hljs-quote {
    color: #5c6370;
    font-style: italic;
}

.hljs-doctag,
.hljs-keyword,
.hljs-formula {
    color: #c678dd;
}

.hljs-section,
.hljs-name,
.hljs-selector-tag,
.hljs-deletion,
.hljs-subst {
    color: #e06c75;
}

.hljs-literal {
    color: #56b6c2;
}

.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-attribute,
.hljs-meta .hljs-string {
    color: #98c379;
}

.hljs-attr,
.hljs-variable,
.hljs-template-variable,
.hljs-type,
.hljs-selector-class,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-number {
    color: #d19a66;
}

.hljs-symbol,
.hljs-bullet,
.hljs-link,
.hljs-meta,
.hljs-selector-id,
.hljs-title {
    color: #61aeee;
}

.hljs-built_in,
.hljs-title.class_,
.hljs-class .hljs-title {
    color: #e6c07b;
}

.hljs-emphasis {
    font-style: italic;
}

.hljs-strong {
    font-weight: bold;
}
