:root {
  color-scheme: light dark;
  --text: light-dark(#1a1a1a, #e0e0e0);
  --text-muted: light-dark(#666, #999);
  --bg: light-dark(#fff, #1a1a1a);
  --link: light-dark(#3a86d0, #7ab6ec);
  --border: light-dark(#e0e0e0, #333);
  --code-bg: light-dark(#f5f5f5, #2a2a2a);
}

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

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

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  max-width: 80ch;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--link);
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;

  .site-title {
    font-weight: 700;
    color: var(--text);
  }

  .nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;

    svg {
      width: 1.2em;
      height: 1.2em;
      vertical-align: middle;
    }
  }

  .site-id {
    display: flex;
    flex-direction: column;
    line-height: 1.2;

    .at {
      color: var(--link);
    }
  }

  .site-name {
    font-size: 0.8rem;
    color: var(--text-muted);
  }
}

.icons {
  display: flex;
  align-items: center;
  gap: 1rem;

  a,
  button,
  button span {
    display: flex;
  }

  button {
    background: none;
    border: none;
    padding: 0;
    color: var(--link);
    cursor: pointer;
  }

  svg {
    width: auto;
    height: 1.1rem;
  }

  .divider {
    width: 1px;
    height: 1.1rem;
    background: var(--border);
  }
}

.empty {
  min-height: 100dvh;
  justify-content: center;

  header nav {
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 0;
  }

  .site-id {
    align-items: center;
  }

  .site-title {
    font-size: 2rem;
  }

  .site-name {
    font-size: 1rem;
  }

  main,
  .divider,
  .theme-toggle {
    display: none;
  }
}

main {
  flex: 1;

  h1 {
    margin-bottom: 1rem;

    svg {
      width: 0.6em;
      height: 0.6em;
      vertical-align: middle;
    }
  }

  h2,
  h3,
  h4 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
  }

  p,
  ul,
  ol,
  blockquote,
  pre,
  hr,
  table {
    margin-bottom: 1rem;
  }
}

.post-header {
  margin-bottom: 2rem;

  h1 {
    margin-bottom: 0.25rem;
  }
}

.post-meta {
  color: var(--text-muted);
  font-size: 0.9rem;

  .tags a {
    margin-left: 0.25rem;

    &::before {
      content: "#";
    }
  }
}

.all-tags {
  display: block;
  margin-top: 1rem;
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.post-list {
  list-style: none;

  li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.4rem 0;
  }

  time {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
  }
}

.tag-list {
  list-style: none;

  li {
    display: inline-block;
    margin: 0.25rem 0.5rem 0.25rem 0;
  }

  .count {
    color: var(--text-muted);
    font-size: 0.85rem;
  }
}

.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
}

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

  blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1rem;
    color: var(--text-muted);
  }

  code {
    background: var(--code-bg);
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    font-size: 0.9em;
  }

  pre {
    position: relative;
    overflow-x: auto;
    padding: 1rem;
    border-radius: 4px;

    code {
      background: none;
      padding: 0;
    }

    .copy-btn {
      position: absolute;
      top: 0.5rem;
      right: 0.5rem;
      background: none;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      padding: 0.25rem;
      font-size: 0.8rem;
      opacity: 0;
      transition: opacity 0.15s;
    }

    &:hover .copy-btn {
      opacity: 0.6;
    }

    .copy-btn:hover {
      opacity: 1;
    }
  }

  hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
  }
}

.toc {
  margin-bottom: 2rem;
  font-size: 0.9rem;

  summary {
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 600;
  }

  ul {
    margin-top: 0.5rem;
    margin-bottom: 0;
    padding-left: 1.25rem;
  }

  li {
    padding: 0.15rem 0;
  }
}

.zola-anchor {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 0.5rem;
  opacity: 0;
  font-size: 0;

  &::after {
    content: "¶";
    font-size: 1rem;
  }

  &:hover {
    opacity: 1;
  }
}

*:hover > .zola-anchor {
  opacity: 0.4;
}

.back-to-top {
  display: block;
  margin-top: 3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

[data-theme="light"] .theme-toggle .sun,
[data-theme="dark"] .theme-toggle .moon {
  display: none;
}
