/* 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);

  /* Sage green, the siao.ai family's brand accent — the literal token
   * from ClaudeDesign/APP_FAMILY.md, not a re-derived approximation.
   * Already measured there: 4.52:1 as text on this paper, which is the
   * reason it is #587b60 and not the original #5f8567 (3.96:1).
   *
   * Used for interaction only — links, hover, focus, the reading
   * progress bar. Not for decoration, and never as the sole signal for
   * anything. */
  --accent: #587b60;
  --accent-wash: rgba(88, 123, 96, 0.09);

  /* Two families, and the split is the point. Reading matter is set in
   * the serif; everything that is *interface* — nav, labels, byline,
   * sidebar, tag chips, table headers — is set in the system sans.
   *
   * Before this split every one of those was Garamond too, and a page
   * of nothing but serif at six different sizes is tiring to read: the
   * eye gets no signal about what is prose and what is furniture.
   * (The marketing homepage can be all-serif because it is one screen
   * with almost no chrome; this site is not that.)
   *
   * The sans is the platform's own — zero bytes downloaded, and it
   * reads as interface precisely because it is the interface face the
   * reader already knows. CJK order follows APP_FAMILY.md: TC before
   * SC, always, or shared codepoints render simplified. */
  --serif: "EB Garamond", "Noto Serif TC", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", "Noto Sans CJK TC", "Heiti TC", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  /* Sans is the default because most of what is on screen at any moment
   * is interface. Reading matter opts back into the serif below. */
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -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 {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* A visible focus ring in the brand colour. The default outline is the
 * browser's blue, which is the one colour on this page that belongs to
 * nobody — and removing it without a replacement is how keyboard
 * navigation gets quietly broken. */
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

/* 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(--accent);
  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);
}

/* The wordmark stays serif — it's the one piece of chrome that is
 * brand rather than interface. `.name` is an <h1> on the index and a
 * <span> elsewhere, so reset the h1 sizing it would otherwise inherit. */
.site-header .name {
  font-family: var(--serif);
  font-size: 1.4rem;
  line-height: 1.2;
  font-weight: 400;
  margin: 0;
}

.site-header .name a {
  border-bottom: none;
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
}

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

.site-nav a:hover {
  color: var(--accent);
}

/* "You are here." The accent is doing real work — it is the only
 * persistent use of colour on a browse page, and it means exactly one
 * thing. Weight carries it too, so the state does not depend on colour
 * alone. */
.site-nav a[aria-current] {
  color: var(--accent);
  font-weight: 600;
}

/* 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;
}

/* Headings are reading matter, so they stay serif even on browse
 * pages where the surrounding chrome is sans. */
h1,
h2,
h3 {
  font-family: var(--serif);
}

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;
}

/* Sans, and small: this is metadata about the article, not part of it.
 * The family has to be stated, not inherited — the byline sits inside
 * <article>, which sets the serif for everything under it. */
.byline {
  font-family: var(--sans);
  color: var(--ink-dim);
  font-size: 0.85rem;
  margin: 0 0 1.75rem;
  letter-spacing: 0.01em;
}

/* Post/archive/tag listings share this shape: a hairline-divided list,
 * each item a title link plus a muted excerpt or meta line. */
/* No border-top: each item carries its own bottom rule, so the list
 * closes itself. It used to have one, which on the index stacked a
 * second hairline directly under the header's own bottom border —
 * two parallel lines with a gap and nothing between them. */
.post-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
}

.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-family: var(--serif);
  font-size: 1.4rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
}

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

.post-list .title a:hover {
  color: var(--accent);
}

/* An excerpt is prose, so it stays serif; a meta line (post counts,
 * dates) is interface, so it doesn't. */
.post-list p {
  font-family: var(--serif);
  color: var(--ink-dim);
  font-style: italic;
  font-size: 1.05rem;
  margin: 0.4rem 0 0;
}

.post-list .meta {
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.85rem;
}

/* 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).
 * Interface, so sans, and tinted with the brand wash on hover rather
 * than just darkening. */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1.75rem;
}

.tags a {
  font-family: var(--sans);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
  color: var(--ink-dim);
}

.tags a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-wash);
}

/* 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-family: var(--serif);
  font-size: 1.25rem; /* 20px */
  line-height: 1.6;
}

/* A link inside prose carries the accent from the start, not only on
 * hover — inside a paragraph there is no other cue that it is a link,
 * and hover is not a cue a touch reader ever receives. */
article a {
  color: var(--accent);
  border-bottom-color: rgba(88, 123, 96, 0.35);
}

article a:hover {
  border-bottom-color: var(--accent);
  background: var(--accent-wash);
}

/* ~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: "· · ·";
  /* The one ornamental mark on the page, so it wears the brand colour
   * rather than another grey. It carries no information, which is
   * exactly why colouring it costs nothing. */
  color: var(--accent);
  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.2rem 0.65rem;
  font-size: 0.8rem;
  color: var(--ink-dim);
}

.tag-cloud a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-wash);
}

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

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

#search-input:focus {
  border-color: var(--accent);
}

.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(--accent);
}
