/*

"Calculus Made Easy 中文" book stylesheet

Adapted from the "Dive Into HTML 5" stylesheet used by calculusmadeeasy.org.

Original stylesheet copyright (c) 2009, Mark Pilgrim, All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

中文化调整:
- Libertine/Essays 1743 只覆盖拉丁字形,中文落回宋体系衬线;
- CJK 行高加大到 1.7(原 1.556 是拉丁书写习惯);
- ponytail: 原站 word-spacing:0.1em 会把中文词间也撑开,略;
- ponytail: 原站 .f 首字下沉(Alphabet of Children 花体)在章节页并未启用,略;
- 数学公式为服务端渲染的 MathJax SVG,附带溢出滚动规则。
*/

/* fonts */

@font-face {
  font-family: "Libertine";
  src: url("../theme/fonts/book/Libertine.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Libertine";
  src: url("../theme/fonts/book/Libertine-bold.woff") format("woff");
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Libertine";
  src: url("../theme/fonts/book/Libertine-italic.woff") format("woff");
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Libertine";
  src: url("../theme/fonts/book/Libertine-bold-italic.woff") format("woff");
  font-weight: bold;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Essays 1743";
  src: url("../theme/fonts/book/Essays1743.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Essays 1743";
  src: url("../theme/fonts/book/Essays1743-bold.woff") format("woff");
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Essays 1743";
  src: url("../theme/fonts/book/Essays1743-italic.woff") format("woff");
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Essays 1743";
  src: url("../theme/fonts/book/Essays1743-bold-italic.woff") format("woff");
  font-weight: bold;
  font-style: italic;
  font-display: swap;
}

/* base */

html {
  overflow-y: scroll;
  -webkit-font-smoothing: antialiased;
}
html, body {
  background: #fff;
  color: #000;
  margin: 0;
  padding: 0;
}
body {
  font-family: "Libertine", "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, "Times New Roman", serif;
  font-size: large;
  line-height: 1.7;
}

.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1em 2em;
}

p, ul, ol {
  margin: 1.556em 0;
}

img {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

address, cite, dfn, var {
  font-style: normal;
}
sup {
  font-variant: small-caps;
  vertical-align: text-top;
}

/* links —— 原站签名式:砖红 + 点线下划线 */

a {
  text-decoration: none;
}
a:link {
  color: FireBrick;
  border-bottom: 1px dotted;
}
a:visited {
  color: RosyBrown;
  border-bottom: 1px dotted;
}
a:link:hover, a:visited:hover {
  border-bottom: 1px solid;
}

/* headers —— Essays 1743 大写居中,拉丁大写对中文无效 */

h1, h2, h3, h4, caption, thead th {
  font-family: "Essays 1743", "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, "Times New Roman", serif;
  font-weight: normal;
  text-transform: uppercase;
  text-shadow: 0 0 1px #667;
}
h1 {
  font-size: 220%;
  line-height: 1.2;
  text-align: center;
  margin: 1.49em 0;
}
h2 {
  font-size: 170%;
  line-height: 1.3125;
  text-align: center;
  margin: 1.167em 0;
  clear: both;
}
h3 {
  font-size: x-large;
  line-height: 1.167;
  text-align: center;
  margin: 1.556em 0;
}

/* 答案折叠 —— 增值功能,原站为平铺;details/summary 原生实现,零 JS。
   summary 照搬 h2 的居中标题样式,▸/▾ 提示可点击与展开态 */

details.answers > summary {
  font-family: "Essays 1743", "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, "Times New Roman", serif;
  font-size: 170%;
  line-height: 1.3125;
  text-align: center;
  margin: 1.167em 0;
  clear: both;
  text-transform: uppercase;
  text-shadow: 0 0 1px #667;
  cursor: pointer;
  list-style: none;
}
details.answers > summary::-webkit-details-marker {
  display: none;
}
details.answers > summary::after {
  content: "▸";
  font-size: 55%;
  margin-left: 0.4em;
  vertical-align: middle;
}
details.answers[open] > summary::after {
  content: "▾";
}

/* asterism —— 原站分节花 ❧;字体栈与原站 screen.css 的 .a 一致,
   否则 ❧ 由 CJK 正文字体回退渲染,字形与原站不同 */

.asterism {
  text-align: center;
  font-family: "Arial Unicode MS", FreeSerif, OpenSymbol, "DejaVu Sans", sans-serif;
  font-size: xx-large;
  line-height: 0.875;
  margin: 1em 0;
  text-shadow: 0 0 2px #667;
}

/* 首页 */

.site-title {
  font-size: 300%;
  margin-top: 1em;
}
.site-author {
  font-size: 160%;
}
.site-quote {
  text-align: center;
}
.site-quote .q {
  font-size: large;
  margin: 0.5em 0;
}
.site-quote .q-src {
  font-size: medium;
  margin: 0.5em 0 2em;
}
.site-intro {
  font-size: medium;
}

/* 目录 */

.toc, .toc li {
  list-style: none;
  margin-left: 0;
  padding-left: 0;
}
.toc li {
  margin: 0.4em 0;
}
.toc .toc-number {
  display: inline-block;
  min-width: 2.2em;
  text-align: right;
  margin-right: 0.6em;
}

/* 未译/待更新标记 —— 素括号小字,不用胶囊 */

.tag {
  font-size: small;
  color: #666;
  margin-left: 0.5em;
  white-space: nowrap;
}
.tag::before { content: "〔"; }
.tag::after { content: "〕"; }

.untranslated-banner {
  margin: 1.75em 0;
  padding: 0.5em 1em;
  border: 1px solid #999;
  font-size: medium;
}

/* 章节页 */

.chapter-number {
  display: block;
  font-size: 60%;
  margin-bottom: 0.4em;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  margin: 2em 0 1em;
  font-size: medium;
}
.chapter-nav .up {
  text-align: center;
  flex: 1;
}
.chapter-nav .prev, .chapter-nav .next {
  flex: 1;
}
.chapter-nav .next {
  text-align: right;
}

.attribution {
  font-size: small;
  color: #333;
  margin-top: 3em;
  padding-top: 1em;
  border-top: 1px solid #999;
}

/* 站点页脚 */

.site-footer {
  margin-top: 4em;
  padding-top: 1em;
  border-top: 1px solid #999;
  font-size: small;
  text-align: center;
  color: #333;
}
.site-footer nav {
  margin: 0.5em 0;
}
.site-footer nav a {
  margin: 0 0.6em;
}

/* 正文内容(渲染的 Markdown) */

.post-content {
  -webkit-hyphens: manual;
  hyphens: manual;
}
@supports (text-autospace: normal) {
  .post-content {
    text-autospace: normal;
  }
}

.post-content img {
  max-width: min(100%, 480px);
  margin: 12px auto;
}

.post-content .footnotes {
  font-size: small;
  opacity: 0.85;
}

.post-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.556em 0;
}
.post-content table, .post-content th, .post-content td {
  border: 1px solid black;
  text-align: center;
  padding: 8px;
}
.post-content th {
  background-color: #d0d0d0;
  font-weight: bold;
}
.post-content tr:nth-child(even) {
  background-color: #f9f9f9;
}

/* MathJax SVG:独立公式居中,小屏溢出滚动 */

.post-content p.standalone-math > mjx-container {
  display: block;
  text-align: center;
}

/* 搜索框(唯一保留的模板组件,样式从简) */

.search__container {
  position: relative;
  max-width: 22em;
  margin: 2em auto;
}
.search__container form {
  display: flex;
  border-bottom: 1px solid #000;
}
.search-input {
  flex: 1;
  border: 0;
  padding: 4px 2px;
  font: inherit;
  background: transparent;
  outline: none;
}
.search__icon {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0 2px;
}
.search__suggestions {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  z-index: 10;
  background: #fff;
  border: 1px solid #000;
  font-size: medium;
}
.js-is-suggestion-active .search__suggestions {
  display: block;
}
.search__suggestions ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.search__suggestions li a {
  display: block;
  padding: 4px 8px;
  border-bottom: 0;
}
.search__suggestions li.search-suggestion-highlight,
.search__suggestions li.search-suggestion-highlight a {
  background: #eee;
}

/* 小屏 */

@media screen and (max-width: 640px) {
  .page {
    padding: 0 0.8em 2em;
  }
  h1 {
    font-size: 170%;
  }
  .site-title {
    font-size: 220%;
  }

  .post-content mjx-container[display="true"],
  .post-content p.standalone-math > mjx-container {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .post-content mjx-container[display="true"] > svg,
  .post-content p.standalone-math > mjx-container > svg {
    max-width: 100%;
    height: auto;
  }
  .post-content mjx-container[display="true"][width="full"] {
    width: 100% !important;
    min-width: 0 !important;
  }

  .post-content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .post-content li > mjx-container:not([display="true"]) {
    display: inline-block;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    vertical-align: middle;
    -webkit-overflow-scrolling: touch;
  }
  .post-content li > mjx-container:not([display="true"]) > svg {
    max-width: 100%;
    height: auto;
  }
}
