/* ==========================================================================
   style.css — blog.adarshd.dev
   Letterpress Refined: warm editorial design with serif headings.
   ========================================================================== */

/* ==========================================================================
   1. Theme Variables
   ========================================================================== */

:root {
  /* Light theme (default) */
  --bg: #faf9f6;
  --bg-secondary: #f5f3ee;
  --bg-tertiary: #eee9e0;
  --bg-hover: #f0ece6;
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #999;
  --text-faint: #bbb;
  --accent: #1a1a1a;
  --accent-hover: #000;
  --link: #2a6496;
  --link-hover: #1a4a6a;
  --border: #e8e4de;
  --border-light: #f0ece6;
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --radius: 6px;

  --tag-bg: #f0ece6;
  --tag-text: #777;
  --tag-border: #e0dcd5;

  --code-bg: #f5f3ee;
  --code-text: #3a3a3a;
  --code-border: #e8e4de;

  --section-color: #b08830;

  --callout-info-bg: #edf4fb;
  --callout-info-border: #3b82f6;
  --callout-info-text: #1e40af;
  --callout-tip-bg: #edf7f0;
  --callout-tip-border: #22c55e;
  --callout-tip-text: #15803d;
  --callout-warning-bg: #fdf6e8;
  --callout-warning-border: #d4a017;
  --callout-warning-text: #7a5a10;
  --callout-danger-bg: #fdf0f0;
  --callout-danger-border: #ef4444;
  --callout-danger-text: #991b1b;

  --header-bg: #faf9f6;
  --header-border: #e8e4de;
  --footer-border: #e8e4de;

  /* Syntax — light */
  --syn-keyword: #8b3e6f;
  --syn-function: #2a6496;
  --syn-string: #5a7a40;
  --syn-comment: #999;
  --syn-number: #7a6520;
  --syn-punctuation: #888;
  --syn-operator: #666;

  --transition: 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0b;
    --bg-secondary: #111110;
    --bg-tertiary: #181816;
    --bg-hover: #141412;
    --text: #d4d0c8;
    --text-secondary: #888;
    --text-muted: #555;
    --text-faint: #333;
    --accent: #d4d0c8;
    --accent-hover: #fff;
    --link: #7aaacc;
    --link-hover: #9ac0dd;
    --border: #1a1a18;
    --border-light: #141412;
    --shadow: none;

    --tag-bg: transparent;
    --tag-text: #444;
    --tag-border: #1a1a18;

    --code-bg: #0d0d0b;
    --code-text: #a0b0a0;
    --code-border: #1a1a18;

    --section-color: #8a6a20;

    --callout-info-bg: rgba(59,130,246,0.06);
    --callout-info-border: #2a4a6a;
    --callout-info-text: #6a9fca;
    --callout-tip-bg: rgba(34,197,94,0.06);
    --callout-tip-border: #2a5a3a;
    --callout-tip-text: #5a9a6a;
    --callout-warning-bg: rgba(214,160,23,0.06);
    --callout-warning-border: #5a4a2a;
    --callout-warning-text: #aa8a4a;
    --callout-danger-bg: rgba(239,68,68,0.06);
    --callout-danger-border: #5a2a2a;
    --callout-danger-text: #aa5a5a;

    --header-bg: #0c0c0b;
    --header-border: #1a1a18;
    --footer-border: #1a1a18;

    --syn-keyword: #c08070;
    --syn-function: #8ab0d0;
    --syn-string: #7a9a6a;
    --syn-comment: #555;
    --syn-number: #b0a070;
    --syn-punctuation: #666;
    --syn-operator: #888;
  }
}

[data-theme="light"] {
  --bg: #faf9f6;
  --bg-secondary: #f5f3ee;
  --bg-tertiary: #eee9e0;
  --bg-hover: #f0ece6;
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #999;
  --text-faint: #bbb;
  --accent: #1a1a1a;
  --accent-hover: #000;
  --link: #2a6496;
  --link-hover: #1a4a6a;
  --border: #e8e4de;
  --border-light: #f0ece6;
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --tag-bg: #f0ece6;
  --tag-text: #777;
  --tag-border: #e0dcd5;
  --code-bg: #f5f3ee;
  --code-text: #3a3a3a;
  --code-border: #e8e4de;
  --section-color: #b08830;
  --header-bg: #faf9f6;
  --header-border: #e8e4de;
  --footer-border: #e8e4de;
  --syn-keyword: #8b3e6f;
  --syn-function: #2a6496;
  --syn-string: #5a7a40;
  --syn-comment: #999;
  --syn-number: #7a6520;
  --syn-punctuation: #888;
  --syn-operator: #666;
  --callout-info-bg: #edf4fb;
  --callout-info-border: #3b82f6;
  --callout-info-text: #1e40af;
  --callout-tip-bg: #edf7f0;
  --callout-tip-border: #22c55e;
  --callout-tip-text: #15803d;
  --callout-warning-bg: #fdf6e8;
  --callout-warning-border: #d4a017;
  --callout-warning-text: #7a5a10;
  --callout-danger-bg: #fdf0f0;
  --callout-danger-border: #ef4444;
  --callout-danger-text: #991b1b;
}

[data-theme="dark"] {
  --bg: #0c0c0b;
  --bg-secondary: #111110;
  --bg-tertiary: #181816;
  --bg-hover: #141412;
  --text: #d4d0c8;
  --text-secondary: #888;
  --text-muted: #555;
  --text-faint: #333;
  --accent: #d4d0c8;
  --accent-hover: #fff;
  --link: #7aaacc;
  --link-hover: #9ac0dd;
  --border: #1a1a18;
  --border-light: #141412;
  --shadow: none;
  --tag-bg: transparent;
  --tag-text: #444;
  --tag-border: #1a1a18;
  --code-bg: #0d0d0b;
  --code-text: #a0b0a0;
  --code-border: #1a1a18;
  --section-color: #8a6a20;
  --header-bg: #0c0c0b;
  --header-border: #1a1a18;
  --footer-border: #1a1a18;
  --syn-keyword: #c08070;
  --syn-function: #8ab0d0;
  --syn-string: #7a9a6a;
  --syn-comment: #555;
  --syn-number: #b0a070;
  --syn-punctuation: #666;
  --syn-operator: #888;
  --callout-info-bg: rgba(59,130,246,0.06);
  --callout-info-border: #2a4a6a;
  --callout-info-text: #6a9fca;
  --callout-tip-bg: rgba(34,197,94,0.06);
  --callout-tip-border: #2a5a3a;
  --callout-tip-text: #5a9a6a;
  --callout-warning-bg: rgba(214,160,23,0.06);
  --callout-warning-border: #5a4a2a;
  --callout-warning-text: #aa8a4a;
  --callout-danger-bg: rgba(239,68,68,0.06);
  --callout-danger-border: #5a2a2a;
  --callout-danger-text: #aa5a5a;
}

/* ==========================================================================
   2. Reset & Base
   ========================================================================== */

*, *::before, *::after { box-sizing:border-box; margin:0; padding:0; }
html { font-size:16px; scroll-behavior:smooth; -webkit-text-size-adjust:100%; }

body {
  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration:none; transition:color var(--transition); }
a:hover { color: var(--link-hover); }
img { max-width:100%; height:auto; display:block; }
ul, ol { list-style:none; }
button { cursor:pointer; border:none; background:none; font-family:inherit; font-size:inherit; }
::selection { background-color: var(--link); color:#fff; }

/* ==========================================================================
   3. Site Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  backdrop-filter: blur(8px);
}

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

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  transition: border-color var(--transition);
}
.header-avatar:hover { border-color: var(--text-muted); }

.header-title {
  font-family: 'Literata', Georgia, serif;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.header-title:hover { color: var(--text); }

.header-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-nav-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.header-nav-link:hover { color: var(--text); }
.header-nav-link.active { color: var(--text); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-search-btn,
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8125rem;
  transition: all var(--transition);
}
.header-search-btn:hover,
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 1rem;
  transition: color var(--transition);
}
.hamburger:hover { color: var(--text); }

/* ==========================================================================
   4. Mobile Menu
   ========================================================================== */

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.mobile-overlay.active { display:block; opacity:1; }

.mobile-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
}
.mobile-menu.open { transform: translateX(0); }

.mobile-menu-inner { padding: 16px 20px; }

.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.mobile-menu-title {
  font-family: 'Literata', serif;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}
.mobile-menu-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1rem;
  border-radius: 4px;
  transition: all var(--transition);
}
.mobile-menu-close:hover { color: var(--text); background: var(--bg-hover); }

.mobile-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition);
}
.mobile-nav-link i { width: 16px; text-align: center; font-size: 0.8125rem; }
.mobile-nav-link:hover { color: var(--text); background: var(--bg-hover); }
.mobile-nav-link.active { color: var(--text); background: var(--bg-secondary); }

.mobile-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.mobile-profile { text-align: center; padding: 8px 0; }
.mobile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  margin: 0 auto 8px;
}
.mobile-name { font-size: 0.875rem; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.mobile-bio { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 10px; }
.mobile-book {
  display: inline-block;
  font-size: 0.6875rem;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  text-decoration: none;
  transition: all var(--transition);
}
.mobile-book i { margin-right: 3px; font-size: 0.625rem; }
.mobile-book:hover { color: var(--text); border-color: var(--text-muted); }

.mobile-social {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 4px 0;
}
.mobile-social a {
  color: var(--text-muted);
  font-size: 1rem;
  transition: color var(--transition);
  text-decoration: none;
}
.mobile-social a:hover { color: var(--text); }

/* ==========================================================================
   5. Search Overlay
   ========================================================================== */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.5);
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  backdrop-filter: blur(2px);
  display: none;
}
.search-overlay.active {
  display: flex;
}

.search-overlay-inner {
  width: 100%;
  max-width: 560px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
  overflow: hidden;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 14px 3rem 14px 2.75rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
}
.search-input::placeholder { color: var(--text-faint); }

.search-kbd {
  position: absolute;
  right: 14px;
  font-family: inherit;
  font-size: 0.6875rem;
  color: var(--text-faint);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}

.search-results {
  max-height: 360px;
  overflow-y: auto;
}

.search-result-item {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-hover); }
.search-result-title { font-size: 0.875rem; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.search-result-title mark { background: rgba(42,100,150,0.15); color: var(--link); border-radius: 2px; padding: 0 1px; }
.search-result-meta { font-size: 0.7rem; color: var(--text-muted); }
.search-result-section { text-transform: uppercase; font-weight: 600; font-size: 0.6rem; letter-spacing: 0.05em; }
.search-no-results { padding: 1.5rem 1rem; text-align: center; color: var(--text-muted); font-size: 0.875rem; }

/* ==========================================================================
   6. Layout
   ========================================================================== */

.layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
  min-height: calc(100vh - 120px);
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 32px 0;
}

/* ==========================================================================
   7. Right Sidebar
   ========================================================================== */

.right-sidebar {
  width: 320px;
  flex-shrink: 0;
  padding: 32px 0 32px 36px;
  border-left: 1px solid var(--border-light);
}

.right-sidebar-inner {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.right-sidebar-inner::-webkit-scrollbar { width: 3px; }
.right-sidebar-inner::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.aside-heading {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.aside-avatar {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  margin-bottom: 12px;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.aside-avatar:hover {
  transform: scale(1.05);
  border-color: var(--text-muted);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.aside-name {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.aside-bio {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.6;
}

.aside-book {
  display: inline-block;
  font-size: 0.75rem;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  text-decoration: none;
  transition: all var(--transition);
}
.aside-book i { margin-right: 3px; font-size: 0.5625rem; }
.aside-book:hover { color: var(--text); border-color: var(--text-muted); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 5px; }

.sections-nav { display: flex; flex-direction: column; gap: 3px; }

.section-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition);
}
.section-card:hover { color: var(--text-secondary); background: var(--bg-hover); }
.section-card i { font-size: 0.7rem; width: 14px; text-align: center; }
.section-count { margin-left: auto; font-size: 0.625rem; color: var(--text-faint); }

.subscribe-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 4px 0;
  transition: color var(--transition);
  text-decoration: none;
}
.subscribe-link:hover { color: var(--text-secondary); }
.subscribe-link i { font-size: 0.625rem; color: #7a4a00; }

/* ==========================================================================
   8. Section Tabs
   ========================================================================== */

.section-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.section-tabs::-webkit-scrollbar { display: none; }

.section-tab {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 0 0 8px;
  margin-right: 20px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: all var(--transition);
  text-decoration: none;
  font-weight: 500;
}
.section-tab:hover { color: var(--text-secondary); }
.section-tab.active { color: var(--text); border-bottom-color: var(--text); }

/* ==========================================================================
   9. Post Cards (list view)
   ========================================================================== */

.post-card {
  padding: 18px 0;
  border-bottom: 1px solid var(--border-light);
}
.post-card:last-child { border-bottom: none; }

.post-card-sections {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--section-color);
  margin-bottom: 4px;
}

.post-card-title {
  font-family: 'Literata', Georgia, serif;
  font-size: 1.1875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 5px;
  letter-spacing: -0.01em;
}
.post-card-title a { color: inherit; text-decoration: none; transition: color var(--transition); }
.post-card-title a:hover { color: var(--text-secondary); }

.post-card-excerpt {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.post-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

/* ==========================================================================
   10. Tags
   ========================================================================== */

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 3px 9px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--tag-border);
  border-radius: 99px;
  text-decoration: none;
  transition: all var(--transition);
}
.tag-pill:hover { color: var(--text); border-color: var(--text-muted); }
.tag-count { font-size: 0.6rem; opacity: 0.6; }

/* ==========================================================================
   11. Post Detail
   ========================================================================== */

.post-header { margin-bottom: 32px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }

.post-sections-badge { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }

.section-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--section-color);
  text-decoration: none;
}

.post-title {
  font-family: 'Literata', Georgia, serif;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-faint);
  flex-wrap: wrap;
}

.separator { color: var(--text-faint); }
.separator::before { content: "\00b7"; }

/* Post content */
.post-content {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-secondary);
  max-width: 800px;
}
.post-content p { margin-bottom: 1.25rem; }

.post-content h2 {
  font-family: 'Literata', Georgia, serif;
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
  line-height: 1.3;
  letter-spacing: -0.01em;
  scroll-margin-top: 80px;
}
.post-content h3 {
  font-family: 'Literata', Georgia, serif;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.625rem;
  line-height: 1.35;
  scroll-margin-top: 80px;
}
.post-content h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.post-content h2 a, .post-content h3 a, .post-content h4 a { color: inherit; text-decoration: none; }
.post-content h2 a:hover, .post-content h3 a:hover { color: var(--link); }

.post-content a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: rgba(42,100,150,0.25);
  text-underline-offset: 3px;
  transition: all var(--transition);
}
.post-content a:hover { text-decoration-color: var(--link); }

.post-content ul, .post-content ol { list-style: revert; padding-left: 1.5rem; margin-bottom: 1.25rem; }
.post-content li { margin-bottom: 0.375rem; }
.post-content li p { margin-bottom: 0.25rem; }

.post-content blockquote {
  border-left: 3px solid var(--border);
  padding: 12px 18px;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--bg-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.post-content blockquote p:last-child { margin-bottom: 0; }

.post-content table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.875rem; overflow-x: auto; display: block; }
.post-content thead { background: var(--bg-secondary); }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; }
.post-content th { font-weight: 600; color: var(--text); font-size: 0.8rem; }
.post-content td { color: var(--text-secondary); }

.post-content img { border-radius: var(--radius); margin: 1.5rem auto; }
.post-content hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

.post-content code:not([class]) {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.875em;
  background: var(--bg-secondary);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 3px;
}

.post-footer { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ==========================================================================
   12. Code Blocks
   ========================================================================== */

pre[class*="language-"] {
  background: var(--code-bg) !important;
  color: var(--code-text);
  padding: 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.84rem;
  line-height: 1.6;
  border: 1px solid var(--code-border);
  position: relative;
}

code[class*="language-"] { font-family: 'IBM Plex Mono', monospace; font-size: inherit; background: none !important; padding: 0; color: inherit; }
code { font-family: 'IBM Plex Mono', monospace; }

.copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-secondary);
  color: var(--text-faint);
  border-radius: 4px;
  font-size: 0.7rem;
  transition: all var(--transition);
  border: 1px solid var(--border);
}
.copy-code-btn:hover { background: var(--bg-tertiary); color: var(--text-muted); }

/* Syntax tokens */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--syn-comment); }
.token.punctuation { color: var(--syn-punctuation); }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol { color: var(--syn-number); }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin { color: var(--syn-string); }
.token.operator, .token.entity, .token.url { color: var(--syn-operator); }
.token.atrule, .token.attr-value, .token.keyword { color: var(--syn-keyword); }
.token.function, .token.class-name { color: var(--syn-function); }
.token.regex, .token.important, .token.variable { color: var(--syn-number); }

/* ==========================================================================
   13. Callouts
   ========================================================================== */

blockquote.prompt-info, blockquote.prompt-tip, blockquote.prompt-warning, blockquote.prompt-danger {
  padding: 12px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
  font-style: normal;
}
blockquote.prompt-info { border-left: 3px solid var(--callout-info-border); background: var(--callout-info-bg); color: var(--callout-info-text); }
blockquote.prompt-tip { border-left: 3px solid var(--callout-tip-border); background: var(--callout-tip-bg); color: var(--callout-tip-text); }
blockquote.prompt-warning { border-left: 3px solid var(--callout-warning-border); background: var(--callout-warning-bg); color: var(--callout-warning-text); }
blockquote.prompt-danger { border-left: 3px solid var(--callout-danger-border); background: var(--callout-danger-bg); color: var(--callout-danger-text); }

blockquote.prompt-info p, blockquote.prompt-tip p, blockquote.prompt-warning p, blockquote.prompt-danger p { margin-bottom: 0.5rem; }
blockquote.prompt-info p:last-child, blockquote.prompt-tip p:last-child, blockquote.prompt-warning p:last-child, blockquote.prompt-danger p:last-child { margin-bottom: 0; }

/* ==========================================================================
   14. Site Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--footer-border);
  background: var(--bg);
  margin-top: 2rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 32px;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.footer-social {
  display: flex;
  gap: 16px;
}
.footer-social a {
  color: var(--text-muted);
  font-size: 1rem;
  text-decoration: none;
  transition: color var(--transition);
}
.footer-social a:hover { color: var(--text); }

.footer-center { display: flex; align-items: center; justify-content: center; }

.footer-psf { opacity: 0.5; transition: opacity var(--transition); display: block; }
.footer-psf:hover { opacity: 0.85; }
.footer-psf-img { width: 96px; height: auto; border-radius: 4px; }

.footer-license {
  display: flex;
  align-items: center;
  gap: 8px;
}
.footer-cc {
  display: flex;
  gap: 3px;
  color: var(--text-faint);
  font-size: 0.875rem;
  text-decoration: none;
  transition: color var(--transition);
}
.footer-cc:hover { color: var(--text-muted); }
.footer-copy { color: var(--text-faint); font-size: 0.6875rem; }

/* ==========================================================================
   15. TOC
   ========================================================================== */

.toc-list { display: flex; flex-direction: column; border-left: 1px solid var(--border); }

.toc-link {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 4px 0 4px 12px;
  border-left: 1px solid transparent;
  margin-left: -1px;
  line-height: 1.4;
  text-decoration: none;
  transition: all var(--transition);
}
.toc-link:hover { color: var(--text-secondary); }
.toc-link.active { color: var(--text); border-left-color: var(--text); font-weight: 500; }
.toc-h3 { padding-left: 24px; font-size: 0.72rem; }

/* Mobile TOC */
.toc-mobile { display: none; margin: 0 0 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; position: sticky; top: 52px; z-index: 50; background: var(--bg); }
.toc-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 10px 14px;
  background: var(--bg-secondary); color: var(--text);
  font-size: 0.8125rem; font-weight: 600;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition); text-align: left;
}
.toc-toggle::after { content: "\f078"; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 0.625rem; color: var(--text-muted); transition: transform var(--transition); }
.toc-toggle.open::after { transform: rotate(180deg); }
.toc-mobile-content { display: none; flex-direction: column; padding: 4px 0; background: var(--bg); }
.toc-mobile-content.open { display: flex; }
.toc-mobile-content .toc-link { padding: 6px 14px; font-size: 0.8125rem; border-left: none; border-bottom: 1px solid var(--border-light); }
.toc-mobile-content .toc-link:last-child { border-bottom: none; }
.toc-mobile-content .toc-h3 { padding-left: 2rem; }

/* ==========================================================================
   16. Pagination
   ========================================================================== */

.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 2rem 0 1rem; flex-wrap: wrap; }
.pagination-pages { display: flex; align-items: center; gap: 4px; }
.pagination-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 5px;
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text-muted); border: 1px solid var(--border);
  background: var(--bg); transition: all var(--transition); text-decoration: none;
}
.pagination-link:hover { color: var(--text); border-color: var(--text-muted); }
.pagination-link.active { color: var(--text); border-color: var(--text); font-weight: 600; }

/* ==========================================================================
   17. Page Layout
   ========================================================================== */

.page { padding: 0.5rem 0; }
.page-header { margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.page-title {
  font-family: 'Literata', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-content { font-size: 1rem; line-height: 1.8; color: var(--text-secondary); }
.page-content p { margin-bottom: 1.25rem; }
.page-content h2 { font-family: 'Literata', Georgia, serif; font-size: 1.25rem; font-weight: 600; margin-top: 2rem; margin-bottom: 0.75rem; color: var(--text); }
.page-content h3 { font-size: 1.1rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.625rem; color: var(--text); }
.page-content ul, .page-content ol { list-style: revert; padding-left: 1.5rem; margin-bottom: 1.25rem; }
.page-content li { margin-bottom: 0.375rem; }
.page-content > p a, .page-content > ul a, .page-content > ol a { color: var(--link); text-decoration: underline; }
.page-content a { color: inherit; text-decoration: none; }

/* ==========================================================================
   18. Section, Archives, Categories, Tags pages
   ========================================================================== */

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.section-title { font-family: 'Literata', Georgia, serif; font-size: 1.25rem; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.section-feed { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--text-muted); text-decoration: none; }
.section-feed:hover { color: #7a4a00; }
.section-feed i { font-size: 0.625rem; }

.archives { padding: 0.5rem 0; }
.archives-year {
  font-family: 'Literata', Georgia, serif;
  font-size: 1rem; font-weight: 600; color: var(--text);
  margin: 2rem 0 0.75rem; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.archives-year:first-child { margin-top: 0; }
.archives-list { display: flex; flex-direction: column; }
.archives-item {
  display: flex; align-items: baseline; gap: 1rem;
  padding: 6px 0; border-bottom: 1px solid var(--border-light); font-size: 0.875rem;
}
.archives-item:last-child { border-bottom: none; }
.archives-date { font-size: 0.7rem; color: var(--text-faint); white-space: nowrap; flex-shrink: 0; font-variant-numeric: tabular-nums; min-width: 6rem; }
.archives-title { color: var(--text); text-decoration: none; line-height: 1.4; transition: color var(--transition); }
.archives-title:hover { color: var(--link); }

/* Category Tree */
.category-tree { display: flex; flex-direction: column; gap: 10px; }

.category-branch {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.category-branch:hover { border-color: var(--text-faint); box-shadow: var(--shadow); }

.category-branch-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-secondary);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 600;
  transition: all var(--transition);
}
.category-branch-header:hover { background: var(--bg-tertiary); color: var(--link); }
.category-branch-header i { color: var(--section-color); font-size: 0.9375rem; width: 20px; text-align: center; }
.category-branch-name { flex: 1; }
.category-branch-count {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

.category-branch-posts {
  display: flex;
  flex-direction: column;
  position: relative;
}
.category-branch-posts::before {
  content: "";
  position: absolute;
  left: 26px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.category-branch-post {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 18px 9px 46px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8125rem;
  transition: all var(--transition);
  position: relative;
}
.category-branch-post::before {
  content: "";
  position: absolute;
  left: 26px;
  top: 50%;
  width: 12px;
  height: 1px;
  background: var(--border);
}
.category-branch-post:hover { background: var(--bg-hover); color: var(--link); }
.category-branch-post-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-branch-post-date { font-size: 0.6875rem; color: var(--text-faint); white-space: nowrap; flex-shrink: 0; }

/* Tags Grid */
.tags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.tag-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all var(--transition);
  text-align: center;
}
.tag-card:hover { border-color: var(--text-faint); background: var(--bg-hover); box-shadow: var(--shadow); }
.tag-card-name { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.tag-card-count { font-size: 0.6875rem; color: var(--text-muted); }

/* Legacy tag cloud page (fallback) */
.tag-cloud-page { padding: 1rem 0; }
.tag-cloud-page .tag-pill { font-size: 0.8rem; padding: 4px 10px; }

/* ==========================================================================
   19. Comments
   ========================================================================== */

.comments-section { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.comments-heading { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 1rem; }

/* ==========================================================================
   20. Utilities
   ========================================================================== */

body.nav-open { overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0; }
.no-posts { color: var(--text-muted); font-style: italic; padding: 3rem 0; text-align: center; }
.page-description, .section-description { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 1.5rem; line-height: 1.6; }

.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 1.5rem; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; transition: color var(--transition); }
.breadcrumb a:hover { color: var(--link); }
.breadcrumb-sep { color: var(--text-faint); }

.tag-page-heading { font-family: 'Literata', Georgia, serif; font-size: 1.375rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.tag-page-count { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 2rem; }

.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 1.5rem; text-decoration: none; transition: color var(--transition); }
.back-link:hover { color: var(--link); }

.error-page { text-align: center; padding: 4rem 1rem; }
.error-code { font-family: 'Literata', Georgia, serif; font-size: 4rem; font-weight: 800; color: var(--text); line-height: 1; margin-bottom: 8px; }
.error-title { font-size: 1.25rem; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.error-description { color: var(--text-muted); margin-bottom: 2rem; }

.post-updated { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; color: var(--text-muted); font-style: italic; }

/* ==========================================================================
   21. Responsive — Tablet
   ========================================================================== */

@media (max-width: 1024px) {
  .header-nav { display: none; }
  .hamburger { display: flex; }
  .right-sidebar { display: none; }
  .main-content { padding: 24px 0; }
  .layout { padding: 0 20px; }
  .header-inner { padding: 12px 20px; }
  .footer-inner { padding: 16px 20px; }
  .toc-mobile { display: block; }
}

/* ==========================================================================
   22. Responsive — Mobile
   ========================================================================== */

@media (max-width: 768px) {
  .layout { padding: 0 16px; }
  .header-inner { padding: 10px 16px; }
  .footer-inner { padding: 14px 16px; flex-wrap: wrap; gap: 12px; justify-content: center; flex-direction: column; align-items: center; }
  .footer-social { order: 1; }
  .footer-center { order: 2; }
  .footer-psf-img { width: 96px; }
  .footer-psf { opacity: 0.7; }
  .footer-license { order: 3; }
  .main-content { padding: 20px 0; }
  .post-title { font-size: 1.375rem; }
  .section-tab { padding: 0 0 6px; margin-right: 14px; font-size: 0.75rem; }
  .post-content h2 { font-size: 1.2rem; }
  .post-content h3 { font-size: 1rem; }
  pre[class*="language-"] { font-size: 0.78rem; padding: 14px; }
  .toc-mobile { display: block; }
  .pagination-link { padding: 4px 8px; font-size: 0.75rem; }
  .archives-item { flex-direction: column; gap: 2px; }
  .archives-date { min-width: unset; }
  .search-overlay-inner { margin: 0 16px; border-radius: 8px; }
  .post-card { padding: 14px 0; }
  .mobile-menu { width: 260px; }
}
