/* Custom overrides */

/* Chinese font fallback for characters not in zql subset */
body {
  font-family: zql, 'LXGW WenKai Screen', serif;
}
.header-bio {
  font-family: 'LXGW WenKai Screen', serif;
}

/* Fix: code expand button text invisible on hover in light mode */
.code-expand-btn:hover span {
  color: #24292e !important;
}
[data-theme=dark] .code-expand-btn:hover span {
  color: #f8f8f2 !important;
}

/* Fix: code block text color in light mode */
.highlight pre code,
.highlight pre {
  color: #24292e !important;
}
[data-theme=dark] .highlight pre code,
[data-theme=dark] .highlight pre {
  color: #f8f8f2 !important;
}

/* Remove blockquote quote icon */
blockquote::before {
  display: none !important;
}

blockquote {
  border-left: 4px solid rgba(0, 0, 0, 0.2) !important;
  font-style: normal !important;
}
[data-theme=dark] blockquote {
  border-left-color: rgba(255, 255, 255, 0.2) !important;
}

/* Image zoom cursor */
.post-content img {
  cursor: zoom-in;
}

/* Typography: match usj.cc article page */
.post-content {
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: 0.005em;
  padding: 0 12px;
}
.post-content p {
  font-size: 16px;
  margin: 0 0 1.2em;
}
.post-content h2 {
  font-size: 1.3rem;
  font-weight: normal;
  margin: 0 0 0.8em;
  padding: 0;
  opacity: 0;
  transform: translateX(-16px);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.post-content h2.h2-revealed {
  opacity: 1;
  transform: translateX(0);
}

.post-content h3 {
  font-size: 1.1rem;
  font-weight: normal;
  margin: 1.6em 0 0.6em;
}
.post-content h4 {
  font-size: 0.95rem;
  font-weight: normal;
  margin: 1.4em 0 0.5em;
}
.post-content blockquote {
  font-size: 0.95rem;
  line-height: 1.75;
}
.post-content pre {
  font-size: 0.88rem;
  line-height: 1.65;
}
.post-content code {
  font-size: 0.88em;
}

/* Meta: breathing space between meta and content */
.meta {
  margin-bottom: 28px;
}
@media (max-width: 768px) {
  .post-content p {
    font-size: 16px;
  }
}

/* Remove post-tags section */
.post-tags {
  display: none !important;
}

/* TOC Overlay */
.toc-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toc-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.toc-overlay-content {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  width: 86%;
  max-width: 420px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.toc-overlay.show .toc-overlay-content {
  transform: translateY(0) scale(1);
}
[data-theme=dark] .toc-overlay-content {
  background: rgba(30, 33, 40, 0.94);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.toc-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
[data-theme=dark] .toc-overlay-header {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}
.toc-overlay-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #333;
}
[data-theme=dark] .toc-overlay-header h3 {
  color: #e5e7eb;
}
.toc-close {
  font-size: 24px;
  cursor: pointer;
  color: #999;
  font-weight: 700;
}
.toc-close:hover { color: #333; }
[data-theme=dark] .toc-close:hover { color: #fff; }
.toc-overlay-body {
  padding: 12px 8px 18px;
  overflow-y: auto;
  max-height: calc(70vh - 60px);
}
.toc-overlay-body a:hover {
  background: rgba(0, 0, 0, 0.05) !important;
}
[data-theme=dark] .toc-overlay-body a:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

/* ===== #9 Fix: blog-img blur reveal animation ===== */
@keyframes blur {
  from { filter: blur(10px); }
  to { filter: blur(0); }
}
.blog-img {
  filter: blur(10px);
  animation: blur 1s ease forwards;
}

/* ===== #17 PJAX page transition (ported from oxxx.cn) ===== */
#pjax-container {
  transition: opacity 0.24s ease, transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  transform: translateY(0);
}
#pjax-container.is-pjax-enter {
  opacity: 0.01;
  transform: translateY(8px);
}
#pjax-container.is-pjax-enter-active {
  opacity: 1;
  transform: translateY(0);
}
.is-pjax-pending {
  opacity: 0.55;
  pointer-events: none;
  cursor: progress;
}
#sen-pjax-progress {
  position: fixed;
  right: 12px;
  top: 25px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-top-color: rgba(59, 130, 246, 0.9);
  border-right-color: rgba(59, 130, 246, 0.35);
  background: transparent;
  opacity: 0;
  z-index: 9999;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: scale(0.82);
}
[data-theme=dark] #sen-pjax-progress {
  border-color: rgba(255, 255, 255, 0.15);
  border-top-color: rgba(96, 165, 250, 0.9);
  border-right-color: rgba(96, 165, 250, 0.35);
}
#sen-pjax-progress.is-active {
  opacity: 1;
  transform: scale(1);
}
html.is-pjax-loading #sen-pjax-progress.is-active {
  animation: senPjaxSpinner 0.82s linear infinite;
}
@keyframes senPjaxSpinner {
  to { transform: rotate(360deg); }
}

/* ===== #20 link-card transition ===== */
.link-card {
  transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}
.link-card:hover {
  transform: translateY(-1px);
}

/* ===== Prev/Next post navigation ===== */
.post-nav {
  display: flex;
  gap: 0;
  margin: 1.5em 0 0;
  padding-top: 1em;
}
.post-nav-prev,
.post-nav-next {
  position: relative;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--link-color-light);
  text-decoration: none;
  transition: background-color 0.2s ease;
  width: 50%;
  min-width: 0;
  box-sizing: border-box;
}
.post-nav-prev {
  justify-content: flex-start;
}
.post-nav-next {
  justify-content: flex-end;
}
.post-nav-title {
  flex: 1;
  min-width: 0;
  line-height: 1.5;
  text-align: center;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.post-nav-label {
  font-size: 0.85rem;
  color: #999;
  flex-shrink: 0;
  line-height: 1;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  z-index: 1;
}
.post-nav a.post-nav-prev,
.post-nav a.post-nav-next {
  color: #333;
  text-decoration: none;
  border: none;
}
[data-theme=dark] .post-nav a.post-nav-prev,
[data-theme=dark] .post-nav a.post-nav-next {
  color: #d1d5db;
  border: none;
}
.post-nav-prev:hover,
.post-nav-next:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #111;
  text-decoration: none;
  border: none;
}
[data-theme=dark] .post-nav-prev:hover,
[data-theme=dark] .post-nav-next:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 0;
  list-style: none;
  margin: 0;
}
.pagination a {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--link-color-light);
  text-decoration: none;
  transition: background-color 0.2s ease;
}
.pagination a:hover {
  background: rgba(0, 0, 0, 0.04);
}
[data-theme=dark] .pagination a {
  color: var(--link-color-dark);
}
[data-theme=dark] .pagination a:hover {
  background: rgba(255, 255, 255, 0.06);
}



/* ===== #2 Image lazy load fade-in ===== */
.post-content img,
.entry-content img {
  opacity: 0;
  transition: opacity 0.4s ease;
}
.post-content img.img-revealed,
.entry-content img.img-revealed {
  opacity: 1;
}
.post-content img.img-cached,
.entry-content img.img-cached {
  opacity: 1;
  transition: none;
}

/* ===== Floating tools: override UIkit a:focus (sets border-color:#1e87f0 blue) ===== */
.floating-tools a:focus,
.floating-tools a:focus-visible {
  outline: 0 !important;
  border-color: rgba(255,255,255,.3) !important;
  box-shadow: 0 2px 8px rgba(15,23,42,8%) !important;
  -webkit-tap-highlight-color: transparent !important;
}
[data-theme=dark] .floating-tools a:focus,
[data-theme=dark] .floating-tools a:focus-visible {
  border-color: rgba(148,163,184,.15) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.2) !important;
}

/* ===== #5 Floating tools slide-in ===== */
.floating-tools {
  opacity: 0;
  animation: tools-fade-in 0.5s ease 0.6s forwards;
}
@keyframes tools-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.floating-tools a {
  opacity: 0;
  animation: tool-item-in 0.35s ease forwards;
}
.floating-tools a:nth-child(1) { animation-delay: 0.7s; }
.floating-tools a:nth-child(2) { animation-delay: 0.78s; }
.floating-tools a:nth-child(3) { animation-delay: 0.86s; }
.floating-tools a:nth-child(4) { animation-delay: 0.94s; }
.floating-tools a:nth-child(5) { animation-delay: 1.02s; }
@keyframes tool-item-in {
  from { opacity: 0; }
  to { opacity: 1; }
}



/* ===== Performance: contain ===== */
/* Override style.min.css content-visibility which can prevent JS from reading textContent */
.post-content {
  content-visibility: visible !important;
}
.barrager {
  contain: strict;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .post-content h2 { opacity: 1; transform: none; transition: none; }
  .post-content img, .entry-content img { opacity: 1; transition: none; }
  .floating-tools, .floating-tools a { opacity: 1; animation: none; }
}

/* Heatmap container: ensure minimum size before echarts renders */
#heatmap {
  min-height: 160px;
  min-width: 300px;
}


/* ============================================================
   Twikoo 评论区美化
   ============================================================ */

/* --- 动画关键帧 --- */
@keyframes tk-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes tk-slide-right {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ========================
   编辑器
   ======================== */

/* 卡片容器 */
.twikoo .tk-submit {
  background: #fff !important;
  border: 1px solid #ddd !important;
  border-radius: 12px !important;
  overflow: hidden !important;
  margin-bottom: 16px !important;
  padding: 0 !important;
  transition: border-color 0.25s, box-shadow 0.25s !important;
}
.twikoo .tk-submit:focus-within {
  border-color: #bbb !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06) !important;
}
[data-theme=dark] .twikoo .tk-submit {
  background: #1e2128 !important;
  border-color: rgba(255,255,255,0.08) !important;
}

/* 隐藏头像，内容区占满 */
.twikoo .tk-submit .tk-avatar { display: none !important; }
.twikoo .tk-submit .tk-col { width: 100% !important; }

/* --- 昵称/邮箱/网址 行 --- */
/* Grid 强制一行，绕过 Element UI inline-table */
.twikoo .tk-meta-input {
  display: grid !important;
  grid-template-columns: 1fr 1fr 1fr !important;
  margin: 0 !important;
  border-bottom: 1px solid rgba(0,0,0,0.06) !important;
}
[data-theme=dark] .twikoo .tk-meta-input {
  border-bottom-color: rgba(255,255,255,0.06) !important;
}

/* 每个输入项：Grid 子项自动同行 */
.twikoo .tk-meta-input .el-input {
  min-width: 0 !important;
  position: relative !important;
}

/* 强制 Element UI input-group 改为 flex 行布局 */
.twikoo .tk-meta-input .el-input-group {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  width: 100% !important;
}
/* 关键：覆盖 Element UI 的 inline-table */
.twikoo .tk-meta-input .el-input-group--prepend {
  display: flex !important;
  table-layout: unset !important;
}

/* 标签文字 */
.twikoo .tk-meta-input .el-input-group__prepend {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 4px 0 14px !important;
  color: #999 !important;
  font-size: 13px !important;
  white-space: nowrap !important;
  display: table-cell !important;
  vertical-align: middle !important;
  height: 42px !important;
  line-height: 42px !important;
  width: auto !important;
}
[data-theme=dark] .twikoo .tk-meta-input .el-input-group__prepend {
  color: #666 !important;
}

/* 输入框 */
.twikoo .tk-meta-input .el-input__inner {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 10px !important;
  font-size: 14px !important;
  color: #24292e !important;
  height: 42px !important;
  line-height: 42px !important;
  display: table-cell !important;
  vertical-align: middle !important;
  width: 100% !important;
}
.twikoo .tk-meta-input .el-input__inner:focus {
  box-shadow: none !important;
}
[data-theme=dark] .twikoo .tk-meta-input .el-input__inner {
  color: #d1d5db !important;
}

/* 竖线分隔 */
.twikoo .tk-meta-input .el-input + .el-input::before {
  content: '' !important;
  position: absolute !important;
  left: 0 !important;
  top: 12% !important;
  height: 76% !important;
  width: 1px !important;
  background: rgba(0,0,0,0.08) !important;
  z-index: 1 !important;
}
[data-theme=dark] .twikoo .tk-meta-input .el-input + .el-input::before {
  background: rgba(255,255,255,0.08) !important;
}

/* --- 文本输入框 --- */
.twikoo .tk-input .el-textarea__inner {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 12px 14px !important;
  min-height: 80px !important;
  font-size: 15px !important;
  color: #24292e !important;
  resize: none !important;
}
[data-theme=dark] .twikoo .tk-input .el-textarea__inner {
  color: #d1d5db !important;
}

/* --- 操作栏：表情 + 按钮同行 --- */
.twikoo .tk-submit .tk-row.actions {
  display: flex !important;
  align-items: center !important;
  padding: 8px 14px !important;
  margin: 0 !important;
  border-top: 1px solid rgba(0,0,0,0.06) !important;
}
[data-theme=dark] .twikoo .tk-submit .tk-row.actions {
  border-top-color: rgba(255,255,255,0.06) !important;
}

/* 发送按钮 */
.twikoo .el-button--primary {
  background: #020617 !important;
  color: #fff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 0 20px !important;
  height: 34px !important;
  font-size: 14px !important;
}
.twikoo .el-button--primary:hover { opacity: 0.85 !important; }
.twikoo .el-button--primary.is-disabled { opacity: 0.3 !important; }
[data-theme=dark] .twikoo .el-button--primary {
  background: #e5e7eb !important;
  color: #1a1718 !important;
}

/* 取消/预览 */
.twikoo .tk-cancel,
.twikoo .tk-preview {
  background: transparent !important;
  border: 1px solid rgba(0,0,0,0.1) !important;
  border-radius: 8px !important;
  color: #666 !important;
  height: 34px !important;
  padding: 0 14px !important;
}
[data-theme=dark] .twikoo .tk-cancel,
[data-theme=dark] .twikoo .tk-preview {
  border-color: rgba(255,255,255,0.1) !important;
  color: #999 !important;
}

/* ========================
   评论列表
   ======================== */

.twikoo .tk-comments-container { min-height: 100px !important; }

.twikoo .tk-comments-title {
  font-size: 15px !important;
  font-weight: 400 !important;
  margin-bottom: 16px !important;
}
.twikoo .tk-comments-count span:first-child {
  font-size: 22px !important;
  margin-right: 4px !important;
}

/* --- 单条评论：初始隐藏，IntersectionObserver 触发动画 --- */
.twikoo .tk-comments-container > .tk-comment {
  padding: 14px 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  opacity: 0;
  transform: translateY(16px);
}
.twikoo .tk-comments-container > .tk-comment.tk-inview {
  animation: tk-slide-up 0.4s ease forwards;
}
.twikoo .tk-comments-container > .tk-comment + .tk-comment {
  border-top: 1px dashed rgba(0,0,0,0.06) !important;
}
[data-theme=dark] .twikoo .tk-comments-container > .tk-comment + .tk-comment {
  border-top-color: rgba(255,255,255,0.06) !important;
}
.twikoo .tk-comment.tk-inview:nth-child(1) { animation-delay: 0s; }
.twikoo .tk-comment.tk-inview:nth-child(2) { animation-delay: 0.06s; }
.twikoo .tk-comment.tk-inview:nth-child(3) { animation-delay: 0.12s; }
.twikoo .tk-comment.tk-inview:nth-child(4) { animation-delay: 0.18s; }
.twikoo .tk-comment.tk-inview:nth-child(5) { animation-delay: 0.24s; }
.twikoo .tk-comment.tk-inview:nth-child(n+6) { animation-delay: 0.3s; }

/* 头像：普通方形 */
.twikoo .tk-avatar img,
.twikoo .tk-avatar .tk-avatar-img {
  width: 36px !important;
  height: 36px !important;
  border-radius: 4px !important;
  box-shadow: none !important;
}

/* 评论主体 */
.twikoo .tk-main {
  opacity: 0;
  transform: translateX(16px);
}
.twikoo .tk-comment.tk-inview .tk-main {
  animation: tk-slide-right 0.4s ease 0.1s forwards;
}

/* 昵称 */
.twikoo .tk-nick strong {
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #24292e !important;
}
.twikoo .tk-nick-link { color: inherit !important; text-decoration: none !important; }
[data-theme=dark] .twikoo .tk-nick strong { color: #d1d5db !important; }

/* 时间 */
.twikoo .tk-time { color: #999 !important; font-size: 13px !important; }

/* 博主标签 */
.twikoo .tk-tag-green {
  background: #696565 !important;
  color: #fff !important;
  border-radius: 3px !important;
  font-size: 12px !important;
  padding: 0 6px !important;
}

/* 评论内容 */
.twikoo .tk-content {
  margin-top: 4px !important;
  word-break: break-word !important;
  line-height: 1.6 !important;
}
.twikoo .tk-content p {
  font-size: 1rem !important;
  color: #24292e !important;
  line-height: 1.6 !important;
  margin: 0 0 0.5em !important;
}
.twikoo .tk-content p:last-child { margin-bottom: 0 !important; }
[data-theme=dark] .twikoo .tk-content p { color: #d1d5db !important; }

/* 图片保持原始大小 */
.twikoo .tk-content img {
  max-width: 100% !important;
  max-height: none !important;
  height: auto !important;
  display: block !important;
  margin: 8px 0 !important;
}

/* 引用块 */
.twikoo .tk-content blockquote {
  margin: 10px 0 !important;
  padding: 12px 16px !important;
  background: #f8f9fa !important;
  border-left: 4px solid #696565 !important;
  border-radius: 4px !important;
  color: #555 !important;
}
[data-theme=dark] .twikoo .tk-content blockquote {
  background: #252526 !important;
  border-left-color: #444 !important;
  color: #b0b0b0 !important;
}

/* 操作栏 */
.twikoo .tk-action-link { color: #999 !important; font-size: 13px !important; }
.twikoo .tk-action-link:hover { color: #24292e !important; }
[data-theme=dark] .twikoo .tk-action-link:hover { color: #e5e7eb !important; }

/* 设备信息 */
.twikoo .tk-extras { margin-top: 6px !important; display: flex !important; gap: 6px !important; flex-wrap: wrap !important; }
.twikoo .tk-extra {
  color: #999 !important;
  background: #f0f0f0 !important;
  border-radius: 3px !important;
  font-size: 11px !important;
  padding: 2px 8px !important;
}
[data-theme=dark] .twikoo .tk-extra { background: rgba(255,255,255,0.06) !important; color: #666 !important; }

/* 回复区域 */
.twikoo .tk-replies { margin-left: 46px !important; padding-left: 0 !important; border-left: none !important; }
.twikoo .tk-replies .tk-comment { margin-top: 8px !important; padding: 8px 0 0 !important; }
.twikoo .tk-replies .tk-avatar img,
.twikoo .tk-replies .tk-avatar .tk-avatar-img { width: 30px !important; height: 30px !important; }

/* 展开按钮 */
.twikoo .tk-expand {
  padding: 14px 0 !important;
  border-top: 1px dashed rgba(0,0,0,0.06) !important;
  margin-top: 16px !important;
  color: #999 !important;
  font-size: 14px !important;
  cursor: pointer !important;
  text-align: center !important;
  background: transparent !important;
}
[data-theme=dark] .twikoo .tk-expand { border-top-color: rgba(255,255,255,0.06) !important; }
.twikoo .tk-expand:hover { color: #24292e !important; background: rgba(0,0,0,0.02) !important; }
[data-theme=dark] .twikoo .tk-expand:hover { color: #e5e7eb !important; }

/* 排序 */
.twikoo .tk-sort-item { color: #999 !important; }
.twikoo .tk-sort-item.__active { color: #24292e !important; }
[data-theme=dark] .twikoo .tk-sort-item.__active { color: #e5e7eb !important; }

/* 无评论 */
.twikoo .tk-comments-no { height: 120px !important; display: flex !important; justify-content: center !important; align-items: center !important; color: #999 !important; }

/* 减弱动效 */
@media (prefers-reduced-motion: reduce) {
  .twikoo .tk-comments-container > .tk-comment,
  .twikoo .tk-main { opacity: 1 !important; transform: none !important; animation: none !important; }
}
