/* ldehai.com — neutral "graph paper" base; each work brings its own color. */
:root {
  --paper: #fafaf8;
  --ink: #1a1f26;
  --graphite: #5b6470;
  --hairline: #e2e4e7;
  --surface: #f1f2ef;
  --link: #2747b8;
  --link-hover: #1a3385;
  --focus: #2747b8;

  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.5rem;
  --step-3: 2.125rem;
  --step-4: 3rem;

  --measure: 40rem;
  --wide: 52rem;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.75;
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--link-hover);
}

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

img {
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3 {
  text-wrap: balance;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.wrap {
  width: min(100% - 2.5rem, var(--wide));
  margin-inline: auto;
}

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

.skip-link:focus {
  top: 1rem;
}

/* Header & footer ------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--hairline);
}

.header-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.1rem;
}

.site-name {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.site-header nav {
  display: flex;
  gap: 1.5rem;
}

.site-header nav a {
  color: var(--graphite);
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a[aria-current="page"] {
  color: var(--ink);
}

.site-header nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.45em;
}

.site-footer {
  margin-top: 6rem;
  border-top: 1px solid var(--hairline);
  color: var(--graphite);
  font-size: var(--step--1);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 1.5rem 2.5rem;
}

.footer-inner p {
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-links a {
  color: var(--graphite);
}

/* Home intro -------------------------------------------------------------- */

.intro {
  padding-block: 4.5rem 2.5rem;
}

.intro-name {
  margin: 0 0 1rem;
  font-size: var(--step-4);
  letter-spacing: -0.02em;
}

.intro-lede {
  max-width: 34rem;
  text-wrap: pretty;
  margin: 0;
  font-size: var(--step-1);
  line-height: 1.7;
}

.intro-links {
  display: flex;
  gap: 1.5rem;
  margin: 1.5rem 0 0;
}

/* Sections ---------------------------------------------------------------- */

.section {
  margin-top: 3.5rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--ink);
}

.section-head h2 {
  margin: 0;
  font-size: var(--step-1);
}

.section-head a {
  font-size: var(--step--1);
}

.page-head {
  padding-block: 3.5rem 0;
}

.page-head h1 {
  margin: 0 0 0.75rem;
  font-size: var(--step-3);
}

.page-lede {
  margin: 0;
  text-wrap: pretty;
  max-width: var(--measure);
  color: var(--graphite);
}

/* Works: spec-sheet rows, each marked with the work's own color ------------- */

.works {
  display: grid;
}

.work {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 1.6rem 0 1.6rem 1.25rem;
  border-bottom: 1px solid var(--hairline);
  border-left: 3px solid var(--work-color, var(--ink));
  margin-top: -1px;
}

.page-head + .section .works {
  border-top: 1px solid var(--ink);
}

.work-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.work-name {
  margin: 0;
  font-size: var(--step-2);
}

.work-name a {
  color: var(--ink);
  text-decoration: none;
}

.work-name a:hover {
  color: var(--work-color, var(--link));
}

.work-kind {
  margin: 0;
  color: var(--graphite);
  font-size: var(--step--1);
  white-space: nowrap;
}

.work-summary {
  margin: 0;
  max-width: var(--measure);
  text-wrap: pretty;
}

.work-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 2rem;
  margin: 0.25rem 0 0;
  font-size: var(--step--1);
}

.work-specs div {
  display: flex;
  gap: 0.6rem;
}

.work-specs dt {
  color: var(--graphite);
}

.work-specs dd {
  margin: 0;
}

.work-more {
  margin: 0.25rem 0 0;
  font-size: var(--step--1);
}

/* Post lists ---------------------------------------------------------------- */

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

.post-list li {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--hairline);
}

.post-list time {
  color: var(--graphite);
  font-size: var(--step--1);
  padding-top: 0.15em;
}

.post-list a {
  color: var(--ink);
  text-decoration: none;
}

.post-list a:hover {
  color: var(--link);
  text-decoration: underline;
}

.year-group {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 1rem;
  border-top: 1px solid var(--ink);
}

.year-group + .year-group {
  margin-top: 2rem;
}

.year {
  margin: 0;
  padding-top: 0.75rem;
  font-size: var(--step-1);
}

.year-group .post-list li {
  grid-template-columns: 6rem 1fr;
}

.year-group .post-list li:last-child {
  border-bottom: 0;
}

/* Articles -------------------------------------------------------------------- */

.post {
  padding-top: 3.5rem;
}

/* Keep articles aligned with the header's left edge, but at a readable measure */
.post > * {
  max-width: var(--measure);
}

.post-header h1 {
  margin: 0 0 0.75rem;
  font-size: var(--step-3);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0 0 2.5rem;
  color: var(--graphite);
  font-size: var(--step--1);
}

.post-tags {
  display: flex;
  gap: 0.5rem;
}

.post-tags span {
  padding: 0 0.5rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
}

.prose > * + * {
  margin-top: 1.1em;
}

.prose h2,
.prose h3,
.prose h4 {
  margin-top: 2.2em;
  margin-bottom: 0;
}

.prose h2 {
  font-size: var(--step-2);
}

.prose h3 {
  font-size: var(--step-1);
}

.prose h4 {
  font-size: var(--step-0);
}

.prose p,
.prose ul,
.prose ol {
  margin-bottom: 0;
}

.prose img {
  display: block;
  border: 1px solid var(--hairline);
  border-radius: 4px;
}

.prose blockquote {
  margin-inline: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--hairline);
  color: var(--graphite);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border-radius: 6px;
  line-height: 1.55;
  font-size: 0.9rem;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--step--1);
}

.prose th,
.prose td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline);
}

.post-nav a {
  display: flex;
  flex-direction: column;
  max-width: 45%;
  color: var(--ink);
  text-decoration: none;
}

.post-nav a[rel="prev"] {
  text-align: right;
  margin-left: auto;
}

.post-nav a span {
  color: var(--graphite);
  font-size: var(--step--1);
}

.post-nav a:hover {
  color: var(--link);
}

/* Code highlighting (highlight.js classes), tuned to the ink palette ---------- */

.hljs-comment,
.hljs-quote {
  color: #6b7280;
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in,
.hljs-type {
  color: #8a2f6b;
}

.hljs-string,
.hljs-attr,
.hljs-template-tag {
  color: #2f6b3a;
}

.hljs-number,
.hljs-literal {
  color: #9a5b12;
}

.hljs-title,
.hljs-title.function_,
.hljs-section {
  color: #2747b8;
}

.hljs-meta {
  color: #5b6470;
}

/* Small screens ------------------------------------------------------------------ */

@media (max-width: 40rem) {
  :root {
    --step-3: 1.75rem;
    --step-4: 2.4rem;
  }

  .intro {
    padding-top: 3rem;
  }

  .work-head {
    flex-direction: column;
    gap: 0.1rem;
  }

  .post-list li,
  .year-group,
  .year-group .post-list li {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .year {
    padding-top: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
