/* Dark theme overrides */

/* Base */
html.dark body {
  background-color: #0b1220;
  color: #e5e7eb;
}
/* Improve touch scrolling reliability */
html.dark html, html.dark body, html.dark .post-container, html.dark .container{
  touch-action: pan-y;
}

/* Glassy fixed navbar (desktop) */
@media (min-width: 1170px) {
  html.dark .navbar-custom.is-fixed {
    background-color: rgba(11,18,32,0.6);
    border-bottom-color: rgba(51,65,85,0.5);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    backdrop-filter: saturate(140%) blur(10px);
  }
}

/* Prevent hidden mobile menu from blocking content */
@media (max-width: 767px){
  html.dark #huxblog_navbar{
    position: fixed;
    top: 60px;
    right: 16px;
    width: 220px;
    max-width: calc(100% - 32px);
    pointer-events: none;
    visibility: hidden;
    transform: translateY(-6px) scale(0.98);
    transition: opacity .2s ease, transform .2s ease;
    opacity: 0;
    z-index: 1000;
  }
  html.dark #huxblog_navbar .navbar-collapse {
    display: block !important;
    overflow: hidden;
    max-height: 0;
    background: rgba(15,23,42,0.95);
    border-radius: 14px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.55);
    border: 1px solid rgba(51,65,85,0.9);
  }
  html.dark #huxblog_navbar .nav>li>a{ color: #e2e8f0; }
  html.dark #huxblog_navbar .navbar-collapse .nav{ padding: 8px 12px; }
  html.dark #huxblog_navbar.in{
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  html.dark #huxblog_navbar.in .navbar-collapse{ max-height: 500px; }
}

@media (max-width: 767px){
  html.dark body{ -webkit-overflow-scrolling: touch; }
}

html.dark a,
html.dark .post-container a {
  color: #93c5fd;
}
html.dark a:hover,
html.dark a:focus,
html.dark .post-container a:hover,
html.dark .post-container a:focus {
  color: #bfdbfe;
}

html.dark hr { border-color: #334155; }
html.dark hr.small { border-color: #64748b; }

/* Navbar */
html.dark .navbar-default {
  background-color: #0b1220;
  border-color: #1f2937;
}
html.dark .navbar-default .navbar-brand,
html.dark .navbar-default .navbar-nav>li>a {
  color: #e5e7eb;
}
html.dark .navbar-default .navbar-brand:hover,
html.dark .navbar-default .navbar-nav>li>a:hover {
  color: #93c5fd;
}
html.dark .navbar-default .navbar-toggle .icon-bar {
  background-color: #e5e7eb;
}
html.dark .navbar-default .navbar-toggle {
  background: transparent;
  border-color: #334155;
}
/* Mobile collapse panel in dark mode */
@media (max-width: 767px){
  html.dark .navbar-default .navbar-collapse{
    background: rgba(11,18,32,0.96) !important;
    border: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  }
  html.dark #huxblog_navbar .navbar-collapse a{ color: #e5e7eb; }
  html.dark #huxblog_navbar .navbar-collapse a:hover{ color: #bfdbfe; }
}

@media (max-width: 767px){
  html.dark #huxblog_navbar{
    position: fixed;
    top: 68px;
    right: 16px;
    width: 230px;
    max-width: calc(100% - 32px);
    display: none;
    z-index: 1000;
  }
  html.dark #huxblog_navbar .navbar-collapse{
    display: block !important;
    overflow: hidden;
    background: rgba(15,23,42,0.95);
    border: 1px solid rgba(51,65,85,0.9);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.55);
    padding: 8px 12px;
  }
  html.dark #huxblog_navbar .nav>li>a{ color: #e2e8f0; display:block; padding:8px 6px; }
  html.dark #huxblog_navbar.in{ display:block; animation: navFloatIn .18s ease-out; }
}

@media (max-width: 767px){
  html.dark body{ -webkit-overflow-scrolling: touch; }
}

/* Footer */
html.dark footer {
  background: #0b1220;
  color: #94a3b8;
}
html.dark footer .copyright.text-muted { color: #94a3b8; }
html.dark footer .fa-circle { color: #334155; }

/* Typography */
html.dark h1,
html.dark h2,
html.dark h3,
html.dark h4,
html.dark h5,
html.dark h6 {
  color: #f1f5f9;
}
html.dark blockquote {
  color: #cbd5e1;
  border-left-color: #334155;
}

/* Reading-lists TOC on dark */
html.dark .toc-container {
  background: #111827;
  border-color: #374151;
}
html.dark .toc-container h3 { color: #93c5fd; }
html.dark .toc-container a { color: #93c5fd; }
html.dark .toc-container a:hover { color: #bfdbfe; }

/* Tables */
html.dark .table th,
html.dark .table td {
  border-color: #374151 !important;
}

/* Code & Preformatted */
html.dark .highlight pre,
html.dark pre,
html.dark .highlight .hll {
  background-color: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
html.dark code,
html.dark pre code {
  background-color: transparent;
  color: #e2e8f0;
}

/* Syntax highlight token colors (Pygments GitHub theme overrides) */
html.dark .highlight .c,  /* Comment */
html.dark .highlight .cm,
html.dark .highlight .c1,
html.dark .highlight .cs { color: #94a3b8; font-style: italic; }
html.dark .highlight .k,  /* Keywords */
html.dark .highlight .kc,
html.dark .highlight .kd,
html.dark .highlight .kn,
html.dark .highlight .kp,
html.dark .highlight .kr,
html.dark .highlight .kt { color: #93c5fd; font-weight: 600; }
html.dark .highlight .o,  /* Operators */
html.dark .highlight .ow { color: #f59e0b; font-weight: 600; }
html.dark .highlight .n,  /* Names */
html.dark .highlight .nn,
html.dark .highlight .nl,
html.dark .highlight .nx { color: #e5e7eb; }
html.dark .highlight .nb { color: #a78bfa; }
html.dark .highlight .nc { color: #fca5a5; }
html.dark .highlight .no { color: #60a5fa; }
html.dark .highlight .ni { color: #f472b6; }
html.dark .highlight .ne,
html.dark .highlight .nf { color: #22d3ee; font-weight: 600; }
html.dark .highlight .nt { color: #60a5fa; }
html.dark .highlight .nv,
html.dark .highlight .vc,
html.dark .highlight .vg,
html.dark .highlight .vi { color: #f8fafc; }
html.dark .highlight .m,
html.dark .highlight .mf,
html.dark .highlight .mh,
html.dark .highlight .mi,
html.dark .highlight .mo,
html.dark .highlight .il { color: #f59e0b; }
html.dark .highlight .s,
html.dark .highlight .sb,
html.dark .highlight .sc,
html.dark .highlight .sd,
html.dark .highlight .s1,
html.dark .highlight .s2,
html.dark .highlight .se,
html.dark .highlight .sh,
html.dark .highlight .si,
html.dark .highlight .sx,
html.dark .highlight .sr,
html.dark .highlight .ss { color: #34d399; }
html.dark .highlight .gd { color: #fecaca; background-color: #7f1d1d; }
html.dark .highlight .gi { color: #bbf7d0; background-color: #14532d; }
html.dark .highlight .gh { color: #cbd5e1; font-weight: 600; }
html.dark .highlight .go { color: #9ca3af; }
html.dark .highlight .gp { color: #94a3b8; }
html.dark .highlight .w  { color: #64748b; }
html.dark .highlight .err { color: #fecaca; background-color: #7f1d1d; }

/* Inputs (if any) */
html.dark input,
html.dark textarea,
html.dark select {
  background-color: #0f172a;
  color: #e5e7eb;
  border-color: #334155;
}

/* Tag cloud default color range override, keep legible */
html.dark #tag_cloud a { color: #93c5fd; }

/* Mermaid container tweaks for dark mode */
html.dark .mermaid { color-scheme: dark; }

/* Ensure code/ASCII art does not wrap; allow horizontal scroll */
html.dark .highlight pre { overflow-x: auto; -webkit-overflow-scrolling: touch; }
html.dark .highlight pre code { white-space: pre !important; }
html.dark pre code { white-space: pre !important; }
html.dark .post-container pre { white-space: pre !important; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Reduce scroll trapping on code and tables */
html.dark .highlight pre,
html.dark pre {
  -webkit-overflow-scrolling: auto; /* avoid iOS capturing vertical scroll */
  touch-action: auto;
  overscroll-behavior: contain;
  overflow-y: visible;              /* let page handle vertical scroll */
}
html.dark .table-responsive {
  overflow-y: visible;              /* don't capture vertical scroll */
  touch-action: auto;
  overscroll-behavior: contain;
}

/* Ensure page-level scroll只由浏览器控制，不让article自己滚动 */
html.dark body > article {
  overflow-y: visible !important;
  overflow-x: visible;
}

/* Pinned badge */
html.dark .pinned-badge {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 700;
  color: #0b1220;
  background: linear-gradient(90deg, #60a5fa, #93c5fd);
  border-radius: 4px;
}

/* Post preview cards */
html.dark .post-preview {
  margin-bottom: 22px;
  background: rgba(15,23,42,0.6);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.48);
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease;
}
html.dark .post-preview:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

/* Archive summary card */
html.dark .archive-summary {
  background: rgba(15,23,42,0.6);
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.48);
}

/* Header readability overlay */
.intro-header{ position: relative; }
@media (min-width: 768px){
  html.dark .intro-header::after{
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(to bottom, rgba(11,18,32,0.00) 0%, rgba(11,18,32,0.20) 60%, rgba(11,18,32,0.32) 100%);
  }
}

/* Ensure header titles don't stick to top, esp. mobile */
@media (max-width: 767px){
  html.dark .intro-header .site-heading,
  html.dark .intro-header .page-heading,
  html.dark .intro-header .post-heading{ padding-top: 130px; padding-bottom: 50px; }
}
