/* Custom properties */

:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #595959;
  --line: #d4d4d4;
  --subtle: #ededed;
  --signal: #002fa7;
  --on-signal: #ffffff;

  --code-keyword: #002fa7;
  --code-string: #1f6b3a;
  --code-number: #a14a00;
  --code-tag: #9c1f4a;

  --font-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --measure: 64rem;
  --prose: 50rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --fg: #f5f5f5;
    --muted: #a3a3a3;
    --line: #2e2e2e;
    --subtle: #1f1f1f;
    --signal: #8fa8ff;
    --on-signal: #0a0a0a;

    --code-keyword: #8fa8ff;
    --code-string: #8fd4a0;
    --code-number: #f0b070;
    --code-tag: #f090b0;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #f5f5f5;
  --muted: #a3a3a3;
  --line: #2e2e2e;
  --subtle: #1f1f1f;
  --signal: #8fa8ff;
  --on-signal: #0a0a0a;

  --code-keyword: #8fa8ff;
  --code-string: #8fd4a0;
  --code-number: #f0b070;
  --code-tag: #f090b0;
}

/* Base */

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

html {
  color-scheme: light dark;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem;
}

a {
  color: var(--signal);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

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

h1,
h2,
h3,
h4 {
  line-height: 1.2;
}

h1 {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.meta,
.pagination,
.feed-links {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Header */

.site-header {
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.site-title {
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
  white-space: nowrap;
}

.main-nav {
  flex: 1;
}

.main-nav > ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.main-nav a,
.main-nav span {
  text-decoration: none;
  color: var(--fg);
}

.main-nav a:hover {
  text-decoration: underline;
}

.main-nav li {
  position: relative;
}

.main-nav li > ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 10rem;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--fg);
  z-index: 10;
}

.main-nav li:hover > ul,
.main-nav li:focus-within > ul {
  display: grid;
  gap: 4px;
}

.main-nav li > ul li > ul {
  top: -5px;
  left: 100%;
}

.main-nav li > ul a,
.main-nav li > ul span {
  display: block;
  padding: 8px 12px;
}

.main-nav li > ul a:hover {
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
}

#theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  padding: 0;
  color: var(--fg);
  width: 36px;
  height: 36px;
  cursor: pointer;
  flex-shrink: 0;
}

#theme-toggle:hover {
  background: var(--subtle);
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.feed-links a {
  color: var(--fg);
}

.feed-links a + a {
  margin-left: 0.75rem;
}

/* Content */

main {
  flex: 1;
  padding: 4rem 0;
}

main h1 {
  margin: 0 0 1rem;
}

.meta {
  color: var(--muted);
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tags a {
  background: var(--subtle);
  color: var(--fg);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  padding: 2px 8px;
  text-decoration: none;
  text-transform: none;
}

.tags a:hover {
  background: var(--fg);
  color: var(--bg);
}

article {
  overflow-wrap: anywhere;
}

.post-header {
  padding-bottom: 2rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--line);
}

.post-header h1 {
  max-width: 20ch;
  font-size: 56px;
}

.post .prose {
  max-width: none;
}

.post .post-header {
  padding-bottom: 0;
  margin-bottom: 2rem;
  border-bottom: 0;
}

.post .post-header h1 {
  max-width: none;
  font-size: 40px;
  margin-bottom: 0.75rem;
}

.prose {
  max-width: var(--prose);
}

.prose > :first-child {
  margin-top: 0;
}

.prose :is(p, ul, ol, blockquote, pre, figure, table) {
  margin: 1.25em 0;
}

.prose :is(h2, h3, h4) {
  margin: 2em 0 0.5em;
}

.prose h2 {
  font-size: 28px;
}

.prose h3 {
  font-size: 22px;
}

.prose :is(ul, ol) {
  padding-left: 1.25em;
}

.prose li + li {
  margin-top: 0.35em;
}

.prose pre {
  margin-left: -1rem;
  margin-right: -1rem;
}

blockquote {
  margin-left: 0;
  padding-left: 1em;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
}

table {
  border-collapse: collapse;
}

:is(th, td) {
  border: 1px solid var(--line);
  padding: 0.3em 0.6em;
}

/* Post list */

.post-summary {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 0.25rem 1.5rem;
  padding: 1.25rem 0;
}

.post-summary:first-child {
  padding-top: 0;
}

.post-summary .meta {
  grid-column: 1;
  grid-row: 1 / span 2;
  padding-top: 0.6rem;
  align-self: start;
}

.post-summary > :not(.meta) {
  grid-column: 2;
}

.post-summary h2 {
  margin: 0;
}

.post-summary h2 a {
  text-decoration: none;
  color: var(--fg);
}

.post-summary h2 a:hover {
  text-decoration: underline;
}

.summary {
  max-width: var(--prose);
  color: var(--muted);
  margin: 0;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: 1.5rem;
  color: var(--muted);
}

.pagination a {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--fg);
  color: var(--fg);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-decoration: none;
}

.pagination a:hover {
  background: var(--subtle);
}

/* Tag list */

section[id] {
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
}

section[id] h2 {
  margin: 0;
}

section[id] h2 span {
  color: var(--muted);
  font-weight: 400;
}

section[id] ul {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}

section[id] li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
}

section[id] time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

/* Code */

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--subtle);
}

code {
  padding: 0.1em 0.3em;
}

pre {
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.55;
  tab-size: 4;
}

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

/* Chroma syntax highlighting */

.chroma {
  color: var(--fg);
}

.chroma :is(.k, .kd, .kt, .nf) { color: var(--code-keyword); }
.chroma :is(.s, .s1, .s2) { color: var(--code-string); }
.chroma :is(.c, .c1, .cm) { color: var(--muted); font-style: italic; }
.chroma :is(.nb, .na, .m, .mi, .mf) { color: var(--code-number); }
.chroma .nt { color: var(--code-tag); }

/* Responsive */

@media (max-width: 48rem) {
  .post-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .post-summary .meta,
  .post-summary > :not(.meta) {
    grid-column: 1;
    grid-row: auto;
    padding-top: 0;
  }
}

@media (max-width: 30rem) {
  .wrap {
    padding: 0 1rem;
  }

  main {
    padding: 2.5rem 0;
  }

  h1,
  .post-header h1 {
    font-size: 34px;
  }

  .post .post-header h1 {
    font-size: 30px;
  }

  .site-header .wrap {
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
  }

  .site-title {
    flex: 1;
  }

  .main-nav {
    order: 1;
    flex-basis: 100%;
  }

  .main-nav > ul {
    gap: 1rem;
  }
}

@media (pointer: coarse) {
  #theme-toggle,
  .pagination a {
    height: 44px;
  }

  #theme-toggle {
    width: 44px;
  }
}
