@font-face {
  font-family: "Bodoni Moda";
  src: url("assets/bodoni-moda-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0d1512;
  --bg-soft: #141e1a;
  --ink: #f2eee3;
  --ink-soft: #d5d4c8;
  --muted: #96a29a;
  --line: rgba(242, 238, 227, 0.14);
  --copper: #d1894b;
  --serif: "Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --maxw: 1160px;
  --pad: clamp(20px, 5vw, 64px);
  --heat-0: #17211c;
  --heat-1: #3b2b1d;
  --heat-2: #5f3f24;
  --heat-3: #8a5a2f;
  --heat-4: #cf8446;
}

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

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

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

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(880px 520px at 82% -10%, rgba(209, 137, 75, 0.12), transparent 62%),
    radial-gradient(720px 440px at 4% 6%, rgba(130, 168, 148, 0.06), transparent 60%);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.zh-only,
.en-only { display: none; }

html[data-lang="zh"] .zh-only,
html[data-lang="en"] .en-only { display: inline; }

.lang-block { display: none; }

html[data-lang="zh"] .lang-block[data-lang="zh"],
html[data-lang="en"] .lang-block[data-lang="en"] { display: block; }

.site-head,
main,
.site-foot {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--pad);
}

.site-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-block: 22px;
}

.head-name {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.head-name:hover { color: var(--copper); }

.head-handle {
  margin-left: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.head-right {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 20px);
}

.head-clock {
  display: flex;
  align-items: center;
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pulse {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--copper);
  animation: pulse 2.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 2px;
}

.lang-btn {
  appearance: none;
  padding: 2px 4px 3px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.lang-btn:hover { color: var(--ink); }

.lang-btn[aria-pressed="true"] {
  color: var(--ink);
  border-bottom-color: var(--copper);
}

.lang-btn:focus-visible {
  outline: 1px solid var(--copper);
  outline-offset: 3px;
}

.hero {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 24px;
  padding-top: clamp(52px, 10vh, 112px);
}

.wordmark {
  grid-column: 1 / -1;
  margin: 0 0 clamp(18px, 2.6vw, 30px) -0.045em;
  font-family: var(--serif);
  font-size: clamp(64px, 15.2vw, 196px);
  font-weight: 500;
  line-height: 0.84;
  letter-spacing: -0.035em;
  font-optical-sizing: auto;
}

.hero-id {
  grid-column: 1 / -1;
  margin: 0 0 clamp(30px, 4.4vw, 48px);
  font-size: 14px;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.statement {
  grid-column: 1 / 8;
  margin: 0;
  font-size: clamp(23px, 3.1vw, 37px);
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

.lede {
  grid-column: 8 / 13;
  align-self: end;
  margin: 0 0 0.35em;
  font-size: 15.5px;
  line-height: 1.95;
  color: var(--muted);
}

.signal {
  grid-column: 1 / -1;
  margin: clamp(52px, 8vw, 88px) 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.signal canvas {
  display: block;
  width: 100%;
  height: clamp(84px, 10vw, 116px);
}

.signal figcaption {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: right;
}

.section { padding-top: clamp(84px, 13vh, 148px); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: clamp(30px, 4vw, 50px);
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.section-head h2 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.section-note {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.section-note a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.section-note a:hover {
  color: var(--copper);
  border-bottom-color: var(--copper);
}

/* Now */

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

.now-item {
  display: grid;
  grid-template-columns: minmax(180px, 250px) minmax(0, 1fr);
  column-gap: clamp(24px, 4vw, 64px);
  padding: 24px 0;
  border-top: 1px solid var(--line);
}

.now-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.now-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.now-dot {
  flex: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--copper);
  transform: translateY(-2px);
}

.now-head h3 {
  margin: 0;
  font-size: clamp(17px, 1.8vw, 20px);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.now-meta {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.now-desc {
  max-width: 52em;
  margin: 0;
  font-size: 15px;
  line-height: 1.9;
  color: var(--ink-soft);
}

/* Experience */

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

.entry {
  display: grid;
  grid-template-columns: minmax(104px, 188px) minmax(0, 1fr);
  column-gap: clamp(24px, 4vw, 64px);
  padding: clamp(28px, 4vw, 44px) 0;
  border-top: 1px solid var(--line);
}

.entry:first-child {
  padding-top: 0;
  border-top: 0;
}

.year {
  display: block;
  font-family: var(--serif);
  font-size: clamp(30px, 3.6vw, 46px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
  font-variant-numeric: lining-nums;
}

.when {
  display: block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.entry-body h3 {
  margin: 0;
  font-size: clamp(19px, 2.2vw, 24px);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.entry-role {
  margin: 8px 0 20px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--copper);
}

.entry-body ul {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entry-body li {
  position: relative;
  max-width: 52em;
  padding-left: 22px;
  font-size: 15.5px;
  line-height: 1.9;
  color: var(--ink-soft);
}

.entry-body li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.95em;
  width: 10px;
  height: 1px;
  background: var(--copper);
  opacity: 0.75;
}

.entry-body strong {
  font-weight: 500;
  color: var(--ink);
}

/* Projects */

.project {
  display: block;
  padding: clamp(24px, 3.4vw, 34px) 0;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.project-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 24px;
}

.project h3 {
  margin: 0;
  font-size: clamp(19px, 2.2vw, 23px);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.2s ease;
}

.project-stack {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.project p {
  max-width: 62ch;
  margin: 12px 0 0;
  font-size: 15px;
  line-height: 1.9;
  color: var(--muted);
}

.project:hover h3 { color: var(--copper); }

.project:focus-visible,
.link-list a:focus-visible,
.head-name:focus-visible {
  outline: 1px solid var(--copper);
  outline-offset: 6px;
}

/* Code activity */

.heatmap svg {
  display: block;
  width: 100%;
  height: auto;
}

.heatmap text {
  font-family: var(--mono);
  font-size: 9px;
  fill: var(--muted);
  letter-spacing: 0.02em;
}

.heatmap rect {
  transition: opacity 0.15s ease;
}

.heatmap rect:hover { opacity: 0.7; }

.activity-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 24px;
  margin-top: 18px;
}

.activity-stats {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.85;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.activity-stats strong {
  font-weight: 500;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.activity-updated {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  opacity: 0.75;
}

.legend {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

.legend .lv1 { background: var(--heat-1); }
.legend .lv2 { background: var(--heat-2); }
.legend .lv3 { background: var(--heat-3); }
.legend .lv4 { background: var(--heat-4); }

/* Stack */

.stack-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(24px, 4vw, 56px);
  margin: 0;
}

.stack-grid dt {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--copper);
}

.stack-grid dd {
  max-width: 26em;
  margin: 14px 0 0;
  font-size: 15px;
  line-height: 1.95;
  color: var(--ink-soft);
}

/* Contact */

.contact-lede {
  max-width: 34em;
  margin: 0 0 clamp(26px, 4vw, 40px);
  font-size: clamp(16.5px, 2vw, 19px);
  line-height: 1.95;
  color: var(--ink-soft);
}

.link-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-list a {
  font-family: var(--serif);
  font-size: clamp(25px, 3.5vw, 44px);
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.link-list a:hover {
  color: var(--copper);
  border-bottom-color: var(--copper);
}

.contact-note {
  margin: clamp(26px, 4vw, 40px) 0 0;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.site-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: clamp(88px, 14vh, 156px);
  padding-top: 28px;
  padding-bottom: 56px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.site-foot p { margin: 0; }

::selection {
  background: rgba(209, 137, 75, 0.32);
  color: var(--ink);
}

/* English typography */

html[lang="en"] .statement {
  line-height: 1.42;
  letter-spacing: -0.01em;
}

html[lang="en"] .lede,
html[lang="en"] .now-desc,
html[lang="en"] .entry-body li,
html[lang="en"] .project p {
  line-height: 1.78;
}

html[lang="en"] .stack-grid dd { line-height: 1.8; }

html[lang="en"] .hero-id { letter-spacing: 0.04em; }

@media (prefers-reduced-motion: no-preference) {
  .wordmark { animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.04s both; }
  .hero-id { animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) 0.14s both; }
  .statement { animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) 0.2s both; }
  .lede { animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) 0.28s both; }
  .signal { animation: fade 1.1s ease 0.36s both; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 900px) {
  .hero { display: block; }
  .statement { margin-top: 4px; }
  .lede { margin-top: 24px; }
  .stack-grid { grid-template-columns: 1fr; }
  .stack-grid dd { max-width: 40em; }
  .entry { grid-template-columns: 1fr; row-gap: 16px; }
  .entry-when { display: flex; align-items: baseline; gap: 14px; }
  .when { margin-top: 0; }
  .year { font-size: 28px; }
  .now-item { grid-template-columns: 1fr; row-gap: 8px; }
  .now-item:first-child { padding-top: 0; }
}

@media (max-width: 520px) {
  body { font-size: 15.5px; }
  .head-clock { display: none; }
  .head-handle { display: none; }
  .entry-body li { padding-left: 18px; }
  .section-head { gap: 12px; }
  .activity-meta { margin-top: 14px; }
}
