/* ===== CSS Custom Properties (Theming) ===== */

[data-theme="light"] {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --text: #1a1a2e;
  --text-secondary: #6c757d;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #e5e7eb;
  --code-bg: #f4f4f5;
  --code-text: #1a1a2e;
  --header-bg: rgba(255, 255, 255, 0.85);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --accent: #60a5fa;
  --accent-hover: #93bbfc;
  --border: #334155;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --header-bg: rgba(15, 23, 42, 0.85);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ===== Reset & Base ===== */

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

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
}

/* ===== Container ===== */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== Header ===== */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

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

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

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

/* ===== Theme Toggle ===== */

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--bg-secondary);
}

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

/* ===== Post List ===== */

.page-title {
  font-size: 1.75rem;
  margin: 3rem 0 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.post-summary {
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--border);
}

.post-summary:last-child {
  border-bottom: none;
}

.post-summary h2 {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

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

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

.article-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.reading-time {
  margin-left: 0.15rem;
}

.post-excerpt {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.5rem;
  line-height: 1.6;
}

/* ===== Single Post ===== */

.post-header {
  margin: 3rem 0 2rem;
}

.post-header h1 {
  font-size: 2.25rem;
  line-height: 1.25;
  margin-bottom: 0.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.post-content h2 {
  font-size: 1.5rem;
  margin: 2.5rem 0 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.post-content h3 {
  font-size: 1.25rem;
  margin: 2rem 0 0.75rem;
  font-weight: 600;
}

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

.post-content strong {
  font-weight: 700;
  color: var(--text);
}

.post-content em {
  font-style: italic;
}

.post-content strong em,
.post-content em strong {
  font-weight: 700;
  font-style: italic;
}

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

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

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

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

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

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

/* ===== Code Block Wrapper & Copy Button ===== */

.code-block-wrapper {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
  z-index: 1;
  font-family: inherit;
}

.code-block-wrapper:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.copy-btn.copied {
  opacity: 1;
  background: #22c55e;
  color: #fff;
  border-color: #22c55e;
}

/* ===== Code Blocks ===== */

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

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

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--code-text);
}

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

/* Chroma syntax highlighting — Light */
[data-theme="light"] .highlight .k,
[data-theme="light"] .highlight .kc,
[data-theme="light"] .highlight .kd,
[data-theme="light"] .highlight .kn,
[data-theme="light"] .highlight .kp,
[data-theme="light"] .highlight .kr { color: #8959a8; font-weight: 500; }
[data-theme="light"] .highlight .s,
[data-theme="light"] .highlight .s1,
[data-theme="light"] .highlight .s2,
[data-theme="light"] .highlight .sa,
[data-theme="light"] .highlight .sb,
[data-theme="light"] .highlight .sc,
[data-theme="light"] .highlight .sd,
[data-theme="light"] .highlight .se,
[data-theme="light"] .highlight .sh,
[data-theme="light"] .highlight .si,
[data-theme="light"] .highlight .sx { color: #718c00; }
[data-theme="light"] .highlight .c,
[data-theme="light"] .highlight .c1,
[data-theme="light"] .highlight .cm,
[data-theme="light"] .highlight .cp,
[data-theme="light"] .highlight .cs,
[data-theme="light"] .highlight .ch { color: #8e908c; font-style: italic; }
[data-theme="light"] .highlight .n,
[data-theme="light"] .highlight .na,
[data-theme="light"] .highlight .nb,
[data-theme="light"] .highlight .nc,
[data-theme="light"] .highlight .nd,
[data-theme="light"] .highlight .nf,
[data-theme="light"] .highlight .ni,
[data-theme="light"] .highlight .nl,
[data-theme="light"] .highlight .nn,
[data-theme="light"] .highlight .nt { color: #4271ae; }
[data-theme="light"] .highlight .mi,
[data-theme="light"] .highlight .mf,
[data-theme="light"] .highlight .mh,
[data-theme="light"] .highlight .mo { color: #f5871f; }
[data-theme="light"] .highlight .o,
[data-theme="light"] .highlight .ow { color: #3e999f; }

/* Chroma syntax highlighting — Dark */
[data-theme="dark"] .highlight .k,
[data-theme="dark"] .highlight .kc,
[data-theme="dark"] .highlight .kd,
[data-theme="dark"] .highlight .kn,
[data-theme="dark"] .highlight .kp,
[data-theme="dark"] .highlight .kr { color: #c792ea; font-weight: 500; }
[data-theme="dark"] .highlight .s,
[data-theme="dark"] .highlight .s1,
[data-theme="dark"] .highlight .s2,
[data-theme="dark"] .highlight .sa,
[data-theme="dark"] .highlight .sb,
[data-theme="dark"] .highlight .sc,
[data-theme="dark"] .highlight .sd,
[data-theme="dark"] .highlight .se,
[data-theme="dark"] .highlight .sh,
[data-theme="dark"] .highlight .si,
[data-theme="dark"] .highlight .sx { color: #c3e88d; }
[data-theme="dark"] .highlight .c,
[data-theme="dark"] .highlight .c1,
[data-theme="dark"] .highlight .cm,
[data-theme="dark"] .highlight .cp,
[data-theme="dark"] .highlight .cs,
[data-theme="dark"] .highlight .ch { color: #676e95; font-style: italic; }
[data-theme="dark"] .highlight .n,
[data-theme="dark"] .highlight .na,
[data-theme="dark"] .highlight .nb,
[data-theme="dark"] .highlight .nc,
[data-theme="dark"] .highlight .nd,
[data-theme="dark"] .highlight .nf,
[data-theme="dark"] .highlight .ni,
[data-theme="dark"] .highlight .nl,
[data-theme="dark"] .highlight .nn,
[data-theme="dark"] .highlight .nt { color: #82aaff; }
[data-theme="dark"] .highlight .mi,
[data-theme="dark"] .highlight .mf,
[data-theme="dark"] .highlight .mh,
[data-theme="dark"] .highlight .mo { color: #f78c6c; }
[data-theme="dark"] .highlight .o,
[data-theme="dark"] .highlight .ow { color: #89ddff; }

/* ===== Attachments ===== */

.post-attachments {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-attachments h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.post-attachments ul {
  list-style: none;
  padding: 0;
}

.post-attachments li {
  margin-bottom: 0.5rem;
}

.post-attachments a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

.post-attachments a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ===== Footer ===== */

.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== Responsive ===== */

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

  .container {
    padding: 0 1rem;
  }

  .post-header h1 {
    font-size: 1.65rem;
  }

  .page-title {
    font-size: 1.5rem;
  }
}
