/* ==========================================================================
   DevPulse Theme - Developer / Dark Tech CSS for Zola SSG
   ========================================================================== */

:root,
[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-surface: #131c31;
  --bg-surface-hover: #1b2742;
  --bg-elevated: rgba(19, 28, 49, 0.78);
  --bg-code: #070a12;
  --bg-terminal-header: #161f33;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #06b6d4;
  --accent-cyan-light: #22d3ee;
  --accent-indigo: #6366f1;
  --accent-indigo-light: #818cf8;
  --accent-emerald: #10b981;
  --border-color: rgba(148, 163, 184, 0.14);
  --border-highlight: rgba(34, 211, 238, 0.38);
  --shadow-card: 0 10px 30px -10px rgba(2, 6, 23, 0.7);
  --shadow-glow: 0 0 28px rgba(6, 182, 212, 0.15);
  --grid-line: rgba(56, 189, 248, 0.04);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f8fafc;
  --bg-elevated: rgba(255, 255, 255, 0.85);
  --bg-code: #0f172a;
  --bg-terminal-header: #1e293b;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-cyan: #0891b2;
  --accent-cyan-light: #06b6d4;
  --accent-indigo: #4f46e5;
  --accent-indigo-light: #6366f1;
  --accent-emerald: #059669;
  --border-color: #e2e8f0;
  --border-highlight: rgba(8, 145, 178, 0.45);
  --shadow-card: 0 10px 25px -5px rgba(15, 23, 42, 0.06);
  --shadow-glow: 0 0 24px rgba(79, 70, 229, 0.1);
  --grid-line: rgba(15, 23, 42, 0.03);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--text-primary);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-cyan-light);
  text-decoration: none;
  transition: color 0.18s ease, opacity 0.18s ease;
}

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

/* Reading Progress Bar */
.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-indigo), var(--accent-emerald));
  z-index: 1000;
  transition: width 0.1s ease-out;
}

/* Container */
.dp-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Navbar */
.dp-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
}

.dp-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.25rem;
  gap: 1rem;
}

.dp-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.dp-brand:hover {
  color: var(--text-primary);
}

.dp-brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.2));
}

.dp-brand-prompt {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: 0.45rem;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.18), rgba(99, 102, 241, 0.18));
  border: 1px solid var(--border-highlight);
  color: var(--accent-cyan-light);
}

.dp-nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dp-nav-link {
  padding: 0.45rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.18s ease;
}

.dp-nav-link:hover,
.dp-nav-link.active {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.dp-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.dp-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.42rem 0.85rem;
  border-radius: 0.6rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.dp-search-btn:hover {
  border-color: var(--border-highlight);
  color: var(--text-primary);
  box-shadow: var(--shadow-glow);
}

.dp-kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.38rem;
  border-radius: 0.3rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.dp-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.6rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s ease;
}

.dp-icon-btn:hover {
  border-color: var(--border-highlight);
  color: var(--accent-cyan-light);
}

/* Hero Section */
.dp-hero {
  position: relative;
  padding: 4rem 0 3rem;
  border-bottom: 1px solid var(--border-color);
  overflow: hidden;
}

.dp-hero::before {
  content: "";
  position: absolute;
  top: -120px;
  right: 10%;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.14) 0%, rgba(99, 102, 241, 0.08) 45%, transparent 70%);
  pointer-events: none;
}

.dp-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid var(--border-highlight);
  color: var(--accent-cyan-light);
  margin-bottom: 1.25rem;
}

.dp-badge-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.dp-hero-title {
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 1.1rem;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-cyan-light) 80%, var(--accent-indigo-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.dp-hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 0 2rem;
}

/* Stats Strip */
.dp-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 1.75rem;
}

.dp-stat-pill {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1rem;
  border-radius: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.dp-stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-cyan-light);
}

/* Featured Hero Post Card */
.dp-featured-card {
  margin-top: 2.75rem;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 2rem;
  padding: 2rem;
  border-radius: 1.25rem;
  background: linear-gradient(145deg, var(--bg-surface), var(--bg-secondary));
  border: 1px solid var(--border-highlight);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  align-items: center;
}

.dp-featured-media {
  border-radius: 0.85rem;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-code);
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dp-featured-media img,
.dp-featured-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Category & Tag Filter Bar */
.dp-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 2.5rem 0 1.75rem;
}

.dp-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dp-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s ease;
}

.dp-pill:hover,
.dp-pill.active {
  background: rgba(6, 182, 212, 0.14);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan-light);
}

/* Post Grid & Cards */
.dp-posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.dp-post-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.dp-post-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-highlight);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.dp-card-thumb {
  aspect-ratio: 16 / 9;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  overflow: hidden;
  position: relative;
}

.dp-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.dp-post-card:hover .dp-card-thumb img {
  transform: scale(1.04);
}

.dp-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(circle at top right, rgba(6, 182, 212, 0.16), rgba(99, 102, 241, 0.08), var(--bg-code));
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-cyan-light);
}

.dp-card-body {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.dp-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.dp-card-title {
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 0.65rem;
}

.dp-card-title a {
  color: var(--text-primary);
}

.dp-card-title a:hover {
  color: var(--accent-cyan-light);
}

.dp-card-excerpt {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
  flex: 1;
}

.dp-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  gap: 0.5rem;
}

/* Single Post Layout with Sticky TOC */
.dp-article-header {
  padding: 3.25rem 0 2.25rem;
  border-bottom: 1px solid var(--border-color);
}

.dp-breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-cyan-light);
  margin-bottom: 1rem;
}

.dp-article-title {
  font-size: clamp(1.85rem, 3.8vw, 2.85rem);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.025em;
  margin: 0 0 1.25rem;
}

.dp-article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 3rem;
  padding: 3rem 0;
  align-items: start;
}

.dp-sidebar {
  position: sticky;
  top: 5.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dp-sidebar-box {
  padding: 1.35rem;
  border-radius: 0.9rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.dp-sidebar-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-cyan-light);
  margin: 0 0 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.dp-toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
}

.dp-toc-list li {
  margin-bottom: 0.45rem;
}

.dp-toc-list ul {
  list-style: none;
  padding-left: 0.95rem;
  margin-top: 0.35rem;
  border-left: 1px solid var(--border-color);
}

.dp-toc-link {
  color: var(--text-secondary);
  display: block;
  padding: 0.2rem 0.4rem;
  border-radius: 0.35rem;
  transition: all 0.15s ease;
}

.dp-toc-link:hover,
.dp-toc-link.active {
  color: var(--accent-cyan-light);
  background: rgba(6, 182, 212, 0.1);
}

/* Technical Prose & Code Highlighting */
.prose-tech {
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.prose-tech h1,
.prose-tech h2,
.prose-tech h3,
.prose-tech h4 {
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 2.4rem;
  margin-bottom: 0.9rem;
  scroll-margin-top: 5.5rem;
}

.prose-tech h2 {
  font-size: 1.6rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border-color);
}

.prose-tech h3 {
  font-size: 1.28rem;
}

.prose-tech p {
  margin: 0 0 1.35rem;
}

.prose-tech code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.18rem 0.45rem;
  border-radius: 0.35rem;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.25);
  color: var(--accent-cyan-light);
}

.dp-code-wrapper {
  margin: 1.75rem 0;
  border-radius: 0.85rem;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-code);
  box-shadow: var(--shadow-card);
}

.dp-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  background: var(--bg-terminal-header);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #94a3b8;
}

.dp-window-dots {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dp-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 9999px;
}

.dp-dot-red { background: #ef4444; }
.dp-dot-amber { background: #f59e0b; }
.dp-dot-green { background: #10b981; }

.dp-copy-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.25rem 0.65rem;
  border-radius: 0.4rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dp-copy-btn:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--accent-cyan);
}

.prose-tech pre {
  margin: 0;
  padding: 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.65;
  background: var(--bg-code) !important;
  color: #e2e8f0;
}

.prose-tech blockquote {
  margin: 1.75rem 0;
  padding: 1rem 1.35rem;
  border-left: 4px solid var(--accent-cyan);
  background: var(--bg-surface);
  border-radius: 0 0.75rem 0.75rem 0;
  color: var(--text-secondary);
}

.prose-tech img,
.prose-tech video {
  max-width: 100%;
  height: auto;
  border-radius: 0.85rem;
  border: 1px solid var(--border-color);
  margin: 1.5rem 0;
}

.prose-tech table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.75rem 0;
  font-size: 0.92rem;
}

.prose-tech th,
.prose-tech td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  text-align: left;
}

.prose-tech th {
  background: var(--bg-surface);
  font-family: var(--font-mono);
  color: var(--accent-cyan-light);
}

.prose-tech th p,
.prose-tech td p {
  margin: 0;
}

/* Newsletter Section */
.dp-newsletter {
  margin: 4rem 0 2rem;
  padding: 2.5rem;
  border-radius: 1.25rem;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(99, 102, 241, 0.12));
  border: 1px solid var(--border-highlight);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.dp-newsletter-form {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex: 1;
  max-width: 460px;
}

.dp-input {
  flex: 1;
  min-width: 220px;
  padding: 0.75rem 1rem;
  border-radius: 0.65rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.92rem;
}

.dp-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.dp-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.35rem;
  border-radius: 0.65rem;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  color: #ffffff;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.dp-btn-primary:hover {
  opacity: 0.94;
  transform: translateY(-1px);
  color: #ffffff;
}

/* Search Modal */
.dp-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(6px);
  z-index: 900;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 5rem 1rem 2rem;
}

.dp-modal-backdrop.open {
  display: flex;
}

.dp-search-modal {
  width: 100%;
  max-width: 640px;
  border-radius: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-highlight);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
  overflow: hidden;
}

.dp-search-input-bar {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  gap: 0.75rem;
}

.dp-search-input-bar input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
}

.dp-search-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 0.75rem;
}

.dp-search-item {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: 0.65rem;
  margin-bottom: 0.35rem;
  transition: background 0.15s ease;
}

.dp-search-item:hover {
  background: var(--bg-surface-hover);
}

/* Footer */
.dp-footer {
  margin-top: auto;
  padding: 3rem 0 2.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 960px) {
  .dp-featured-card {
    grid-template-columns: 1fr;
  }
  .dp-article-layout {
    grid-template-columns: 1fr;
  }
  .dp-sidebar {
    position: static;
  }
}

@media (max-width: 720px) {
  .dp-nav-links {
    display: none;
  }
  .dp-posts-grid {
    grid-template-columns: 1fr;
  }
}
