/* Claude/Anthropic Theme — Warm Editorial
   Direction: claude
   Palette: Parchment canvas + Terracotta accent + warm neutrals
   Posture: serif headings, generous line-height, ring-based shadows,
   warm cream borders, soft rounded corners, literary reading experience.

   Based on Claude (Anthropic) design system:
   - Parchment (#f5f4ed) background — never pure white
   - Ivory (#faf9f5) for elevated/ card surfaces
   - Terracotta (#c96442) as the single brand accent — earthy, un-tech
   - All grays carry a yellow-brown undertone — no cool blue-grays
   - Serif (Georgia) for headings, sans for body text
   - Ring-based depth (0 0 0 1px) instead of traditional drop shadows
   - Generous body line-height (1.6) for literary reading experience
*/

/* ============================================================
   Tokens — Claude/Anthropic Design System
   ============================================================ */
:root {
  /* Surface — 3 levels: Parchment → Ivory → Warm Sand */
  --bg:      #f5f4ed;
  --surface: #faf9f5;
  --bg-secondary: #e8e6dc;     /* Warm Sand — subtle background contrast */
  --bg-card:     var(--surface);
  --bg-code:     #ecebe4;      /* Slightly warmer than Warm Sand for code */

  /* Foreground — 4 levels: Near Black → Dark Warm → Olive Gray → Stone Gray */
  --fg:    #141413;             /* Anthropic Near Black — warmest "black" */
  --text:  var(--fg);
  --text-secondary: #3d3d3a;   /* Dark Warm */
  --muted: #5e5d59;            /* Olive Gray — secondary body text */
  --text-light: #87867f;       /* Stone Gray — tertiary text, footnotes */

  /* Borders — cream-tinted, warm */
  --border:     #f0eee6;       /* Border Cream — standard */
  --border-soft: #e8e6dc;      /* Border Warm — emphasized dividers */

  /* Accent — Terracotta Brand, the only chromatic element */
  --accent:       #c96442;
  --accent-hover: #b55a3b;
  --accent-active: #a14e33;
  --accent-light: #f5edea;     /* Terracotta tinted bg for badges/tags */

  /* Shadow — ring-based depth */
  --shadow: none;
  --elev-ring: 0 0 0 1px var(--border);
  --elev-raised: rgba(0, 0, 0, 0.05) 0px 4px 24px;

  /* Focus ring — Focus Blue is the ONLY cool color, accessibility only */
  --focus-ring: 0 0 0 3px rgba(56, 152, 236, 0.3);

  /* Typography */
  --font-display: Georgia, "Times New Roman", "Noto Serif CJK SC", serif;
  --font-body:    system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono:    ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;

  /* Type scale */
  --text-xs:     10px;
  --text-sm:     14px;
  --text-base:   16px;
  --text-lg:     18px;
  --text-xl:     25px;
  --text-2xl:    32px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;

  /* Radius */
  --radius:    8px;            /* Comfortably rounded — standard cards */
  --radius-sm: 6px;            /* Subtly rounded — secondary elements */
  --radius-md: 12px;           /* Generously rounded — primary, inputs */
  --radius-lg: 16px;           /* Very rounded — featured containers */
}

/* ============================================================
   Dark Theme — warm charcoal, never cool blue-grays
   ============================================================ */
[data-theme="dark"] {
  --bg:      #141413;           /* Deep Dark — page background */
  --surface: #1e1e1d;           /* Slightly lighter than bg for cards */
  --bg-secondary: #262625;      /* Container bg */
  --bg-card:     #1e1e1d;
  --bg-code:     #1a1a19;

  --fg:    #e8e6dc;             /* Warm Silver — primary text */
  --text:  #e8e6dc;
  --text-secondary: #b0aea5;
  --muted: #87867f;             /* Stone Gray */
  --text-light: #666560;

  --border:     #2a2a28;
  --border-soft: #353532;

  --accent:       #d97757;       /* Coral Accent — lighter terracotta for dark mode */
  --accent-hover: #e08666;
  --accent-active: #e89678;
  --accent-light: #2a1e1a;      /* Dark tint for tags/badges */

  --elev-raised: rgba(0, 0, 0, 0.15) 0px 4px 24px;
  --focus-ring: 0 0 0 3px rgba(56, 152, 236, 0.4);
}

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

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease, color 0.25s ease;
}

[data-theme] * { transition: background-color 0.2s ease, border-color 0.2s ease, color 0.15s ease; }

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }

::selection { background: var(--accent); color: #fff; }

/* ============================================================
   Layout containers
   ============================================================ */
.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
}
main { width: 100%; flex: 1; }

/* ============================================================
   Header — warm solid background, literary feel
   ============================================================ */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.header-left { flex-shrink: 0; }

.site-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;            /* Claude uses weight 500 for all headings */
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.site-title:hover { color: var(--accent); text-decoration: none; }

.header-nav {
  flex: 1;
  display: flex;
  justify-content: center;
}
.header-nav nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}
.header-nav nav a {
  font-size: 0.9rem;
  font-weight: 450;
  color: var(--muted);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  white-space: nowrap;
}
.header-nav nav a:hover {
  color: var(--text);
  background: var(--bg);
  text-decoration: none;
}

/* Nav dropdown */
.nav-dropdown { position: relative; display: inline-block; }
.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.9rem;
  font-weight: 450;
  color: var(--muted);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.nav-dropdown-trigger:hover { color: var(--text); background: var(--bg); }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 170px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--elev-raised);
  padding: 0.35rem;
  z-index: 200;
}
.nav-dropdown-menu a {
  display: block;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.nav-dropdown-menu a:hover {
  color: var(--text);
  background: var(--bg);
  text-decoration: none;
}
@media (min-width: 769px) {
  .nav-dropdown:hover .nav-dropdown-menu { display: block; }
}

/* Header icons */
.header-icons {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex-shrink: 0;
}
.nav-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: all 0.15s;
}
.nav-icon-btn:hover { background: var(--surface); color: var(--accent); }

/* Search — left-slide */
.search-wrap { position: relative; display: flex; align-items: center; }
.nav-search {
  display: none;
  position: absolute;
  right: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.nav-search.expanded {
  display: flex;
  animation: searchExpand 0.2s ease forwards;
}
@keyframes searchExpand {
  from { opacity: 0; width: 40px; }
  to { opacity: 1; width: 200px; }
}
.nav-search:focus-within { border-color: var(--accent); }
.nav-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  width: 160px;
}
.nav-search input::placeholder { color: var(--text-light); }

/* Theme toggle */
.theme-toggle svg { transition: transform 0.3s ease; }
.theme-toggle:hover svg { transform: rotate(15deg); }

/* ============================================================
   Mobile menu
   ============================================================ */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  color: var(--muted);
  align-items: center;
  justify-content: center;
}
@media (max-width: 768px) {
  .header-nav nav { display: none; }
  .header-nav nav.mobile-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    gap: 0.25rem;
    z-index: 99;
    align-items: stretch;
  }
  .header-nav nav.mobile-open a { padding: 0.5rem 0.75rem; }
  .mobile-menu-btn { display: flex; }
}

/* ============================================================
   Post grid — warm editorial two-column
   ============================================================ */
.home-layout {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 2rem;
  margin-top: 2.5rem;
}
.home-layout-article { padding-left: 120px; }
.home-main { flex: 1; min-width: 0; }
.home-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 84px;
}

.post-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.post-grid .pagination {
  grid-column: 1 / -1;
  justify-self: center;
  margin: 0.5rem 0 0;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
  box-shadow: var(--elev-raised);
}
.post-card:hover {
  border-color: var(--accent);
  box-shadow: var(--elev-ring), var(--elev-raised);
}
.post-card:hover .post-card-title a { color: var(--accent); }

.post-card-cover {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius) var(--radius) 0 0;
}

.post-card-body { padding: 1.25rem 1.5rem 1rem; }

.post-card-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.post-card-meta span { display: flex; align-items: center; gap: 0.3rem; }

.post-card-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;            /* Claude-style weight 500 */
  line-height: 1.35;
  margin-bottom: 0.5rem;
}
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--accent); text-decoration: none; }

.post-card-summary {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-family: var(--font-body);
}

.post-card-tags { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.card-category {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}
.card-category a { color: var(--accent); text-decoration: none; }

/* Tag badge */
.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  background: var(--accent-light);
  color: var(--accent);
  transition: all 0.15s;
}
.tag:hover { background: var(--accent); color: #fff; text-decoration: none; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin: 2.5rem 0;
}
.pagination a,
.pagination span {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.7rem;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
}
.pagination a {
  color: var(--muted);
  border: 1px solid var(--border);
  transition: all 0.15s;
  background: var(--surface);
}
.pagination a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  box-shadow: var(--elev-ring);
}
.pagination .current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 500;
}

/* ============================================================
   Article page — reading-focused layout
   ============================================================ */
.article-header {
  max-width: 720px;
  margin: 2.5rem auto 1.5rem;
  padding: 0;                  /* No card wrapper — clean editorial */
}
.article-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 500;            /* Claude-style weight 500 */
  line-height: 1.25;
  margin-bottom: 0.75rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  color: var(--text-light);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.75rem;
}
.article-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.article-category {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}
.article-category a { color: #fff; text-decoration: none; }

/* Article content — centered reading column */
.article-content {
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  box-shadow: var(--elev-raised);
}

.article-content h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  line-height: 1.3;
}
.article-content h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
  margin: 1.75rem 0 0.5rem;
  color: var(--text);
  line-height: 1.35;
}
.article-content h4 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}
.article-content p { margin-bottom: 1.15rem; max-width: 65ch; }

.article-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--muted);
  font-style: italic;
  line-height: 1.7;
}
.article-content blockquote p:last-child { margin-bottom: 0; }

.article-content pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
  font-size: 0.85rem;
}
.article-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}
.article-content :not(pre) > code {
  background: var(--accent-light);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  color: var(--accent);
  font-size: 0.85em;
  font-weight: 450;
}
.article-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}
.article-content th,
.article-content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.article-content th {
  background: var(--bg-secondary);
  font-weight: 500;
  font-size: 0.85rem;
}
.article-content ul,
.article-content ol { padding-left: 1.5rem; margin: 1rem 0; }
.article-content li { margin-bottom: 0.3rem; line-height: 1.7; }
.article-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* Code copy button */
.code-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  font-family: inherit;
}
.article-content pre:hover .code-copy-btn,
.code-copy-btn:focus { opacity: 1; }
.code-copy-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============================================================
   Share buttons
   ============================================================ */
.share-buttons {
  max-width: 720px;
  margin: 1.5rem auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.share-label { font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  background: var(--surface);
  transition: all 0.15s;
  font-family: inherit;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }
.share-btn svg { width: 14px; height: 14px; }

/* ============================================================
   Article navigation (prev/next)
   ============================================================ */
.article-nav {
  max-width: 720px;
  margin: 1.5rem auto;
  display: flex;
  gap: 0.75rem;
}
.article-nav a {
  flex: 1;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  transition: all 0.15s;
  background: var(--surface);
  box-shadow: var(--elev-raised);
}
.article-nav a:hover {
  border-color: var(--accent);
  text-decoration: none;
  box-shadow: var(--elev-ring), var(--elev-raised);
}
.article-nav-prev { text-align: left; }
.article-nav-next { text-align: right; }

/* ============================================================
   TOC — sidebar
   ============================================================ */
.toc-sidebar {
  position: fixed;
  top: 80px;
  left: 0;
  width: 220px;
  height: calc(100vh - 96px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 90;
  transition: transform 0.25s ease;
  transform: translateX(0);
  overflow: hidden;
  display: flex;
}
.toc-sidebar.toc-collapsed { transform: translateX(-220px); }

.toc-trigger {
  position: absolute;
  top: 50%;
  right: -28px;
  transform: translateY(-50%);
  width: 28px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  z-index: 5;
  transition: color 0.15s;
}
.toc-trigger:hover { color: var(--accent); }
.toc-trigger svg { transition: transform 0.2s; }
.toc-collapsed .toc-trigger svg { transform: rotate(-180deg); }

.toc-content {
  padding: 0;
  width: 220px;
  overflow-y: auto;
}
.toc-content .toc-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  padding: 1rem 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}
.toc-content ul { list-style: none; }
.toc-content li { margin: 0; }
.toc-content li[data-level="3"] { padding-left: 0.75rem; }
.toc-content li[data-level="4"] { padding-left: 1.5rem; }
.toc-content a {
  display: block;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-left: 2px solid transparent;
  transition: all 0.15s;
  line-height: 1.4;
  text-decoration: none;
}
.toc-content a:hover {
  color: var(--text);
  background: var(--accent-light);
  text-decoration: none;
}
.toc-content a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-light);
}

/* FAB for TOC / back-to-top on mobile */
.toc-fab {
  position: fixed;
  bottom: 1.5rem;
  left: 1rem;
  width: 40px;
  height: 40px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 91;
  transition: all 0.2s;
  box-shadow: var(--elev-raised);
}
.toc-fab:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 1024px) {
  .toc-sidebar { display: none; }
}

/* ============================================================
   In-article TOC (for themes without sidebar)
   ============================================================ */
.toc {
  max-width: 720px;
  margin: 0 auto 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--elev-raised);
}
.toc .toc-title {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}
.toc ul { list-style: none; }
.toc li { margin: 0.2rem 0; }
.toc li[data-level="2"] { padding-left: 0; }
.toc li[data-level="3"] { padding-left: 1rem; }
.toc li[data-level="4"] { padding-left: 2rem; }
.toc a { color: var(--muted); font-size: 0.85rem; }
.toc a:hover { color: var(--accent); text-decoration: none; }

/* ============================================================
   Reading progress bar
   ============================================================ */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: var(--accent);
  z-index: 1000;
  transition: width 0.1s linear;
}

/* ============================================================
   Sidebar cards
   ============================================================ */
.home-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--elev-raised);
}
.sidebar-profile-card,
.sidebar-category-card { width: 100%; }
.home-card-title {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-profile { text-align: center; }
.sidebar-avatar {
  width: 72px;
  height: 72px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}
.sidebar-bio {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}
.sidebar-social {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
}
.sidebar-social a {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: all 0.15s;
}
.sidebar-social a:hover { color: var(--accent); background: var(--accent-light); }

.sidebar-pinned { list-style: none; }
.sidebar-pinned li { margin-bottom: 0.35rem; }
.sidebar-pinned a {
  font-size: 0.85rem;
  color: var(--muted);
  display: block;
  padding: 0.25rem 0;
  line-height: 1.5;
}
.sidebar-pinned a:hover { color: var(--accent); text-decoration: none; }

.sidebar-tag-cloud { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.sidebar-tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  background: var(--accent-light);
  color: var(--accent);
  transition: all 0.15s;
}
.sidebar-tag:hover { background: var(--accent); color: #fff; text-decoration: none; }

.sidebar-social-list { display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar-social-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.sidebar-social-link:hover { color: var(--accent); background: var(--accent-light); text-decoration: none; }

/* ============================================================
   Tags / Archives / Categories pages
   ============================================================ */
.tags-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag-item {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--muted);
  transition: all 0.15s;
  background: var(--surface);
}
.tag-item:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  box-shadow: var(--elev-ring);
}
.tag-count { opacity: 0.5; font-size: 0.8rem; }

.archive-year { margin-bottom: 2rem; }
.archive-year h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.archive-month { margin-left: 0.5rem; margin-bottom: 1rem; }
.archive-month h3 { font-size: 1rem; margin-bottom: 0.4rem; color: var(--muted); }
.archive-count { color: var(--text-light); font-size: 0.85rem; }
.archive-list { list-style: none; }
.archive-list li { padding: 0.3rem 0; }
.archive-list li a { color: var(--text); font-size: 0.9rem; }
.archive-list li a:hover { color: var(--accent); }
.archive-date { color: var(--muted); font-size: 0.8rem; margin-left: 0.5rem; }

.categories-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.category-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--elev-raised);
}
.category-item:hover {
  border-color: var(--accent);
  text-decoration: none;
  box-shadow: var(--elev-ring), var(--elev-raised);
}
.category-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1rem;
}
.category-desc { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }
.category-count { font-size: 0.78rem; color: var(--text-light); margin-top: 0.2rem; }

/* ============================================================
   Search page
   ============================================================ */
.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  max-width: 600px;
}
.search-input {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 0.95rem;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s;
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--elev-ring); }
.search-btn {
  padding: 0.65rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: var(--font-body);
}
.search-btn:hover { background: var(--accent-hover); }
.search-highlight {
  background: var(--accent);
  color: #fff;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

/* ============================================================
   About page
   ============================================================ */
.about-content {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0;
  line-height: 1.8;
  color: var(--text);
}
.about-content p { margin-bottom: 1rem; max-width: 65ch; }

/* ============================================================
   404 page
   ============================================================ */
.not-found-page {
  text-align: center;
  padding: 6rem 0;
  max-width: 500px;
  margin: 0 auto;
}
.not-found-page h1 {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.5rem;
}
.not-found-text {
  font-family: var(--font-body);
  font-size: 1.2rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.not-found-link {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md);
  transition: background 0.15s;
  font-weight: 500;
}
.not-found-link:hover { background: var(--accent-hover); text-decoration: none; }

/* ============================================================
   Footer
   ============================================================ */
footer {
  margin-top: 4rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}
.footer-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.footer-inner a { color: var(--muted); }
.footer-inner a:hover { color: var(--accent); }
.footer-sep { color: var(--border); }
.footer-stats { font-variant-numeric: tabular-nums; }

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 4rem 0;
  color: var(--muted);
  font-family: var(--font-body);
}
.empty-state svg {
  width: 40px;
  height: 40px;
  margin-bottom: 0.75rem;
  opacity: 0.3;
}

/* ============================================================
   Dark mode image dimming
   ============================================================ */
[data-theme="dark"] .post-card-cover,
[data-theme="dark"] .article-content img {
  filter: brightness(0.75) contrast(1.05);
  transition: filter 0.3s;
}
[data-theme="dark"] .post-card-cover:hover,
[data-theme="dark"] .article-content img:hover {
  filter: brightness(0.85) contrast(1.05);
}

/* ============================================================
   Related posts
   ============================================================ */
.related-posts {
  max-width: 720px;
  margin: 2rem auto;
}
.related-posts-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.related-posts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.related-post-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--elev-raised);
}
.related-post-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  box-shadow: var(--elev-ring), var(--elev-raised);
}
.related-post-cover {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
}
.related-post-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.related-post-date {
  font-size: 0.72rem;
  color: var(--text-light);
}
@media (max-width: 600px) {
  .related-posts-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Comment section placeholder
   ============================================================ */
.article-comments {
  max-width: 720px;
  margin: 2rem auto;
  padding: 1.5rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--elev-raised);
}
.article-comments-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.article-comments-placeholder {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ============================================================
   Back-to-top button
   ============================================================ */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 90;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.25s;
  pointer-events: none;
  box-shadow: var(--elev-raised);
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ============================================================
   Post card footer (homepage tags area)
   ============================================================ */
.post-card-footer {
  padding: 0.25rem 0 0;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .home-layout { flex-direction: column; }
  .home-sidebar { width: 100%; position: static; }
  .home-layout-article { padding-left: 0; }
}

@media (max-width: 768px) {
  .container { padding: 0 1rem; }
  .header-inner { padding: 0 1rem; }
  .post-grid { grid-template-columns: 1fr; }
  .post-grid .post-card-cover { height: 200px; }
  .post-grid .pagination { grid-column: 1; justify-self: center; }
  .article-title { font-size: 1.6rem; }
  .article-header { padding: 0; }
  .article-content { padding: 1.25rem; }
  .article-nav { flex-direction: column; }
  .categories-list { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; gap: 0.25rem; }
}

/* ============================================================
   Print styles
   ============================================================ */
@media print {
  header, footer, .toc-sidebar, .back-to-top, .toc-fab,
  .share-buttons, .article-nav, .related-posts, .article-comments,
  #reading-progress, .search-wrap, .theme-toggle { display: none !important; }
  body { background: white; color: black; }
  .article-content { box-shadow: none; border: none; max-width: 100%; }
}

/* ============================================================
   Motion preference
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
