/*
 Theme Name: TechFlow
 Theme URI: https://github.com/techflow
 Description: 简洁大气的科技风格Typecho主题
 Version: 1.0.0
 Author: Matrix Agent
 Author URI: https://matrixagent.ai
*/

/* ================================
   CSS Variables
================================ */
:root {
  /* Light Mode Colors */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.1);
  --gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
}

/* Dark Mode Colors */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --border: #334155;
  --border-light: #1e293b;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* ================================
   Reset & Base
================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
}

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

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

/* ================================
   Layout
================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .header {
  background: rgba(30, 41, 59, 0.95);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--gradient);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg {
  width: 20px;
  height: 20px;
  fill: white;
}

.nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav a {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 8px 0;
  position: relative;
}

.nav a:hover,
.nav a.active {
  color: var(--text-primary);
}

.nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.nav a:hover::after,
.nav a.active::after {
  width: 100%;
}

/* Theme Toggle Button */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: var(--text-secondary);
  transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
  fill: var(--accent);
}

.theme-toggle .sun-icon {
  display: block;
}

.theme-toggle .moon-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  display: block;
}

/* Main Layout */
.main-wrapper {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  padding: 40px 0;
  min-height: calc(100vh - 64px);
}

.main-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 32px;
  box-shadow: var(--shadow);
}

/* ================================
   Sidebar
================================ */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-widget {
  background: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow);
}

.widget-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.widget-about {
  text-align: center;
}

.widget-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-bottom: 16px;
  border: 3px solid var(--accent);
}

.widget-about p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.widget-links {
  list-style: none;
}

.widget-links li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.widget-links li:last-child {
  border-bottom: none;
}

.widget-links a {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-item {
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.tag-item:hover {
  background: var(--accent);
  color: white;
}

/* ================================
   Post Cards
================================ */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.post-card {
  padding: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.post-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.post-date,
.post-category {
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.post-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.4;
}

.post-title a {
  color: var(--text-primary);
}

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

.post-excerpt {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 16px;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.post-tag {
  padding: 4px 10px;
  background: var(--bg-secondary);
  border-radius: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ================================
   Reading Progress
================================ */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--gradient);
  z-index: 10000;
  transition: width 0.1s ease;
  border-radius: 0 2px 2px 0;
}

/* ================================
   Single Post
================================ */
.single-post {
  padding: 0;
}

.post-cover {
  margin: -32px -32px 24px;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  max-height: 400px;
}

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

.post-category-badge {
  margin-bottom: 12px;
}

.post-category-badge .badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent);
  color: white;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.post-category-badge a {
  color: var(--accent);
  font-weight: 500;
}

.single-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.single-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 16px;
  color: var(--text-primary);
  position: relative;
}

.single-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.meta-item svg {
  opacity: 0.6;
}

.single-content {
  font-size: 1.05rem;
  line-height: 1.8;
}

.single-content h1,
.single-content h2,
.single-content h3,
.single-content h4,
.single-content h5,
.single-content h6 {
  margin-top: 2em;
  margin-bottom: 1em;
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.4;
}

.single-content h2 {
  font-size: 1.5rem;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.single-content h3 {
  font-size: 1.25rem;
}

.single-content p {
  margin-bottom: 1.5em;
}

.single-content ul,
.single-content ol {
  margin-bottom: 1.5em;
  padding-left: 2em;
}

.single-content li {
  margin-bottom: 0.5em;
}

.single-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5em 0;
}

.single-content blockquote {
  border-left: 4px solid var(--accent);
  padding: 16px 20px;
  margin: 1.5em 0;
  background: var(--bg-tertiary);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* ================================
   Article Table of Contents
================================ */
.post-toc {
  background: var(--bg-tertiary);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 32px;
  border: 1px solid var(--border);
}

.toc-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
}

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

.toc-content li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
}

.toc-content li:last-child {
  border-bottom: none;
}

.toc-content a {
  color: var(--text-secondary);
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

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

/* ================================
   Post Footer
================================ */
.post-footer {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.post-tags-section {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  color: var(--text-muted);
}

.post-tags-section a {
  padding: 6px 14px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.post-tags-section a:hover {
  background: var(--accent);
  color: white;
}

/* ================================
   Share Section
================================ */
.share-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
  margin-bottom: 24px;
}

.share-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.share-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.share-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--text-secondary);
}

.share-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.share-btn:hover svg {
  fill: var(--accent);
}

.share-btn.weibo:hover {
  border-color: #e6162d;
  background: #e6162d;
}

.share-btn.weibo:hover svg {
  fill: white;
}

.share-btn.twitter:hover {
  border-color: #1da1f2;
  background: #1da1f2;
}

.share-btn.twitter:hover svg {
  fill: white;
}

.share-btn.copy:hover {
  border-color: var(--accent);
  background: var(--accent);
}

.share-btn.copy:hover svg {
  fill: white;
}

/* Reward Image */
.reward-img {
  max-width: 200px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* ================================
   Reward Section
================================ */
.reward-section {
  text-align: center;
  margin-bottom: 32px;
}

.reward-btn {
  padding: 12px 32px;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  color: white;
  border: none;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.reward-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
}

.reward-qr {
  display: none;
  margin-top: 20px;
  padding: 24px;
  background: var(--bg-tertiary);
  border-radius: 16px;
  animation: fadeIn 0.3s ease;
}

.reward-qr.show {
  display: block;
}

.reward-qr p {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.qr-placeholder {
  width: 200px;
  height: 200px;
  margin: 0 auto;
  background: var(--bg-secondary);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border: 2px dashed var(--border);
}

.reward-img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  display: block;
}

/* ================================
   Post Navigation
================================ */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}

.post-nav > div {
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.post-nav > div span {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.post-nav > div a {
  color: var(--text-primary);
  font-weight: 500;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-nav > div a:hover {
  color: var(--accent);
}

.nav-prev {
  text-align: left;
}

.nav-next {
  text-align: right;
}

.post-nav .disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

.post-nav .disabled a {
  color: var(--text-muted);
  pointer-events: none;
}

/* ================================
   Related Posts
================================ */
.related-posts {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.related-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.related-title svg {
  fill: var(--accent);
}

.related-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.related-list a {
  display: block;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.related-list a:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.related-list .related-title {
  font-size: 0.95rem;
  margin-bottom: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.related-list .related-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ================================
   Code Highlighting (Prism.js)
================================ */
pre[class*="language-"],
code[class*="language-"] {
  font-family: "Fira Code", "Cascadia Code", Consolas, Monaco, "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  direction: ltr;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  tab-size: 2;
  hyphens: none;
}

pre[class*="language-"] {
  padding: 20px;
  margin: 1.5em 0;
  overflow: auto;
  background: var(--code-bg);
  border-radius: 12px;
  position: relative;
}

code[class*="language-"] {
  background: var(--code-bg);
  color: var(--code-text);
}

:not(pre) > code[class*="language-"] {
  padding: 2px 8px;
  border-radius: 4px;
  white-space: normal;
}

/* Prism.js Theme */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6a737d;
}

.token.punctuation {
  color: #e2e8f0;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: #f472b6;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #34d399;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: #fbbf24;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: #60a5fa;
}

.token.function,
.token.class-name {
  color: #c084fc;
}

.token.regex,
.token.important,
.token.variable {
  color: #fb923c;
}

/* ================================
   Footer
================================ */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 40px;
  text-align: center;
}

.footer-inner {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.footer-links a {
  color: var(--text-secondary);
}

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

/* ================================
   Pagination
================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.pagination a,
.pagination span {
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s ease;
}

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

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

/* ================================
   Responsive
================================ */
@media (max-width: 1024px) {
  .main-wrapper {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 0;
    gap: 12px;
  }

  .nav {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 16px;
  }

  .main-content {
    padding: 20px;
  }

  .single-title {
    font-size: 1.5rem;
  }

  .post-meta {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* ================================
   Animations
================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.post-card {
  animation: fadeIn 0.4s ease forwards;
}

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

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

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

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