/* ---------- Tokens ---------- */
:root {
  --paper: #eff1ec;
  --ink: #1e2638;
  --muted: #5d6474;
  --line: #cdd2c8;
  --accent: #4e6b2f;      /* moss */
  --wordmark: #1e2638;

  --font: "Bricolage Grotesque", "Noto Sans TC", system-ui, sans-serif;
  --font-cjk: "Noto Sans TC", "Bricolage Grotesque", system-ui, sans-serif;

  /* type scale (≈ 1.25) */
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3125rem;
  --step-2: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem);

  --gutter: clamp(1.25rem, 4vw, 3rem);
  --max: 72rem;
  --rail: 11rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171c28;
    --ink: #e6e8e1;
    --muted: #9aa1ae;
    --line: #2e3546;
    --accent: #a9c77a;
    --wordmark: #e6e8e1;
  }
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-cjk);
  font-size: var(--step-0);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.25em; }
a:hover { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection { background: var(--accent); color: var(--paper); }

.skip {
  position: absolute;
  left: var(--gutter);
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  color: var(--paper);
  z-index: 10;
}
.skip:focus { top: 0.75rem; }

/* ---------- Header ---------- */
.site-header {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem var(--gutter);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font);
  font-weight: 700;
  font-size: var(--step-1);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.brand span { color: var(--muted); font-weight: 400; }

.site-header nav { display: flex; gap: 1.5rem; font-size: var(--step--1); }
.site-header nav a { text-decoration: none; color: var(--muted); }
.site-header nav a:hover { color: var(--ink); }

/* ---------- Hero ---------- */
.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(3rem, 10vh, 7rem) var(--gutter) 0;
  overflow: hidden;
}

.hero-text { max-width: 38rem; margin-left: var(--rail); }

.hero h1 {
  font-family: var(--font-cjk);
  font-size: var(--step-2);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.01em;
  margin: 0 0 1.25rem;
}

.lede { color: var(--muted); margin: 0; max-width: 34rem; }

/* The one loud thing: the name, set to fill the page width */
.wordmark {
  font-family: var(--font);
  font-size: clamp(5rem, 25.5vw, 19rem);
  font-weight: 800;
  font-variation-settings: "wdth" 75, "opsz" 96;
  letter-spacing: -0.055em;
  line-height: 0.78;
  color: var(--wordmark);
  margin: clamp(2.5rem, 8vh, 5rem) 0 0 -0.04em;
  white-space: nowrap;
  user-select: none;
  animation: settle 1.4s cubic-bezier(.2, .7, .1, 1) both;
}

@keyframes settle {
  from { font-weight: 300; font-variation-settings: "wdth" 100, "opsz" 96; letter-spacing: 0.02em; opacity: 0; }
  to   { font-weight: 800; font-variation-settings: "wdth" 75, "opsz" 96; letter-spacing: -0.055em; opacity: 1; }
}

/* ---------- Sections ---------- */
.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(3rem, 8vh, 5rem) var(--gutter);
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

.section h2 {
  font-family: var(--font-cjk);
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--muted);
  margin: 0.35rem 0 0;
  letter-spacing: 0.08em;
}

.section-body { max-width: 40rem; margin: 0; }

.prose p { margin: 0 0 1.1em; }

.facts {
  margin: 2rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1.25rem 2rem;
}
.facts dt { font-size: var(--step--1); color: var(--muted); }
.facts dd { margin: 0.15rem 0 0; font-weight: 500; }

/* List rows for work + writing */
.rows { list-style: none; padding: 0; }

.rows li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: baseline;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
}
.rows li:first-child { padding-top: 0; }
.rows li:last-child { border-bottom: 0; padding-bottom: 0; }

.rows a { text-decoration: none; display: block; }
.row-title { display: block; font-weight: 700; font-size: var(--step-1); line-height: 1.4; }
.row-desc { display: block; color: var(--muted); }
.rows a:hover .row-title { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.25em; }
.row-meta { font-family: var(--font); font-size: var(--step--1); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Contact */
.contact-line { margin: 0 0 1.5rem; }
.email {
  font-family: var(--font);
  font-size: var(--step-2);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--accent);
  overflow-wrap: anywhere;
}
.links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem var(--gutter) 3rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: var(--step--1);
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.site-footer p { margin: 0; }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  :root { --rail: 0rem; }
  .section { grid-template-columns: 1fr; gap: 1rem; }
  .hero-text { margin-left: 0; }
  .site-header nav { gap: 1.1rem; }
  .rows li { grid-template-columns: 1fr; gap: 0.25rem; }
  .rows .row-meta { order: -1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .wordmark { animation: none; }
}
