/* ---- theme tokens ---- */

:root {
  --bg: #111;
  --bg-surface: #1a1a1a;
  --text: #d4d4d4;
  --text-muted: #888;
  --accent: #5bcf80;
  --accent-hover: #4ab86e;
  --border: #2a2a2a;
  --code-bg: #1e1e1e;
  --inline-code-bg: #252525;
  --link: #5bcf80;
  --link-hover: #8ee0a6;
  --link-visited: #5bcf80;
  --font-heading:
    "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    sans-serif;

  /* font sizes */
  --fs-base: 18px;
  --fs-h1: 2.2rem;
  --fs-h2: 1.9rem;
  --fs-h3: 1.1rem;
  --fs-home-h1: 2rem;
  --fs-home-tagline: 1.1rem;
  --fs-recent-h2: 1.8rem;
  --fs-nav-name: 1.5rem;
  --fs-nav-link: 0.92rem;
  --fs-post-title: 1.2rem;
  --fs-small: 0.85rem;
  --fs-body-small: 0.92rem;
  --fs-code: 0.88em;
  --fs-code-block: 0.85rem;
}

[data-theme="light"] {
  --bg: #fafafa;
  --bg-surface: #fff;
  --text: #1a1a1a;
  --text-muted: #666;
  --accent: #16803c;
  --accent-hover: #15803d;
  --border: #e0e0e0;
  --code-bg: #f3f4f6;
  --inline-code-bg: #eee;
  --link: #16803c;
  --link-hover: #166534;
  --link-visited: #16803c;
  --font-heading:
    "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    sans-serif;
}

/* ---- reset ---- */

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

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

h1,
h2,
h3,
h4,
h5,
h6,
.nav-name {
  font-family: var(--font-heading);
}

strong,
b {
  font-weight: 700;
}

html {
  font-family:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    sans-serif;
  font-weight: 300;
  font-size: var(--fs-base);
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- layout ---- */

header,
main,
footer {
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

main {
  flex: 1;
  padding-top: 2rem;
  padding-bottom: 4rem;
}

/* ---- nav ---- */

header {
  padding-top: 2.5rem;
  padding-bottom: 1.5rem;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-name {
  font-weight: 600;
  font-size: var(--fs-nav-name);
  color: var(--text);
  text-decoration: none;
}

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--fs-nav-link);
  transition: color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
}

#theme-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}

#theme-toggle:hover {
  color: var(--accent);
}

/* ---- footer ---- */

footer {
  padding-top: 2rem;
  padding-bottom: 2.5rem;
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-small);
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

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

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

/* ---- markdown content ---- */

.content h1 {
  font-size: var(--fs-h1);
  font-weight: 600;
  margin-bottom: 1.5rem;
  line-height: 1.3;
  color: var(--text);
}

.content h2 {
  font-size: var(--fs-h2);
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.content h3 {
  font-size: var(--fs-h3);
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.content p {
  margin-bottom: 1.25rem;
}

.content a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.content ul,
.content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.content li {
  margin-bottom: 0.35rem;
}

.content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-radius: 0 4px 4px 0;
}

.content blockquote p {
  margin-bottom: 0;
}

.content img {
  max-width: 100%;
  border-radius: 4px;
  margin: 1.5rem 0;
}

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

.content code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: var(--fs-code);
  background: var(--inline-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.5;
}

.content pre code {
  background: none;
  padding: 0;
  font-size: var(--fs-code-block);
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: var(--fs-body-small);
}

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

.content th {
  background: var(--bg-surface);
  font-weight: 600;
}

.content tr:nth-child(even) {
  background: var(--bg-surface);
}

/* ---- home page ---- */

.home-intro h1 {
  font-size: var(--fs-home-h1);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.home-intro .tagline {
  color: var(--text-muted);
  font-size: var(--fs-home-tagline);
  margin-bottom: 2rem;
}

.home-intro p {
  margin-bottom: 1rem;
  line-height: 1.8;
}

.home-intro .home-links {
  margin-top: 2rem;
  display: flex;
  gap: 1.5rem;
}

.home-intro .home-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.home-intro .home-links a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---- recent posts (home) ---- */

.recent-posts {
  margin-top: 2.25rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.recent-posts h2 {
  font-size: var(--fs-recent-h2);
  font-weight: 600;
  margin-bottom: 1.75rem;
  color: var(--text);
}

.recent-post-item {
  margin-bottom: 1.75rem;
}

.recent-post-title {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  font-size: var(--fs-post-title);
  display: block;
}

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

.recent-post-title:visited {
  color: var(--text);
}

.recent-post-item time {
  display: block;
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.recent-post-preview {
  margin-top: 0.4rem;
  font-size: var(--fs-body-small);
  color: var(--text-muted);
  line-height: 1.6;
}

/* ---- blog list ---- */

.blog-list h1 {
  font-size: var(--fs-h1);
  font-weight: 600;
  margin-bottom: 2rem;
}

.post-item {
  margin-bottom: 1.75rem;
}

.post-item a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  font-size: var(--fs-post-title);
}

.post-item a:visited {
  color: var(--text);
}

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

.post-item time {
  display: block;
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.post-item-preview {
  margin-top: 0.4rem;
  font-size: var(--fs-body-small);
  color: var(--text-muted);
  line-height: 1.6;
}

/* ---- blog post ---- */

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

.post-header h1 {
  font-size: var(--fs-h1);
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-small);
  color: var(--text-muted);
  flex-wrap: wrap;
}

.post-meta-sep {
  opacity: 0.4;
}

.tldr-link {
  color: var(--accent);
  text-decoration: none;
}

.tldr-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-body {
  line-height: 1.8;
  color: var(--text);
}

.post-body p {
  margin-bottom: 1.25rem;
}

/* ---- loading ---- */

.loading {
  color: var(--text-muted);
  font-style: italic;
}

/* ---- responsive ---- */

@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  header {
    padding-top: 1.5rem;
  }

  .home-intro h1 {
    font-size: 1.6rem;
  }
  .content h1,
  .blog-list h1,
  .post-header h1 {
    font-size: 1.5rem;
  }

  .home-intro .home-links {
    flex-direction: column;
    gap: 0.75rem;
  }
}
