
@import url(https://fonts.googleapis.com/earlyaccess/cwtexfangsong.css);
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@300;400;700&display=swap');

/* ============================
   色彩系統（統一管理）
   ============================ */
:root {
  --c-primary:    #1a5632;   /* 墨綠：H1、H3 */
  --c-secondary:  #1a4a7a;   /* 深藍：H2 */
  --c-accent:     #8b4513;   /* 赭褐：H4 */
  --c-subtle:     #4a7a6a;   /* 灰綠：H5、輔助文字 */
  --c-text:       #2c2c2c;   /* 正文 */
  --c-text-light: #666;      /* 次要文字 */
  --c-bg:         #fcfcfa;   /* 頁面底色（微暖白） */
  --c-bg-code:    #f6f8fa;   /* 程式碼底色 */
  --c-bg-inline:  #e6f0e9;   /* 行內指令底色（淺綠） */
  --c-border:     #d0d7de;   /* 邊框 */
  --c-link:       #1a5a9c;   /* 連結 */
  --c-link-visit: #6a5aac;   /* 已訪問 */
}

/* ============================
   基礎
   ============================ */
body {
  margin: auto;
  width: 90%;
  font-family: 'Noto Serif TC', 'Georgia', serif;
  font-size: 1em;
  font-weight: 300;
  background: var(--c-bg);
  padding: 2%;
  color: var(--c-text);
  line-height: 1.75em;
  counter-reset: section toc-section;
  counter-increment: toc-section;
}

/* ============================
   標題系統（墨綠 → 深藍 → 赭褐 漸層）
   ============================ */
H1 {
  margin: 5px 10px;
  padding: 12px 16px;
  font-family: 'Noto Serif TC', serif;
  font-weight: 700;
  color: var(--c-primary);
  background: linear-gradient(135deg, #e8f0ec 0%, #d4e4da 100%);
  font-size: 2.4em;
  line-height: 1.2;
  letter-spacing: 1px;
  border-bottom: 3px solid var(--c-primary);
}

H2 {
  margin: 50pt 0 0 -35px;
  padding: 6px 12px 6px 14px;
  color: var(--c-secondary);
  font-family: 'cwTeXFangSong', serif;
  font-weight: bold;
  font-size: 1.5em;
  border: 1px solid var(--c-secondary);
  border-left: 6px solid var(--c-secondary);
  background: #e8eef6;
  line-height: 1.8;
}

H3 {
  margin: 40pt 0 0 -25px;
  padding: 5px 10px 5px 12px;
  color: var(--c-primary);
  font-family: 'cwTeXFangSong', serif;
  font-weight: bold;
  font-size: 1.25em;
  border-bottom: 1px solid var(--c-primary);
  border-left: 6px solid var(--c-primary);
  background: #eaf2ec;
  line-height: 1.5;
}

H4 {
  margin: 20pt 0 0 -15px;
  padding: 4px 10px 4px 12px;
  font-family: 'cwTeXFangSong', serif;
  font-weight: bold;
  font-size: 1.1em;
  color: var(--c-accent);
  border-bottom: 1px solid var(--c-accent);
  border-left: 5px solid var(--c-accent);
  line-height: 1.4;
}

H5 {
  margin: 15pt 0 0 -5px;
  padding: 3px 10px;
  font-family: 'Noto Serif TC', serif;
  font-weight: bold;
  font-size: 1em;
  color: var(--c-subtle);
  border-bottom: 1px solid var(--c-subtle);
  border-left: 4px solid var(--c-subtle);
  line-height: 1.3;
}

H2:hover, H3:hover, H4:hover, H5:hover {
  border-bottom-style: dashed;
}

H2:link, H2:active, H3:link, H3:active, H4:link, H4:active, H5:link, H5:active {
  border-width: 1px;
  border-style: inset;
}

H6.mulu {
  color: #46357c;
  margin: 0 0 -10px -35px;
  font-size: 14px;
}

/* ============================
   程式碼區塊
   ============================ */
pre {
  margin-top: 5px;
  margin-bottom: 20px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 0.8em;
  padding-left: 4.5em;
  white-space: pre-wrap;
  background: var(--c-bg-code);
  color: var(--c-text);
  text-align: left;
  counter-reset: line;
  font-size: 1em;
  line-height: 1.6;
}

/* 行號 */
pre .linenr:not(.org-src-container) {
  content: counter(line);
  counter-increment: line;
  padding-right: 1em;
  color: #a0b0a8;
  border-right: 1px dashed #c0d0c8;
  margin-right: 1em;
  margin-left: -4.5em;
  display: inline-block;
  width: 3em;
  text-align: right;
  user-select: none;
}

pre .linenr.org-src-container {
  display: none;
}

.src .linenr {
  user-select: none;
}

/* 語言標籤（Python / Shell 等），對齊 Copy 按鈕 */
pre.src:before {
  display: inline !important;
  margin-top: 0 !important;
  position: absolute;
  top: -15px;
  right: 30px;
  background: white;
  color: var(--c-accent);
  font-size: 0.9em;
  font-weight: 400;
  padding: 4px 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  line-height: 1.2;
  z-index: 1;
}

/* Example block */
pre.example {
  background-color: #fefcf3;
  color: #5c4a1e;
  border: 1px dashed #d8c88c;
  font-family: 'Noto Serif TC', serif;
  font-size: 0.9em;
  padding: 1em;
  padding-left: 1em;
  line-height: 1.8;
  border-radius: 6px;
}

/* Prompt 區塊（#+begin_src prompt）：給 AI 的指令，不編行號、用內文字體 */
pre.src-prompt {
  padding-left: 1em;
  font-family: inherit;
  background: #f3f8f4;
  border-left: 4px solid var(--c-primary);
}

pre.src-prompt code {
  font-family: inherit;
}

pre.src-prompt:before {
  content: "Prompt";
  color: var(--c-primary);
}

/* Copy 按鈕（保持原樣） */
button.copy-button {
  position: absolute;
  top: -1.0em;
  right: 10px;
  background: #0567A2;
  color: white;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 0.9em;
  padding: 4px 10px;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

button.copy-button:hover {
  background: #e0e0e0;
  color: #0567A2;
  border-color: #999;
}

/* src block 穩定性 */
pre[class^="src-"], pre[class*=" src-"] {
  overflow: visible;
  line-height: 1.6;
  padding-right: 4em;
}

pre[class^="src-"] span,
pre[class*=" src-"] span {
  position: static;
  transition: none;
}

/* ============================
   連結
   ============================ */
a { text-decoration: none; }
a:link { color: var(--c-link); padding: 1px; }
a:active { color: #999; }
a:visited { color: var(--c-link-visit); }
a:hover {
  text-decoration: none;
  border-bottom: 1px solid var(--c-link);
  padding-bottom: 1px;
}

/* ============================
   圖片
   ============================ */
img {
  clear: both;
  margin: 8px 0;
  border: none;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ============================
   清單
   ============================ */
ul { margin-top: 5px; margin-bottom: 5px; }
ol { margin-top: 5px; margin-bottom: 5px; }
li { margin-bottom: 0.2em; }

/* ============================
   分隔線
   ============================ */
hr {
  width: 100%;
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--c-border), transparent);
  margin: 1.5em 0;
}

/* ============================
   表格
   ============================ */
table {
  min-width: 100%;
  margin-top: 1em;
  border-collapse: collapse;
  border-top: 2px solid var(--c-primary);
  border-bottom: 2px solid var(--c-primary);
}

table, tbody, td, tr, th, colgroup, thead {
  border: 0;
  padding: 10px;
  text-align: center;
}

thead {
  background: #eaf2ec;
  border-bottom: 1px solid var(--c-primary);
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--c-primary);
  padding: 8px 10px;
}

td {
  padding: 8px 10px;
}

tr:nth-child(even) { background: #f7f9f8; }
tr:nth-child(odd) { background: #fff; }

tr:hover {
  background: #eef4f0;
}

/* ============================
   TOC 目錄
   ============================ */
#table-of-contents {
  padding-top: 0;
  margin-top: 0;
  text-transform: uppercase;
}

#table-of-contents ul {
  padding: 0;
  font-weight: 400;
  list-style: none;
  counter-reset: list 0;
}

#table-of-contents ul ul {
  padding-left: 2em;
  font-weight: 300;
  font-size: 90%;
  line-height: 1.5em;
  margin-top: 0;
  margin-bottom: 1em;
}

#table-of-contents h2:before {
  content: "";
  counter-reset: section;
}

#table-of-contents ul li {
  vertical-align: top;
  display: inline-block;
  width: 32%;
  color: var(--c-primary);
  font-weight: 700;
  margin-bottom: 0.4em;
}

#table-of-contents ul li a {
  color: var(--c-primary);
  font-weight: 700;
}

#table-of-contents ul li ul li {
  color: var(--c-subtle) !important;
  font-weight: 400;
  font-size: 0.95em;
  margin-left: 1.5em;
  margin-bottom: 0.3em;
}

#table-of-contents ul li:before {
  display: inline-block;
  counter-increment: list;
  width: 2em;
  margin-left: -2em;
  text-align: right;
  text-transform: uppercase;
  color: var(--c-secondary);
}

#table-of-contents ul li ul,
#table-of-contents ul li ul li {
  display: static;
  width: 100%;
  padding-left: 0;
  line-height: 1.35em;
}

#table-of-contents ul li ul li:before {
  content: "";
}

#table-of-contents h2:before {
  content: "     ";
}

#table-of-contents h2 {
  font-size: 24px;
  font-weight: bold;
  font-family: 'Noto Serif TC', serif;
  color: var(--c-primary);
  background: #faf5ea url(../css/camus.png) no-repeat left center;
  background-size: 50px 34px;
  border: 1px solid var(--c-primary);
  border-left: 6px solid var(--c-primary);
  margin-left: -35px;
  margin-right: 0;
  margin-top: 50pt;
  padding: 3px 0 3px 10px;
  line-height: 2;
  text-indent: 50px;
}

/* ============================
   頁尾
   ============================ */
#content, #postamble {
  margin: 0 auto;
  max-width: 920px;
  margin-top: 2.5%;
  margin-bottom: 2.5%;
}

#postamble {
  padding-top: 1.5em;
}

#postamble p, #postamble a {
  color: #999;
  line-height: 1.25em;
  margin: 0;
  text-align: right;
}

/* ============================
   標籤、狀態
   ============================ */
span.tag {
  background-color: #f0f0f0;
  border: 1px solid #e0e0e0;
  color: #888;
  cursor: pointer;
  display: block;
  float: right;
  font-size: 80%;
  font-weight: normal;
  margin: 0 3px;
  padding: 1px 6px;
  border-radius: 10px;
}

span.todo {
  background-color: #e8806a;
  padding: 1px 6px;
  color: #fff;
  border-radius: 3px;
}

span.todo.WAIT {
  background-color: #6ab097;
}

span.todo.done {
  background-color: #6ab0de;
  padding: 1px 6px;
  color: #fff;
}

span.flagged {
  background-color: #c0392b;
  border: 1px solid #c0392b;
  color: white;
  font-weight: bold;
}

/* ============================
   blockquote（引用區塊）
   ============================ */
blockquote {
  border-left: 4px solid var(--c-subtle);
  background: #f5f7f6;
  margin: 1em 0;
  padding: 0.8em 1.2em;
  color: var(--c-text-light);
  font-style: italic;
  border-radius: 0 6px 6px 0;
}

/* ============================
   雜項
   ============================ */
.postmeta {
  font-size: 9px;
  font-weight: bold;
  text-align: right;
  color: #777;
  padding: 0;
  margin: 2px;
  vertical-align: middle;
}

.postmeta a:link, .postmeta a:visited, .postmeta a:active, .postmeta a:hover {
  color: #777;
  text-decoration: none;
  border-width: 0;
}

.code {
  padding: 0;
  border: none;
  background: var(--c-bg-code);
  white-space: pre-wrap;
  color: #003366;
  font-family: Consolas, Monaco, 'Courier New', monospace;
}

/* 行內指令（Org 的 =…= 與 ~…~） */
:not(pre) > code {
  font-size: 1.07em;
  font-weight: 600;
  color: var(--c-primary);
  background: var(--c-bg-inline);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

.code-container {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
  padding: 1em;
}

.code-container .copy-button {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  padding: 0.3em 0.6em;
  font-size: 0.8em;
  cursor: pointer;
}

.copy-button {
  position: absolute;
  right: 10px;
  top: -15px;
  background-color: #0277bd;
  color: white;
  border: #005a9c 1px solid;
  padding: 5px;
  cursor: pointer;
  z-index: 2;
}

/* 已合併至 button.copy-button */

.footer {
  position: relative;
  bottom: 0;
  padding: 20px;
  width: 100%;
  height: 50px;
}

#navlist ul { margin-left: 0; padding-left: 0; }
#navlist li { display: inline; list-style-type: none; text-align: left; }
#navlist a { padding: 3px 10px; border: 1px; }
#navlist a:link, #navlist a:visited { color: #fff; background-color: var(--c-secondary); text-decoration: none; }
#navlist a:hover { color: #fff; background-color: var(--c-link); text-decoration: none; }

/* ============================
   程式碼語法上色（org htmlize css 模式）
   ============================ */
pre.src .org-keyword           { color: #cf222e; }
pre.src .org-builtin           { color: #8250df; }
pre.src .org-function-name     { color: #6639ba; font-weight: 500; }
pre.src .org-variable-name     { color: #953800; }
pre.src .org-string            { color: #0a3069; }
pre.src .org-doc               { color: #0a3069; font-style: italic; }
pre.src .org-comment,
pre.src .org-comment-delimiter { color: #6e7781; font-style: italic; }
pre.src .org-constant          { color: #0550ae; }
pre.src .org-type              { color: #953800; }
pre.src .org-preprocessor      { color: #cf222e; }
pre.src .org-operator          { color: #2c2c2c; }
pre.src .org-warning           { color: #cf222e; font-weight: bold; }
