/* Custom overrides */

/* Remove all focus outlines globally */
*:focus,
*:focus-visible {
  outline: none !important;
}

/* 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;
}

/* 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;
}

/* ===== Performance: Disable backdrop-filter on mobile ===== */
@media (max-width: 768px) {
  .main {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(255, 255, 255, 0.98) !important;
  }
  [data-theme=dark] .main {
    background: rgba(15, 23, 42, 1) !important;
  }
  .toc-overlay {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(0, 0, 0, 0.5) !important;
  }
  .toc-overlay-content {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* ===== Performance: content-visibility for post cards ===== */
.post {
  content-visibility: auto;
  contain-intrinsic-size: auto 60px;
}

/* ===== Performance: Barrage will-change hint ===== */
.barrage-item {
  will-change: transform;
}

/* ===== Animation: mascot only animates when visible ===== */
.search-mascot {
  animation-play-state: paused;
}
.search-hint-wrapper.visible .search-mascot {
  animation-play-state: running;
}

/* ===== Prev/Next post navigation ===== */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 1.5em 0 0;
  padding-top: 1em;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
[data-theme=dark] .post-nav {
  border-top-color: rgba(255, 255, 255, 0.08);
}
.post-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--link-color-light);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
  max-width: 48%;
  min-width: 0;
}
.post-nav-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.post-nav a:hover {
  background: rgba(0, 0, 0, 0.04);
  text-decoration: none !important;
}
[data-theme=dark] .post-nav a {
  color: var(--link-color-dark);
}
[data-theme=dark] .post-nav a:hover {
  background: rgba(255, 255, 255, 0.06);
}
.post-nav .post-nav-prev {
  margin-right: auto;
}
.post-nav .post-nav-next {
  margin-left: auto;
  text-align: right;
}
.post-nav-label {
  display: block;
  font-size: 0.75rem;
  color: #999;
  margin-bottom: 2px;
}
