/* Skybu 手記 v3
   全站一種明體，內文一般體、標題與站名粗體；頁面不用顏色，顏色只來自插圖。
   版面 7:3：左邊是文章，右邊是分類、關於、目錄等資訊，中間一條直線分開。
   橫線只用來分區：開場、主體、頁尾。 */

:root {
  --paper: #eeefed;
  --ink: #1e2126;
  --grey: #62666d;
  --tint: #e2e4e1;
  --line: #c2c5c1;

  --ming: 'Noto Serif TC', 'Songti TC', 'PMingLiU', serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --measure: 36rem;
  --gutter: 56px;
}

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

html { scroll-padding-top: 32px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/2 var(--ming);
  font-synthesis: none;
}

h1, h2, p, ul, ol, figure { margin: 0; }
h1, h2 { font-weight: 700; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; height: auto; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

[hidden] { display: none !important; }

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip { position: absolute; left: -999px; }
.skip:focus { left: 20px; top: 12px; z-index: 2; background: var(--ink); color: var(--paper); padding: 4px 14px; }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 56px);
}

/* ---------- 頁首 ---------- */

.site {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 14px 56px;
  padding: 40px 0;
}
.brand { font-size: 27px; font-weight: 700; line-height: 1.3; letter-spacing: 0.04em; }

.nav { display: flex; gap: 1.6em; color: var(--grey); }
.nav a:hover { color: var(--ink); }
.nav a[aria-current] {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 8px;
}

.search { margin-left: auto; }
.search input {
  width: 9em;
  padding: 0 0 2px;
  border: 0;
  border-bottom: 1px solid var(--grey);
  border-radius: 0;
  background: none;
  line-height: 1.7;
}
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.search input::placeholder { color: var(--grey); opacity: 1; }
.search input:focus { outline: none; border-bottom-color: var(--ink); box-shadow: 0 1px 0 var(--ink); }

/* ---------- 7:3 版面 ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
  border-top: 1px solid var(--line);
}
.main { padding: 56px var(--gutter) 96px 0; }
.side {
  border-left: 1px solid var(--line);
  padding: 62px 0 96px 40px;
  font-size: 15px;
  line-height: 1.9;
}
.side section + section, .side nav + section { margin-top: 48px; }
.side h2 { margin-bottom: 8px; font-size: 17px; }
.side .note { margin-top: 6px; color: var(--grey); }
.side-sticky { position: sticky; top: 32px; }

.topics li { display: grid; grid-template-columns: 3.4em 1fr; }
.topics a, .toc a { justify-self: start; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
.topics a:hover, .toc a:hover { color: var(--grey); }
.topics span { color: var(--grey); }

.toc li + li { margin-top: 4px; }

.taglist { display: flex; flex-wrap: wrap; gap: 2px 1.4em; }
.taglist a, .tags a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
.taglist a:hover, .tags a:hover { color: var(--grey); }
.taglist span { margin-left: 0.4em; color: var(--grey); font-variant-numeric: tabular-nums; }

/* ---------- 分類、日期 ---------- */

.meta {
  display: flex;
  gap: 1em;
  color: var(--grey);
  font-size: 15px;
  line-height: 1.8;
  font-variant-numeric: tabular-nums;
}
.meta .category:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 5px; }

/* ---------- 首頁 ---------- */

.intro {
  padding: 64px 0 80px;
  font-size: clamp(30px, 4.2vw, 46px);
  line-height: 1.55;
  letter-spacing: 0.02em;
}

.intro h1 { font: inherit; font-weight: 700; }
.intro p { margin-top: 8px; color: var(--grey); font-size: 17px; line-height: 2; letter-spacing: 0; }

.posts { display: flex; flex-direction: column; gap: 56px; }

.post {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}
.post .meta { grid-column: 1; }
.post-text { grid-column: 1; max-width: var(--measure); }
.post h2 { margin-top: 2px; font-size: 29px; line-height: 1.5; letter-spacing: 0.02em; }
.post h2 a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 8px; }
.post .excerpt { margin-top: 8px; color: var(--grey); }
.thumb { grid-column: 2; grid-row: 1 / span 2; width: 168px; margin: 8px 0 0 32px; }
.thumb img { aspect-ratio: 3 / 2; object-fit: cover; }

.posts .empty { color: var(--grey); }

.excerpt mark { background: none; color: var(--ink); font-weight: 700; }

.codehead button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}
.codehead button:hover { color: var(--grey); }

/* ---------- 文章頁 ---------- */

.article h1 { margin-top: 6px; font-size: clamp(30px, 4vw, 42px); line-height: 1.5; letter-spacing: 0.02em; }
.article .lead { max-width: var(--measure); margin-top: 20px; color: var(--grey); font-size: 19px; line-height: 1.95; }

/* 橫線延伸到中間的直線 */
.article-body {
  margin: 56px calc(var(--gutter) * -1) 0 0;
  padding-right: var(--gutter);
  border-top: 1px solid var(--line);
}
.article-body > * { max-width: var(--measure); }
.article-body h2 { margin-top: 72px; font-size: 25px; line-height: 1.5; letter-spacing: 0.02em; }
.article-body > h2:first-child { margin-top: 56px; }
.article-body p { margin-top: 20px; }
.article-body figure { margin-top: 36px; }
.article-body figcaption { margin-top: 8px; font-size: 15px; color: var(--grey); }

.highlight { margin-top: 32px; background: var(--tint); }
.codehead, .highlight > .filename {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 10px 20px 0;
  font-size: 15px;
  color: var(--grey);
}
.highlight > .filename { display: block; }
.highlight .filename { font: 14px/2 var(--mono); }
.highlight pre:first-child { padding-top: 16px; }
.codehead button { color: var(--ink); }

pre { margin: 0; padding: 8px 20px 20px; overflow-x: auto; tab-size: 4; font: 14px/1.9 var(--mono); }
code { font-family: inherit; }
.linenos {
  display: inline-block;
  width: 1.2em;
  margin-right: 1.6em;
  color: var(--grey);
  text-align: right;
  user-select: none;
}
/* 語法標示只分兩階：字串用灰，其餘用墨 */
.highlight span[class^="s"] { color: var(--grey); }

.article-body .copy-status { margin-top: 8px; min-height: 2em; font-size: 15px; color: var(--grey); }

.article-body .tags { display: flex; flex-wrap: wrap; gap: 0 1.2em; margin-top: 72px; font-size: 15px; color: var(--grey); }
.article-body .tags a { color: var(--ink); }
.article-body .return { margin-top: 32px; }
.return a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }
.return a:hover { color: var(--grey); }

/* ---------- 頁尾 ---------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 32px;
  border-top: 1px solid var(--line);
  padding: 28px 0 56px;
  font-size: 15px;
  color: var(--grey);
}
.footer a:hover { color: var(--ink); }

/* ---------- 窄版：右側資訊移到文章下方 ---------- */

@media (max-width: 860px) {
  :root { --gutter: 0px; }

  .site { gap: 14px 24px; padding: 28px 0; }
  .nav { order: 3; width: 100%; gap: 1.3em; }

  .intro { padding: 44px 0 56px; }

  .layout { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 48px 0 64px; }
  .side { border-left: 0; border-top: 1px solid var(--line); padding: 40px 0 64px; }
  .side-sticky { position: static; }

  .posts { gap: 48px; }
  .post { grid-template-columns: minmax(0, 1fr); }
  .post h2 { font-size: 25px; }
  .thumb { grid-column: 1; grid-row: auto; width: 100%; max-width: var(--measure); margin: 16px 0 0; }

  .article-body { margin-top: 40px; }
  .article-body h2 { margin-top: 56px; }
  .article-body > h2:first-child { margin-top: 40px; }
  .codehead, .highlight > .filename, pre { padding-left: 14px; padding-right: 14px; }
  pre { font-size: 13px; }
  .linenos { margin-right: 1em; }

  .footer { padding: 24px 0 40px; }
}
