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

/* === Base === */
:root {
  --text: #374151;
  --text-strong: #1f2937;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --bg: #fafaf9;
  --bg-warm: #f5f5f0;
  --border: #e5e5e0;
  --link: #4b6a88;
  --link-hover: #374151;
  --code-bg: #282c34;
  --code-text: #abb2bf;
  --mono: "JetBrains Mono", "Fira Code", Consolas, monospace;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --content-width: 680px;
  --page-width: 880px;
}

body {
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* === Layout === */
.container {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 24px;
}

.content-narrow {
  max-width: var(--content-width);
}

/* === Header === */
header {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.site-title {
  font-weight: 600;
  font-size: 1.05em;
  color: var(--text-strong);
  text-decoration: none;
}

.site-title:hover {
  color: var(--text-strong);
  text-decoration: none;
}

.site-tagline {
  font-size: 0.82em;
  color: var(--text-faint);
}

nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

nav a {
  font-size: 0.82em;
  color: var(--text-muted);
  text-decoration: none;
}

nav a:hover {
  color: var(--text-strong);
  text-decoration: none;
}

.nav-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
}

.author-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.author-link img {
  border-radius: 50%;
  display: block;
  opacity: 0.85;
}

.author-link:hover img {
  opacity: 1;
}

/* === Main === */
main {
  padding: 40px 0 64px;
}

/* === Typography === */
h1, h2, h3, h4 {
  color: var(--text-strong);
  line-height: 1.35;
  margin: 1.6em 0 0.6em;
}

h1 { font-size: 1.5em; font-weight: 600; }
h2 { font-size: 1.25em; font-weight: 600; }
h3 { font-size: 1.05em; font-weight: 600; }

p {
  margin-bottom: 1em;
}

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

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

ul, ol {
  margin: 0 0 1em 1.4em;
}

li {
  margin-bottom: 0.25em;
}

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

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

img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* === Post Article === */
.post-header {
  margin-bottom: 28px;
}

.post-header h1 {
  font-size: 1.6em;
  margin: 0 0 10px;
  line-height: 1.3;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.82em;
  color: var(--text-faint);
}

.post-meta a {
  text-decoration: none;
}

.post-author {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
}

.post-author img {
  border-radius: 50%;
  display: block;
}

.post-author:hover {
  color: var(--text-strong);
  text-decoration: none;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.tag {
  display: inline-block;
  font-size: 0.72em;
  padding: 2px 8px;
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.12s, border-color 0.12s;
}

.tag:hover {
  border-color: var(--text-muted);
  color: var(--text-strong);
  text-decoration: none;
}

.post-cover {
  margin-bottom: 28px;
}

.post-cover img {
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.post-body {
  font-size: 1em;
}

.post-body h2 {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
}

/* === Table of Contents === */
.toc {
  margin: 0 0 28px;
  padding: 14px 18px;
  background: var(--bg-warm);
  border-radius: 6px;
  font-size: 0.88em;
}

.toc-title {
  font-size: 0.78em;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 5px;
}

.toc-title::before {
  content: "\25BE";
  font-size: 0.8em;
  transition: transform 0.2s;
}

.toc.collapsed .toc-title::before {
  transform: rotate(-90deg);
}

.toc.collapsed nav {
  display: none;
}

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

.toc li { margin: 0; }

.toc a {
  display: block;
  padding: 2px 0;
  color: var(--text-muted);
  text-decoration: none;
}

.toc a:hover {
  color: var(--text-strong);
  text-decoration: none;
}

.toc ul ul {
  padding-left: 14px;
}

.toc ul ul a {
  font-size: 0.94em;
  color: var(--text-faint);
}

/* === Code === */
code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-warm);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-strong);
}

pre {
  position: relative;
  margin: 0 0 1.2em;
  border-radius: 6px;
  overflow: hidden;
}

pre code {
  display: block;
  padding: 16px 18px;
  background: var(--code-bg);
  color: var(--code-text);
  overflow-x: auto;
  line-height: 1.55;
  font-size: 0.82em;
  -webkit-overflow-scrolling: touch;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  color: rgba(255,255,255,0.3);
  font-family: var(--mono);
  font-size: 0.65em;
  padding: 2px 7px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

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

.copy-btn:hover {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.6);
}

.copy-btn.copied {
  color: #8bc34a;
  opacity: 1;
}

/* === Post List === */
.page-title {
  font-size: 1.2em;
  font-weight: 600;
  margin: 0 0 20px;
}

/* === Featured Article === */
.featured {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.featured-link {
  display: block;
  text-decoration: none;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  transition: box-shadow 0.2s;
}

.featured-link:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  text-decoration: none;
}

.featured-thumb {
  aspect-ratio: 21 / 9;
  overflow: hidden;
  background: var(--bg-warm);
}

.featured-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.4s ease;
}

.featured-link:hover .featured-thumb img {
  transform: scale(1.04);
}

.featured-body {
  padding: 24px 28px 28px;
}

.featured-title {
  font-size: 1.4em;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0 0 8px;
  line-height: 1.3;
}

.featured-summary {
  font-size: 0.92em;
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0 0 14px;
}

.featured-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.82em;
  color: var(--text-faint);
}

.featured-avatar {
  border-radius: 50%;
  display: block;
}

.featured-author {
  color: var(--text-muted);
  font-weight: 500;
}

.featured-date {
  font-family: var(--mono);
  font-size: 0.9em;
}

.featured-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Card author elements */
.card-avatar {
  border-radius: 50%;
  display: block;
  margin-top: 6px;
  opacity: 0.7;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75em;
  color: var(--text-faint);
  margin-top: 4px;
}

.card-date {
  opacity: 0.6;
}

/* === Wide Card (horizontal) === */
.card-wide-wrap {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.card-wide {
  display: flex;
  text-decoration: none;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  transition: box-shadow 0.2s;
}

.card-wide:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  text-decoration: none;
}

.card-wide-thumb {
  flex: 0 0 45%;
  overflow: hidden;
  background: var(--bg-warm);
}

.card-wide-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-wide-body {
  flex: 1;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.card-wide-title {
  font-size: 1.2em;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0 0 8px;
  line-height: 1.35;
}

.card-wide-summary {
  font-size: 0.88em;
  color: var(--text-muted);
  margin: 0 0 12px;
  line-height: 1.6;
}

.card-wide-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82em;
  color: var(--text-faint);
  margin-bottom: 8px;
}

@media (max-width: 600px) {
  .card-wide {
    flex-direction: column;
  }
  .card-wide-thumb {
    flex: none;
    aspect-ratio: 16 / 9;
  }
}

/* === Section Spacing === */
.section-gap {
  margin-bottom: 32px;
}

/* === Card Grid === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.card-grid.grid-2col {
  grid-template-columns: repeat(2, 1fr);
}

.card {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  text-decoration: none;
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  text-decoration: none;
}

.card.card-more {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-warm);
  border: 2px dashed var(--border);
  transition: border-color 0.2s, background 0.2s;
}

.card.card-more:hover {
  border-color: var(--link);
  background: #fff;
}

.card-more-label {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--link);
}

.card-thumb {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-warm);
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.3s;
}

.cover-fill img {
  object-fit: cover;
  object-position: center;
}

.card:hover .card-thumb img {
  transform: scale(1.03);
}

.card-info {
  padding: 12px 14px;
}

.card-title {
  font-size: 0.85em;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-strong);
  margin: 0;
}

.card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.96);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.card:hover .card-overlay {
  opacity: 1;
}

.card-overlay p {
  font-size: 0.82em;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 10px;
}

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

.card-tags .tag {
  font-size: 0.65em;
  padding: 1px 6px;
}

/* === Tag Cloud === */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 28px;
}

.tag-cloud .tag.active {
  background: var(--text-strong);
  color: #fff;
  border-color: var(--text-strong);
}

/* === Pagination === */
.pagination {
  margin-top: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  font-size: 0.82em;
}

.pagination a {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  text-decoration: none;
}

.pagination a:hover {
  border-color: var(--text-muted);
  color: var(--text-strong);
  text-decoration: none;
}

.pagination span {
  color: var(--text-faint);
}

/* === 404 === */
.error-page {
  text-align: center;
  padding: 80px 0;
}

.error-page h1 {
  font-size: 5em;
  font-weight: 600;
  color: var(--border);
  margin: 0;
  line-height: 1;
}

.error-page p {
  color: var(--text-muted);
}

/* === Author Profile === */
.author-profile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  padding: 24px;
  border-radius: 10px;
  background: var(--bg-warm);
  border: 1px solid var(--border);
}

.author-profile-left {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  min-width: 0;
}

.author-profile-avatar {
  border-radius: 50%;
  display: block;
  flex-shrink: 0;
}

.author-profile-info {
  min-width: 0;
}

.author-profile-name {
  font-size: 1.4em;
  font-weight: 600;
  margin: 0;
  color: var(--text-strong);
}

.author-profile-fullname {
  font-size: 0.88em;
  color: var(--text-faint);
  margin: 2px 0 0;
}

.author-profile-stats {
  font-size: 0.82em;
  color: var(--text-faint);
  margin: 4px 0 10px;
}

.author-profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.author-profile-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 18px 28px;
  border: 2px solid var(--link);
  border-radius: 8px;
  text-decoration: none;
  text-align: center;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.author-profile-cta:hover {
  background: var(--link);
  transform: translateY(-1px);
}

.author-profile-cta-label {
  font-size: 0.78em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--link);
  margin-bottom: 4px;
}

.author-profile-cta:hover .author-profile-cta-label {
  color: #fff;
}

.author-profile-cta-url {
  font-size: 0.95em;
  font-weight: 500;
  color: var(--text-strong);
}

.author-profile-cta:hover .author-profile-cta-url {
  color: #fff;
}

@media (max-width: 600px) {
  .author-profile {
    flex-direction: column;
    align-items: stretch;
  }
  .author-profile-cta {
    align-self: stretch;
  }
}

/* === Footer === */
footer {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.78em;
}

/* === Responsive === */
@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .header-left {
    flex-direction: column;
    gap: 2px;
  }

  nav {
    gap: 10px;
  }

  .nav-sep {
    display: none;
  }

  .featured-body {
    padding: 16px;
  }

  .featured-title {
    font-size: 1.15em;
  }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .card-overlay {
    padding: 14px 12px;
  }

  .post-header h1 {
    font-size: 1.35em;
  }
}
