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

:root {
  --bg: #fafaf9;
  --bg-card: #ffffff;
  --bg-secondary: #f3f2ef;
  --bg-tertiary: #e8e6e1;
  --text: #1a1a1a;
  --text-secondary: #555550;
  --text-muted: #8c8c84;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --border: #e5e4e0;
  --border-light: #edece8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 0 3px rgba(37,99,235,0.12);
  --green: #16a34a;
  --purple: #7c3aed;
  --orange: #ea580c;
  --pink: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --content-width: 720px;
  --container-width: 1280px;
  --sidebar-width: 250px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

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

/* Layout */
.site-container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 2rem;
}

/* ============================================
   HEADER
   ============================================ */
.site-header {
  position: sticky;
  top: 0;
  background: rgba(250, 250, 249, 0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 0;
  z-index: 100;
}

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

.site-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

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

.site-logo {
  font-size: 1.5rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-stat {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-weight: 500;
}

/* ============================================
   HOME PAGE LAYOUT
   ============================================ */
main {
  padding: 1.5rem 0;
  min-height: calc(100vh - 150px);
}

.home-page {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 2.5rem;
  align-items: start;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.sidebar::-webkit-scrollbar {
  width: 3px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-left: 0.75rem;
}

.sidebar-category {
  margin-bottom: 0.25rem;
}

.sidebar-category-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.sidebar-category-header:hover {
  background: var(--bg-secondary);
  color: var(--accent);
}

.sidebar-category-header .icon {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
}

.sidebar-count {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  min-width: 1.25rem;
  text-align: center;
}

.sidebar-links {
  list-style: none;
  margin-top: 0.125rem;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.sidebar-category.collapsed .sidebar-links {
  max-height: 0;
  margin: 0;
}

.sidebar-link {
  display: block;
  padding: 0.3rem 0.75rem 0.3rem 2.25rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.sidebar-link::before {
  content: '';
  position: absolute;
  left: 1.25rem;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--border);
  transform: translateY(-50%);
  transition: background var(--transition);
}

.sidebar-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.sidebar-link:hover::before {
  background: var(--accent);
}

/* ============================================
   FILTER BAR
   ============================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.filter-btn.active:hover {
  background: var(--accent-hover);
  color: white;
  transform: translateY(-1px);
}

.filter-icon {
  font-size: 0.9rem;
}

.filter-count {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.6;
  margin-left: 0.125rem;
}

.filter-btn.active .filter-count {
  opacity: 0.85;
}

/* ============================================
   CATEGORY SECTIONS
   ============================================ */
.category-section {
  margin-bottom: 2.5rem;
  animation: fadeSlideIn 0.4s ease forwards;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition);
}

.category-header:hover {
  border-bottom-color: var(--accent);
}

.category-label {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.category-icon {
  font-size: 1.375rem;
}

.category-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  transition: color var(--transition);
}

.category-header:hover .category-name {
  color: var(--accent);
}

.category-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}

/* ============================================
   CARD GRID
   ============================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

/* ============================================
   ENTRY CARD
   ============================================ */
.entry-card {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
  height: 88px;
  animation: fadeSlideIn 0.4s ease both;
}

.entry-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md), var(--shadow-glow);
  text-decoration: none;
  transform: translateY(-2px);
}

.card-image-wrapper {
  flex-shrink: 0;
  width: 112px;
  height: 88px;
  overflow: hidden;
  background: var(--bg-secondary);
  position: relative;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.entry-card:hover .card-image {
  transform: scale(1.08);
}

/* Placeholder gradients per category */
.card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
}

.card-placeholder[data-category="AI Education"] {
  background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
}

.card-placeholder[data-category="Claude Code"] {
  background: linear-gradient(135deg, #fce7f3 0%, #ede9fe 100%);
}

.card-placeholder[data-category="Skills & Plugins"] {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.card-placeholder[data-category="AI Research"] {
  background: linear-gradient(135deg, #d1fae5 0%, #cffafe 100%);
}

.card-placeholder[data-category="Programming"] {
  background: linear-gradient(135deg, #e0e7ff 0%, #ddd6fe 100%);
}

.card-content {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.375rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.01em;
}

.entry-card:hover .card-title {
  color: var(--accent);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.card-tag {
  padding: 0.15rem 0.5rem;
  background: var(--bg-secondary);
  border-radius: 4px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state code {
  background: var(--bg-secondary);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* ============================================
   ENTRY PAGE
   ============================================ */
.entry-container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding-bottom: 4rem;
}

.entry-cover-wrapper {
  margin: -1.5rem -1.5rem 2rem;
  width: calc(100% + 3rem);
  max-height: 380px;
  overflow: hidden;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

@media (min-width: 768px) {
  .entry-cover-wrapper {
    margin: -1.5rem calc(-50vw + 360px) 2rem;
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
  }
}

.entry-cover {
  width: 100%;
  height: 100%;
  max-height: 380px;
  object-fit: cover;
}

.entry-header {
  margin-bottom: 2rem;
}

.entry-title {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.entry-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.8rem;
}

.meta-category {
  background: var(--accent);
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 500;
}

.meta-date {
  color: var(--text-muted);
}

.meta-tag {
  background: var(--bg-secondary);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  color: var(--text-secondary);
}

/* ============================================
   ENTRY CONTENT
   ============================================ */
.entry-content {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
}

.entry-content h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  margin: 2.5rem 0 0.875rem;
  padding-bottom: 0.375rem;
  border-bottom: 2px solid var(--border);
  color: var(--text);
  letter-spacing: -0.02em;
}

.entry-content h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
  color: var(--text);
}

.entry-content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.375rem;
  color: var(--text);
}

.entry-content p {
  margin-bottom: 1rem;
}

.entry-content ul, .entry-content ol {
  margin: 0.75rem 0 1.25rem 1.5rem;
}

.entry-content li {
  margin-bottom: 0.375rem;
}

.entry-content strong {
  color: var(--text);
  font-weight: 600;
}

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

.entry-content code {
  background: var(--bg-secondary);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--pink);
}

.entry-content pre {
  background: #1e1e2e;
  border: 1px solid #313244;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.entry-content pre code {
  padding: 0;
  background: none;
  color: #cdd6f4;
  font-size: 0.82rem;
  line-height: 1.6;
}

.entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.9rem;
}

.entry-content th, .entry-content td {
  padding: 0.625rem 0.875rem;
  text-align: left;
  border: 1px solid var(--border);
}

.entry-content th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text);
}

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

.entry-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1rem 0;
}

.entry-content a {
  text-decoration: underline;
  text-decoration-color: rgba(37, 99, 235, 0.3);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition);
}

.entry-content a:hover {
  text-decoration-color: var(--accent);
}

/* ============================================
   RELATED ENTRIES
   ============================================ */
.related-section {
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 2px solid var(--border);
}

.related-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.875rem;
  color: var(--text-secondary);
}

.related-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.related-link {
  background: var(--bg-card);
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all var(--transition);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
}

.related-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  .home-page {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    padding-right: 0;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-category {
    display: inline-block;
    margin-right: 0.375rem;
    margin-bottom: 0.375rem;
  }

  .sidebar-links {
    display: none;
  }

  .sidebar-category-header {
    padding: 0.375rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
  }

  .sidebar-count {
    display: none;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    padding: 0.75rem 1rem;
  }
}

@media (max-width: 600px) {
  .site-container {
    padding: 0 1rem;
  }

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

  .entry-cover-wrapper {
    margin: -1.5rem -1rem 1.5rem;
    width: calc(100% + 2rem);
  }

  .entry-card {
    height: 76px;
  }

  .card-image-wrapper {
    width: 88px;
    height: 76px;
  }

  .card-content {
    padding: 0.5rem 0.75rem;
  }

  .card-title {
    font-size: 0.8rem;
  }

  .filter-bar {
    gap: 0.375rem;
  }

  .filter-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
  }
}
