/* CSS Variables */
:root {
  /* Light theme colors */
  --bg-primary: #faf9f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f5f4f2;
  --text-primary: #2d3748;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --accent-color: #e07a5f;
  --accent-hover: #cf6649;
  --border-color: #e2e8f0;
  --shadow: rgba(0, 0, 0, 0.1);
  --code-bg: #f7fafc;
  --blockquote-bg: #f7fafc;
  --blockquote-border: #e07a5f;
  --tag-bg: #edf2f7;
  --tag-hover: #e2e8f0;
}

.dark {
  /* Dark theme colors */
  --bg-primary: #1a202c;
  --bg-secondary: #2d3748;
  --bg-tertiary: #233040;
  --text-primary: #f7fafc;
  --text-secondary: #e2e8f0;
  --text-muted: #a0aec0;
  --accent-color: #f6ad55;
  --accent-hover: #ed8936;
  --border-color: #4a5568;
  --shadow: rgba(0, 0, 0, 0.3);
  --code-bg: #1a202c;
  --blockquote-bg: #2d3748;
  --blockquote-border: #f6ad55;
  --tag-bg: #2d3748;
  --tag-hover: #4a5568;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-title {
  font-size: 1.8rem;
  font-weight: 700;
}

.site-title a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

.nav {
  display: flex;
  gap: 1.5rem;
}

.nav-item {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
  position: relative;
}

.nav-item:hover {
  color: var(--accent-color);
}

/* Theme Toggle Button */
.theme-toggle {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
}

.sun-icon, .moon-icon {
  color: var(--text-primary);
}

.sun-icon {
  display: block;
}

.moon-icon {
  display: none;
}

.dark .sun-icon {
  display: none;
}

.dark .moon-icon {
  display: block;
}

/* Search */
.search-container {
  display: flex;
  gap: 0.5rem;
  position: relative;
}

#searchInput {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  width: 200px;
  transition: all 0.3s ease;
}

#searchInput:focus {
  outline: none;
  border-color: var(--accent-color);
  width: 250px;
}

.search-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.search-btn:hover {
  background: var(--bg-tertiary);
}

.search-results {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 6px var(--shadow);
  max-width: 400px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
}

.search-results.hidden {
  display: none;
}

.search-result-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

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

.search-result-item a {
  color: var(--text-primary);
  text-decoration: none;
}

.search-result-item a:hover {
  color: var(--accent-color);
}

.search-result-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.search-result-excerpt {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Content Wrapper & Sidebar */
.content-wrapper {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 2rem;
}

/* Profile Card */
.profile-card {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 4px 12px var(--shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.profile-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
  opacity: 0.1;
  border-radius: 16px 16px 0 0;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--bg-secondary);
  box-shadow: 0 4px 12px var(--shadow);
  position: relative;
  z-index: 1;
  transition: all 0.3s ease;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-hover) 100%);
  color: white;
}

.avatar-placeholder svg {
  width: 50px;
  height: 50px;
}

.profile-name {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 1;
}

.profile-bio {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
}

/* Profile Stats */
.profile-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  position: relative;
  z-index: 1;
}

.stat-item {
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-color);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Profile Social Links */
.profile-social {
  display: flex;
  justify-content: center;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.social-link {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: 50%;
  color: var(--text-secondary);
  transition: all 0.3s ease;
  cursor: pointer;
}

.social-link:hover {
  background: var(--accent-color);
  color: white;
  transform: translateY(-2px);
}

.social-link svg {
  width: 20px;
  height: 20px;
}

/* Custom Cursor Effect on Profile Card */
.profile-card {
  cursor: default;
}

.profile-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px var(--shadow);
}

.profile-card:hover .profile-avatar {
  transform: scale(1.05);
  border-color: var(--accent-color);
}

/* Magic cursor effect */
.profile-card * {
  cursor: default;
}

.profile-card .social-link {
  cursor: pointer;
}

/* Main Content */
.main {
  min-height: calc(100vh - 300px);
  padding: 2rem 0;
}

/* Home Page */
.home {
  animation: fadeIn 0.5s ease;
}

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

.profile {
  text-align: center;
  padding: 3rem 0;
  margin-bottom: 2rem;
}

.profile h2 {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 1.2rem;
}

/* Posts */
.post {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 4px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.post:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
}

.post-title {
  margin-bottom: 0.75rem;
}

.post-title a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

.post-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.category {
  color: var(--accent-color);
}

.tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  background: var(--tag-bg);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  transition: background 0.2s ease;
}

.tag:hover {
  background: var(--tag-hover);
}

.post-excerpt {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.7;
}

.read-more {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.read-more:hover {
  color: var(--accent-hover);
}

/* Post Detail */
.post-detail {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 3rem 2rem;
  box-shadow: 0 2px 4px var(--shadow);
}

.post-detail .post-title {
  font-size: 2.2rem;
  margin-bottom: 1.5rem;
}

.post-detail .post-meta {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

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

.post-content h2 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.post-content h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.post-content p {
  margin-bottom: 1rem;
}

.post-content a {
  color: var(--accent-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.post-content a:hover {
  border-bottom-color: var(--accent-color);
}

.post-content ul,
.post-content ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

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

.post-content code {
  background: var(--code-bg);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.post-content pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.post-content pre code {
  background: transparent;
  padding: 0;
}

.post-content blockquote {
  border-left: 4px solid var(--blockquote-border);
  background: var(--blockquote-bg);
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
  border-radius: 0 8px 8px 0;
}

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

/* Comments */
.comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.comments h2 {
  margin-bottom: 1.5rem;
}

/* Archive */
.archive-year {
  margin-bottom: 2rem;
}

.archive-year h3 {
  color: var(--accent-color);
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.archive-post {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.archive-post:last-child {
  border-bottom: none;
}

.archive-post time {
  color: var(--text-muted);
  font-size: 0.9rem;
  min-width: 80px;
}

.archive-post a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* Tags & Categories */
.tags-cloud,
.categories-list {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.tag-item,
.category-item {
  background: var(--bg-secondary);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  box-shadow: 0 2px 4px var(--shadow);
  transition: all 0.3s ease;
}

.tag-item:hover,
.category-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
  color: var(--accent-color);
}

.tag-count,
.category-count {
  background: var(--accent-color);
  color: white;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  margin-top: 2rem;
  padding: 1rem 0;
}

.pagination a {
  color: var(--accent-color);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.3s ease;
}

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

.page-number {
  color: var(--text-secondary);
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
  margin-top: 3rem;
  color: var(--text-muted);
}

.footer p {
  margin-bottom: 0.5rem;
}

.footer a {
  color: var(--accent-color);
  text-decoration: none;
}

.social-links {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.social-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* Responsive Design */
@media (max-width: 768px) {
  .content-wrapper {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .profile-card {
    margin-bottom: 2rem;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .search-container {
    width: 100%;
  }

  #searchInput {
    width: 100%;
  }

  #searchInput:focus {
    width: 100%;
  }

  .search-results {
    left: 0;
    right: 0;
  }

  .post {
    padding: 1.5rem;
  }

  .post-detail {
    padding: 2rem 1.5rem;
  }

  .post-detail .post-title {
    font-size: 1.8rem;
  }
}
