@tailwind base;
@tailwind components;
@tailwind utilities;

/* CSS Variables */
:root {
  /* 浅色模式 */
  --color-bg-primary: #F7F5F0;
  --color-bg-secondary: #FFFFFF;
  --color-bg-tertiary: #EDE9E0;
  --color-text-primary: #2D3E50;
  --color-text-secondary: #5A6A7A;
  --color-text-tertiary: #8A94A6;
  --color-accent: #C9A961;
  --color-accent-hover: #B89850;
  --color-border: #E5E1D8;
  --color-code-bg: #F0EDE6;
}

[data-theme="dark"] {
  /* 暗色模式 */
  --color-bg-primary: #1A1F2B;
  --color-bg-secondary: #232936;
  --color-bg-tertiary: #2D3544;
  --color-text-primary: #D4D4D4;
  --color-text-secondary: #A0AAB8;
  --color-text-tertiary: #6B7280;
  --color-accent: #D4B86A;
  --color-accent-hover: #E0C87A;
  --color-border: #3A4150;
  --color-code-bg: #1E2530;
}

/* 系统偏好检测 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg-primary: #1A1F2B;
    --color-bg-secondary: #232936;
    --color-bg-tertiary: #2D3544;
    --color-text-primary: #D4D4D4;
    --color-text-secondary: #A0AAB8;
    --color-text-tertiary: #6B7280;
    --color-accent: #D4B86A;
    --color-accent-hover: #E0C87A;
    --color-border: #3A4150;
    --color-code-bg: #1E2530;
  }
}

/* Base Styles */
@layer base {
  body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
  }
  
  h1, h2, h3, h4, h5, h6 {
    font-family: 'Noto Serif SC', 'Source Serif 4', serif;
    font-weight: 600;
  }
}

/* Utility Classes */
@layer utilities {
  .bg-primary { background-color: var(--color-bg-primary); }
  .bg-secondary { background-color: var(--color-bg-secondary); }
  .bg-tertiary { background-color: var(--color-bg-tertiary); }
  .text-primary { color: var(--color-text-primary); }
  .text-secondary { color: var(--color-text-secondary); }
  .text-tertiary { color: var(--color-text-tertiary); }
  .text-accent { color: var(--color-accent); }
  .hover\:text-accent:hover { color: var(--color-accent); }
  .border-border { border-color: var(--color-border); }
}

/* Typography */
.font-serif {
  font-family: 'Noto Serif SC', 'Source Serif 4', serif;
}

.font-sans {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Article Content */
.article-content {
  line-height: 1.8;
  font-size: 1.0625rem;
}

.article-content h2 {
  font-size: 1.5rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--color-text-primary);
}

.article-content h3 {
  font-size: 1.25rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--color-text-primary);
}

.article-content p {
  margin-bottom: 1.25rem;
}

.article-content a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.2s;
}

.article-content a:hover {
  text-decoration-color: var(--color-accent);
}

.article-content ul,
.article-content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.article-content li {
  margin-bottom: 0.5rem;
}

.article-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

.article-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875em;
  background-color: var(--color-code-bg);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
}

.article-content pre {
  background-color: var(--color-code-bg);
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.article-content pre code {
  background: none;
  padding: 0;
}

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
}

/* Table of Contents */
.toc {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
}

.toc-title {
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--color-text-primary);
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li {
  margin: 0.375rem 0;
}

.toc a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
}

.toc a:hover {
  color: var(--color-accent);
}

/* Card Styles */
.card {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Tag Styles */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  background-color: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  border-radius: 9999px;
  transition: background-color 0.2s, color 0.2s;
}

.tag:hover {
  background-color: var(--color-accent);
  color: var(--color-bg-primary);
}

/* Search Results */
.search-result {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
  transition: background-color 0.15s;
}

.search-result:hover {
  background-color: var(--color-bg-secondary);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result-title {
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: 0.25rem;
}

.search-result-summary {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.search-highlight {
  background-color: rgba(201, 169, 97, 0.3);
  padding: 0.125rem 0.25rem;
  border-radius: 0.125rem;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 3rem;
}

.pagination a,
.pagination span {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

.pagination a {
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  transition: all 0.2s;
}

.pagination a:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.pagination .current {
  background-color: var(--color-accent);
  color: var(--color-bg-primary);
}

/* Mobile Menu Animation */
#mobile-menu {
  transition: all 0.2s ease-in-out;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* Selection */
::selection {
  background-color: rgba(201, 169, 97, 0.3);
  color: var(--color-text-primary);
}
