/* ============================================================
   Plaazaa Markdown Rendering — Premium Styles
   Scoped under .pz-markdown-rendered to prevent leaking
   ============================================================ */

/* --- Accent border on markdown posts --- */
.pz-md-accent .post-description {
  border-left: 3px solid;
  border-image: linear-gradient(180deg, #6366f1, #8b5cf6) 1;
  padding-left: 16px !important;
}

/* --- MD Badge --- */
.pz-md-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 8px;
  vertical-align: middle;
  line-height: 1;
  cursor: default;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Toggle raw/rendered button --- */
.pz-md-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: #6366f1;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  z-index: 5;
  line-height: 1;
}
.post-description:hover .pz-md-toggle,
.pz-md-toggle:focus {
  opacity: 1;
}
.pz-md-toggle:hover {
  background: rgba(99, 102, 241, 0.15);
}

/* --- Make post-description relative for toggle positioning --- */
.pz-markdown-rendered .post-description {
  position: relative;
}

/* --- Rendered content wrapper --- */
.pz-markdown-rendered .pz-md-content {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.7;
  color: #1a1a2e;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* --- Raw text view (hidden by default) --- */
.pz-md-raw {
  display: none;
  white-space: pre-wrap;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #555;
  background: #f8f9fa;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}
.pz-md-show-raw .pz-md-content { display: none; }
.pz-md-show-raw .pz-md-raw { display: block; }

/* ---- Typography ---- */

.pz-md-content h1, .pz-md-content h2, .pz-md-content h3,
.pz-md-content h4, .pz-md-content h5, .pz-md-content h6 {
  margin: 1.2em 0 0.5em;
  font-weight: 700;
  line-height: 1.3;
  color: #111827;
}
.pz-md-content h1:first-child, .pz-md-content h2:first-child,
.pz-md-content h3:first-child { margin-top: 0; }
.pz-md-content h1 { font-size: 1.6em; }
.pz-md-content h2 { font-size: 1.35em; border-bottom: 1px solid #e5e7eb; padding-bottom: 0.3em; }
.pz-md-content h3 { font-size: 1.15em; }
.pz-md-content h4 { font-size: 1.05em; }

.pz-md-content p { margin: 0.6em 0; }

.pz-md-content strong { font-weight: 700; color: #111; }
.pz-md-content em { font-style: italic; }

/* --- Links --- */
.pz-md-content a {
  color: #6366f1;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.pz-md-content a:hover {
  border-bottom-color: #6366f1;
}

/* --- Lists --- */
.pz-md-content ul, .pz-md-content ol {
  padding-left: 1.8em !important;
  margin: 0.6em 0;
  list-style: disc !important;
}
.pz-md-content ol {
  list-style: decimal !important;
}
.pz-md-content li {
  margin: 0.25em 0;
}
.pz-md-content ul li::marker {
  color: #6366f1;
}
.pz-md-content ol li::marker {
  color: #6366f1;
  font-weight: 600;
}

/* --- Blockquotes --- */
.pz-md-content blockquote {
  margin: 0.8em 0;
  padding: 10px 16px;
  border-left: 3px solid;
  border-image: linear-gradient(180deg, #6366f1, #8b5cf6) 1;
  background: rgba(99, 102, 241, 0.04);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: #4b5563;
}
.pz-md-content blockquote p { margin: 0.3em 0; }

/* --- Inline code --- */
.pz-md-content code:not(pre code) {
  background: #f1f3f5;
  color: #c7254e;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.88em;
}

/* --- Code blocks --- */
.pz-md-content pre {
  margin: 0.8em 0;
  border-radius: 10px;
  overflow: hidden;
  background: #1e1e2e;
  position: relative;
}
.pz-md-content pre code {
  display: block;
  padding: 14px 16px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.55;
  overflow-x: auto;
  color: #c9d1d9;
  background: transparent;
}

/* --- Code block header (language label + copy button) --- */
.pz-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  background: #161622;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.pz-code-lang {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #8b8ba7;
}
.pz-code-copy {
  background: rgba(255,255,255,0.08);
  border: none;
  color: #8b8ba7;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.pz-code-copy:hover {
  background: rgba(255,255,255,0.15);
  color: #e0e0e0;
}
.pz-code-copy.copied {
  color: #34d399;
}

/* --- Tables --- */
.pz-md-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0.8em 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  font-size: 13.5px;
}
.pz-md-content thead th {
  background: linear-gradient(135deg, #f0f0ff, #f5f3ff);
  font-weight: 700;
  color: #374151;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid #e5e7eb;
}
.pz-md-content tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid #f0f0f0;
  color: #4b5563;
}
.pz-md-content tbody tr:last-child td {
  border-bottom: none;
}
.pz-md-content tbody tr:hover {
  background: rgba(99, 102, 241, 0.03);
}

/* --- Horizontal rule --- */
.pz-md-content hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d1d5db, transparent);
  margin: 1.2em 0;
}

/* --- Images --- */
.pz-md-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 0.5em 0;
}

/* --- Read More / Read Less for markdown posts --- */
.pz-md-readmore {
  display: block;
  color: #6366f1;
  font-weight: 500;
  font-size: 14px;
  padding: 4px 0;
  cursor: pointer;
}
.pz-md-readmore:hover {
  text-decoration: underline;
}

/* ============================================================
   DARK MODE
   ============================================================ */
body.dark .pz-md-content,
body.night_mode .pz-md-content {
  color: #d1d5db;
}
body.dark .pz-md-content h1, body.dark .pz-md-content h2,
body.dark .pz-md-content h3, body.dark .pz-md-content h4,
body.night_mode .pz-md-content h1, body.night_mode .pz-md-content h2,
body.night_mode .pz-md-content h3, body.night_mode .pz-md-content h4 {
  color: #f3f4f6;
}
body.dark .pz-md-content h2,
body.night_mode .pz-md-content h2 {
  border-bottom-color: #374151;
}
body.dark .pz-md-content strong,
body.night_mode .pz-md-content strong {
  color: #f9fafb;
}
body.dark .pz-md-content blockquote,
body.night_mode .pz-md-content blockquote {
  background: rgba(99, 102, 241, 0.08);
  color: #9ca3af;
}
body.dark .pz-md-content code:not(pre code),
body.night_mode .pz-md-content code:not(pre code) {
  background: #2d2d3f;
  color: #f472b6;
}
body.dark .pz-md-content pre,
body.night_mode .pz-md-content pre {
  background: #0d1117;
}
body.dark .pz-code-header,
body.night_mode .pz-code-header {
  background: #090d14;
}
body.dark .pz-md-content table,
body.night_mode .pz-md-content table {
  border-color: #374151;
}
body.dark .pz-md-content thead th,
body.night_mode .pz-md-content thead th {
  background: linear-gradient(135deg, #1e1e3a, #252547);
  color: #d1d5db;
  border-bottom-color: #374151;
}
body.dark .pz-md-content tbody td,
body.night_mode .pz-md-content tbody td {
  border-bottom-color: #1f2937;
  color: #9ca3af;
}
body.dark .pz-md-content tbody tr:hover,
body.night_mode .pz-md-content tbody tr:hover {
  background: rgba(99, 102, 241, 0.06);
}
body.dark .pz-md-content hr,
body.night_mode .pz-md-content hr {
  background: linear-gradient(90deg, transparent, #4b5563, transparent);
}
body.dark .pz-md-raw,
body.night_mode .pz-md-raw {
  background: #1a1a2e;
  border-color: #374151;
  color: #9ca3af;
}
body.dark .pz-md-toggle,
body.night_mode .pz-md-toggle {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
  color: #818cf8;
}
body.dark .pz-md-toggle:hover,
body.night_mode .pz-md-toggle:hover {
  background: rgba(99, 102, 241, 0.22);
}
body.dark .pz-md-readmore,
body.night_mode .pz-md-readmore {
  color: #818cf8;
}
