/* style.css — global styles for the Zola blog.
   Plain CSS, no build step. Light and dark themes via CSS variables. */

/* ---------- Theme variables ---------- */

:root {
  /* Light theme (default). */
  --bg: #fdfdfc;
  --fg: #1f2328;
  --muted: #59636e;
  --accent: #0969da;
  --border: #d1d9e0;

  /* Font stacks. The CJK fonts cover the Chinese post content. */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
          "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, "Liberation Mono",
          "Courier New", monospace;

  /* Code renders on the github-dark surface in both themes so the
     syntax colors keep their contrast on light pages too. Zola's
     highlighted blocks emit these same colors as inline styles. */
  --code-bg: #24292e;
  --code-fg: #e1e4e8;
  --code-border: #444c56;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --fg: #e6edf3;
    --muted: #8b949e;
    --accent: #4493f8;
    --border: #30363d;
  }
}

/* ---------- Base ---------- */

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
}

a {
  color: var(--accent);
}

a:hover {
  text-decoration: none;
}

h1, h2, h3, h4 {
  line-height: 1.35;
  font-weight: 650;
  margin: 1.4em 0 0.5em;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

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

/* ---------- Layout ---------- */

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

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

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

.site-title {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--fg);
  text-decoration: none;
}

.site-title:hover {
  color: var(--accent);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-nav a:hover {
  color: var(--accent);
}

main.wrap {
  padding-top: 2rem;
  padding-bottom: 3rem;
  min-height: 70vh;
}

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

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

.site-footer a {
  color: var(--muted);
}

.site-footer a:hover {
  color: var(--accent);
}

/* ---------- Article: three-column layout ---------- */

.post-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 680px) 240px;
  gap: 1.5rem 3rem;
  justify-content: center;
}

.post-sidebar {
  color: var(--muted);
  font-size: 0.9rem;
  position: sticky;
  top: 1.5rem;
  align-self: start;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}

.post-body {
  min-width: 0; /* allow the center column to shrink below content width */
}

.post-meta div {
  margin-bottom: 0.9rem;
}

.post-meta dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.post-meta dd {
  margin: 0;
  color: var(--fg);
}

.post-title {
  margin-top: 0;
}

.post-subtitle {
  color: var(--muted);
  font-size: 1.05rem;
}

.post-content {
  max-width: 680px;
}

/* Table of contents. */

.toc h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.toc ul {
  list-style: none;
  padding-left: 0.75rem;
  margin: 0;
}

.toc > ul {
  padding-left: 0;
}

.toc li {
  margin: 0.3rem 0;
}

.toc a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.toc a:hover {
  color: var(--accent);
}

/* ---------- Post listing cards ---------- */

.section-heading {
  margin-top: 0;
}

.intro {
  color: var(--muted);
  max-width: 680px;
}

.post-card {
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--border);
  max-width: 720px;
}

.post-card-title {
  margin: 0 0 0.3rem;
  font-size: 1.25rem;
}

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

.post-card-title a:hover {
  color: var(--accent);
}

.post-card-meta {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.post-card-summary {
  margin: 0 0 0.5rem;
  color: var(--muted);
}

.all-posts {
  max-width: 720px;
}

/* ---------- Tags ---------- */

.tags {
  list-style: none;
  padding: 0;
  margin: 0.5em 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tags li {
  margin: 0;
}

.tag-link {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.6rem;
}

.tag-link:hover {
  border-color: var(--accent);
}

.tag-group {
  margin-bottom: 1.5rem;
  max-width: 720px;
}

.tag-group h2 {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
}

.tag-count {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.9rem;
}

.tag-posts {
  margin: 0;
  padding-left: 1.2rem;
}

.tag-posts li {
  margin: 0.25rem 0;
}

.section-subtitle {
  color: var(--muted);
}

/* ---------- Code blocks ---------- */

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}

pre {
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.55;
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.25em 0;
  position: relative;
}

/* white-space: pre keeps ASCII flowcharts aligned; a monospace font
   guarantees every glyph has the same advance width. */
pre,
pre code {
  white-space: pre;
}

pre code {
  display: block;
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  font-size: inherit;
}

/* Copy button, positioned inside the top-right corner of the pre. */
.copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  line-height: 1;
  color: #8b949e;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.copy-button:hover {
  opacity: 1;
  color: #e6edf3;
}

.copy-button.copied {
  color: #3fb950;
  border-color: #3fb950;
}

/* Zola heading anchors (insert_anchor_links = "right"). */
.zola-anchor {
  margin-left: 0.4em;
  text-decoration: none;
  opacity: 0.4;
  font-size: 0.85em;
}

.zola-anchor:hover {
  opacity: 1;
}

/* ---------- Prose extras ---------- */

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

.post-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: 0.9rem;
}

.post-content th,
.post-content td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

/* ---------- 404 ---------- */

.not-found {
  max-width: 680px;
}

.not-found h1 {
  font-size: 3rem;
  margin: 0 0 0.5rem;
}

/* ---------- Responsive ---------- */

/* Below 1024px: single column, sidebars hidden. */
@media (max-width: 1024px) {
  .post-layout {
    grid-template-columns: minmax(0, 680px);
  }

  .post-sidebar {
    display: none;
  }
}

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

  .site-header .wrap {
    flex-direction: column;
    align-items: flex-start;
  }

  h1 {
    font-size: 1.6rem;
  }
}