/* overall layout */
* { box-sizing: border-box; }
body {
  margin: 0 auto 0;
  line-height: 1.5;
  overflow-x: hidden;
}
main, .menu ul, .footer, .single section, .post-nav {
  max-width: 800px;
  margin: 0 auto 0;
}
main {
  display: block;
  hyphens: auto;
}
.list main {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  & > * {
    flex: 1 0 100%;
  }
  & > .post-card {
    flex: 0 0 calc(50% - .5em);
  }
}
.menu, .container { padding: 0 1em 0; }
.post-card { margin-top: 1em; }
.article-list, .single main, .single .appendix {
  margin-top: 2em;
  padding: 1em;
  box-shadow: 0 0 8px #ccc;
  background: #fff;
}
.article-meta { background: #f8f8f8; }
.article-meta .terms, main .side > *, figcaption { font-size: .9em; }
.single .appendix { background: none; }

/* header and footer areas */
.menu {
  background: #fafafa;
  box-shadow: 0px 10px 10px -5px rgba(0,0,0,0.1);
}

.sticky-top {
  position: sticky;
  top: 0;
  z-index: 2;
}
.menu li, .terms li, .footer li { display: inline-block; }
footer { background: #ffffff; }
.menu ul {
  padding: 1em 0 1em;
  display: flex;
}
.article-meta, .menu a, .footer a, .terms a, .bg-number {
  text-decoration: none;
  padding: 5px;
  border-radius: 5px;
}
a {
    color: #000000;
    padding: 2px 4px;
    border-radius: 4px;
    background-size: 0% 2px;
    background-position: 0 100%;
}
a:not([class]):hover {
    text-decoration: none;
    color: #007BFF;
    font-weight: bold;
    background: linear-gradient(-90deg, #ED1B2F, #ab3ce7, #23a6d5);
    background-size: 100% 2px;
    background-position: 0% 100%;
    background-repeat: no-repeat;
    transition: background 0.3s ease, background-size 0.5s ease, color 1s ease;
}
.menu a, .footer a { margin: 1px; }
.menu a, .pagination a, .article-meta a { color: darkslategray; }
.menu a:hover, .menu .active, .summary::first-letter, .footer a:hover, .terms a:hover, .bg-number {
  background: #007bff;
  color: #fff;
}
.menu, .article-meta, .post-nav { text-align: center; }
.menu ul, .terms { padding-left: 0; }
.footer ul { padding-left: 0rem; }
.menu .left {
  flex-grow: 1;
  font-weight: 600;
  text-align: left;
}
.title {
  font-size: 1.1em;
  line-height: 1em;
}
.terms a {
  border: 1px solid lightslategray;
  line-height: 2em;
}
.terms a, .bg-number {
  padding: 1px 5px;
}
.footer {
  display: flex;
  justify-content: space-between;
  a { text-decoration: none; }
}
footer {
  margin-top: 2rem;
  margin-bottom: 2rem;
  padding: 0px 1em;
}
hr {
  border-style: dashed;
  color: #ddd;
  width: 50%;
}
.footnotes hr { margin-left: 0; }
.appendix div:not(:last-child):not(.side) {
  border-bottom: 1px dashed lightslategray;
  padding-bottom: 1em;
  margin-bottom: 1em;
}

/* code */
.appendix pre code { white-space: pre-wrap; }

h3.side-left { text-align: right; }

.spacer { width: 1em; }
.spacer-left { border-left: 1px dashed; }
.spacer-right { border-right: 1px dashed; }

/* search */
.search .menu li, .search .container, .search footer, .search-results { display: none; }
.search #menu-search, .search .search-results {
  display: flex;
  width: 100%;
}
.search #menu-search div:first-child { flex-grow: 1; }
.search input, .search #menu-search a {
  padding: .5em;
  font-size: 1.5em;
}
.search input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 2px solid lightslategray;
}
.search-results b {
  font-weight: normal;
  background: orange;
}

/* misc elements */
img, iframe, video { max-width: 100%; }
iframe, video {
  display: block;
  margin: auto;
}
.title, .article-list .side-title { hyphens: none; }
blockquote, .article tbody tr:nth-child(odd) { background: #f9f9f9; }
blockquote {
  border-left: 5px solid #ccc;
  padding: 1px 0 1px 1em;
  margin: auto;
}
.categories {
  text-transform: uppercase;
  font-size: .8em;
}
.article-list a, .footer a {
  text-decoration: none;
  color: #000;
}
.article-list h1 {
  a {
    width: 100%;
    display: inline-block;
  }
  a:hover { color: #71a5d4; }
  border-bottom: 1px solid #ddd;
  margin: 5px 0px 10px;
}
.article-list {
  .side-title h1 { transform: rotate(90deg); }
  &:nth-child(even):not(.post-card) .side-title { transform: rotate(180deg); }
  table {
    margin: 0;
    border: none;
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
  }
  td { padding: 0; }
}
#TOC {
  .numbered {
    padding-left: 0;
    li { list-style: none; }
    ul { padding-left: 1em; }
  }
  .active { font-weight: bold; }
}
.side-title { width: 3em; }
.side-title h1 { border: none; }
.post-card .side-title h1 a, .post-card .spacer-right, .appendix h3 { color: lightslategray; }
.appendix h3 { text-align: right; }
.summary { margin-top: .5em; }
.summary::first-letter {
  font-size: 3.5em;
  padding: .1em .2em .1em .1em;
  margin: 0 .1em 0 0;
  display: inline-block;
  float: left;
  line-height: 1em;
}
.pagination { text-align: center; padding-inline-start: 0px; }
.pagination li { display: inline; }
.pagination a { padding: 0 .2em; }
.active a, #TOC a { text-decoration: none; }
.post-nav { margin: 1em auto; }
.post-nav span {
  display: inline-block;
  width: 45%;
}
.nav-prev { text-align: right; }
.nav-next { text-align: left; }
.footer, .footer a { color: gray; }
.more { font-style: italic; }
.hidden { display: none; }
.draft {
  background: repeating-linear-gradient( 135deg, white, white 10px, #ffd4a3 12px, #ffd4a3 12px );
}
.watermark {
  position: fixed;
  transform: rotate(-45deg);
  font-size: 12em;
  width: 100%;
  color: lightgray;
  opacity: 0.3;
  left: 0;
  text-align: center;
  top: 50%;
}
.pseudocode {
  margin: 1em auto;
}
table {
  margin: .5rem auto auto;
  border-top: 2px solid #666;
  border-bottom: 2px solid #666;
}
table thead th { border-bottom: 1px solid #ddd; }
th, td { padding: 5px; }
.clustrmaps-block{
  display: flex;
  justify-content: center;
  align-items: center;
}
.clustrmaps{
  width: 200px;
}
/* 只给“块级公式”开滚动；行内公式保持正常流 */
mjx-container[display="true"] {
  display: block;              /* 保证占一行 */
  max-width: 100%;             /* 不要撑破版心 */
  overflow-x: auto;            /* 关键：横向滚动 */
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch; /* iOS 惯性滚动 */
  padding-bottom: .25rem;      /* 可选：给滚动条留点空间 */
}
/* 细节优化：SVG 输出时，保持图元不被裁掉 */
mjx-container[jax="SVG"][display="true"] svg {
  overflow: visible;
}
/* 如果你的正文容器是 flex/grid，需要确保可缩放 */
.prose, .post, main, article {
  min-width: 0;  /* 防止父容器把子元素撑出视口导致无法滚动 */
}
/* responsive */
@media (max-width: 1264px) {
  .appendix h3 { text-align: initial; }
}
@media (max-width: 800px) {
  li.optional { display: none; }
  .article-list { margin-top: 1.5em; }
  .list main .post-card { flex: inherit; }
  .menu ul, .footer { flex-wrap: wrap; }
  .search input, .search #menu-search a { font-size: 1em; }
}

/* dark theme */
@media (prefers-color-scheme: dark) {
  body {
    background-color: darkslategray;
    filter: invert(1);
  }
  img { filter: invert(1); }
  .article-list { box-shadow: 0 0 8px #333; }
}
