/*
 * toomore.net 全站共用樣式
 *
 * 配色取自首頁那張 Lomo LC-A 120 鏡中自拍（舉著相機、臉被擋住）：
 *   暗房    #22261A  照片最暗處的橄欖黑，用在首頁 hero 與內頁頂端色條
 *   卡其    #D6C9A6  照片最亮的主色 #CEBF9D 提亮，暗房上的文字
 *   黃銅    #D4AE5E  照片的 #8E723B 提亮（淺底上用加深版 #785D26）
 *   苔綠    #43582A  照片的 #625628 與 #748265 之間，連結與標題
 *   紙      #EAEDE3  刻意偏綠的淺灰，不是暖奶油
 * 完整規範與用法見 /design.html。
 *
 * 首頁另外載入 home.css。字型 self-host（latin subset），不向 Google Fonts 發請求。
 */

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/barlow-condensed-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/barlow-condensed-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* 暗房：兩種模式都是深色 */
  --darkroom: #22261a;
  --khaki: #d6c9a6;
  --khaki-soft: #a89e80;
  --brass-lit: #d4ae5e;

  /* 相紙 */
  --paper: #eaede3;
  --paper-deep: #dfe3d6;
  --ink: #1f2218;
  --ink-soft: #5c604d;
  --rule: #cdd2c1;
  --moss: #43582a;
  --brass: #785d26;

  --display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue Condensed",
    sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang TC", "Noto Sans TC",
    "Microsoft JhengHei", "Heiti TC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --t-micro: 0.8125rem;
  --t-meta: 0.9375rem;
  --t-body: 1.0625rem;
  --t-lead: 1.25rem;
  --t-section: 1.875rem;

  --measure: 64rem;
  --text-measure: 44rem;
  --gutter: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --darkroom: #0f1109;
    --paper: #1a1d14;
    --paper-deep: #23271c;
    --ink: #e4e6d9;
    --ink-soft: #a2a68f;
    --rule: #33382a;
    --moss: #a8c27a;
    --brass: #d4ae5e;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── 連結 ──────────────────────────────────────── */

/* 句子裡的連結保留淡底線；獨立成行的標題類連結在各自的區塊拿掉底線 */
a {
  color: var(--moss);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}

a:hover {
  text-decoration-color: currentColor;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 3px;
  border-radius: 1px;
}

code,
kbd,
pre {
  font-family: var(--mono);
}

/* ── 內頁頂端：暗房色條 ────────────────────────── */

.site-bar {
  background: var(--darkroom);
  color: var(--khaki);
}

.site-bar-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1rem var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}

.site-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.625rem;
  line-height: 1;
  color: var(--khaki);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1.25rem;
  font-size: var(--t-meta);
}

.site-nav a {
  color: var(--khaki-soft);
  text-decoration: none;
}

.site-name:hover,
.site-nav a:hover {
  color: var(--brass-lit);
}

.site-nav a[aria-current="page"] {
  color: var(--khaki);
}

.site-bar a:focus-visible {
  outline-color: var(--brass-lit);
}

/* ── 文章 ──────────────────────────────────────── */

.article {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4rem) var(--gutter) 1rem;
}

.article > * {
  max-width: var(--text-measure);
}

.article h1 {
  margin: 0 0 1.5rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.25rem, 6vw, 3.25rem);
  line-height: 1.05;
  color: var(--ink);
}

/* 中文標題在窄體英文字型裡沒有對應字形，會落到系統字型；字級收小一點才不會壓過版面 */
.article h1:lang(zh-Hant) {
  font-family: var(--sans);
  font-size: clamp(1.625rem, 4vw, 2.125rem);
  line-height: 1.35;
}

.article h2 {
  margin: 2.75rem 0 0.9rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--t-section);
  line-height: 1.15;
  color: var(--moss);
}

.article h2:lang(zh-Hant) {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.375rem;
}

.article h3 {
  margin: 2rem 0 0.4rem;
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1.4;
}

.article h4 {
  margin: 1.25rem 0 0.35rem;
  font-size: var(--t-meta);
  font-weight: 600;
  color: var(--brass);
}

.article h5 {
  margin: 1.5rem 0 0.25rem;
  font-size: 1.0625rem;
  font-weight: 700;
}

.article h3 small {
  font-weight: 400;
  color: var(--ink-soft);
}

.article p,
.article ul,
.article ol,
.article pre,
.article figure {
  margin: 0 0 1rem;
}

.article ul,
.article ol {
  padding-left: 1.4rem;
}

.article li + li {
  margin-top: 0.35rem;
}

.article li > ul,
.article li > ol {
  margin: 0.35rem 0 0;
}

.article strong {
  font-weight: 700;
}

.article small {
  font-size: var(--t-meta);
  color: var(--ink-soft);
}

.article .lede {
  font-size: var(--t-meta);
  color: var(--ink-soft);
}

.article hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.article code {
  padding: 0.1em 0.35em;
  background: var(--paper-deep);
  border-radius: 3px;
  font-size: 0.9em;
}

.article pre {
  padding: 1rem 1.15rem;
  background: var(--paper-deep);
  border-left: 3px solid var(--moss);
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

/* 指紋與指令需要完整看到，窄螢幕時自動換行而不是橫向捲動 */
.article pre.wrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.article pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.article figure a {
  display: block;
}

.article figure img {
  width: 100%;
}

.article figcaption {
  margin-top: 0.5rem;
  font-size: var(--t-micro);
  color: var(--ink-soft);
}

.mono {
  font-family: var(--mono);
  font-size: 0.9375rem;
}

.button {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--moss);
  background: transparent;
  color: var(--moss);
  font: 600 var(--t-meta) / 1.4 var(--sans);
  cursor: pointer;
}

.button:hover {
  background: var(--moss);
  color: var(--paper);
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.copy-row pre {
  margin: 0;
  flex: 1 1 14rem;
}

/* 中英並列的頁面：英文標題後面附一個中文小標 */
.article h2 .h-zh {
  margin-left: 0.6rem;
  font-family: var(--sans);
  font-size: 0.6em;
  font-weight: 600;
  color: var(--ink-soft);
}

/* 文章頂端的發布資訊 */
.dateline {
  margin-top: -0.75rem !important;
  font-size: var(--t-meta);
  color: var(--ink-soft);
}

/* ── 索引列表：寫作、演講 ──────────────────────── */

.article .index {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.article .index > li {
  display: grid;
  grid-template-columns: 6.75rem 1fr;
  gap: 0 1rem;
  margin: 0;
  padding: 0.9rem 0;
  border-top: 1px solid var(--rule);
}

.article .index > li:last-child {
  border-bottom: 1px solid var(--rule);
}

.index .when {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--brass);
  font-variant-numeric: tabular-nums;
}

.index .title {
  font-weight: 700;
  text-decoration: none;
}

.index a.title:hover {
  text-decoration: underline;
}

.index .lang-tag {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0 0.4rem;
  border: 1px solid var(--rule);
  font-size: var(--t-micro);
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink-soft);
  vertical-align: 0.1em;
  white-space: nowrap;
}

.index .note {
  display: block;
  margin-top: 0.15rem;
  font-size: var(--t-meta);
  color: var(--ink-soft);
}

/* ── 作品案例 ──────────────────────────────────── */

.case {
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule);
}

.case .case-meta {
  margin: 0;
  font-size: var(--t-meta);
  color: var(--ink-soft);
}

.case .case-meta .when {
  font-family: var(--display);
  font-weight: 600;
  color: var(--brass);
  margin-right: 0.5rem;
}

.article .case h3 {
  margin: 0.2rem 0 0.5rem;
}

.case p:last-child {
  margin-bottom: 0;
}

.case .case-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: var(--t-meta);
}

/* ── 表格 ──────────────────────────────────────── */

.table-scroll {
  overflow-x: auto;
  margin: 0 0 1rem;
}

.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-meta);
}

.article th,
.article td {
  padding: 0.55rem 0.9rem 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.article th {
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

.article td.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 40rem) {
  .article .index > li {
    grid-template-columns: 1fr;
  }
}

/* ── 頁尾 ──────────────────────────────────────── */

.site-foot {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 3rem;
}

.site-foot-inner {
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  font-size: var(--t-micro);
  color: var(--ink-soft);
}

.site-foot-inner a {
  color: var(--ink-soft);
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.foot-links a[aria-current="page"] {
  color: var(--ink);
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ── 履歷頁的列印按鈕 ─────────────────────────── */

.print-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  font-size: var(--t-meta);
}

/* ── 列印 ──────────────────────────────────────── */
/*
 * 履歷的 PDF 也從這裡產生（.tools/build-resume-pdf.py），網頁和 PDF 共用同一份內容。
 * 這段必須放在檔案最後：開著深色模式列印時，prefers-color-scheme: dark 與 print
 * 會同時成立，放在後面的列印配色才會蓋掉深色配色。
 */
@media print {
  @page {
    size: A4;
    margin: 14mm 16mm;
  }

  :root {
    --paper: #ffffff;
    --paper-deep: #f1f2ec;
    --ink: #16171d;
    --ink-soft: #4a4d3f;
    --rule: #c9cdbd;
    --moss: #33451f;
    --brass: #5f4a1e;
  }

  body {
    background: #ffffff;
    font-size: 10pt;
    line-height: 1.45;
  }

  .site-bar,
  .site-foot,
  .no-print {
    display: none !important;
  }

  .article {
    max-width: none;
    padding: 0;
  }

  .article > * {
    max-width: none;
  }

  .article h1 {
    margin-bottom: 4pt;
    font-size: 24pt;
  }

  .article h2 {
    margin: 12pt 0 5pt;
    padding-top: 5pt;
    font-size: 14pt;
  }

  .article h3 {
    margin: 9pt 0 2pt;
    font-size: 11pt;
  }

  .article h4 {
    margin: 5pt 0 1pt;
    font-size: 9.5pt;
  }

  .article h5 {
    margin: 7pt 0 1pt;
    font-size: 10pt;
  }

  .article p,
  .article ul,
  .article ol,
  .article pre {
    margin-bottom: 5pt;
  }

  .article li + li {
    margin-top: 2pt;
  }

  .article small,
  .article .lede,
  .contact-line {
    font-size: 9.5pt;
  }

  /* 紙上點不了連結，拿掉底線；網址本身已經寫在內文裡 */
  a {
    color: inherit;
    text-decoration: none;
  }

  h1, h2, h3, h4, h5 {
    break-after: avoid;
  }

  p, li {
    orphans: 3;
    widows: 3;
  }

  li, pre, figure {
    break-inside: avoid;
  }

  .article pre {
    white-space: pre-wrap;
    border-left-color: var(--rule);
  }
}
