/*
Theme Name: 墨羽 (Moyu)
Theme URI: https://example.com/moyu
Author: Your Name
Author URI: https://example.com
Description: 墨羽主题 — 简洁优雅的 WordPress 主题，如水墨羽翼般轻盈灵动
Version: 1.0.0
License: GPL v2 or later
Text Domain: moyu
*/

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --text: #1f2937;
  --text-light: #6b7280;
  --bg: #ffffff;
  --bg-alt: #f9fafb;
  --border: #e5e7eb;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* 防止 100vw 导致的移动端左右晃动 */
}

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

a:hover {
  color: var(--primary-dark);
}

img {
  max-width: 100%;
  height: auto;
}

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

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  background: var(--bg);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

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

.site-description {
  font-size: 0.875rem;
  color: var(--text-light);
}

/* Navigation */
.main-navigation ul {
  list-style: none;
  display: flex;
  gap: 24px;
}

.main-navigation a {
  color: var(--text);
  font-weight: 500;
  font-size: 0.95rem;
}

.main-navigation a:hover {
  color: var(--primary);
}

.main-navigation .current-menu-item > a {
  color: var(--primary);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

/* Content */
.site-content {
  padding: 48px 0;
  min-height: 60vh;
}

.content-area {
  display: flex;
  gap: 40px;
}

.content-area.has-sidebar .primary {
  flex: 1;
  min-width: 0;
}

.content-area.has-sidebar .secondary {
  width: 320px;
  flex-shrink: 0;
}

/* Posts */
.post,
.page {
  margin-bottom: 48px;
}

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

.entry-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
}

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

.entry-meta {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 16px;
}

.entry-meta span::after {
  content: "·";
  margin: 0 8px;
}

.entry-meta span:last-child::after {
  content: none;
}

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

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

.entry-content h2,
.entry-content h3 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.entry-content ul,
.entry-content ol {
  margin: 1em 0;
  padding-left: 24px;
}

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

.entry-content img {
  border-radius: var(--radius);
  margin: 1.5em 0;
}

.entry-content blockquote {
  border-left: 4px solid var(--primary);
  padding: 16px 20px;
  margin: 1.5em 0;
  background: var(--bg-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
}

.entry-content pre {
  background: #1f2937;
  color: #f3f4f6;
  padding: 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.9rem;
  margin: 1.5em 0;
}

.entry-content code {
  background: var(--bg-alt);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

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

/* Featured Image */
.post-thumbnail {
  margin-bottom: 24px;
}

.post-thumbnail img {
  border-radius: var(--radius);
  width: 100%;
}

/* Read More */
.read-more {
  display: inline-block;
  margin-top: 16px;
  font-weight: 600;
}

/* Pagination */
.pagination {
  margin-top: 40px;
  text-align: center;
}

.pagination .nav-links {
  display: inline-flex;
  gap: 8px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.pagination .current {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Sidebar */
.widget {
  margin-bottom: 32px;
}

.widget-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.widget ul {
  list-style: none;
}

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

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

.widget a {
  color: var(--text);
}

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

/* Search Form */
.search-form {
  display: flex;
  gap: 8px;
}

.search-form input[type="search"] {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
}

.search-form input[type="search"]:focus {
  border-color: var(--primary);
}

.search-form button {
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.search-form button:hover {
  background: var(--primary-dark);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  color: var(--text-light);
  font-size: 0.875rem;
}

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

/* 404 */
.error-404 {
  text-align: center;
  padding: 80px 20px;
}

.error-404 h1 {
  font-size: 6rem;
  color: var(--primary);
  line-height: 1;
}

.error-404 p {
  font-size: 1.2rem;
  margin: 16px 0 32px;
  color: var(--text-light);
}

/* Comments */
.comments-area {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.comment-list {
  list-style: none;
}

.comment {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.comment-meta {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

.comment-content {
  font-size: 0.95rem;
}

.reply a {
  font-size: 0.875rem;
  font-weight: 600;
}

/* ===== Single Article ===== */

/* Reading Progress */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 9999;
}

.reading-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #8b5cf6, #ec4899);
  transition: width 0.1s ease;
  border-radius: 0 2px 2px 0;
}

/* Article Hero */
.article-hero {
  position: relative;
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-top: calc(-48px);
  padding-top: 48px;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  transform: scale(1.05);
  transition: transform 0.3s;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.45) 50%, rgba(0,0,0,0.7) 100%);
}

.hero-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.08;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(255,255,255,0.3) 0, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.2) 0, transparent 50%),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,0.15) 0, transparent 50%);
}

.hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 800px;
  padding: 120px 20px 80px;
  animation: heroFadeIn 0.8s ease-out;
}

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

.hero-cats {
  margin-bottom: 20px;
}

.hero-cats a {
  display: inline-block;
  padding: 6px 16px;
  margin: 0 4px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.3s;
}

.hero-cats a:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.hero-title {
  font-size: clamp(1.8rem, 5vw, 3.5rem);
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
  text-shadow: 0 2px 20px rgba(0,0,0,0.3);
  margin-bottom: 24px;
}

.hero-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.hero-author {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero-author img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
}

.hero-author span {
  color: #fff;
  font-weight: 600;
}

.hero-meta-divider {
  color: rgba(255,255,255,0.4);
}

.hero-scroll-indicator {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  animation: bounceDown 2s infinite;
  z-index: 2;
}

@keyframes bounceDown {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(8px); }
}

/* Article Layout */
.article-layout {
  display: flex;
  gap: 48px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
}

/* Table of Contents */
.article-toc {
  display: none;
}

@media (min-width: 1024px) {
  .article-toc {
    display: block;
    width: 220px;
    flex-shrink: 0;
    margin-left: -240px;
  }

  .toc-sticky {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
    scrollbar-width: thin;
  }

  .toc-sticky::-webkit-scrollbar { width: 4px; }
  .toc-sticky::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  margin-bottom: 16px;
}

.toc-list {
  list-style: none;
  border-left: 2px solid var(--border);
}

.toc-list li {
  margin: 0;
}

.toc-list a {
  display: block;
  padding: 6px 16px;
  font-size: 0.85rem;
  color: var(--text-light);
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition: all 0.2s;
  line-height: 1.4;
}

.toc-list a:hover,
.toc-list a.active {
  color: var(--primary);
  border-left-color: var(--primary);
}

.toc-list .h3 { padding-left: 32px; font-size: 0.8rem; }

/* Article Main */
.article-main {
  flex: 1;
  min-width: 0;
  padding-top: 48px;
}

.article-main .entry-content {
  font-size: 1.1rem;
  line-height: 1.85;
  color: var(--text);
}

.article-main .entry-content h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 2em;
  margin-bottom: 0.6em;
  padding-bottom: 0.3em;
  border-bottom: 2px solid var(--border);
}

.article-main .entry-content h3 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
}

.article-main .entry-content h4 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 0.4em;
}

.article-main .entry-content p {
  margin-bottom: 1.4em;
}

.article-main .entry-content a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: rgba(37, 99, 235, 0.3);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  transition: text-decoration-color 0.2s;
}

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

.article-main .entry-content ul,
.article-main .entry-content ol {
  margin: 1.2em 0;
  padding-left: 28px;
}

.article-main .entry-content li {
  margin-bottom: 0.5em;
}

.article-main .entry-content img {
  border-radius: 12px;
  margin: 2em auto;
  display: block;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.article-main .entry-content blockquote {
  border: none;
  position: relative;
  padding: 24px 32px;
  margin: 2em 0;
  background: linear-gradient(135deg, #f0f4ff, #faf5ff);
  border-radius: 12px;
  font-style: italic;
  font-size: 1.15rem;
  color: #374151;
}

.article-main .entry-content blockquote::before {
  content: '"';
  position: absolute;
  top: -8px;
  left: 16px;
  font-size: 4rem;
  line-height: 1;
  color: var(--primary);
  opacity: 0.3;
  font-family: Georgia, serif;
}

.article-main .entry-content blockquote p:last-child {
  margin-bottom: 0;
}

.article-main .entry-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 24px;
  border-radius: 12px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 1.5em 0;
  position: relative;
}

.article-main .entry-content code {
  background: rgba(37, 99, 235, 0.08);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.88em;
  color: var(--primary);
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

.article-main .entry-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 0.9rem;
}

.article-main .entry-content hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 3em 0;
}

.article-main .entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 2em 0;
  font-size: 0.95rem;
}

.article-main .entry-content th,
.article-main .entry-content td {
  padding: 12px 16px;
  border: 1px solid var(--border);
  text-align: left;
}

.article-main .entry-content th {
  background: var(--bg-alt);
  font-weight: 600;
}

.article-main .entry-content tr:nth-child(even) {
  background: var(--bg-alt);
}

.article-main .entry-content iframe {
  border-radius: 12px;
  margin: 2em 0;
  max-width: 100%;
}

/* Tags */
.article-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

.tags-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.article-tags a {
  display: inline-block;
  padding: 5px 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--text);
  transition: all 0.2s;
}

.article-tags a:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Author Bio */
.author-bio {
  display: flex;
  gap: 24px;
  padding: 32px;
  margin-top: 32px;
  background: linear-gradient(135deg, var(--bg-alt), #f0f4ff);
  border-radius: 16px;
  align-items: flex-start;
}

.author-avatar img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.author-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.author-name a {
  color: var(--text);
}

.author-desc {
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.6;
}

/* Post Navigation */
.post-navigation {
  display: flex;
  gap: 20px;
  margin-top: 40px;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.nav-previous,
.nav-next {
  flex: 1;
}

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

.nav-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  margin-bottom: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  transition: color 0.2s;
}

.nav-next .nav-link {
  flex-direction: row-reverse;
}

.nav-link:hover {
  color: var(--primary);
}

.nav-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.nav-title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}

/* Related Posts */
.related-posts {
  margin-top: 48px;
}

.related-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.related-card {
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  transition: all 0.3s;
  display: block;
  color: var(--text);
}

.related-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.1);
  border-color: transparent;
  color: var(--text);
}

.related-thumb {
  height: 160px;
  background-size: cover;
  background-position: center;
}

.related-body {
  padding: 16px 18px 20px;
}

.related-cat {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}

.related-post-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 6px 0 8px;
  line-height: 1.35;
}

.related-date {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* Back to Top */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: all 0.3s;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--primary);
  transform: translateY(-3px);
}

/* Comments on Single */
.single-article .comments-area {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.single-article .comment-list {
  list-style: none;
}

.single-article .comment {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}

.single-article .comment-meta {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

.single-article .comment-content {
  font-size: 0.95rem;
}

.single-article .reply a {
  font-size: 0.85rem;
  font-weight: 600;
}

/* Responsive: Article */
@media (max-width: 1024px) {
  .article-hero { min-height: 55vh; }
  .hero-bg { background-attachment: scroll; } /* 修复中尺寸平板下的背景卡顿 */
  .related-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .main-navigation ul {
    display: none;
    flex-direction: column;
    gap: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
  }

  .main-navigation ul.toggled {
    display: flex;
  }

  .menu-toggle {
    display: block;
  }

  .main-navigation {
    position: relative;
  }

  .content-area.has-sidebar {
    flex-direction: column;
  }

  .content-area.has-sidebar .secondary {
    width: 100%;
  }

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

  .article-hero {
    min-height: 50vh;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-top: calc(-48px);
    padding: 48px 0 0;
    border-radius: 0;
  }

  .hero-bg {
    background-attachment: scroll;
  }

  .hero-title {
    font-size: 1.6rem;
  }

  .hero-meta {
    font-size: 0.8rem;
  }

  .hero-scroll-indicator {
    display: none;
  }

  .article-layout {
    padding: 0 16px;
  }

  .article-main {
    padding-top: 32px;
  }

  .article-main .entry-content {
    font-size: 1rem;
  }

  .article-main .entry-content h2 {
    font-size: 1.4rem;
  }

  .article-main .entry-content h3 {
    font-size: 1.15rem;
  }

  .article-main .entry-content blockquote {
    padding: 20px;
    font-size: 1rem;
  }

  .author-bio {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px;
  }

  .post-navigation {
    flex-direction: column;
    gap: 16px;
  }

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

  .nav-next .nav-link {
    flex-direction: row;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }

  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 42px;
    height: 42px;
  }
}

/* WordPress 标准图片对齐样式兼容 */
.aligncenter {
  display: block;
  margin: 1.5em auto;
}
.alignleft {
  float: left;
  margin: 0.5em 1.5em 1.5em 0;
}
.alignright {
  float: right;
  margin: 0.5em 0 1.5em 1.5em;
}
.clear, .clear-fix {
  clear: both;
}