/* ==========================================================================
   IT-INDIA Blog — Editorial Theme (Light Default + Dark Toggle)
   ========================================================================== */
:root {
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --pill-bg: #f1f5f9;
  --pill-text: #334155;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --sidebar-width: 260px;
  --max-width: 1180px;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --bg-subtle: #161920;
  --surface: #161920;
  --surface-hover: #1e222b;
  --border: #272c38;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --pill-bg: #1e222b;
  --pill-text: #cbd5e1;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s ease, color 0.15s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* --- Top Header Bar --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { background: var(--surface-hover); }

.brand { flex: 1; min-width: 0; }
.brand-title {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.brand-tagline {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- AJAX Search Bar --- */
.search-wrap {
  position: relative;
  width: 280px;
}
.search-input {
  width: 100%;
  padding: 8px 34px 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}
.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: none;
  padding: 2px 4px;
}
.search-clear.visible { display: block; }

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-width: 90vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: none;
  z-index: 60;
}
.search-dropdown.open { display: block; }
.search-item {
  display: block;
  padding: 10px 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--surface-hover); color: var(--text); }
.search-item small { display: block; color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }
.search-empty { padding: 14px; color: var(--text-muted); font-size: 0.88rem; text-align: center; }

/* --- Two-Column Layout & Collapsible Sidebar --- */
.layout-container {
  max-width: var(--max-width);
  margin: 28px auto 60px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

body.sidebar-collapsed .layout-container {
  grid-template-columns: minmax(0, 1fr);
}
body.sidebar-collapsed .sidebar {
  display: none;
}

.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.sidebar-mobile-head {
  display: none;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section { margin-bottom: 24px; }
.sidebar-section:last-child { margin-bottom: 0; }
.sidebar-heading {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
}

.nav-list, .cat-list, .recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-list li { margin-bottom: 6px; }
.nav-list a {
  display: block;
  padding: 4px 0;
  font-size: 0.92rem;
  color: var(--accent);
}
.nav-list a.active { font-weight: 600; }

.cat-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.cat-list a { color: var(--text); }
.cat-list a:hover { color: var(--accent); }
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--pill-text);
  font-size: 0.78rem;
  transition: border-color 0.15s ease;
}
.tag-pill:hover { border-color: var(--accent); color: var(--accent); }

.recent-list li { margin-bottom: 12px; }
.recent-list a {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}
.recent-list a:hover { color: var(--accent); }
.recent-list time { display: block; font-size: 0.76rem; color: var(--text-muted); margin-top: 2px; }

/* --- Main Feed & Post Cards --- */
.archive-banner {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.archive-banner h1 { margin: 0; font-size: 1.15rem; }

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.post-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

/* Featured Top Hero Card */
.post-card.featured .card-media {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--border);
}
.post-card.featured .card-body { padding: 24px; }
.post-card.featured .card-title { font-size: 1.65rem; margin: 10px 0 8px; }

/* Horizontal Secondary Cards */
.post-card.horizontal {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}
.post-card.horizontal.no-image {
  grid-template-columns: minmax(0, 1fr);
}
.post-card.horizontal .card-media {
  width: 100%;
  height: 100%;
  min-height: 190px;
  object-fit: cover;
  display: block;
  border-right: 1px solid var(--border);
}
.post-card.horizontal .card-body { padding: 20px 22px; }
.post-card.horizontal .card-title { font-size: 1.25rem; margin: 8px 0 6px; }

.card-badges {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cat-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 500;
}
.featured-label {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-transform: uppercase;
}
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--accent); }
.card-meta { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 10px; }
.card-excerpt { font-size: 0.94rem; color: var(--text-muted); margin: 0 0 14px; }
.read-more { font-size: 0.9rem; font-weight: 600; }

/* --- Single Article & "In this Article" TOC (roadmap.sh inspired) --- */
.article-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  box-shadow: var(--shadow-sm);
}
.article-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 24px;
}
.article-title {
  font-size: 2rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 10px 0 12px;
}
.article-hero {
  width: 100%;
  max-height: 440px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.toc-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 28px;
}
.toc-box summary {
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--text);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toc-box summary::-webkit-details-marker { display: none; }
.toc-box summary::after { content: "▴"; color: var(--text-muted); }
.toc-box:not([open]) summary::after { content: "▾"; }
.toc-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}
.toc-list li { margin-bottom: 6px; font-size: 0.9rem; }
.toc-list li.toc-h3 { padding-left: 16px; }
.toc-list a { color: var(--text-muted); }
.toc-list a:hover { color: var(--accent); }

.post-content { font-size: 1.04rem; line-height: 1.75; }
.post-content h2 { font-size: 1.45rem; margin: 1.8em 0 0.6em; scroll-margin-top: 80px; }
.post-content h3 { font-size: 1.2rem; margin: 1.4em 0 0.5em; scroll-margin-top: 80px; }
.post-content img { max-width: 100%; height: auto; border-radius: 8px; }
.post-content figure { margin: 22px 0; }
.post-content pre, .post-content code {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.post-content code { padding: 2px 6px; font-size: 0.9em; }

/* --- Pagination & Footer --- */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
}
.page-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.page-btn:hover { background: var(--surface-hover); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* --- Mobile Drawer & Responsive Rules --- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 45;
  display: none;
}
.drawer-backdrop.open { display: block; }

@media (max-width: 860px) {
  .header-inner { flex-wrap: wrap; }
  .search-wrap { order: 3; width: 100%; }
  .search-dropdown { width: 100%; }

  .layout-container { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 290px;
    max-width: 85vw;
    z-index: 50;
    border-radius: 0;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  body.drawer-open .sidebar {
    display: block;
    transform: translateX(0);
  }
  .sidebar-mobile-head { display: flex; }

  .post-card.horizontal { grid-template-columns: minmax(0, 1fr); }
  .post-card.horizontal .card-media { border-right: none; border-bottom: 1px solid var(--border); max-height: 220px; }
  .article-wrap { padding: 22px 18px; }
  .article-title { font-size: 1.55rem; }
}

/* --- Sidebar Enhancements --- */
.sidebar {
  position: sticky;
  top: 84px;
}
.sidebar-heading {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.74rem;
  color: var(--text-muted);
}
.nav-list a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-list a:hover {
  background: var(--surface-hover);
  color: var(--accent);
}
.nav-list a.active {
  background: var(--bg-subtle);
  color: var(--accent);
  font-weight: 600;
  border: 1px solid var(--border);
}
.cat-list a.active {
  color: var(--accent);
  font-weight: 600;
}
.tag-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* --- Article body: code blocks, lists, quotes (added) --- */
.post-content p { margin: 0 0 1em; }
.post-content ul,
.post-content ol { margin: 0 0 1.1em; padding-left: 1.6em; }
.post-content li { margin-bottom: 0.35em; }
.post-content li > ul,
.post-content li > ol { margin: 0.35em 0 0; }

.post-content pre {
  padding: 14px 16px;
  margin: 0 0 1.2em;
  overflow-x: auto;
  line-height: 1.55;
  font-size: 0.88rem;
  tab-size: 2;
}
.post-content pre code {
  padding: 0;
  border: none;
  background: none;
  font-size: inherit;
  white-space: pre;
}

.post-content blockquote {
  margin: 0 0 1.2em;
  padding: 4px 18px;
  border-left: 4px solid var(--accent);
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-radius: 0 8px 8px 0;
}
.post-content hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.post-content figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}
.post-content h1 { font-size: 1.7rem; margin: 1.8em 0 0.6em; }
