/* ==========================================================================
   Pure Compact - Elegant, Compact, Full-width CSS Theme
   ========================================================================== */

/* Google Fonts - Elegant, modern sans-serif */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Font Families */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Global transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  /* Light Theme Variables (Simple, Elegant, No Gradients) */
  --bg-primary: #ffffff;
  --bg-sidebar: #f8fafc;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --accent-color: #0f172a; /* Slate 900 for Light Accent */
  --accent-hover: #334155;
  --selection-bg: #e2e8f0;
  --tag-bg: #f1f5f9;
  --tag-text: #475569;
  --highlight-bg: #fef08a; /* Soft yellow for search highlight */
  --highlight-text: #0f172a;
}

/* Dark Theme Variables */
:root.dark {
  --bg-primary: #0f172a;
  --bg-sidebar: #0b0f19;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border-color: #334155;
  --accent-color: #f8fafc; /* Slate 50 for Dark Accent */
  --accent-hover: #cbd5e1;
  --selection-bg: #334155;
  --tag-bg: #1e293b;
  --tag-text: #cbd5e1;
  --highlight-bg: #ca8a04; /* Darker gold for dark mode search highlight */
  --highlight-text: #ffffff;
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px; /* Global 4px border radius */
}

/* Button & Inputs Global 4px Rounded */
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  border-radius: 4px !important; /* Global 4px round constraint */
  border: 1px solid var(--border-color);
  background-color: transparent;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

/* Grid & Layout Structure (Full screen width) */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Fixed Sidebar (Left Sidebar Menu) */
.sidebar {
  width: 280px;
  min-width: 280px;
  height: 100vh;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

/* Main Content Panel (Right Panel, Full remaining width) */
.main-content {
  flex-grow: 1;
  height: 100vh;
  overflow-y: auto;
  padding: 16px; /* Compact padding */
  display: flex;
  flex-direction: column;
}

/* Sidebar Top Section */
.sidebar-header {
  margin-bottom: 16px;
}

.site-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Search Box Layout - Compact */
.search-container {
  position: relative;
  width: 100%;
  margin-bottom: 16px;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  font-size: 13px;
  background-color: var(--bg-primary);
  border-color: var(--border-color);
}

.search-input:focus {
  border-color: var(--text-primary);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Sidebar Navigation - Dynamic Categories List */
.sidebar-nav {
  flex-grow: 1;
  overflow-y: auto;
  margin-bottom: 16px;
}

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px; /* Compact spacing */
}

.category-item a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 4px;
  color: var(--text-secondary);
}

.category-item a:hover, .category-item.active a {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.category-count {
  font-size: 11px;
  font-family: var(--font-mono);
  background-color: var(--tag-bg);
  color: var(--tag-text);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Sidebar Footer & Theme Toggle Button */
.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.theme-toggle-btn {
  width: 100%;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
  font-size: 13px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.theme-toggle-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.site-meta {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* --- Compact List Layout --- */
.posts-list {
  display: flex;
  flex-direction: column;
  gap: 12px; /* Smallest comfortable gap for high density */
  width: 100%;
}

.post-list-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  transition: border-color var(--transition-fast);
}

.post-list-item:hover {
  border-color: var(--text-primary);
}

.list-thumbnail-link {
  display: block;
  width: 220px;
  min-width: 220px;
  height: 140px;
}

.list-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-right: 1px solid var(--border-color);
  border-radius: 0;
}

.list-body {
  padding: 12px 16px; /* Compact padding */
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 8px;
  justify-content: center;
}

.list-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.list-title {
  font-size: 19px; /* Was 16px, now 19px for larger text */
  font-weight: 700;
  line-height: 1.35;
}

.list-title a:hover {
  color: var(--text-secondary);
}

.list-summary {
  font-size: 14.5px; /* Was 12.5px, now 14.5px for larger text */
  color: var(--text-secondary);
  line-height: 1.45;
  /* Multi-line ellipsis (2 lines max) */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.list-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.tag-badge {
  font-size: 11px;
  background-color: var(--tag-bg);
  color: var(--tag-text);
  padding: 2px 6px;
  border-radius: 4px;
}


/* --- Search Dynamic Snippet Styles --- */
.snippet-box {
  background-color: var(--bg-hover);
  border-left: 2px solid var(--text-muted);
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-secondary);
  border-radius: 4px;
  margin-top: 4px;
}

mark.highlight {
  background-color: var(--highlight-bg);
  color: var(--highlight-text);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 500;
}

/* --- Article Post Page Layout (post.html) --- */
.post-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.post-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.post-back-btn:hover {
  color: var(--text-primary);
}

.post-meta-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.post-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-main-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

/* Markdown Content Styling (Optimized for readability but compact) */
.post-body {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  width: 100%;
}

.post-body a {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.post-body a:hover {
  color: #1d4ed8;
}

:root.dark .post-body a {
  color: #60a5fa;
}

:root.dark .post-body a:hover {
  color: #93c5fd;
}

/* Grid image loops (1 or more images loop) */
.post-body p {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.post-body li {
  color: var(--text-secondary);
}

.post-body img {
  max-width: 100%;
  width: auto;
  height: auto;
  margin: 12px 0;
  border: 1px solid var(--border-color);
}

/* Custom layout for multiple adjacent images */
.post-body p:has(> img:nth-child(2)),
.post-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.post-image-grid img {
  margin: 0 !important;
}

/* Headings inside article */
.post-body h1, .post-body h2, .post-body h3, .post-body h4 {
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 24px;
  margin-bottom: 10px;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.post-body h2 {
  font-size: 20px;
  margin-top: 42px;
}
.post-body h3 { font-size: 17px; }

.post-body ul, .post-body ol {
  margin-left: 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.post-body blockquote {
  border-left: 3px solid var(--text-muted);
  padding-left: 12px;
  color: var(--text-secondary);
  font-style: italic;
  margin: 12px 0;
}

/* Code highlight style */
.post-body pre {
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.post-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background-color: var(--bg-sidebar);
  padding: 2px 4px;
  border-radius: 4px;
}

.post-body pre code {
  background-color: transparent;
  padding: 0;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.post-body th, .post-body td {
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  text-align: left;
}

.post-body th {
  background-color: var(--bg-sidebar);
  font-weight: 600;
}

/* Responsive Web Design (Mobile/Tablet tweaks) */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
    overflow-y: auto;
    height: auto;
  }

  .sidebar {
    width: 100%;
    height: auto;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 12px;
    position: relative;
  }

  .main-content {
    width: 100%;
    height: auto;
    overflow-y: visible;
    padding: 12px;
  }

  .posts-list {
    gap: 12px;
  }
}

@media (max-width: 576px) {
  .post-list-item {
    flex-direction: column;
  }

  .list-thumbnail-link {
    width: 100%;
    height: 180px;
    min-width: 100%;
  }

  .list-thumbnail {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
}
