/* ================================================================
   CP Club VJTI — Premium Blog Stylesheet
   Color Palette: #0a0f0a (bg), #00ff88 (accent green), #ffffff (text)
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ── CSS Variables ────────────────────────────────────────────── */
:root {
  --bg-primary: #0a0f0a;
  --bg-secondary: #0f1a0f;
  --bg-card: rgba(0, 255, 136, 0.04);
  --bg-card-hover: rgba(0, 255, 136, 0.08);
  --bg-sidebar: #0c140c;
  --accent: #00ff88;
  --accent-dim: #00cc6a;
  --accent-glow: rgba(0, 255, 136, 0.25);
  --accent-subtle: rgba(0, 255, 136, 0.1);
  --text-primary: #e8f5e9;
  --text-secondary: #8aab8a;
  --text-muted: #4a6a4a;
  --border: rgba(0, 255, 136, 0.15);
  --border-hover: rgba(0, 255, 136, 0.4);
  --navbar-height: 65px;
  --sidebar-width: 280px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-sans: 'Inter', sans-serif;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border);
  --shadow-glow: 0 0 20px var(--accent-glow);
}

[data-theme="light"] {
  --bg-primary: #f0f7f0;
  --bg-secondary: #e8f5e8;
  --bg-card: rgba(0, 150, 80, 0.05);
  --bg-card-hover: rgba(0, 150, 80, 0.1);
  --bg-sidebar: #e4f0e4;
  --accent: #007a42;
  --accent-dim: #005c31;
  --accent-glow: rgba(0, 122, 66, 0.2);
  --accent-subtle: rgba(0, 122, 66, 0.08);
  --text-primary: #0d1f0d;
  --text-secondary: #2a5a2a;
  --text-muted: #5a7a5a;
  --border: rgba(0, 122, 66, 0.2);
  --border-hover: rgba(0, 122, 66, 0.5);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.1), 0 0 0 1px var(--border);
  --shadow-glow: 0 0 20px var(--accent-glow);
}

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

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  transition: background-color var(--transition), color var(--transition);
}

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,255,136,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,255,136,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ── Navbar ───────────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-height);
  background: rgba(10, 15, 10, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 1000;
  gap: 16px;
  transition: background var(--transition);
}

[data-theme="light"] .navbar {
  background: rgba(240, 247, 240, 0.85);
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-logo img,
.navbar-logo svg {
  height: 40px;
  width: auto;
}

.navbar-logo-text {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.05em;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.navbar-logo-text span { color: var(--text-primary); font-size: 0.7rem; letter-spacing: 0.2em; }

.navbar-spacer { flex: 1; }

/* Search bar */
.navbar-search {
  position: relative;
  width: min(340px, 40vw);
}

.navbar-search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px 9px 40px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.navbar-search input::placeholder { color: var(--text-muted); }

.navbar-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

/* Search results dropdown */
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  max-height: 360px;
  overflow-y: auto;
  display: none;
  z-index: 2000;
}

.search-results.active { display: block; }

.search-result-item {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-card-hover); }

.search-result-item .result-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--accent);
}

.search-result-item .result-excerpt {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-item .result-tags {
  margin-top: 4px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.search-no-results {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  white-space: nowrap;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Hamburger (mobile) */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

/* ── Layout ───────────────────────────────────────────────────── */
.layout {
  display: flex;
  padding-top: var(--navbar-height);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: var(--navbar-height);
  height: calc(100vh - var(--navbar-height));
  overflow-y: auto;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  transition: transform var(--transition), background var(--transition);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-section-label {
  padding: 0 20px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-nav { list-style: none; }

.sidebar-nav li a {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 20px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  transition: color var(--transition), border-color var(--transition), background var(--transition), padding-left var(--transition);
  white-space: normal;
  overflow: visible;
}

.sidebar-nav li a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-subtle);
  padding-left: 24px;
}

.sidebar-nav li a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-subtle);
  font-weight: 600;
}

.sidebar-nav li a .nav-icon { font-size: 14px; flex-shrink: 0; }
.sidebar-nav li a > span:not(.nav-icon):not(.nav-num) {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.sidebar-nav li a .nav-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
  padding-top: 0.1rem;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 20px;
}

/* Tag filter in sidebar */
.sidebar-tags {
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Main Content ─────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px;
  max-width: 900px;
}

/* ── Tags / Pills ─────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform 0.15s;
  text-decoration: none;
  user-select: none;
}

.tag:hover, .tag.active {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* ── Cards (Blog listing) ─────────────────────────────────────── */
.blogs-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 32px;
}

.blog-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  display: block;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.blog-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.blog-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  transform: translateY(-2px);
}

.blog-card:hover::before { opacity: 1; }

.blog-card-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  margin-bottom: 8px;
  opacity: 0.7;
}

.blog-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  transition: color var(--transition);
}

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

.blog-card-excerpt {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.blog-card-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.blog-card-author {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.blog-card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* ── Page Header ──────────────────────────────────────────────── */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 12px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.page-header .accent-bar {
  width: 48px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 2px;
  margin-bottom: 16px;
}

/* ── Blog Post Content ────────────────────────────────────────── */
.post-header {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 16px;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.post-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.post-meta-item .icon { font-size: 12px; }
.post-meta-item.author { color: var(--accent); font-weight: 600; }

.post-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.post-body { max-width: 720px; color: var(--text-primary); }

/* Markdown rendered content */
.post-body h1, .post-body h2, .post-body h3, .post-body h4 {
  color: var(--text-primary);
  font-weight: 700;
  margin-top: 2em;
  margin-bottom: 0.75em;
  line-height: 1.3;
}

.post-body h1 { font-size: 1.9rem; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.post-body h2 { font-size: 1.5rem; color: var(--accent); }
.post-body h3 { font-size: 1.2rem; }

.post-body p { margin-bottom: 1.25em; }

.post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity var(--transition);
}
.post-body a:hover { opacity: 0.75; }

.post-body ul, .post-body ol {
  padding-left: 1.5em;
  margin-bottom: 1.25em;
}
.post-body li { margin-bottom: 0.4em; }

.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 20px;
  margin: 1.5em 0;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--accent-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: rgba(0, 255, 136, 0.1);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.post-body pre {
  background: #080d08;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  overflow-x: auto;
  margin: 1.5em 0;
  position: relative;
}

[data-theme="light"] .post-body pre {
  background: #1a2a1a;
}

.post-body pre code {
  background: none;
  color: #a8ffcc;
  padding: 0;
  border: none;
  font-size: 0.85rem;
  border-radius: 0;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.9rem;
}

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

.post-body th {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.05em;
}

.post-body td { vertical-align: top; }
.post-body tr:nth-child(even) td { background: var(--bg-card); }

.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* ── Reading Progress Bar ─────────────────────────────────────── */
.reading-progress {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dim));
  z-index: 999;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ── Home Page Specific ───────────────────────────────────────── */
.home-hero {
  margin-bottom: 40px;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.home-hero::after {
  content: '</>';
  position: absolute;
  bottom: -10px;
  right: 20px;
  font-family: var(--font-mono);
  font-size: 6rem;
  font-weight: 800;
  color: rgba(0, 255, 136, 0.04);
  pointer-events: none;
  user-select: none;
}

.home-hero-content { position: relative; z-index: 1; }

.home-body { max-width: 760px; color: var(--text-primary); }
.home-body h1 {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
  margin-bottom: 16px;
}
.home-body h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 1.75em;
  margin-bottom: 0.75em;
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}
.home-body h3 { font-size: 1.1rem; color: var(--text-secondary); margin: 1.25em 0 0.5em; }
.home-body p { margin-bottom: 1.1em; color: var(--text-secondary); }
.home-body ul, .home-body ol { padding-left: 1.5em; margin-bottom: 1.1em; }
.home-body li { margin-bottom: 0.4em; color: var(--text-secondary); }
.home-body strong { color: var(--text-primary); font-weight: 600; }
.home-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.home-body em { color: var(--accent); font-style: italic; }

.home-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 0 8px 20px;
  margin: 1.5em 0;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--accent-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Blog listing section title */
.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 700;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* No posts found */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.no-results .icon { font-size: 3rem; margin-bottom: 12px; }
.no-results p { font-size: 0.95rem; }

/* ── Post Navigation ──────────────────────────────────────────── */
.post-nav {
  display: flex;
  gap: 16px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.post-nav-link {
  flex: 1;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: border-color var(--transition), background var(--transition);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.post-nav-link:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.post-nav-link.next { text-align: right; }

.post-nav-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.post-nav-title { font-size: 0.9rem; color: var(--accent); font-weight: 600; }

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeInUp 0.5s var(--transition) both;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(n+6) { animation-delay: 0.3s; }

/* ── Footer ───────────────────────────────────────────────────── */
.footer {
  margin-top: 80px;
  padding: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main-content { padding: 24px 24px; }
}

@media (max-width: 768px) {
  .hamburger { display: flex; }

  .sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    height: calc(100vh - var(--navbar-height));
    transform: translateX(-100%);
    z-index: 900;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }

  .sidebar.open { transform: translateX(0); }

  .navbar-search { width: min(200px, 40vw); }

  .post-header h1 { font-size: 1.8rem; }
  .post-nav { flex-direction: column; }
}

@media (max-width: 480px) {
  .main-content { padding: 20px 16px; }
  .navbar-search { display: none; }
  .page-header h1 { font-size: 1.6rem; }
}
