/* Bootstrap 走两条路引入，两条都需要，别删任何一条：

   1. assets/aandds-head.html 里的 <link> —— 覆盖 org 导出的 369 个页面。
      用 <link> 而不是只靠下面的 @import，是因为 @import 会串行化请求：
      浏览器得先下载解析完本文件才发现它，再发第二个请求。
   2. 下面这条 @import —— 覆盖**不走 org 导出**的页面。
      translate/ 下有 1811 个 makeinfo 生成的手册页，它们有自己的 <head>，
      只引用 main.css，拿不到上面那个 <link>。这些文件不受构建管理
      （没被 git 跟踪，:base-extension 也不含 html），是早年直接提交进
      部署仓库的，改不了它们，只能靠 main.css 把 Bootstrap 带进去。

   对 org 页面而言这条 @import 是同一个 URL 的重复引用，浏览器直接命中缓存，
   没有额外开销。 */
@import url(/static/vendor/bootstrap.min.css);
@import url(readtheorg.min.css);

/*
  在设置 dark mode 后，跳转页面时出现白屏一闪而过的问题。
  为了解决这个问题，在 main.css 中默认不显示 body，当 dark mode（如果已经设置）应用后，才在 js 中让 body 显示
  参考：https://zwbetz.com/fix-the-white-flash-on-page-load-when-using-a-dark-theme-on-a-static-site/
*/
body {
    margin: 0 auto 2em;
}

/* 页尾 AdSense 广告位。不设 min-height —— 响应式广告位没广告可填时会自行折叠，
   预留固定高度反而会在没有广告时留下一块空白。 */
/* 广告由 AdSense 后台的「自动广告」投放，页面上不写 <ins>，也没有 .ad-footer 容器了。
   这条兜底规则仍然保留：AdSense 填不出广告时不会自己折叠 —— 实测 data-ad-status="unfilled"
   的 <ins> 仍占 280px 高，里面那个 iframe 是一块黄色空白。这是 Google 官方给的折叠写法。 */
ins.adsbygoogle[data-ad-status="unfilled"] {
    display: none !important;
}

/* 切换页面时防止深色模式白闪：先藏起 body，等脚本给 <html> 加上 .ready 再显示。
   只在 <html> 带 .js 时才隐藏 —— 没有 JS 的浏览器直接看到内容，不会白屏。
   加 .ready 的逻辑在 assets/aandds-head.html 的内联脚本里，走 load 事件 + 超时双保险。 */
html.js:not(.ready) body {
    visibility: hidden;
    opacity: 0;
}

body.light-theme {
    color: #222;
    background-color: #fff;
}
body.dark-theme {
    color: #b3b3b3;
    background-color: #343131;
}

/* 让类 form-control 适应 light mode */
body.light-theme .form-control {
    color: #222;
    background-color: #fff;
}
/* 让类 form-control 适应 dark mode */
body.dark-theme .form-control {
    color: #b3b3b3;
    background-color: #343131;
}

/* bootstrap navbar 中链接在访问后会变为 visited 指定的颜色（红色），这样比较丑。这里统一一下访问前后链接的颜色
 * 下面颜色方案只适应于深色的 navbar。目前固定使用深色 navbar，如果使用浅色 navbar 则需要相应调整
 */
.nav-link, .nav-link:visited, .nav-link:hover, .nav-link:active {
    color: #DCDCDC;
    display: contents;
}
.nav-link:hover {
    color: #ffffff;
}

/*
  Fix: top nav bar blocking top content of the page, see https://stackoverflow.com/questions/10336194/top-nav-bar-blocking-top-content-of-the-page
*/
body {
    padding-top: 55px;
}
#table-of-contents {
    padding-top: 55px;
}
/*
  Fix: Navbar hides initial content when jumping to in-page anchor, see https://github.com/twbs/bootstrap/issues/1768
*/
*[id]:before {
    display: inline;
    content: " ";
    margin-top: -55px;
    height: 55px;
    visibility: hidden;
}

#content{
    max-width: unset; /* readtheorg.css 中限制了 800px，这里去掉这个限制 */
}

table {
    margin: 0 auto;  /* Put table in the center of the page. */
    display: block;  /* Show x scrollbar, https://stackoverflow.com/a/62451601 */
    overflow-x: auto; /* Show x scrollbar, https://stackoverflow.com/a/62451601 */
    max-width: -moz-fit-content;  /* Show x scrollbar, https://stackoverflow.com/a/62451601 */
    max-width: fit-content;  /* Show x scrollbar, https://stackoverflow.com/a/62451601 */
}
table.nowrap-1st-column td:nth-child(1) { white-space: nowrap; }
table.nowrap-2nd-column td:nth-child(2) { white-space: nowrap; }
table.nowrap-3rd-column td:nth-child(3) { white-space: nowrap; }
table.nowrap-4th-column td:nth-child(4) { white-space: nowrap; }

caption {
    text-align: center;   /* The caption of table use <caption>, make it center align */
}

.title  {
    text-align: center;  /* 标题居中 */
    margin-bottom: .2em;
}

/* Inline code 的设置 */
code {
    color: unset; /* #bf616a; */
    background-color: unset;
    border: unset;
    font-size: unset;
}

.underline {
    text-decoration: underline;
}

/* 图片居中 */
figure{
    display:block;
}
figure {
    text-align: center;
}

.org-right  { margin-left: auto; margin-right: 0px;  text-align: right; }
.org-left   { margin-left: 0px;  margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }

.svg100px { width: 100px; }
.svg200px { width: 200px; }
.svg300px { width: 300px; }
.svg400px { width: 400px; }
.svg500px { width: 500px; }

.MathJax {
    /* https://stackoverflow.com/questions/61915118/mathjax-equation-does-not-fit-the-width-of-window-when-using-mobile/61942403#61942403 */
    overflow-x: auto;
    overflow-y: hidden;
}

#postamble{
    /* background: #fcfcfc; */
    margin-left: 300px;  /* 左侧是 Table of Contents */
    /* margin:auto; */
    /* max-width: unset; */
    padding: 0em 3.236em;
}
#postamble p{
    font-size: 80%;
    margin: .1em;
}

#disqus_thread {
    margin-left: 300px;  /* 左侧是 Table of Contents */
    padding: 1.618em 3.236em;
}

@media screen and (max-width: 768px){
    #disqus_thread {
        margin-left: unset; /* 小屏下左侧的 Table of Contents没有显示，所以不用缩进 */
        padding: 1.618em 3.236em;
    }
}

@media print{
    #disqus_thread {
        display:none}
}

#navbarSupportedContent > ul > li > a {
    color: #DCDCDC;
    display: contents;
}


/* ===== 归档页：标签浏览 + 搜索（Org-mode/archives.org） =====
   颜色都按 body.light-theme / body.dark-theme 分别定义 —— 本站的深色模式是
   给 body 加 class 实现的，只写一套颜色会在其中一个主题下看不清。 */

.archive { margin: 1.5em 0; }

.archive-controls { margin-bottom: 1.2em; }

.archive-search {
    width: 100%;
    padding: .55em .9em;
    font-size: 1rem;
    border-radius: 8px;
}

.archive-summary {
    display: flex;
    align-items: center;
    gap: 1em;
    margin-top: .6em;
    font-size: .9rem;
    opacity: .75;
}

.archive-clear {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    color: inherit;
    opacity: .8;
}
.archive-clear:hover { opacity: 1; }

.archive-facet { margin-bottom: 1em; }

.archive-chips {
    display: flex;
    flex-wrap: wrap;      /* 窄屏下自动换行，不横向溢出 */
    gap: .45em;
}

.archive-chip {
    display: inline-flex;
    align-items: center;
    gap: .4em;
    padding: .25em .7em;
    font-size: .85rem;
    line-height: 1.6;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color .12s, border-color .12s;
}

.archive-chip-n {
    font-size: .75em;
    opacity: .6;
    font-variant-numeric: tabular-nums;
}

.archive-list {
    list-style: none;
    padding: 0;
    margin: 1.2em 0 0;
}

.archive-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .6em;
    padding: .4em 0;
}

.archive-date {
    font-variant-numeric: tabular-nums;
    font-size: .85rem;
    opacity: .6;
    flex: 0 0 auto;
}

.archive-badge {
    font-size: .72rem;
    padding: .05em .5em;
    border-radius: 4px;
    opacity: .8;
}

.archive-empty { opacity: .6; margin-top: 1.5em; }

/* ---- 浅色 ---- */
body.light-theme .archive-chip {
    background-color: #f1f3f5;
    border: 1px solid #dee2e6;
    color: #343a40;
}
body.light-theme .archive-chip:hover { background-color: #e9ecef; }
body.light-theme .archive-chip.is-on {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}
body.light-theme .archive-chip.is-on .archive-chip-n { opacity: .85; }
body.light-theme .archive-badge { background-color: #f1f3f5; color: #495057; }
body.light-theme .archive-item { border-bottom: 1px solid #f1f3f5; }

/* ---- 深色 ---- */
body.dark-theme .archive-chip {
    background-color: #3f3f3f;
    border: 1px solid #555;
    color: #d0d0d0;
}
body.dark-theme .archive-chip:hover { background-color: #4a4a4a; }
body.dark-theme .archive-chip.is-on {
    background-color: #4d8fd6;
    border-color: #4d8fd6;
    color: #fff;
}
body.dark-theme .archive-chip.is-on .archive-chip-n { opacity: .85; }
body.dark-theme .archive-badge { background-color: #3f3f3f; color: #b0b0b0; }
body.dark-theme .archive-item { border-bottom: 1px solid #3a3a3a; }
