/* eric-yen.com: styles every page shares. Page-specific rules stay in each page. */
/* ========== Tokens (Kami parchment) ========== */
:root {
  --parchment:    #f5f4ed;
  --ivory:        #faf9f5;
  --inline-code-bg: #f0eee6;

  --brand:        #1B365D;
  --brand-light:  #2D5A8A;
  --brand-tint:   #EEF2F7;

  --near-black:   #141413;
  --dark-warm:    #3d3d3a;
  --olive:        #504e49;
  --stone:        #6b6a64;

  --border:       #e8e6dc;
  --border-soft:  #e5e3d8;

  /* Latin first so mixed runs ("15 年", "AI") share the CJK baseline */
  --serif: Charter, "Bitstream Charter", "LXGW WenKai TC", "Noto Serif TC", "Source Han Serif TC", "Songti TC", serif;
  --latin-ui: "PingFang TC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--parchment);
  color: var(--near-black);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0.4px;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; transition: color .15s; }
@media (hover: hover) { a:hover { color: var(--brand-light); } }
.num { font-variant-numeric: lining-nums tabular-nums; }

.page { max-width: 1120px; margin: 0 auto; padding: 88px 64px 120px; }

/* ========== Buttons ========== */
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--latin-ui); font-weight: 500; font-size: 15px;
  letter-spacing: .2px; padding: 13px 28px; border-radius: 999px;
  border: 1.5px solid var(--brand); min-width: 158px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-ghost { background: transparent; color: var(--brand); }
@media (hover: hover) {
  .btn-primary:hover { background: var(--brand-light); border-color: var(--brand-light); color: var(--on-brand); transform: translateY(-1px); }
  .btn-ghost:hover { background: var(--brand-tint); color: var(--brand); transform: translateY(-1px); }
}

/* ========== Hero ========== */
.hero { padding-bottom: 56px; border-bottom: 1px solid var(--border-soft); margin-bottom: 96px; }
.eyebrow {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-family: var(--latin-ui); font-size: 12px; font-weight: 500;
  letter-spacing: .4px; text-transform: uppercase; color: var(--stone); margin: 0 0 28px;
}
.lang-switch { display: flex; align-items: center; gap: 2px; font-family: var(--latin-ui); font-size: 12px; font-weight: 500; letter-spacing: .4px; margin-left: 6px; padding-left: 18px; border-left: 1px solid var(--border); }
/* Same box for the current language (span) and the other one (a), so the row never moves between pages */
.lang-switch > a, .lang-switch > span { display: inline-block; min-width: 40px; text-align: center; line-height: 20px; padding: 3px 7px; border-radius: 999px; }
.lang-switch a { color: var(--stone); }
.lang-switch [aria-current] { color: var(--brand); background: var(--brand-tint); }
@media (hover: hover) { .lang-switch a:hover { color: var(--brand); } }

/* Brand icons: one size, one colour, everywhere they appear */
.ico { width: 18px; height: 18px; fill: currentColor; display: block; }
.hero-links, .icons, .colophon .links { display: flex; align-items: center; gap: 18px; }
.hero-links > a, .icons a, .colophon .links a { color: var(--stone); display: inline-flex; padding: 4px; margin: -4px; }
@media (hover: hover) { .hero-links > a:hover, .icons a:hover, .colophon .links a:hover { color: var(--brand); } }
.hero-name { display: flex; align-items: center; gap: 24px; margin: 0 0 22px; }
.hero-name img { width: 104px; height: 104px; mix-blend-mode: multiply; flex: none; }
.hero h1 { font-weight: 500; font-size: 88px; line-height: 1.05; margin: 0; }
.hero .tagline { font-size: 26px; line-height: 1.5; color: var(--near-black); margin: 0 0 14px; max-width: 820px; }
.hero-sub { font-size: 17px; line-height: 1.7; color: var(--olive); margin: 0 0 24px; max-width: 760px; }
.hero-tokens { display: flex; flex-wrap: wrap; margin: 0 0 36px; font-family: var(--latin-ui); font-size: 13px; color: var(--stone); }
.hero-tokens span:not(:last-child)::after { content: "·"; margin: 0 10px; color: color-mix(in srgb, var(--stone) 58%, transparent); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }

/* ========== Sections ========== */
section { margin-bottom: 96px; }
.section-num { font-family: var(--latin-ui); font-size: 12px; font-weight: 500; letter-spacing: .4px; color: var(--stone); margin: 0 0 10px; }
.section-title { font-weight: 500; font-size: 36px; line-height: 1.25; margin: 0 0 12px; }
.section-lede { color: var(--olive); font-size: 17px; margin: 0 0 40px; }

/* Metrics */
.metrics { display: flex; flex-wrap: wrap; gap: 32px; margin: 2px 0 16px; }
.metric b { display: block; font-weight: 500; font-size: 28px; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.metric span { font-family: var(--latin-ui); font-size: 13px; color: var(--stone); }

/* Features (tools) */
.features { border-top: 1px solid var(--border-soft); }
.feature { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 36px; padding: 28px 0; border-bottom: 1px solid var(--border-soft); }
.feature-name { font-size: 22px; font-weight: 500; line-height: 1.35; color: var(--near-black); margin: 0; }
.feature-name small { display: block; margin-top: 6px; font-size: 13px; font-style: italic; font-weight: 400; color: var(--olive); }
.feature-desc { color: var(--dark-warm); font-size: 15.5px; margin: 0; }
.feature-desc p { margin: 0 0 12px; }
.feature-links { font-family: var(--latin-ui); font-size: 14px; }
.feature-links a:not(:last-child)::after { content: "·"; margin: 0 10px; color: var(--stone); }

/* Writing list */
.posts { list-style: none; margin: 0 0 24px; padding: 0; border-top: 1px solid var(--border-soft); }
.posts li { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 24px; padding: 18px 0; border-bottom: 1px solid var(--border-soft); }
.posts time { font-family: var(--latin-ui); font-size: 13px; color: var(--stone); padding-top: 3px; font-variant-numeric: lining-nums tabular-nums; }
.posts a { font-size: 18px; line-height: 1.45; }
.more { font-family: var(--latin-ui); font-size: 14px; }

/* Milestones: a dated rail, key turns marked in brand ink */
.milestones { list-style: none; margin: 0; padding: 0; position: relative; }
.milestones::before { content: ""; position: absolute; left: 117px; top: 10px; bottom: 10px; width: 1px; background: var(--border); }
.milestones li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 44px; padding: 0 0 30px; position: relative; }
.milestones li:last-child { padding-bottom: 0; }
.milestones li::before { content: ""; position: absolute; left: 112px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--parchment); border: 1.5px solid var(--stone); }
.milestones li.key::before { background: var(--brand); border-color: var(--brand); }
.milestones time { font-family: var(--latin-ui); font-size: 13px; color: var(--stone); text-align: right; padding-top: 1px; font-variant-numeric: lining-nums tabular-nums; }
.milestones h3 { font-weight: 500; font-size: 18px; line-height: 1.45; margin: 0 0 4px; color: var(--near-black); }
.milestones p { margin: 0; color: var(--olive); font-size: 14.5px; line-height: 1.6; }
@media (max-width: 480px) {
  .milestones::before { left: 4px; }
  .milestones li { grid-template-columns: minmax(0, 1fr); gap: 2px; padding-left: 24px; }
  .milestones li::before { left: 0; }
  .milestones time { text-align: left; }
}

/* Help groups: each group lists the concrete things, name + one line */
.items { list-style: none; margin: 0; padding: 0; }
.items li { padding: 0 0 16px; }
.items li:last-child { padding-bottom: 0; }
.items a { font-size: 16.5px; }
.items span { display: block; color: var(--olive); font-size: 14.5px; line-height: 1.6; }
.feature-desc .lead { margin: 0 0 16px; }
.items span b, .feature-desc .lead b { font-weight: 500; color: var(--near-black); }
.items span b + *, .items span b { margin-right: .15em; }


/* Stances: three short lines in his own words, each with where he said it */
.stances { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.stances li { counter-increment: s; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px; padding: 22px 0; border-top: 1px solid var(--border-soft); }
.stances li:last-child { border-bottom: 1px solid var(--border-soft); }
.stances li::before { content: counter(s, decimal-leading-zero); font-family: var(--latin-ui); font-size: 13px; color: var(--stone); padding-top: 8px; }
.stances q { quotes: none; display: block; font-size: 21px; line-height: 1.6; color: var(--near-black); }
.stances q em { font-style: normal; color: var(--brand); }
.stances small { display: block; margin-top: 6px; font-family: var(--latin-ui); font-size: 13px; color: var(--stone); }
@media (max-width: 480px) { .stances li { grid-template-columns: minmax(0, 1fr); gap: 0; } .stances li::before { padding-top: 0; } .stances q { font-size: 18px; } }

/* Manifesto */
.manifesto { font-size: 22px; line-height: 1.7; letter-spacing: .05em; color: var(--near-black); margin: 0; max-width: 860px; }
.manifesto em { font-style: normal; color: var(--brand); }
.manifesto-src { font-family: var(--latin-ui); font-size: 13px; color: var(--stone); margin-top: 20px; }

/* Subscribe */
.subscribe { background: var(--ivory); border: 1px solid var(--border); border-radius: 8px; padding: 40px; }
.sub-form { display: flex; gap: 10px; max-width: 520px; margin-top: 20px; }
.sub-form input {
  flex: 1; min-width: 0; font-family: var(--latin-ui); font-size: 15px; color: var(--near-black);
  background: var(--parchment); border: 1.5px solid var(--border); border-radius: 999px; padding: 12px 22px;
  outline: none; transition: border-color .15s;
}
.sub-form input::placeholder { color: var(--stone); }
.sub-form input:focus { border-color: var(--brand); }
.sub-form .btn-primary { min-width: 112px; }
.sub-note { font-family: var(--latin-ui); font-size: 13px; color: var(--stone); margin: 10px 0 0 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.subscribe .channels { display: flex; align-items: center; gap: 16px; font-family: var(--latin-ui); font-size: 14px; color: var(--stone); margin: 20px 0 0; }

/* Footer */
footer { display: flex; justify-content: space-between; gap: 48px; padding-top: 40px; border-top: 1px solid var(--border-soft); }
.mark b { display: block; font-size: 20px; font-weight: 500; }
.mark span { font-family: var(--latin-ui); font-size: 13px; color: var(--stone); }
.colophon { text-align: right; }
.colophon .links { justify-content: flex-end; }
.ethos { font-style: italic; color: var(--olive); font-size: 14px; max-width: 600px; margin: 12px 0 0 auto; }

/* ========== Responsive ========== */
@media (max-width: 880px) {
  .page { padding: 64px 32px 96px; }
  .hero { margin-bottom: 72px; }
  section { margin-bottom: 72px; }
  .hero h1 { font-size: 64px; }
  .hero-name img { width: 80px; height: 80px; }
  .feature { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  footer { flex-direction: column; gap: 24px; }
  .colophon { text-align: left; }
  .colophon .links { justify-content: flex-start; }
  .ethos { margin-left: 0; }
}
@media (max-width: 480px) {
  .page { padding: 40px 16px 72px; }
  .hero { margin-bottom: 56px; padding-bottom: 40px; }
  section { margin-bottom: 56px; }
  .hero h1 { font-size: 48px; }
  .hero-name { gap: 14px; }
  .hero-name img { width: 64px; height: 64px; }
  .hero .tagline { font-size: 21px; }
  .hero-sub { font-size: 15.5px; }
  .section-title { font-size: 28px; }
  .metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .metric b { font-size: 22px; }
  .posts li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .posts a { font-size: 17px; }
  .manifesto { font-size: 19px; }
  .subscribe { padding: 24px 18px; }
  .sub-form .btn-primary { min-width: 88px; padding: 12px 20px; }
  .eyebrow { flex-direction: column; align-items: flex-start; gap: 14px; }
}

/* Phones: every tap target at least 44px tall, layout unchanged */
@media (max-width: 480px) {
  .hero-links, .colophon .links { gap: 0; }
  .hero-links > a, .colophon .links a { padding: 13px 8px; margin: -13px 0; }
  .hero-links > a:first-child, .colophon .links a:first-child { margin-left: -8px; }
  .lang-switch { margin-left: 6px; padding-left: 14px; white-space: nowrap; }
  .lang-switch > a, .lang-switch > span { padding: 13px 8px; margin: -10px 0; }
  .feature-links a, .more { display: inline-block; padding: 12px 0; margin: -12px 0; }
  .posts a { display: block; padding: 10px 0; margin: -10px 0; }
}

/* ========== Dark theme: only when the reader picks it (default is light) ========== */
:root { --on-brand: #faf9f5; color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --parchment: #1b1a17; --ivory: #23221e; --inline-code-bg: #2a2925;
  --brand: #9db8dc; --brand-light: #c0d3ec; --brand-tint: #26303d;
  --near-black: #ecebe4; --dark-warm: #d2d0c7; --olive: #b5b2a6; --stone: #8f8c82;
  --border: #34322d; --border-soft: #2f2d29; --on-brand: #141413;
}
/* The avatar is black ink on white: it melts into the paper in light mode and
   keeps its own white ground (cut to a circle) after dark, unaltered */
:root[data-theme="dark"] .hero-name img { mix-blend-mode: normal; border-radius: 50%; }

/* ========== Theme toggle: moon in light mode, sun after dark ========== */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; position: relative;
  width: 26px; height: 26px; margin-left: 4px; padding: 0; border: 0; background: none;
  color: var(--stone); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.theme-toggle svg {
  position: absolute; width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  transition: opacity .3s, transform .45s cubic-bezier(.3, 1.3, .5, 1);
}
.theme-toggle .sun { opacity: 0; transform: rotate(-90deg) scale(.6); }
:root[data-theme="dark"] .theme-toggle .moon { opacity: 0; transform: rotate(90deg) scale(.6); }
:root[data-theme="dark"] .theme-toggle .sun { opacity: 1; transform: none; }
@media (hover: hover) { .theme-toggle:hover { color: var(--brand); } }
.theme-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .theme-toggle svg { transition: none; } }
@media (max-width: 480px) { .theme-toggle { width: 34px; height: 44px; margin: -9px 0 -9px 2px; } }
/* Language switch is a page navigation, animated as a page turn (see head script) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
/* Language switch turns the page: forward lifts the old sheet off the top,
   back lays the new sheet down over it. Both hinge on the left edge. */
html[data-turn="forward"]::view-transition-old(root) { z-index: 2; }
html[data-turn]::view-transition-group(root) { animation-duration: 0s; }

/* Eyebrow: the label never wraps. When label + icon row no longer fit side by
   side, stack them (label above, icons below) instead of squeezing the label. */
.eyebrow > span:first-child { white-space: nowrap; }
@media (max-width: 720px) {
  .eyebrow { flex-direction: column; align-items: flex-start; gap: 14px; }
}

/* Very narrow phones (≤360px): six icons + language + theme still fit on one row.
   Tap height stays 44px; only the horizontal padding tightens. */
@media (max-width: 360px) {
  .hero-links > a, .colophon .links a { padding: 13px 5px; }
  .hero-links > a:first-child, .colophon .links a:first-child { margin-left: -5px; }
  .lang-switch { margin-left: 2px; padding-left: 10px; }
  .lang-switch > a, .lang-switch > span { min-width: 34px; padding: 13px 5px; }
  .theme-toggle { width: 30px; }
}

/* Footer bio: same items as the hero, never broken inside an item */
.ethos { text-wrap: balance; }
.ethos span { white-space: nowrap; }
.ethos span:not(:last-child)::after { content: " /"; }
@media (max-width: 360px) { .ethos span { white-space: normal; } }

/* Phones: seven icons no longer fit beside the language switch and theme button.
   Language + theme join the label's line; the icons get their own row below. */
@media (max-width: 480px) {
  .eyebrow { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 0; }
  .eyebrow > span:first-child { flex: 1 1 auto; order: 0; }
  .hero-links { display: contents; }
  .eyebrow .lang-switch { order: 1; margin-left: 0; padding-left: 0; border-left: 0; }
  .eyebrow .theme-toggle { order: 2; }
  .eyebrow::after { content: ""; flex-basis: 100%; order: 3; }
  .hero-links > a { order: 4; }
}

/* Design credit: one quiet line, once */
.credit { font-family: var(--latin-ui); font-size: 12px; color: var(--stone); margin: 10px 0 0; }
.credit a { color: var(--stone); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: color-mix(in srgb, var(--stone) 45%, transparent); }
@media (hover: hover) { .credit a:hover { color: var(--brand); } }

/* ========== Site chrome: header nav + shared footer ========== */
.crumb { color: var(--stone); text-transform: none; }
.crumb a { color: var(--stone); }
.crumb .sep { margin: 0 6px; color: var(--border); }
.crumb [aria-current] { color: var(--dark-warm); }
@media (hover: hover) { .crumb a:hover { color: var(--brand); } }
.site-nav { display: flex; align-items: center; gap: 18px; font-family: var(--latin-ui); font-size: 13px; font-weight: 500; text-transform: none; letter-spacing: .2px; }
.site-nav a { color: var(--stone); }
.site-nav a[aria-current] { color: var(--near-black); }
@media (hover: hover) { .site-nav a:hover { color: var(--brand); } }
.foot-nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 18px; font-family: var(--latin-ui); font-size: 13px; margin: 0 0 14px; }
.foot-nav a { color: var(--dark-warm); }
@media (hover: hover) { .foot-nav a:hover { color: var(--brand); } }
.site-foot { margin-top: 56px; }
@media (max-width: 880px) { .foot-nav { justify-content: flex-start; } }
@media (max-width: 480px) { .eyebrow .site-nav { order: 4; } }

/* ========== Links in running text: brighter blue + soft underline (option B) ========== */
:root { --link: #2456a6; }
:root[data-theme="dark"] { --link: #8fb4ea; }
.feature-links a, .items a, .posts a, .more, .manifesto-src a, .go-link, .sub-note a, .doc p a, .doc li a, .faq details p a, .install p a, .note a, .stances small a, .product-foot .links a {
  color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
  text-decoration-color: color-mix(in srgb, var(--link) 38%, transparent); transition: text-decoration-color .15s, color .15s;
}
@media (hover: hover) {
  .feature-links a:hover, .items a:hover, .posts a:hover, .more:hover, .manifesto-src a:hover, .go-link:hover, .sub-note a:hover,
  .doc p a:hover, .doc li a:hover, .faq details p a:hover, .install p a:hover, .note a:hover, .stances small a:hover, .product-foot .links a:hover { color: var(--link); text-decoration-color: currentColor; }
}
/* the separators between links sit inside the anchors; keep them un-underlined */
.feature-links a:not(:last-child)::after, .product-foot .links a:not(:last-child)::after { display: inline-block; text-decoration: none; }
/* Header on narrow screens: one row when label + controls fit; otherwise the
   controls (GitHub, language, theme) wrap together onto a second row. */
@media (max-width: 720px) {
  .eyebrow { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
  .eyebrow > span:first-child { flex: 0 1 auto; min-width: 0; max-width: 100%; }
  .hero-links { display: flex; margin-left: auto; }
  .eyebrow::after { content: none; }
  .eyebrow .site-nav, .eyebrow .lang-switch, .eyebrow .theme-toggle, .hero-links > a { order: 0; }
}
@media (max-width: 480px) {
  .eyebrow .lang-switch { margin-left: 6px; padding-left: 12px; border-left: 1px solid var(--border); }
}
/* scroll: sections rise in once; a thin reading-progress line on long pages */
.rv { transition: opacity .55s ease, transform .55s cubic-bezier(.2,.7,.2,1); }
.js-reveal .rv:not(.in) { opacity: 0; transform: translateY(14px); }
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; background: var(--brand); transform: scaleX(0); transform-origin: 0 50%; z-index: 50; pointer-events: none; opacity: .85; }
@media (prefers-reduced-motion: reduce) { .rv { transition: none; } .js-reveal .rv:not(.in) { opacity: 1; transform: none; } }
@media (max-width: 720px) { .read-progress { display: none; } }   /* phones: it floats over text and the OS has its own scroll bar */
@media print { .js-reveal .rv:not(.in) { opacity: 1; transform: none; } .read-progress { display: none; } }
