/* YoiBlog Default Theme */

/* === CSS Variables === */
:root {
  --bg: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #dbeafe;
  --border: #e2e8f0;
  --code-bg: #f1f5f9;
  --code-text: #0f172a;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 780px;
  --header-height: 64px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #60a5fa;
  --accent-hover: #93bbfd;
  --accent-light: #1e3a5f;
  --border: #334155;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* === Header === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.site-title:hover { color: var(--accent); }

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

.nav a {
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}
.nav a:hover, .nav a.active {
  color: var(--accent);
  background: var(--accent-light);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  margin-left: 8px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
}

/* === Main Content === */
.main {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px;
  flex: 1;
}

.wide-layout { max-width: 1100px; }

/* === Post List (Index) === */
.post-list { display: flex; flex-direction: column; gap: 24px; }

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: all var(--transition);
}
.post-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.post-card-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--accent); }

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

.post-excerpt {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

/* === Tags === */
.tag {
  display: inline-block;
  padding: 2px 10px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all var(--transition);
}
.tag:hover {
  background: var(--accent);
  color: white;
}

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

.tag-large { font-size: 1rem; padding: 4px 16px; }
.tag-medium { font-size: 0.88rem; padding: 3px 12px; }

/* === Post Content === */
.post-header { margin-bottom: 32px; }

.post-title {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

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

.post-content h1 { font-size: 1.8rem; margin: 2em 0 0.6em; font-weight: 800; letter-spacing: -0.02em; }
.post-content h2 { font-size: 1.5rem; margin: 1.8em 0 0.5em; font-weight: 700; letter-spacing: -0.02em; }
.post-content h3 { font-size: 1.25rem; margin: 1.5em 0 0.4em; font-weight: 600; }
.post-content h4 { font-size: 1.1rem; margin: 1.3em 0 0.3em; font-weight: 600; }

.post-content p { margin-bottom: 1.2em; }

.post-content ul, .post-content ol {
  margin-bottom: 1.2em;
  padding-left: 1.5em;
}
.post-content li { margin-bottom: 0.3em; }

.post-content blockquote {
  border-left: 4px solid var(--accent);
  padding: 16px 20px;
  margin: 1.5em 0;
  background: var(--bg-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-style: italic;
}
.post-content blockquote p:last-child { margin-bottom: 0; }

.post-content code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--code-text);
}

.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  overflow-x: auto;
  margin: 1.5em 0;
  position: relative;
}
.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.88rem;
  line-height: 1.6;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.95rem;
}
.post-content th, .post-content td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}
.post-content th {
  background: var(--bg-secondary);
  font-weight: 600;
}
.post-content tr:hover { background: var(--bg-secondary); }

.post-content img {
  display: block;
  margin: 1.5em auto;
  box-shadow: var(--shadow);
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.post-content .task-list-item {
  list-style: none;
  margin-left: -1.5em;
}
.post-content .task-list-item input {
  margin-right: 8px;
}

/* === Syntax Highlighting (Pygments) === */
.highlight { background: var(--code-bg); border-radius: var(--radius-sm); }
.highlight pre { margin: 0; padding: 16px; }

/* === Post Navigation === */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.post-nav-item {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.post-nav-item:hover {
  border-color: var(--accent);
  background: var(--bg-secondary);
}

.post-nav-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.post-nav-title { font-weight: 600; font-size: 0.95rem; color: var(--text); }

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

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

.toc-title {
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.toc ul {
  list-style: none;
  padding-left: 0;
}
.toc ul ul { padding-left: 16px; }
.toc li { margin: 4px 0; }
.toc a {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.toc a:hover { color: var(--accent); }

/* === Pagination === */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 40px;
  padding-top: 24px;
}

.pagination a, .pagination span {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}
.pagination a {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  transition: all var(--transition);
}
.pagination a:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.pagination .current {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
}

/* === Archive === */
.archive-year {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
  margin: 32px 0 16px;
  letter-spacing: -0.02em;
}
.archive-year:first-child { margin-top: 0; }

.archive-list { list-style: none; }
.archive-item {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.archive-date {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.archive-title a { color: var(--text); font-weight: 500; }
.archive-title a:hover { color: var(--accent); }

/* === Search === */
.search-input {
  width: 100%;
  padding: 14px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
  margin-bottom: 24px;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

.search-results { list-style: none; }
.search-result-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.search-result-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }
.search-result-excerpt { color: var(--text-secondary); font-size: 0.9rem; }

/* === Page Title === */
.page-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 32px;
}

/* === Footer === */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: auto;
}
.footer a { color: var(--text-secondary); }
.footer a:hover { color: var(--accent); }

/* === Responsive === */
@media (max-width: 768px) {
  .header-inner { padding: 0 16px; }

  .nav { display: none; }
  .nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px;
    box-shadow: var(--shadow-lg);
  }

  .mobile-menu-btn { display: block; }

  .main { padding: 24px 16px; }

  .post-title { font-size: 1.6rem; }
  .post-card { padding: 20px; }
  .post-card-title { font-size: 1.2rem; }

  .post-nav { grid-template-columns: 1fr; }

  .archive-item { flex-direction: column; gap: 4px; }
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.post-card { animation: fadeIn 0.4s ease both; }
.post-card:nth-child(2) { animation-delay: 0.05s; }
.post-card:nth-child(3) { animation-delay: 0.1s; }
.post-card:nth-child(4) { animation-delay: 0.15s; }
.post-card:nth-child(5) { animation-delay: 0.2s; }

/* === Permalink anchors === */
.post-content .headerlink {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-left: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}
.post-content h1:hover .headerlink,
.post-content h2:hover .headerlink,
.post-content h3:hover .headerlink,
.post-content h4:hover .headerlink { opacity: 1; }

/* === Profile Page === */
.profile-page { max-width: 640px; margin: 0 auto; }

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  margin-bottom: 32px;
}

.profile-header { margin-bottom: 24px; }

.profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 16px;
  border: 3px solid var(--accent-light);
}

.profile-avatar-placeholder {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: white;
  font-size: 3rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.profile-name {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.profile-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

.profile-bio {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 24px;
  padding: 0 16px;
}

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 24px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.profile-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
}
.profile-stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.profile-social {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-social-link {
  display: inline-block;
  padding: 6px 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.profile-social-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.profile-recent { margin-top: 8px; }
.profile-section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
}

/* === Math (KaTeX) === */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 0;
}
.arithmatex { overflow-x: auto; }

/* === Extended Markdown === */
.post-content mark, .post-content .mark {
  background: #fef08a;
  padding: 1px 4px;
  border-radius: 3px;
}
[data-theme="dark"] .post-content mark,
[data-theme="dark"] .post-content .mark {
  background: #854d0e;
  color: #fef08a;
}

.post-content sub { font-size: 0.8em; }
.post-content sup { font-size: 0.8em; }

.post-content del { color: var(--text-muted); }

.post-content abbr {
  text-decoration: underline dotted;
  cursor: help;
}

.post-content dt {
  font-weight: 700;
  margin-top: 1em;
}
.post-content dd {
  margin-left: 1.5em;
  margin-bottom: 0.5em;
  color: var(--text-secondary);
}

.post-content details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 1.2em 0;
  background: var(--bg-secondary);
}
.post-content details[open] > summary { margin-bottom: 12px; }
.post-content summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}

.post-content kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.82em;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* === Sort Controls === */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.sort-bar-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}
.sort-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}
.sort-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.sort-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* === Print === */
@media print {
  .header, .footer, .post-nav, .toc, .theme-toggle { display: none; }
  body { color: #000; background: #fff; }
  .main { max-width: 100%; }
}
