/**
 * Mark's Blog - Global Stylesheet
 * PaperMod Style Theme
 * 
 * 使用方法：在所有页面中引入此文件
 * <link rel="stylesheet" href="/assets/css/global.css" />
 */

/* ===== CSS Variables - Theme System ===== */
:root {
  /* Light Theme Colors */
  --theme: #ffffff;
  --entry: #ffffff;
  --primary: #1e1e1e;
  --secondary: #6c6c6c;
  --tertiary: #d6d6d6;
  --content: #1f1f1f;
  --code-bg: #f5f5f5;
  --border: #eeeeee;
  
  /* Spacing & Sizing */
  --gap: 24px;
  --radius: 8px;
  --header-height: 60px;
  --main-width: 720px;
  
  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --theme: #1d1e20;
    --entry: #2e2e33;
    --primary: #dadada;
    --secondary: #9b9c9d;
    --tertiary: #414244;
    --content: #c4c4c5;
    --code-bg: #37383e;
    --border: #333333;
  }
}

/* Manual Dark Mode Toggle Class */
.dark {
  --theme: #1d1e20;
  --entry: #2e2e33;
  --primary: #dadada;
  --secondary: #9b9c9d;
  --tertiary: #414244;
  --content: #c4c4c5;
  --code-bg: #37383e;
  --border: #333333;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--primary);
  background: var(--theme);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  word-break: break-word;
  overflow-wrap: break-word;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--secondary);
}

img {
  max-width: 100%;
  height: auto;
}

/* ===== Header & Navigation ===== */
.header {
  background: var(--theme);
  position: sticky;
  top: 0;
  z-index: 99;
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: calc(var(--main-width) + var(--gap) * 2);
  margin: 0 auto;
  padding: 0 var(--gap);
  height: var(--header-height);
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.logo:hover {
  opacity: 0.8;
  color: var(--primary);
}

.nav-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 24px;
}

.nav-menu li a {
  color: var(--primary);
  font-size: 1rem;
  font-weight: 500;
  padding: 8px 4px;
  position: relative;
}

.nav-menu li a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width 0.3s ease;
}

.nav-menu li a:hover::after,
.nav-menu li a.active::after {
  width: 100%;
}

/* ===== Main Content Container ===== */
.main {
  max-width: var(--main-width);
  margin: 0 auto;
  padding: calc(var(--gap) * 2) var(--gap);
  min-height: calc(100vh - var(--header-height) - 120px);
}

/* ===== Page Title ===== */
.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 var(--gap) 0;
  padding-bottom: 12px;
  position: relative;
}

.page-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 60px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

/* ===== Card Component ===== */
.card {
  background: var(--entry);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
  margin-bottom: var(--gap);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: var(--primary);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 8px 0;
}

.card-meta {
  font-size: 0.875rem;
  color: var(--secondary);
  margin-bottom: 12px;
}

.card-content {
  color: var(--secondary);
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* ===== Button Component ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--primary);
  background: transparent;
  border: 1px solid var(--primary);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:hover {
  background: var(--primary);
  color: var(--theme);
}

.btn-primary {
  background: var(--primary);
  color: var(--theme);
}

.btn-primary:hover {
  opacity: 0.85;
}

/* ===== Tag Component ===== */
.tag {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--primary);
  background: var(--tertiary);
  border-radius: 20px;
  transition: all 0.2s ease;
}

.tag:hover {
  background: var(--primary);
  color: var(--theme);
}

/* ===== Article Content (Markdown) ===== */
.article-content {
  font-family: var(--font-sans);
  line-height: 1.8;
  color: var(--content);
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
  color: var(--primary);
  font-weight: 600;
  line-height: 1.3;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.article-content h1 { font-size: 2em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.article-content h2 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.article-content h3 { font-size: 1.25em; }
.article-content h4 { font-size: 1.1em; }

.article-content p {
  margin: 1em 0;
}

.article-content a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article-content img {
  border-radius: var(--radius);
  margin: 1em 0;
  border: 1px solid var(--border);
}

.article-content blockquote {
  margin: 1em 0;
  padding: 0.5em 1em;
  border-left: 4px solid var(--tertiary);
  background: var(--code-bg);
  color: var(--secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.article-content ul,
.article-content ol {
  padding-left: 2em;
  margin: 1em 0;
}

.article-content li {
  margin: 0.5em 0;
}

.article-content pre {
  background: var(--code-bg);
  padding: 16px;
  border-radius: var(--radius);
  overflow: auto;
  max-height: 500px;
  border: 1px solid var(--border);
  margin: 1em 0;
}

.article-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.article-content pre code {
  padding: 0;
  background: transparent;
  font-size: 0.85em;
  line-height: 1.5;
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
}

.article-content th,
.article-content td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}

.article-content th {
  background: var(--code-bg);
  font-weight: 600;
}

.article-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* ===== Footer ===== */
.footer {
  max-width: var(--main-width);
  margin: 0 auto;
  text-align: center;
  padding: var(--gap);
  color: var(--secondary);
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
}

.footer a {
  color: var(--secondary);
}

.footer a:hover {
  color: var(--primary);
}

.footer p {
  margin: 8px 0;
}

/* ===== Profile Card ===== */
.profile-card {
  text-align: center;
  background: var(--entry);
  border-radius: var(--radius);
  padding: 40px 30px;
  margin-bottom: var(--gap);
  border: 1px solid var(--border);
}

.profile-avatar {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.profile-avatar:hover {
  transform: scale(1.05);
}

.profile-name {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 16px 0 8px 0;
}

.profile-bio {
  color: var(--secondary);
  font-size: 1rem;
  margin: 0;
}

/* ===== Social Links ===== */
.social-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: var(--gap);
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.social-link:hover {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--theme);
}

.social-link svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ===== Archive List ===== */
.archive-list {
  margin: var(--gap) 0;
}

.archive-item {
  padding: 20px 24px;
  margin-bottom: 16px;
  background: var(--entry);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.archive-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.archive-date {
  font-size: 0.875rem;
  color: var(--secondary);
  margin-bottom: 8px;
}

.archive-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 8px 0;
}

.archive-summary {
  color: var(--secondary);
  font-size: 0.9375rem;
  margin: 0 0 12px 0;
  line-height: 1.6;
}

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  :root {
    --gap: 16px;
  }

  html {
    font-size: 15px;
  }

  .nav {
    flex-direction: column;
    height: auto;
    padding: 16px var(--gap);
    gap: 12px;
  }

  .nav-menu {
    gap: 16px;
  }

  .nav-menu li a {
    font-size: 0.9375rem;
  }

  .page-title {
    font-size: 1.5rem;
    text-align: center;
  }

  .page-title::after {
    left: 50%;
    transform: translateX(-50%);
  }

  .main {
    padding: var(--gap);
  }

  .profile-card {
    padding: 30px 20px;
  }

  .profile-avatar {
    width: 100px;
    height: 100px;
  }

  .social-links {
    flex-direction: column;
    align-items: center;
  }

  .social-link {
    width: 100%;
    max-width: 200px;
    justify-content: center;
  }
}
/* ===== Animated Signature ===== */
.animated-signature {
  display: block;
  margin: 0 auto 16px;
  max-width: 120px;
  height: auto;
}

.animated-signature svg {
  width: 100%;
  height: auto;
  display: block;
}

.animated-signature path {
  stroke-dasharray: 2400;
  stroke-dashoffset: 2400;
  fill: transparent;
  animation: drawSignature 6s ease-in-out infinite;
  stroke-width: 0.25mm;
  stroke: var(--primary);
}

@keyframes drawSignature {
  0% {
    stroke-dashoffset: 2400;
  }
  15% {
    fill: transparent;
  }
  35%, 75% {
    stroke-dashoffset: 0;
    fill: var(--primary);
  }
  90%, to {
    stroke-dashoffset: 2400;
    fill: transparent;
  }
}