/* ---- tokens ---- */
:root {
  color-scheme: light dark;

  --bg:      #f4f4f4;
  --card:    #ffffff;
  --ink:     #222222;
  --body:    #555555;
  --muted:   #6b6b6b;
  --rule:    #e4e4e4;
  --accent:  #fc6423;
  --link:    #c9430c;
  --code-bg: #f6f6f6;
  --shadow:  0 1px 3px rgba(0,0,0,.06);

  --sans: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", Consolas, Menlo, monospace;

  /* Lato carries no CJK glyphs. Without a per-language stack the browser
     picks a default from the visitor's own locale, so Japanese text can
     end up rendered with Chinese glyph forms. Lato stays first in each
     stack: fallback is per glyph, so Latin text is unaffected. */
  --sans-ja:      "Lato", -apple-system, BlinkMacSystemFont, "Hiragino Sans",
                  "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP",
                  Meiryo, sans-serif;
  --sans-zh-hans: "Lato", -apple-system, BlinkMacSystemFont, "PingFang SC",
                  "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
                  sans-serif;
  --sans-zh-hant: "Lato", -apple-system, BlinkMacSystemFont, "PingFang TC",
                  "Hiragino Sans CNS", "Microsoft JhengHei", "Noto Sans TC",
                  sans-serif;
  --sans-ko:      "Lato", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
                  "Noto Sans KR", "Malgun Gothic", sans-serif;
}

/* Swap the token rather than setting font-family directly: :lang() matches
   every descendant, which would collide with the .when / .where / time
   rules that ask for --mono at the same specificity. zh-Hant must follow
   zh, which it also matches by BCP 47 prefix. */
:root:lang(ja)      { --sans: var(--sans-ja); }
:root:lang(zh)      { --sans: var(--sans-zh-hans); }
:root:lang(zh-Hant) { --sans: var(--sans-zh-hant); }
:root:lang(ko)      { --sans: var(--sans-ko); }

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #17181c;
    --card:    #212328;
    --ink:     #e3e4e6;
    --body:    #b0b3b8;
    --muted:   #9aa0a6;
    --rule:    #32353b;
    --accent:  #ff7a42;
    --link:    #ff7a42;
    --code-bg: #1a1c20;
    --shadow:  0 1px 3px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: none; transition: color .15s; }
a:hover { color: var(--link); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: 50%; top: 8px; transform: translateX(-50%);
  background: var(--ink); color: var(--card);
  padding: 8px 14px; z-index: 10;
}

/* tabindex="-1" on <main> so the skip link actually moves focus. Chrome and
   Firefox move the sequential focus starting point on their own, Safari does
   not. No outline: the target was jumped to, not tabbed to, and ringing the
   whole content area would only confuse. */
main:focus { outline: none; }

/* ---- nav ---- */
.site-head {
  max-width: 780px;
  margin: 28px auto 0;
  padding: 18px 32px;
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 3px;
  display: flex; flex-wrap: wrap;
  align-items: baseline; justify-content: space-between;
  gap: 10px 24px;
}

.wordmark { font-size: 17px; font-weight: 700; color: var(--ink); }

.site-head nav { display: flex; gap: 24px; font-size: 14px; }
.site-head nav a { color: var(--muted); padding-bottom: 3px; }
.site-head nav a:hover { color: var(--link); }
.site-head nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
}

/* ---- content ---- */
.page {
  max-width: 780px;
  margin: 18px auto 0;
  padding: 44px 32px 48px;
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 3px;
}

.site-foot {
  max-width: 780px;
  margin: 18px auto 0;
  padding: 18px 32px 60px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 620px) {
  .site-head, .page { border-radius: 0; padding-left: 22px; padding-right: 22px; }
  .site-head { margin-top: 0; }
  .site-foot { padding-left: 22px; padding-right: 22px; }
}

/* ---- shared ---- */
.eyebrow {
  font-family: var(--mono);
  font-size: 12px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  margin: 0 0 22px;
}

h1 {
  color: var(--ink);
  font-weight: 700;
  font-size: clamp(27px, 5.5vw, 36px);
  line-height: 1.25;
  margin: 0;
}

.lede { font-size: 17px; margin-top: 20px; }
p { margin: 0 0 20px; }

.rubric {
  font-size: 13px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 18px; padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

section { margin-top: 46px; }

/* ---- entries ---- */
.entry { margin-bottom: 24px; }
.entry:last-child { margin-bottom: 0; }
.entry-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.when { font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap; }
.what { font-weight: 700; color: var(--ink); }
.what a { color: var(--ink); border-bottom: 1px solid var(--rule); }
.what a:hover { color: var(--link); border-color: var(--link); }
.where { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.entry p { margin: 4px 0 0; font-size: 15px; }

.facts { margin: 0; padding: 0; list-style: none; }
.facts li { padding-left: 20px; position: relative; margin-bottom: 12px; }
.facts li::before {
  content: ""; position: absolute; left: 0; top: 12px;
  width: 9px; height: 2px; background: var(--accent);
}

.meta { font-size: 14px; line-height: 2; }
.meta b { color: var(--ink); font-weight: 700; }
.meta a { color: var(--body); border-bottom: 1px solid var(--rule); }
.meta a:hover { color: var(--link); border-color: var(--link); }

/* ---- writing list ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--rule); }
.list a { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; padding: 16px 0; }
.list time { font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap; }
.title { color: var(--ink); }

/* The list pages are English, so a CJK title inherits the Latin stack.
   Re-declaring font-family here is required, not just the token: the
   var() in body's font-family is substituted at body, and descendants
   inherit the result rather than the reference. */
.title:lang(ja)      { font-family: var(--sans-ja); }
.title:lang(zh)      { font-family: var(--sans-zh-hans); }
.title:lang(zh-Hant) { font-family: var(--sans-zh-hant); }
.title:lang(ko)      { font-family: var(--sans-ko); }
.list a:hover .title { color: var(--link); }

.back { font-size: 14px; margin-top: 44px; }
.back a { color: var(--muted); }

/* ---- article body ---- */
.prose > h1 { margin-bottom: 30px; }
.prose h2 { color: var(--ink); font-size: 22px; font-weight: 700; margin: 42px 0 14px; }
.prose h3 { color: var(--ink); font-size: 18px; font-weight: 700; margin: 30px 0 10px; }
.prose a { color: var(--link); border-bottom: 1px solid var(--rule); }
.prose a:hover { border-color: var(--link); }
.prose ul, .prose ol { margin: 0 0 20px; padding-left: 22px; }
.prose li { margin-bottom: 8px; }

.prose blockquote {
  margin: 24px 0; padding: 2px 0 2px 20px;
  border-left: 3px solid var(--accent); color: var(--muted);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose code {
  font-family: var(--mono); font-size: .87em;
  background: var(--code-bg); color: var(--ink);
  padding: 2px 6px; border-radius: 3px;
}
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 16px 18px; border-radius: 3px;
  overflow-x: auto; font-size: 13.5px; line-height: 1.6;
  margin: 0 0 24px;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }

.prose img { max-width: 100%; height: auto; display: block; margin: 24px 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 0 0 24px; font-size: 15px; }
.prose th, .prose td { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); }
.prose th { color: var(--ink); font-weight: 700; font-size: 14px; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 40px 0; }
