@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-regular.woff2")
    format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: "LXGW Zhuque Fangsong";
  src: url("../fonts/lxgw-zhuque-fangsong-regular.woff2")
    format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  color-scheme: dark;
  --background: #111318;
  --surface: #17191f;
  --text: #ddd8cd;
  --text-strong: #f2eee5;
  --muted: #918e86;
  /* This also serves as a no-JavaScript fallback. */
  --special-color: var(--accent-5);
  --border: #33343a;
  --content-width: 760px;
  --wide-width: 1120px;
}

/*
 * Keep the site multicolored when an external script is blocked or stale.
 * theme-colors.js overrides these values with a shuffled palette when it runs.
 */
nav a:nth-child(7n + 1),
.post-card:nth-child(7n + 1),
.tag-list a:nth-child(7n + 1),
.archive-year-group:nth-child(7n + 1),
.sidebar-year-group:nth-child(7n + 1),
.article-toc a:nth-child(7n + 1),
.post-tags a:nth-child(7n + 1),
.footer-socials a:nth-child(7n + 1) {
  --special-color: var(--accent-1);
}

nav a:nth-child(7n + 2),
.post-card:nth-child(7n + 2),
.tag-list a:nth-child(7n + 2),
.archive-year-group:nth-child(7n + 2),
.sidebar-year-group:nth-child(7n + 2),
.article-toc a:nth-child(7n + 2),
.post-tags a:nth-child(7n + 2),
.footer-socials a:nth-child(7n + 2) {
  --special-color: var(--accent-2);
}

nav a:nth-child(7n + 3),
.post-card:nth-child(7n + 3),
.tag-list a:nth-child(7n + 3),
.archive-year-group:nth-child(7n + 3),
.sidebar-year-group:nth-child(7n + 3),
.article-toc a:nth-child(7n + 3),
.post-tags a:nth-child(7n + 3) {
  --special-color: var(--accent-3);
}

nav a:nth-child(7n + 4),
.post-card:nth-child(7n + 4),
.tag-list a:nth-child(7n + 4),
.archive-year-group:nth-child(7n + 4),
.sidebar-year-group:nth-child(7n + 4),
.article-toc a:nth-child(7n + 4),
.post-tags a:nth-child(7n + 4) {
  --special-color: var(--accent-4);
}

nav a:nth-child(7n + 5),
.post-card:nth-child(7n + 5),
.tag-list a:nth-child(7n + 5),
.archive-year-group:nth-child(7n + 5),
.sidebar-year-group:nth-child(7n + 5),
.article-toc a:nth-child(7n + 5),
.post-tags a:nth-child(7n + 5) {
  --special-color: var(--accent-5);
}

nav a:nth-child(7n + 6),
.post-card:nth-child(7n + 6),
.tag-list a:nth-child(7n + 6),
.archive-year-group:nth-child(7n + 6),
.sidebar-year-group:nth-child(7n + 6),
.article-toc a:nth-child(7n + 6),
.post-tags a:nth-child(7n + 6) {
  --special-color: var(--accent-6);
}

nav a:nth-child(7n),
.post-card:nth-child(7n),
.tag-list a:nth-child(7n),
.archive-year-group:nth-child(7n),
.sidebar-year-group:nth-child(7n),
.article-toc a:nth-child(7n),
.post-tags a:nth-child(7n) {
  --special-color: var(--accent-7);
}

.hero > p:first-child {
  --special-color: var(--accent-1);
}

.section-heading > a,
.scroll-cue {
  --special-color: var(--accent-3);
}

.home-about a,
.about-content a {
  --special-color: var(--accent-6);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: "Source Serif 4", "LXGW Zhuque Fangsong", serif;
  font-size: 18px;
  line-height: 1.85;
}

a {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  text-decoration-color: var(--special-color);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

a:hover,
a:focus-visible {
  color: var(--special-color);
}

a:focus,
summary:focus {
  outline: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--text-strong);
  font-weight: 400;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

h1 {
  max-width: 13em;
  margin-bottom: 1.8rem;
  font-size: clamp(2.25rem, 7vw, 4.2rem);
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.45rem;
}

h3 {
  margin-bottom: 0.75rem;
  font-size: clamp(1.35rem, 4vw, 1.8rem);
}

.site-header,
body:not(.home-page) > main,
.site-footer {
  width: min(calc(100% - 2.5rem), var(--content-width));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 2rem;
  border-bottom: 1px solid var(--border);
}

.site-name {
  color: var(--text-strong);
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
}

nav a {
  color: var(--muted);
  text-decoration: none;
}

nav a[aria-current="page"] {
  color: var(--text-strong);
}

.hero {
  padding-block: 2rem;
}

.hero > p:first-child,
.section-heading > div > p,
.meta,
.post-card > p:first-child,
.site-footer,
.scroll-cue {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

.hero > p:first-child,
.section-heading > div > p {
  margin-bottom: 1.4rem;
  color: var(--special-color);
}

.hero > p:last-child {
  max-width: 34em;
  margin-bottom: 0;
  color: var(--muted);
}

.archive-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.8rem;
}

.archive-title-row h1 {
  margin-bottom: 0;
}

.archive-title-row span,
.archive-year-group summary span:last-child {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

.compact-hero {
  padding-bottom: 2rem;
}

.about-hero {
  position: relative;
}

.about-title-image {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: clamp(8rem, 24vw, 11rem);
  height: auto;
  border-radius: 50%;
}

.about-content {
  padding-block: 2rem;
  border-top: 1px solid var(--border);
}

.about-content > * {
  max-width: 34em;
}

.about-content > :last-child {
  margin-bottom: 0;
}

.listing {
  border-top: 1px solid var(--border);
}

.archive-years {
  border-top: 1px solid var(--border);
}

.archive-year-group {
  border-bottom: 1px solid var(--border);
}

.archive-year-group summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  padding-block: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  list-style: none;
}

.archive-year-group summary::-webkit-details-marker {
  display: none;
}

.archive-year-group summary::before {
  width: 1rem;
  color: inherit;
  font-size: 1.45rem;
  line-height: 1.35;
  content: "+";
}

.archive-year-group[open] summary::before {
  content: "−";
}

.archive-year-group summary span:first-child {
  font-size: 1.45rem;
  line-height: 1.35;
}

.archive-year-group summary span:last-child {
  grid-column: 3;
  color: inherit;
}

.archive-year-group summary:hover,
.archive-year-group summary:focus-visible,
.archive-year-group summary:active {
  color: var(--special-color);
}

.archive-year-posts {
  padding-bottom: 0.5rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 2rem;
}

.section-heading h2,
.section-heading p {
  margin-bottom: 0;
}

.section-heading > a {
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.section-heading h2 a {
  text-decoration: none;
}

.post-card {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 1.25rem;
  padding-block: 2rem;
  border-top: 1px solid var(--border);
}

.post-card:first-child {
  border-top: 0;
}

.post-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.post-card .meta,
.post-card h3,
.post-card .post-summary {
  margin-bottom: 0;
}

.post-card h3 a {
  text-decoration: none;
}

.post-card h3 a:hover,
.post-card h3 a:focus-visible,
.post-card h3 a:active {
  color: var(--special-color);
}

.post-card .post-summary {
  max-width: 38em;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.post-card > p:first-child {
  margin: 0;
  color: var(--special-color);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}

.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  font-size: 0.82rem;
}

.post-card-tags a {
  color: var(--muted);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.post-card-tags a:hover,
.post-card-tags a:focus-visible,
.post-card-tags a:active {
  color: var(--special-color);
}

.archive-tags {
  margin-top: 0;
  padding-block: 2rem;
  border-top: 1px solid var(--border);
}

.tag-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 3rem;
}

.tag-list a {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  justify-content: space-between;
  min-width: 0;
  padding-block: 0.65rem;
  color: var(--muted);
  text-decoration: none;
}

.tag-list a span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tag-list a span:last-child {
  flex-shrink: 0;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding-block: 2rem;
  border-top: 1px solid var(--border);
}

.site-footer p {
  margin-bottom: 0;
}

.footer-socials {
  display: flex;
  gap: 0.75rem;
  margin-left: auto;
}

.footer-socials a {
  display: grid;
  width: 2rem;
  height: 2rem;
  color: var(--muted);
  border-radius: 50%;
  place-items: center;
  transition: color 160ms ease, background-color 160ms ease;
}

.footer-socials a:hover,
.footer-socials a:focus-visible,
.footer-socials a:active {
  color: var(--special-color);
  background: var(--surface);
}

.footer-socials svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

/* Home */
.welcome {
  position: relative;
  display: grid;
  min-height: 100svh;
  place-content: center;
  text-align: center;
}

.welcome h1 {
  margin: 0;
}

.not-found {
  display: grid;
  min-height: 100svh;
  gap: 1.5rem;
  place-content: center;
  justify-items: center;
  padding: 1.25rem;
  text-align: center;
}

.not-found h1 {
  max-width: none;
  margin: 0;
  font-size: 1rem;
  line-height: inherit;
}

.not-found-home {
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
  transition: color 160ms ease;
}

.not-found-home:hover,
.not-found-home:focus-visible,
.not-found-home:active {
  color: var(--special-color);
}

.welcome-line {
  margin: 0.75rem 0 0;
  color: var(--text-strong);
}

.scroll-cue {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  display: grid;
  gap: 0.25rem;
  justify-items: center;
  transform: translateX(-50%);
  text-decoration: none;
}

.home-content {
  width: min(calc(100% - 2.5rem), var(--content-width));
  margin-inline: auto;
  padding-bottom: 0;
}

.home-content h2 {
  font-size: clamp(1.6rem, 4vw, 2rem);
}

.home-about {
  padding-block: 2rem;
  border-top: 1px solid var(--border);
}

.home-about h2 {
  margin: 0;
}

.home-about a {
  text-decoration: none;
}

nav a:hover,
nav a:focus-visible,
nav a:active,
nav a[aria-current="page"],
.section-heading > a:hover,
.section-heading > a:focus-visible,
.section-heading > a:active,
.tag-list a:hover,
.tag-list a:focus-visible,
.tag-list a:active,
.scroll-cue:hover,
.scroll-cue:focus-visible,
.scroll-cue:active {
  color: var(--special-color);
}

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .site-header {
    align-items: center;
    gap: 1rem;
  }

  nav {
    gap: 0.8rem;
  }

  .tag-list {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-block: 2rem;
  }

  .post-card {
    grid-template-columns: auto 1fr;
    gap: 0.5rem 2rem;
  }

  .post-card-body {
    display: contents;
  }

  .post-card .meta {
    flex-wrap: nowrap;
    align-self: baseline;
    margin-bottom: 0;
  }

  .post-card h3,
  .post-card .post-summary,
  .post-card-tags {
    grid-column: 1 / -1;
  }

  .section-heading {
    align-items: center;
  }

}
body.sidebar-scroll-locked {
  overflow: hidden;
}
