/* Custom Styles for GitHub-Style Theme */

/* Global Styles */
:root {
  --primary-color: #2563eb;
  --secondary-color: #1e40af;
  --accent-color: #3b82f6;
  --text-color: #1f2937;
  --bg-color: #ffffff;
  --border-color: #e5e7eb;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

:root {
  --article-bg: #fcfcfa;
  --article-text: #1f2937;
  --article-heading: #111827;
  --article-muted: #6b7280;
  --article-border: rgba(17, 24, 39, 0.08);
  --article-border-strong: rgba(17, 24, 39, 0.14);
  --article-toolbar-bg: rgba(252, 252, 250, 0.9);
  --article-surface: #f7f5f0;
  --article-code-bg: #f3f4f6;
  --article-pre-bg: #fbfbfc;
  --article-tag-bg: rgba(37, 99, 235, 0.06);
  --article-tag-border: rgba(37, 99, 235, 0.14);
  --article-tag-text: #1d4ed8;
}

/* Language Toggle Button in Header */
.language-toggle-container {
  display: flex;
  gap: 4px;
}

.language-toggle-link {
  color: var(--color-fg-default);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  display: inline-block;
}

/* Ensure proper color inheritance from GitHub's CSS variables */
.language-toggle-link,
.language-toggle-link:visited {
  color: inherit;
}

/* Article reading experience */
.article-shell {
  background: var(--article-bg);
  min-height: 100vh;
}

.article-main {
  padding: 32px 24px 80px;
}

.article-hero {
  margin: 0 auto 28px;
  max-width: 780px;
}

.article-hero-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.article-meta-line {
  color: var(--article-muted);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.5;
}

.article-meta-separator {
  margin: 0 0.4rem;
}

.article-title {
  margin: 0;
  color: var(--article-heading);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.12;
  font-weight: 740;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.article-description {
  margin: 0;
  max-width: 42rem;
  color: color-mix(in srgb, var(--article-text) 78%, white);
  font-size: 1.2rem;
  line-height: 1.75;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.article-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.38rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--article-tag-border);
  background: var(--article-tag-bg);
  color: var(--article-tag-text);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex !important;
}

.article-tag:hover {
  background: rgba(37, 99, 235, 0.12);
  text-decoration: none;
}

.article-body-wrap {
  display: flex;
  justify-content: center;
}

.article-body {
  width: 100%;
  max-width: 780px;
  color: var(--article-text);
  font-family: Georgia, Cambria, "Times New Roman", Times, serif;
  font-size: 1.24rem;
  line-height: 1.92;
  letter-spacing: 0.002em;
  hanging-punctuation: first last;
}

.article-body.markdown-body {
  background: transparent;
}

.article-body.markdown-body > *:first-child {
  margin-top: 0;
}

.article-body.markdown-body > *:last-child {
  margin-bottom: 0;
}

.article-body.markdown-body > h1:first-child {
  display: none;
}

.article-body.markdown-body p,
.article-body.markdown-body ul,
.article-body.markdown-body ol,
.article-body.markdown-body blockquote,
.article-body.markdown-body pre,
.article-body.markdown-body table {
  margin-top: 0;
  margin-bottom: 1.28em;
}

.article-body.markdown-body li + li {
  margin-top: 0.35em;
}

.article-body.markdown-body h1,
.article-body.markdown-body h2,
.article-body.markdown-body h3,
.article-body.markdown-body h4,
.article-body.markdown-body h5,
.article-body.markdown-body h6 {
  margin-top: 1.8em;
  margin-bottom: 0.48em;
  color: var(--article-heading);
  border-bottom: 0;
  padding-bottom: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-weight: 760;
  letter-spacing: -0.03em;
  line-height: 1.18;
}

.article-body.markdown-body h1 {
  font-size: 2.2rem;
  margin-top: 1.2em;
}

.article-body.markdown-body h2 {
  font-size: 1.8rem;
  margin-top: 1.7em;
}

.article-body.markdown-body h3 {
  font-size: 1.45rem;
  margin-top: 1.45em;
}

.article-body.markdown-body h4,
.article-body.markdown-body h5,
.article-body.markdown-body h6 {
  font-size: 1.12rem;
}

.article-body.markdown-body a {
  color: #0f5bd3;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.article-body.markdown-body a:hover {
  color: #0b4ab0;
}

.article-body.markdown-body strong {
  color: var(--article-heading);
  font-weight: 700;
}

.article-body.markdown-body blockquote {
  padding: 0.2rem 0 0.2rem 1.35rem;
  border-left: 3px solid var(--article-heading);
  background: transparent;
  color: #374151;
  border-radius: 0;
  font-style: italic;
}

.article-body.markdown-body code {
  padding: 0.18em 0.42em;
  border-radius: 0.4rem;
  background: var(--article-code-bg);
  color: var(--article-heading);
  font-size: 0.84em;
}

.article-body.markdown-body pre {
  padding: 22px 24px;
  border: 1px solid var(--article-border);
  border-radius: 18px;
  background: var(--article-pre-bg);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.06);
  overflow: auto;
}

.article-body.markdown-body pre code {
  padding: 0;
  background: transparent;
  font-size: 0.9em;
}

.article-body.markdown-body hr {
  height: 1px;
  margin: 3rem auto;
  background: linear-gradient(90deg, transparent, rgba(17, 24, 39, 0.18), transparent);
  border: 0;
}

.article-body.markdown-body img {
  display: block;
  max-width: min(100%, 920px);
  margin: 2.4rem auto;
  border-radius: 20px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.12);
}

.article-body.markdown-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.article-body.markdown-body table th,
.article-body.markdown-body table td {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--article-border);
}

.article-body.markdown-body ul,
.article-body.markdown-body ol {
  padding-left: 1.4em;
}

.article-body.markdown-body > p:first-of-type {
  color: color-mix(in srgb, var(--article-text) 88%, white);
}

.article-body.markdown-body figcaption,
.article-body.markdown-body .image-caption {
  margin-top: -1.25rem;
  margin-bottom: 2rem;
  color: var(--article-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
}

/* Modern Black & White Scrollbar */
/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: #111;
  border-radius: 10px;
  border: 2px solid #f0f0f0;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: #2b2b2b;
}

::-webkit-scrollbar-thumb:active {
  background: #000;
}

/* Firefox */
body,
html,
.markdown-body,
.markdown-body pre,
#toc-list,
.SelectMenu-modal,
.SelectMenu-list {
  scrollbar-width: thin;
  scrollbar-color: #111 #f0f0f0;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #111 #f0f0f0;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  ::-webkit-scrollbar-track {
    background: #0f0f10;
  }

  ::-webkit-scrollbar-thumb {
    background: #cfcfcf;
    border-color: #0f0f10;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: #e0e0e0;
  }

  ::-webkit-scrollbar-thumb:active {
    background: #f5f5f5;
  }

  body,
  html,
  .markdown-body,
  .markdown-body pre,
  #toc-list,
  .SelectMenu-modal,
  .SelectMenu-list {
    scrollbar-color: #d0d0d0 #0f0f10;
  }

  * {
    scrollbar-color: #d0d0d0 #0f0f10;
  }
}

/* Hide tags display - only show categories */
.f6.text-gray.mt-2 a[href*="/tags/"],
.f6.text-gray.mt-2 a[href*="/zh/tags/"],
.muted-link[href*="/tags/"],
.muted-link[href*="/zh/tags/"],
a[href*="/tags/"],
a[href*="/zh/tags/"] {
  display: none !important;
}

.article-tags a[href*="/tags/"],
.article-tags a[href*="/zh/tags/"] {
  display: inline-flex !important;
}

/* Fix pinned items text preview and code overflow */
.pinned-item-desc {
  /* Limit text preview to 10 lines maximum */
  display: -webkit-box;
  -webkit-line-clamp: 10;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  max-height: calc(1.4em * 10); /* 10 lines * line-height */
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

/* Handle code blocks within pinned item descriptions */
.pinned-item-desc pre {
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.8em;
  margin: 0.5em 0;
  padding: 0.5em;
  background-color: var(--color-canvas-subtle);
  border-radius: 4px;
  border: 1px solid var(--color-border-default);
}

.pinned-item-desc code {
  font-size: 0.85em;
  background-color: var(--color-canvas-subtle);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--color-border-default);
}

/* Search Results Styling */
#search-result {
  background-color: var(--color-canvas-default);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#search-result .search-results-count {
  background: var(--color-canvas-default);
  color: var(--color-fg-default);
  border-radius: 8px 8px 0 0;
  padding: 16px 20px;
  margin: 0;
  font-weight: 600;
  border-bottom: 1px solid var(--color-border-default);
}

#search-result .search-results-count svg {
  margin-right: 8px;
  vertical-align: middle;
}

#search-result ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#search-result li {
  border-bottom: 1px solid var(--color-border-default);
  transition: background-color 0.2s ease;
  padding: 16px 20px;
}

#search-result li:hover {
  background-color: var(--color-canvas-subtle);
}

#search-result li:last-child {
  border-bottom: none;
  border-radius: 0 0 8px 8px;
}

#search-result .search-result-header {
  margin-bottom: 8px;
}

#search-result .search-result-content {
  padding-left: 0;
}

#search-result h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
}

#search-result h3 a {
  color: var(--color-accent-fg);
  text-decoration: none;
  transition: color 0.2s ease;
}

#search-result h3 a:hover {
  color: var(--color-accent-emphasis);
  text-decoration: underline;
}

#search-result .search-result-content {
  color: var(--color-fg-muted);
  line-height: 1.5;
  font-size: 14px;
  margin-bottom: 12px;
}

#search-result .search-result-content span[style="color: red;"] {
  background-color: var(--color-attention-subtle);
  color: var(--color-attention-fg);
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 500;
}

#search-result .back-button {
  background: var(--color-btn-bg);
  color: var(--color-btn-text);
  border: 1px solid var(--color-btn-border);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 16px 20px;
}

#search-result .back-button:hover {
  background: var(--color-btn-hover-bg);
  border-color: var(--color-btn-hover-border);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#search-result .no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-fg-muted);
  font-style: italic;
}

/* Avatar Styling - Soft blur edges and shadow */
.avatar-user,
.avatar {
  /* Soft shadow for depth */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.12);
  
  /* Smooth transition for hover effects */
  transition: all 0.3s ease;
  
  /* Subtle border to blend with background */
  border: 2px solid rgba(255, 255, 255, 0.8) !important;
  
  /* Circular avatar for softer look - comment this out if you prefer square */
  border-radius: 50% !important;
  
  /* Alternative: Enhanced border radius for softer square look - uncomment if you prefer square */
  /* border-radius: 8px !important; */
}

/* Hover effect for avatar */
.avatar-user:hover,
.avatar:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Large avatar specific styling */
.avatar.width-full {
  /* Gradient overlay to soften harsh backgrounds */
  position: relative;
  overflow: hidden;
}

.avatar.width-full::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.1) 0%, 
    rgba(255, 255, 255, 0.05) 50%, 
    transparent 100%);
  pointer-events: none;
  border-radius: inherit;
}

/* For green background specifically - add a subtle filter */
.avatar-user[src*="avatar"],
.avatar[src*="avatar"] {
  /* Slight desaturation to reduce color intensity */
  filter: saturate(0.85) contrast(1.05);
}

/* Alternative: If you want a circular avatar instead of rounded square */
.avatar-circular {
  border-radius: 50% !important;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .article-main {
    padding: 22px 16px 56px;
  }

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

  .article-title {
    font-size: clamp(1.7rem, 8vw, 2.35rem);
    line-height: 1.16;
  }

  .article-description {
    font-size: 1.05rem;
    line-height: 1.65;
  }

  .article-meta-line {
    font-size: 0.8rem;
  }

  .article-body {
    font-size: 1.1rem;
    line-height: 1.86;
  }

  .article-body.markdown-body h1 {
    font-size: 1.9rem;
  }

  .article-body.markdown-body h2 {
    font-size: 1.55rem;
  }

  .article-body.markdown-body h3 {
    font-size: 1.28rem;
  }

  .article-body.markdown-body pre {
    padding: 18px;
    border-radius: 14px;
  }

  .article-body.markdown-body img {
    margin: 1.8rem auto;
    border-radius: 14px;
  }

  #search-result {
    margin: 8px;
    border-radius: 6px;
  }
  
  #search-result .search-results-count {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  #search-result h3 {
    font-size: 16px;
  }
  
  #search-result .search-result-content {
    font-size: 13px;
  }
  
  #search-result .back-button {
    margin: 12px 16px;
    padding: 6px 12px;
    font-size: 13px;
  }
  
  /* Mobile avatar adjustments */
  .avatar-user,
  .avatar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  }
}

.article-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--article-muted);
  font-size: 0.92rem;
}

.article-breadcrumbs a {
  color: inherit;
  text-decoration: none;
}

.article-breadcrumbs a:hover {
  color: var(--article-heading);
  text-decoration: underline;
}

.article-breadcrumb-separator {
  opacity: 0.55;
}

.article-callout,
.article-support-card {
  max-width: 780px;
  margin: 0 auto;
  border: 1px solid var(--article-border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 245, 240, 0.92));
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.article-callout {
  padding: 18px 20px;
}

.article-callout-compact {
  padding-bottom: 14px;
}

.article-callout h2,
.article-support-card h2 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.article-callout p,
.article-callout ul,
.article-support-card p,
.article-support-card ul {
  margin: 0;
  color: color-mix(in srgb, var(--article-text) 84%, white);
  font-size: 1rem;
  line-height: 1.75;
}

.article-callout ul,
.article-citation-text ul {
  padding-left: 1.2rem;
}

.article-support-block {
  padding: 0 24px 28px;
}

.article-support-card {
  padding: 24px;
}

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

.article-related-card {
  padding: 16px;
  border: 1px solid var(--article-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.article-related-card h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  line-height: 1.4;
}

.article-related-card p {
  color: var(--article-muted);
  font-size: 0.95rem;
}

.article-faq-list {
  display: grid;
  gap: 12px;
}

.article-faq-item {
  border: 1px solid var(--article-border);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.7);
}

.article-faq-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--article-heading);
}

.article-faq-item p {
  margin-top: 0.75rem;
}

.article-figure {
  margin: 1.6rem 0;
}

.article-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
}

.article-figure figcaption {
  margin-top: 0.65rem;
  color: var(--article-muted);
  font-size: 0.95rem;
  text-align: center;
}

.post-preview-categories {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-right: 6px;
}

.post-preview-category {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border: 1px solid var(--color-border-primary);
  border-radius: 999px;
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
}

.post-preview-category:hover {
  color: var(--color-text-primary);
  text-decoration: none;
  border-color: var(--color-border-tertiary);
}

.post-catalog-taxonomy {
  margin: 0 0 12px;
  padding: 10px 0 14px;
}

.post-catalog-taxonomy-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 8px;
}

.post-catalog-taxonomy-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.34rem 0.72rem;
  border: 1px solid var(--color-border-primary);
  border-radius: 999px;
  background: var(--color-bg-canvas);
  color: var(--color-text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: border-color 120ms ease, color 120ms ease, background-color 120ms ease;
}

.post-catalog-taxonomy-chip:hover {
  color: var(--color-text-primary);
  text-decoration: none;
  border-color: var(--color-border-tertiary);
  background: var(--color-bg-secondary);
}
