/* blog.siao.ai — extends the siao.ai homepage's visual identity
 * (ClaudeDesign/BLOG.md), not the app family's. Same literal color
 * tokens as the homepage, same editorial detailing (hairlines,
 * letter-spaced labels, the ↗ hover affordance). One serif stack for
 * everything — no separate sans face for chrome.
 */

/* size-adjust exists because this site sets Latin and Traditional
 * Chinese in the same line constantly ("Markdown 渲染管線", "GFM 表格").
 *
 * Measured, not guessed: at the same font-size, EB Garamond's cap
 * height renders at 65.8px per 100px em while Noto Serif TC's glyph
 * height renders at 91.6px — the Latin is only 72% as tall, because
 * Garamonds are historically small-on-the-body faces and CJK glyphs
 * fill their em box. Unadjusted, every English word in a Chinese
 * sentence reads as a size too small.
 *
 * 108% brings the Latin cap to ~78% of the CJK glyph, which is the
 * comfortable ratio for a serif pairing. Applied to the @font-face
 * rather than to selectors, so it holds everywhere Latin appears
 * without anybody having to remember it.
 */
@font-face {
  font-family: "EB Garamond";
  src: url("/fonts/eb-garamond-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  size-adjust: 108%;
  font-display: block; /* a flash of the wrong serif reads worse than a moment of nothing */
}

@font-face {
  font-family: "EB Garamond";
  src: url("/fonts/eb-garamond-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  size-adjust: 108%;
  font-display: block;
}

@font-face {
  font-family: "EB Garamond";
  src: url("/fonts/eb-garamond-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  size-adjust: 108%;
  font-display: block;
}

@font-face {
  font-family: "Noto Serif TC";
  src: url("/fonts/noto-serif-tc-chinese-traditional-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: block;
}

@font-face {
  font-family: "Noto Serif TC";
  src: url("/fonts/noto-serif-tc-chinese-traditional-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: block;
}

:root {
  --paper: #faf9f6;
  --ink: #1a1a1a;
  --ink-dim: #6e6b65;
  --hairline: rgba(26, 26, 26, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "EB Garamond", "Noto Serif TC", Georgia, serif;
  font-size: 1.125rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;

  /* 禁則處理: Chinese typesetting does not allow a line to *begin* with
   * closing punctuation (。、」）) or to *end* with opening punctuation.
   * Browsers default to `line-break: auto`, which is permissive and
   * regularly strands a 。 alone at the start of a line. This is the
   * single most visible difference between text that has been typeset
   * for Chinese and text that has merely been displayed in it. */
  line-break: strict;
  /* Don't break a Latin word mid-glyph when it sits inside Chinese
   * text; wrap it whole to the next line instead. */
  overflow-wrap: break-word;
}

a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--hairline);
}

a:hover {
  border-bottom-color: var(--ink);
}

/* Fills left-to-right as the reader scrolls through a post
 * (reading-progress.js). Zero width, invisible, and inert on any page
 * without an <article> — the script is a no-op there. */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--ink);
  z-index: 10;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* A post page is narrower, so the reading column ends up optically
 * centred in the viewport rather than sitting left of a sidebar that
 * isn't there. Measured against Medium's own article page, which
 * centres a 680px column with nothing beside it. */
.wrap-read {
  max-width: 712px; /* 680px column + the 1.5rem padding either side */
}

/* Two columns — reading column plus a persistent sidebar
 * (ClaudeDesign/BLOG.md: search, tags, recent posts always visible,
 * not one click away). Stacks to one column once there isn't room for
 * both without the sidebar crowding the reading measure. */
.layout {
  display: flex;
  gap: 3rem;
  align-items: flex-start;
}

.layout main {
  flex: 1;
  min-width: 0;
  max-width: 640px;
}

/* Reading shape: no sidebar, so main takes the full (already narrow)
 * wrap and the 680px measure comes from the wrap itself. */
.layout-read main {
  max-width: none;
}

@media (max-width: 720px) {
  .layout {
    flex-direction: column;
  }
  .layout main {
    max-width: none;
  }
}

/* The site header: name + the tag/archive nav ClaudeDesign/BLOG.md's
 * "personal wiki" framing asks for, present on every page. */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.25rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--hairline);
}

.site-header .name a {
  font-size: 1.4rem;
  border-bottom: none;
}

.site-nav {
  display: flex;
  gap: 1.25rem;
}

.site-nav a {
  border-bottom: none;
  color: var(--ink-dim);
}

.site-nav a:hover,
.site-nav a[aria-current] {
  color: var(--ink);
}

/* Uppercase, letter-spaced section labels — same device the homepage
 * uses above its list groups (e.g. ELSEWHERE, CONTACT). */
.label {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 0.75rem;
}

h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

/* A post's own headline — deliberately larger and more confident than
 * a section-index h1 (歸檔/標籤), the same "commit to the headline"
 * move Medium makes on an article page. */
.post-title {
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.15;
}

h2 {
  font-size: 1.3rem;
  margin: 2rem 0 0.75rem;
}

.byline {
  color: var(--ink-dim);
  font-size: 0.95rem;
  margin: 0 0 1.75rem;
}

/* Post/archive/tag listings share this shape: a hairline-divided list,
 * each item a title link plus a muted excerpt or meta line. */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--hairline);
}

.post-list li {
  padding: 1.6rem 0;
  border-bottom: 1px solid var(--hairline);
}

/* The headline of a listing entry — upright and weighted, so it reads
 * as a title rather than as another line of the italic body voice the
 * excerpt below it uses. `font-style: normal` is load-bearing: the
 * rule below sets every `p` in a list item italic, and the title is a
 * `p` too. */
.post-list .title {
  font-size: 1.35rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
}

.post-list .title a {
  border-bottom: none;
}

.post-list .title a:hover {
  border-bottom: 1px solid var(--ink);
}

.post-list .meta,
.post-list p {
  color: var(--ink-dim);
  font-style: italic;
  font-size: 0.95rem;
  margin: 0.3rem 0 0;
}

/* Tag chips — on a post page (linking to that tag's index) and on the
 * tag index itself (linking to each tag, with its post count). */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1.75rem;
}

.tags a {
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.15rem 0.6rem;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.tags a:hover {
  color: var(--ink);
  border-color: var(--ink);
}

/* Archive: year headings, month sub-groups. */
.archive-year {
  font-size: 1.5rem;
  margin: 2.5rem 0 0.5rem;
}

.archive-year:first-of-type {
  margin-top: 0;
}

.archive-month {
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 1.25rem 0 0.5rem;
}

/* A post's own body content.
 *
 * Reading type is set HERE, not on `body` — the site chrome (nav,
 * sidebar, listings) stays at the smaller global size. Medium tunes
 * exactly this way: 20px/1.6 for article prose, smaller everywhere
 * else. Measured off their article page rather than guessed.
 */
article {
  margin-top: 0.5rem;
  font-size: 1.25rem; /* 20px */
  line-height: 1.6;
}

/* ~34px between paragraphs at this size, matching the measured
 * breathing room on Medium — noticeably more than the browser default,
 * and the single biggest thing that makes long prose feel readable
 * rather than dense. */
article p {
  margin: 0 0 1.7rem;
}

article h2 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 2.75rem 0 1rem;
}

article h3 {
  font-size: 1.25rem;
  margin: 2rem 0 0.75rem;
}

/* The headline block (title, byline, tags) sits closer together than
 * body prose, so it reads as one unit rather than three stacked
 * paragraphs. */
.post-title + .byline {
  margin-top: -0.25rem;
}

/* A markdown `---` becomes this — a centered "· · ·" scene break
 * instead of a plain rule, Medium's section-divider convention. The
 * author already writes `---` for this in GFM; nothing new to learn. */
article hr {
  border: none;
  height: auto;
  margin: 2.5rem 0;
  text-align: center;
}

article hr::after {
  content: "· · ·";
  color: var(--ink-dim);
  letter-spacing: 0.5em;
  font-size: 1.1rem;
}

/* Horizontal rules only — no vertical lines, no outer box. A full grid
 * on every cell reads as a spreadsheet; the same data with rules only
 * between rows reads as typeset. This is the same hairline the rest of
 * the site divides with, so a table sits in the page rather than on
 * top of it. */
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.95em;
}

article th,
article td {
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 0.7rem 1rem 0.7rem 0;
  text-align: left;
  vertical-align: top;
}

article thead th {
  border-bottom-color: var(--ink);
  font-size: 0.8em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-weight: 400;
  padding-bottom: 0.5rem;
}

article tbody tr:last-child td {
  border-bottom: none;
}

article figure {
  margin: 2rem 0;
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: 3px;
}

/* A code block is a quotation of something else, not a hole punched in
 * the page. The dark shiki theme measured 13.93:1 against this paper —
 * a near-black slab that pulled the eye off the prose every time. A
 * light theme on a barely-tinted panel keeps the code legible as code
 * while leaving the page one continuous surface. */
article pre {
  overflow-x: auto;
  padding: 1.1rem 1.25rem;
  margin: 0;
  background: #f4f2ec !important;
  border-radius: 3px;
  line-height: 1.55;
}

article code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
}

/* Inline code — distinguished by a tint, not a border, so it doesn't
 * fragment a sentence into boxes. */
article p > code,
article li > code {
  background: #f0eee8;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* Language switcher, the same hairline/label device as everything
 * else — not a separate widget style. */
nav[aria-label="Languages"] {
  color: var(--ink-dim);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

nav[aria-label="Languages"] a,
nav[aria-label="Languages"] span {
  border-bottom: none;
}

/* "Referenced in" / embed-source notes render as quiet, italic asides
 * — the same register as the homepage's italic descriptions. */
p[role="note"] {
  color: var(--ink-dim);
  font-style: italic;
  font-size: 0.95rem;
}

/* Sidebar: search, tag cloud, recent posts, post count — all real
 * data, no placeholder categories (ClaudeDesign/BLOG.md). */
.sidebar {
  width: 240px;
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .sidebar {
    width: 100%;
  }
}

.widget {
  margin-bottom: 2rem;
}

.widget .label {
  margin-bottom: 0.6rem;
}

.widget-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.widget-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 0.95rem;
}

.widget-list li:last-child {
  border-bottom: none;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-cloud a {
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.15rem 0.6rem;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.tag-cloud a:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.sidebar > .meta {
  color: var(--ink-dim);
  font-style: italic;
  font-size: 0.9rem;
}

#search-input {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.4rem 0.6rem;
}

#search-input:focus {
  outline: none;
  border-color: var(--ink);
}

.search-results {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
}

.search-results li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
}

.search-results a {
  border-bottom: none;
}

.search-empty {
  color: var(--ink-dim);
  font-style: italic;
}

.site-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline);
  color: var(--ink-dim);
  font-size: 0.9rem;
}

.site-footer a {
  border-bottom: none;
  color: var(--ink-dim);
}

.site-footer a:hover {
  color: var(--ink);
}
