/* Custom overrides */

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

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

/* ===== #17 PJAX page transition ===== */
#pjax-container {
  transition: opacity 0.2s ease;
}
#pjax-container.pjax-loading {
  opacity: 0;
}

/* ===== #20 link-card transition: specific properties only ===== */
.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);
}

/* ===== #5 About page responsive ===== */
.about-card .uk-grid-small {
  gap: 20px;
}
@media (max-width: 768px) {
  .about-card .uk-grid-small {
    gap: 16px;
  }
  .about-card .uk-grid-small > div {
    padding: 16px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
  }
  [data-theme=dark] .about-card .uk-grid-small > div {
    background: rgba(255, 255, 255, 0.04);
  }
}

/* ===== #12 Copy toast fadeInOut animation ===== */
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* TOC Overlay */
.toc-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  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;
  gap: 0;
  margin: 1.5em 0 0;
  padding-top: 1em;
}
.post-nav-prev,
.post-nav-next {
  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-end;
}
.post-nav-next {
  justify-content: flex-start;
  margin-left: auto;
}
.post-nav-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
  max-height: 3em;
  min-width: 0;
}
.post-nav-prev .post-nav-title {
  text-align: right;
}
.post-nav-next .post-nav-title {
  text-align: left;
}
.post-nav-label {
  font-size: 0.85rem;
  color: #999;
  flex-shrink: 0;
  line-height: 1;
  border: none;
  text-decoration: none;
}
.post-nav-prev .post-nav-label {
  margin-right: 6px;
}
.post-nav-next .post-nav-label {
  margin-left: 6px;
}
.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;
}

/* =====================================================
   Reading Experience Optimization
   ===================================================== */

/* --- Container width --- */
.main {
  max-width: 720px;
  padding: 48px 40px;
}
.container {
  padding: 0 16px;
}

/* --- Post title --- */
.post-title {
  font-size: 1.85rem;
  font-weight: normal;
  line-height: 1.35;
  margin: 0 0 0.6em;
  letter-spacing: 0.01em;
}

/* --- Post content headings fade-in --- */
.post-content h2,
.post-content h3,
.post-content h4 {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.post-content h2.is-visible,
.post-content h3.is-visible,
.post-content h4.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Post content typography --- */
.post-content {
  font-size: 1.15rem;
  line-height: 1.85;
  letter-spacing: 0.01em;
  word-break: break-word;
}
.post-content p {
  margin: 0 0 1.2em;
}
.post-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2em 0 0.8em;
}
.post-content h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 1.6em 0 0.6em;
}
.post-content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.4em 0 0.5em;
}

/* --- Lists --- */
.post-content ul,
.post-content ol {
  margin: 0 0 1.2em;
  padding-left: 1.5em;
}
.post-content li {
  margin: 0.3em 0;
  line-height: 1.75;
}
.post-content li::marker {
  color: #999;
}
[data-theme=dark] .post-content li::marker {
  color: #6b7280;
}

/* --- Blockquote --- */
.post-content blockquote {
  font-size: 0.95rem;
  line-height: 1.75;
  margin: 1.2em 0;
  padding: 12px 20px;
  border-radius: 0 8px 8px 0;
  background: rgba(0, 0, 0, 0.02);
}
[data-theme=dark] .post-content blockquote {
  background: rgba(255, 255, 255, 0.03);
}

/* --- Code --- */
.post-content code {
  font-size: 0.88em;
  padding: 2px 6px;
  border-radius: 4px;
}
.post-content pre {
  margin: 1.2em 0;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.65;
}
.post-content pre code {
  font-size: inherit;
  padding: 0;
  border: none;
  background: none;
}

/* --- Images --- */
.post-content img {
  border-radius: 8px;
  margin: 0.5em auto;
}
.post-content .sen-image-frame {
  margin: 1.2em auto;
}

/* --- HR --- */
.post-content hr {
  margin: 2em 0;
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}
[data-theme=dark] .post-content hr {
  border-top-color: rgba(255, 255, 255, 0.1);
}

/* --- Links --- */
.post-content a {
  color: inherit;
  text-decoration: none;
  border-bottom: none;
}
.post-content a:hover {
  color: inherit;
  text-decoration: none;
  border-bottom: none;
}

/* --- Strong / Bold --- */
.post-content strong {
  font-weight: 700;
  color: inherit;
}

/* --- Meta info --- */
.meta {
  font-size: 0.85rem;
  margin-bottom: 1.5em;
}
#word-count:empty,
#reading-time:empty {
  display: none;
}

/* =====================================================
   Mobile Typography
   ===================================================== */
@media (max-width: 768px) {
  .main {
    max-width: 100%;
    padding: 28px 20px;
    border-radius: 0;
  }
  .container {
    padding: 0;
  }
  .post-title {
    font-size: 1.6rem;
    line-height: 1.4;
  }
  .post-content {
    font-size: 1.08rem;
    line-height: 1.8;
  }
  .post-content h2 {
    font-size: 1.3rem;
  }
  .post-content h3 {
    font-size: 1.15rem;
  }
  .post-content pre {
    font-size: 0.82rem;
    border-radius: 8px;
    margin-left: -8px;
    margin-right: -8px;
  }
  .post-content blockquote {
    margin-left: 0;
    margin-right: 0;
    padding: 10px 16px;
  }
  .post-nav-prev,
  .post-nav-next {
    padding: 8px 12px;
  }
}

/* ===== Pagination: consistent button style ===== */
.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);
}
