/* Site-level refinements kept outside the npm-managed Butterfly theme. */
:root {
  --blog-accent: #4338ca;
  --blog-accent-bright: #6366f1;
  --blog-text: #263449;
  --blog-muted: #64748b;
  --blog-border: rgba(100, 116, 139, 0.14);
  --blog-card-shadow: 0 8px 24px rgba(15, 23, 42, 0.055);
}

#web_bg {
  background:
    radial-gradient(circle at 12% 8%, rgba(99, 102, 241, 0.08), transparent 28rem),
    radial-gradient(circle at 88% 38%, rgba(56, 189, 248, 0.06), transparent 24rem),
    #f4f6fb !important;
}

[data-theme='dark'] #web_bg {
  background:
    radial-gradient(circle at 12% 8%, rgba(99, 102, 241, 0.16), transparent 28rem),
    #0d1117 !important;
}

#page-header.full_page::before {
  background:
    linear-gradient(90deg, rgba(2, 6, 23, 0.76), rgba(15, 23, 42, 0.42) 48%, rgba(2, 6, 23, 0.68)),
    linear-gradient(0deg, rgba(2, 6, 23, 0.32), transparent 45%) !important;
}

#page-header.full_page {
  background-position: center 48%;
}

#page-header.full_page:not(.nav-fixed) #nav .site-icon {
  filter: brightness(0) invert(1);
}

[data-theme='dark'] #page-header.nav-fixed #nav .site-icon {
  filter: brightness(0) invert(1);
}

#page-header.full_page #site-title {
  letter-spacing: -0.03em;
  text-shadow: 0 3px 18px rgba(2, 6, 23, 0.7);
}

#page-header.full_page #site-subtitle {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.8;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 12px rgba(2, 6, 23, 0.72);
}

#page-header.full_page #subtitle {
  display: inline-block;
  white-space: pre-line;
}

#nav {
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.5), transparent);
}

#page-header.nav-fixed #nav {
  border-bottom: 1px solid var(--blog-border);
}

.layout {
  gap: 16px;
}

.layout > div:first-child,
#recent-posts,
#post,
#article-container {
  min-width: 0;
}

#recent-posts .recent-post-item,
.card-widget,
#post,
#page {
  border: 1px solid var(--blog-border);
  box-shadow: var(--blog-card-shadow);
}

#recent-posts .recent-post-item {
  height: auto;
  min-height: 0;
}

#recent-posts .recent-post-item > .recent-post-info.no-cover {
  padding: 34px 38px;
}

#recent-posts .recent-post-item .article-title {
  font-size: 1.42em;
}

#recent-posts .recent-post-item .content {
  color: var(--blog-muted);
  line-height: 1.8;
}

/* Homepage: text-first single-column feed. */
#page-header.full_page + #content-inner #recent-posts::before {
  display: block;
  margin: 2px 0 18px;
  color: var(--blog-text);
  content: '最新文章';
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

#page-header.full_page + #content-inner #recent-posts .recent-post-item {
  margin-bottom: 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

#page-header.full_page + #content-inner #recent-posts .recent-post-item:hover {
  border-color: rgba(99, 102, 241, 0.28);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.09);
  transform: translateY(-3px);
}

#page-header.full_page + #content-inner #recent-posts .recent-post-item > .recent-post-info.no-cover {
  padding: 28px 30px 27px;
}

#page-header.full_page + #content-inner #recent-posts .recent-post-item .article-title {
  display: block;
  font-size: 1.26rem;
  line-height: 1.48;
}

#page-header.full_page + #content-inner #recent-posts .recent-post-item .article-meta-wrap {
  margin: 10px 0 12px;
  font-size: 0.78rem;
}

#page-header.full_page + #content-inner #recent-posts .recent-post-item .content {
  display: block;
  overflow: visible;
  margin-top: 0;
  font-size: 0.92rem;
  line-height: 1.75;
  -webkit-line-clamp: unset;
}

#page-header.full_page + #content-inner #recent-posts .recent-post-items {
  width: 100%;
}

#page-header.full_page + #content-inner #recent-posts .recent-post-item {
  width: 100%;
}

#recent-posts.infinite-scroll-enabled #pagination {
  display: none;
}

.infinite-scroll-status {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  color: var(--blog-muted);
  font-size: 0.9rem;
  text-align: center;
}

.infinite-scroll-status[data-state='loading']::before {
  width: 15px;
  height: 15px;
  margin-right: 10px;
  border: 2px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--blog-accent-bright);
  border-radius: 50%;
  content: '';
  animation: blog-loading-spin 0.8s linear infinite;
}

.infinite-scroll-retry {
  padding: 8px 14px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 999px;
  background: transparent;
  color: var(--blog-accent);
  cursor: pointer;
  font: inherit;
}

@keyframes blog-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

[data-theme='dark'] #page-header.full_page + #content-inner #recent-posts .recent-post-item {
  background: rgba(24, 30, 42, 0.94);
}

#article-container {
  color: var(--blog-text);
  font-size: 16px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}

#article-container > blockquote:first-child {
  margin-bottom: 28px;
  padding: 16px 20px;
  border-left-color: var(--blog-accent-bright);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.09), rgba(56, 189, 248, 0.07));
  color: #475569;
}

#article-container h2 {
  margin-top: 36px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--blog-border);
}

#article-container h3 {
  margin-top: 28px;
}

#article-container a:not(.headerlink),
#recent-posts a.article-title {
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

#article-container img,
#article-container video,
#article-container iframe {
  max-width: 100%;
}

#article-container pre,
#article-container .highlight,
#article-container .table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

#content-inner:has(#post) #aside-content > .card-info,
#content-inner:has(#post) #aside-content > .card-announcement {
  display: none;
}

/* Keep the homepage sidebar focused on identity, recent posts and categories. */
#page-header.full_page + #content-inner #aside-content .card-tags,
#page-header.full_page + #content-inner #aside-content .card-archives,
#page-header.full_page + #content-inner #aside-content .card-webinfo {
  display: none;
}

#page-header.full_page + #content-inner #aside-content .card-info {
  padding: 24px 20px;
}

#page-header.full_page + #content-inner #aside-content .card-info .avatar-img {
  width: 84px;
  height: 84px;
}

#page-header.full_page + #content-inner #aside-content .card-recent-post .thumbnail {
  display: none;
}

#page-header.full_page + #content-inner #aside-content .card-recent-post .aside-list-item .content {
  width: 100%;
}

#page-header.full_page + #content-inner #aside-content .card-recent-post .aside-list-item {
  padding: 9px 0;
  border-bottom: 1px solid var(--blog-border);
}

#page-header.full_page + #content-inner #aside-content .card-recent-post .aside-list-item:last-child {
  border-bottom: 0;
}

.card-info-social-icons .social-icon i {
  color: var(--blog-accent) !important;
}

[data-theme='dark'] #article-container {
  color: rgba(255, 255, 255, 0.82);
}

[data-theme='dark'] #article-container > blockquote:first-child {
  color: rgba(255, 255, 255, 0.72);
}

:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 3px;
}

@media screen and (max-width: 768px) {
  html,
  body {
    overflow-x: clip;
  }

  #page-header.full_page {
    height: clamp(420px, 52vh, 500px) !important;
    min-height: 420px;
    background-position: center center;
    background-attachment: scroll;
  }

  #page-header.full_page #site-title {
    font-size: 2em;
  }

  #page-header.full_page #site-subtitle {
    padding: 0 20px;
    font-size: 1.02em;
    line-height: 1.65;
  }

  #page-header #site_social_icons .social-icon,
  #page-header #site_social_icons .social-icon i {
    color: rgba(255, 255, 255, 0.88) !important;
  }

  #nav {
    padding: 0 16px;
  }

  #nav .menus_items {
    display: none !important;
  }

  #nav #toggle-menu {
    display: inline-block !important;
    margin-left: 8px;
    color: rgba(255, 255, 255, 0.94);
  }

  .layout {
    gap: 0;
    padding-right: 8px;
    padding-left: 8px;
  }

  .layout > div:first-child:not(.nc) {
    padding: 30px 18px;
  }

  #recent-posts .recent-post-item {
    min-height: 0;
  }

  #recent-posts .recent-post-item > .recent-post-info.no-cover {
    padding: 26px 22px;
  }

  #page-header.full_page + #content-inner #recent-posts::before {
    margin: 4px 6px 16px;
    font-size: 1.22rem;
  }

  #page-header.full_page + #content-inner #recent-posts .recent-post-item > .recent-post-info.no-cover {
    padding: 24px 22px;
  }

  #recent-posts .recent-post-item .article-title {
    font-size: 1.3em;
    line-height: 1.45;
  }

  #article-container {
    font-size: 15.5px;
    line-height: 1.85;
  }

  #article-container > blockquote:first-child {
    margin-right: 0;
    margin-left: 0;
    padding: 14px 16px;
  }
}

@media screen and (max-width: 600px) {
  #page-header.post-bg {
    height: 280px;
  }

  #post-info .post-title {
    font-size: 1.48em;
    line-height: 1.35;
  }

  #post-info #post-meta {
    font-size: 80%;
  }

  #post-info #post-meta .meta-secondline,
  #post-info #post-meta .post-meta-date-created + .post-meta-separator,
  #post-info #post-meta .post-meta-date .fa-history,
  #post-info #post-meta .post-meta-date .fa-history + .post-meta-label,
  #post-info #post-meta .post-meta-date-updated {
    display: none;
  }
}
