/* ═══════════════════════════════════════════════
   Hermes Blog Theme — Custom Design
   Typography: Instrument Serif + Inter + DM Mono
   Palette: Warm paper + terracotta + deep navy
   ═══════════════════════════════════════════════ */

:root {
  --bg: #F7F5F0;
  --bg-card: #EFEDE8;
  --bg-code: #1A1B1E;
  --text: #1A1A1A;
  --text-secondary: #6B6560;
  --text-muted: #9C958F;
  --accent: #C44B3C;
  --accent-hover: #A83A2E;
  --accent-light: #F0D6D2;
  --border: #DCD7D0;
  --code-text: #E4E4E7;
  --code-keyword: #F472B6;
  --code-string: #86EFAC;
  --code-func: #7DD3FC;
  --code-comment: #6B7280;
  --max-width: 1080px;
  --content-width: 720px;
}

.dark {
  --bg: #161618;
  --bg-card: #1E1E20;
  --text: #E4E4E7;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;
  --accent: #E66050;
  --accent-hover: #F47060;
  --accent-light: #2D1B18;
  --border: #2A2A2E;
  --bg-code: #0E0E10;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  transition: background .3s, color .3s;
  -webkit-font-smoothing: antialiased;
}

/* ── Container ── */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }

/* ── Header ── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  background: rgba(247,245,240,0.92);
}
.dark .site-header { background: rgba(22,22,24,0.92); }
.site-header .container {
  display: flex; align-items: center; gap: 2rem;
  height: 3.75rem;
}
.logo {
  font-family: "DM Mono", monospace;
  font-size: 1.125rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
  letter-spacing: -0.03em;
  flex-shrink: 0;
}
.logo span {
  color: var(--accent);
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-weight: 400;
}
.main-nav {
  display: flex;
  gap: 1.5rem;
  margin-left: auto;
  align-items: center;
}
.main-nav a {
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color .2s;
  white-space: nowrap;
}
.main-nav a:hover { color: var(--accent); }
.theme-toggle, .menu-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: 0.375rem; padding: 0.375rem 0.625rem;
  cursor: pointer; font-size: 1rem; line-height: 1;
  color: var(--text);
  transition: border-color .2s;
}
.theme-toggle:hover, .menu-toggle:hover { border-color: var(--accent); }
.menu-toggle { display: none; flex-shrink: 0; }

/* ── Hero ── */
.hero {
  padding: 5rem 0 3rem;
  text-align: center;
}
.hero-title {
  font-family: "Instrument Serif", serif;
  font-size: 3.5rem;
  font-weight: 400;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 0.75rem;
}
@media (max-width: 640px) { .hero-title { font-size: 2.5rem; } }
.hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto 1.5rem;
}
.hero-stats { display: flex; gap: 1.5rem; justify-content: center; }
.hero-stats .stat {
  font-size: 0.875rem;
  color: var(--text-muted);
  padding: 0.375rem 0.875rem;
  background: var(--bg-card);
  border-radius: 999px;
}

/* ── Sections Grid ── */
.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 4rem;
}
.section-card {
  display: block;
  padding: 1.5rem;
  background: var(--bg-card);
  border-radius: 0.75rem;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  transition: border-color .2s, transform .2s;
}
.section-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.section-card h2 {
  font-family: "Instrument Serif", serif;
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
}
.section-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.section-count {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Section Title ── */
.section-title {
  font-family: "Instrument Serif", serif;
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Post List ── */
.post-list { display: flex; flex-direction: column; gap: 1.5rem; }
.post-card {
  padding: 1.5rem;
  background: var(--bg-card);
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  transition: border-color .2s;
}
.post-card:hover { border-color: var(--accent); }
.post-meta {
  display: flex; gap: 0.75rem; align-items: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.post-category {
  color: var(--accent);
  font-weight: 500;
}
.post-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  line-height: 1.4;
}
.post-card h3 a {
  text-decoration: none;
  color: var(--text);
  transition: color .2s;
}
.post-card h3 a:hover { color: var(--accent); }
.post-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}
.post-tags { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.tag {
  font-size: 0.75rem;
  padding: 0.1875rem 0.625rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 999px;
  font-weight: 500;
}
.dark .tag {
  background: var(--accent-light);
}

/* ── List Page ── */
.list-page { padding: 3rem 1.5rem; max-width: var(--content-width); margin: 0 auto; }
.list-header { margin-bottom: 2.5rem; }
.list-header h1 {
  font-family: "Instrument Serif", serif;
  font-size: 2.5rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
}
.list-desc { color: var(--text-secondary); font-size: 1rem; }

/* ── Article ── */
.article { padding: 3rem 1.5rem 5rem; max-width: var(--content-width); margin: 0 auto; }
.article-header { margin-bottom: 2.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.article-meta {
  display: flex; gap: 0.75rem; align-items: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.article-category { color: var(--accent); font-weight: 500; }
.article-header h1 {
  font-family: "Instrument Serif", serif;
  font-size: 2.5rem;
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}
@media (max-width: 640px) { .article-header h1 { font-size: 1.875rem; } }
.article-tags { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Article Content ── */
.article-content { font-size: 1rem; line-height: 1.85; }
.article-content h2 {
  font-family: "Instrument Serif", serif;
  font-size: 1.625rem;
  font-weight: 400;
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border);
}
.article-content h3 {
  font-family: "Instrument Serif", serif;
  font-size: 1.25rem;
  font-weight: 400;
  margin: 1.5rem 0 0.5rem;
}
.article-content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.375rem;
}
.article-content p { margin-bottom: 1rem; }
.article-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  word-break: break-word;
}
.article-content a:hover { color: var(--accent-hover); }
.article-content ul, .article-content ol {
  margin: 0 0 1rem 1.5rem;
}
.article-content li { margin-bottom: 0.25rem; }
.article-content strong { font-weight: 600; }
.article-content blockquote {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem 0.75rem 1.25rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-card);
  border-radius: 0 0.5rem 0.5rem 0;
  color: var(--text-secondary);
}
.article-content hr {
  margin: 2rem 0;
  border: none;
  border-top: 1px solid var(--border);
}
.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 1.5rem auto;
  display: block;
}

/* ── Code Blocks ── */
.article-content pre {
  margin: 1.25rem 0;
  padding: 1.25rem;
  background: var(--bg-code);
  border-radius: 0.75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-family: "DM Mono", "Fira Code", monospace;
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--code-text);
  border: 1px solid var(--border);
}
.article-content pre::-webkit-scrollbar { height: 4px; }
.article-content pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.article-content code {
  font-family: "DM Mono", "Fira Code", monospace;
  font-size: 0.875em;
  padding: 0.2em 0.35em;
  background: var(--bg-card);
  border-radius: 0.25rem;
  word-break: break-word;
}
.article-content pre code {
  padding: 0;
  background: none;
  font-size: inherit;
  color: inherit;
  border-radius: 0;
  word-break: normal;
}

/* ── Tables ── */
.article-content table {
  width: 100%;
  margin: 1.25rem 0;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.article-content th, .article-content td {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}
.article-content th {
  background: var(--bg-card);
  font-weight: 600;
}
.article-content tr:nth-child(even) { background: var(--bg-card); }

/* ── Article Navigation ── */
.article-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.article-nav a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: color .2s;
  max-width: 45%;
}
.article-nav a:hover { color: var(--accent); }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.site-footer a { color: var(--text-secondary); text-decoration: underline; }

/* ── Responsive ── */

/* Tablet and small desktop */
@media (max-width: 900px) {
  .sections-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* Mobile */
@media (max-width: 768px) {
  .container { padding: 0 1rem; }
  
  .main-nav {
    display: none;
    position: fixed;
    top: 3.25rem;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.75rem 1rem;
    gap: 0;
    z-index: 99;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  }
  .dark .main-nav { box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
  .main-nav.open { display: flex; }
  .main-nav a {
    display: block;
    padding: 0.625rem 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
  }
  .main-nav a:last-child { border-bottom: none; }
  
  .menu-toggle { display: block; }
  
  .site-header .container { height: 3.25rem; gap: 0.75rem; }
  .logo { font-size: 1rem; }
  
  .hero { padding: 2.5rem 0 1.5rem; }
  .hero-stats { gap: 0.75rem; flex-wrap: wrap; }
  
  .sections-grid { grid-template-columns: 1fr; gap: 0.75rem; margin-bottom: 2.5rem; }
  .section-card { padding: 1.125rem; }
  .section-card h2 { font-size: 1.25rem; }
  
  .section-title { font-size: 1.375rem; margin-bottom: 1rem; }
  
  .post-list { gap: 0.75rem; }
  .post-card { padding: 1rem; }
  .post-card h3 { font-size: 1rem; }
  
  .list-page { padding: 2rem 1rem 3rem; }
  .list-header h1 { font-size: 1.75rem; }
  
  .article { padding: 1.5rem 1rem 3rem; }
  .article-header h1 { font-size: 1.5rem; }
  .article-header { margin-bottom: 1.5rem; padding-bottom: 1rem; }
  .article-meta { font-size: 0.75rem; flex-wrap: wrap; }
  
  .article-content { font-size: 0.9375rem; line-height: 1.75; }
  .article-content h2 { font-size: 1.375rem; margin: 1.5rem 0 0.5rem; }
  .article-content h3 { font-size: 1.125rem; }
  .article-content p { margin-bottom: 0.875rem; }
  .article-content ul, .article-content ol { margin-left: 1.25rem; }
  
  /* Code blocks on mobile - full width with smaller text */
  .article-content pre {
    margin: 1rem -1rem;
    border-radius: 0;
    padding: 1rem;
    font-size: 0.75rem;
    line-height: 1.55;
    border-left: none;
    border-right: none;
  }
  .article-content code { font-size: 0.8125em; }

  /* Tables on mobile - scrollable */
  .article-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.8125rem;
    white-space: nowrap;
  }
  .article-content th, .article-content td {
    padding: 0.5rem 0.625rem;
  }

  /* Blockquote on mobile */
  .article-content blockquote {
    margin: 1rem 0;
    padding: 0.625rem 0.75rem 0.625rem 1rem;
  }

  /* Article nav - stack vertically */
  .article-nav {
    flex-direction: column;
    gap: 0.5rem;
  }
  .article-nav a { max-width: 100%; font-size: 0.8125rem; }
  
  .site-footer { padding: 1.5rem 0; font-size: 0.75rem; }
}

/* Small phones */
@media (max-width: 480px) {
  .hero-title { font-size: 1.875rem; }
  .hero-subtitle { font-size: 0.9375rem; }
  .article-content { font-size: 0.875rem; }
  .article-header h1 { font-size: 1.25rem; }
  .article-content h2 { font-size: 1.25rem; }
  .article-content pre { font-size: 0.6875rem; padding: 0.875rem; }
}
