/* lobovit — Emacs-inspired purple/lilac theme (mobile-first) */

:root {
  --bg: #2d1b4e;
  --bg2: #362258;
  --fg: #e8e0f0;
  --fg-dim: #9888b8;
  --link: #c792ea;
  --link-hover: #dbb2ff;
  --accent: #bb86fc;
  --border: #4a3a6a;
  --code-bg: #1e1030;
  --code-fg: #d0c0f0;
  --tag-bg: #3a2560;
  --content-max: 1100px;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.7 "Inter", system-ui, -apple-system, sans-serif;
}

.frame {
  width: 92%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 16px 0 32px;
}

/* ── Nav (mobile: stacked) ── */
header nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-size: 14px;
  color: var(--fg-dim);
}

.site-title {
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  font-size: 18px;
}

.desc { color: var(--fg-dim); }

.nav-links {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.nav-links a {
  color: var(--link);
  text-decoration: none;
  font-size: 15px;
  padding: 4px 0;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--link-hover);
  text-decoration: underline;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0 20px;
}

/* ── Headings ── */
h1, h2, h3, h4 {
  font-weight: normal;
  margin: 22px 0 8px;
  color: #fff;
  line-height: 1.3;
}

h1 { font-size: 22px; color: var(--accent); }

h2 {
  font-size: 18px;
  color: #d4b8ff;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 1rem;
}

h2::after {
  content: "";
  background-color: var(--border);
  height: 2px;
  flex: 1;
  min-width: 20px;
  box-shadow: 0 0 6px var(--accent);
}

h3 { font-size: 15px; color: #c8a8f0; }
h4 { font-size: 14px; color: var(--fg-dim); }

/* ── Post list ── */
.post-list {
  list-style: none;
  margin-top: 16px;
}

.post-list li {
  padding: 8px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin-bottom: -22px;
}

.post-list time {
  color: var(--fg-dim);
  font-size: 13px;
  white-space: nowrap;
}

.post-list a {
  color: var(--link);
  text-decoration: none;
  font-size: 16px;
}

.post-list a:hover,
.post-list a:focus-visible {
  color: var(--link-hover);
  text-decoration: underline;
}

/* ── Meta ── */
.meta {
  color: var(--fg-dim);
  font-size: 13px;
  margin-bottom: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--accent);
  padding: 2px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
}

/* ── Content ── */
.content p { margin: 10px 0; }

.content a {
  color: var(--link);
  text-decoration: none;
  word-break: break-word;
}

.content a:hover,
.content a:focus-visible {
  text-decoration: underline;
}

.content strong,
.content b { color: #fff; }

.content blockquote {
  border-left: 3px solid var(--accent);
  margin: 14px 0;
  padding: 8px 14px;
  background: var(--bg2);
  color: var(--fg-dim);
  font-style: italic;
  font-size: 14px;
}

.content ul,
.content ol {
  margin: 8px 0 8px 22px;
}

.content li { margin: 4px 0; }

.content img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: block;
  margin: 14px auto;
}

/* ── Mermaid ── */
.content pre.mermaid { text-align: center; }

.content .mermaid svg {
  max-width: 100%;
  display: block;
  margin: 0 auto;
}

/* Mermaid node types — purple-tuned */
.mermaid .node.code > *,
.mermaid .node.code span { fill: #2d1b6e !important; stroke: #7c6bc0 !important; color: #e0d8f8 !important; }

.mermaid .node.parser > *,
.mermaid .node.parser span { fill: #3d1b5e !important; stroke: #8b6bc0 !important; color: #e8d8f8 !important; }

.mermaid .node.decision > *,
.mermaid .node.decision span { fill: #4d1b3e !important; stroke: #c06b90 !important; color: #f0d8e8 !important; }

.mermaid .node.raw > *,
.mermaid .node.raw span { fill: #362258 !important; stroke: #6b58a0 !important; color: #d0c0f0 !important; }

.mermaid .node.ignore > *,
.mermaid .node.ignore span { fill: #2a1f40 !important; stroke: #4a3a6a !important; color: #a090c0 !important; }

.mermaid .node.fp > *,
.mermaid .node.fp span { fill: #4e1b2e !important; stroke: #c06b7a !important; color: #f0c8d0 !important; }

.mermaid .node.filter > *,
.mermaid .node.filter span { fill: #3d2b1e !important; stroke: #c08b50 !important; color: #f0dcc8 !important; }

.mermaid .node.pass > *,
.mermaid .node.pass span { fill: #2d4e2d !important; stroke: #7ab86b !important; color: #d0f0c8 !important; }

.mermaid .node.tp > *,
.mermaid .node.tp span { fill: #2d4e3d !important; stroke: #6bc08b !important; color: #c8f0d8 !important; }

.content figure { margin: 14px 0; text-align: center; }

.content figcaption {
  color: var(--fg-dim);
  font-size: 12px;
  margin-top: 4px;
}

/* ── Code ── */
.content code,
.content pre {
  font-family: "Hack", "JetBrains Mono", "Consolas", "Courier New", monospace;
}

.content :not(pre) > code {
  background: var(--code-bg);
  padding: 1px 5px;
  color: var(--code-fg);
  border: 1px solid var(--border);
  word-break: break-word;
}

.content pre {
  background: var(--code-bg);
  padding: 14px;
  overflow-x: auto;
  margin: 14px 0;
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.6;
  border-radius: 1rem;
  -webkit-overflow-scrolling: touch;
}

.content pre code {
  background: none;
  padding: 0;
  border: none;
  white-space: pre;
}

.highlight { border-radius: 1rem !important; }
.highlight pre { border-radius: 1rem !important; }

pre[class*="language-"] {
  background: var(--code-bg) !important;
  border-radius: 1rem !important;
}

:not(pre) > code[class*="language-"] {
  background: var(--code-bg) !important;
  color: var(--code-fg) !important;
}

/* ── Chroma syntax highlighting ── */
.chroma {
  color: var(--code-fg);
  background: var(--code-bg);
  border-radius: 1rem;
}

.chroma .k, .chroma .kd, .chroma .kr, .chroma .kt { color: #d4b8ff; }
.chroma .s, .chroma .s1, .chroma .s2, .chroma .sh, .chroma .sb { color: #a6e3a1; }
.chroma .c, .chroma .c1, .chroma .cm { color: #6b58a0; font-style: italic; }
.chroma .nf, .chroma .nb, .chroma .bp { color: var(--accent); }
.chroma .mi, .chroma .mf, .chroma .mh { color: #fab387; }
.chroma .nx { color: var(--code-fg); }
.chroma .o { color: #a090c0; }
.chroma .na, .chroma .nc { color: #e8c8ff; }
.chroma .nt { color: var(--link); }
.chroma .nv { color: #fab387; }
.chroma .err { color: #f38ba8; }

/* ── Tables ── */
.content .table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 14px 0;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.content thead {
  border-bottom: 2px solid var(--accent);
}

.content th {
  padding: 8px 10px;
  text-align: left;
  font-weight: bold;
  color: #fff;
  background: var(--bg2);
  white-space: nowrap;
}

.content td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.content tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.03);
}

.content tr:hover td {
  background: rgba(187, 134, 252, 0.08);
}

/* ── Video shortcode ── */
.video {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin: 14px 0;
  max-width: 100%;
}

.video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ── Footer ── */
footer {
  font-size: 12px;
  color: var(--fg-dim);
  margin-top: 32px;
}

footer a { color: var(--link); }

/* ── Back to top ── */
.back-to-top {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 14px;
  font: 13px "Inter", sans-serif;
  cursor: pointer;
  display: none;
  z-index: 99;
  border-radius: 4px;
  opacity: 0.85;
  transition: opacity .15s;
}

.back-to-top:hover,
.back-to-top:focus-visible {
  background: var(--link);
  opacity: 1;
}

.back-to-top.visible { display: block; }

/* ── Custom scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #6b58a0; border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Focus visible (a11y) ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ================================================================
   Responsive: tablet+ (>= 640px)
   ================================================================ */
@media (min-width: 640px) {
  body { font-size: 16px; line-height: 1.8; }

  .frame { width: 88%; padding: 20px 0 40px; }

  /* Nav: horizontal layout */
  header nav {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
  }

  .nav-links { margin-left: auto; margin-top: 0; gap: 0; }

  .nav-links a { margin-left: 16px; padding: 0; font-size: 16px; }

  h1 { font-size: 24px; }

  h2 { font-size: 20px; }

  h3 { font-size: 17px; }
  h4 { font-size: 15px; }

  .post-list li { gap: 10px; }
  .post-list time { font-size: 14px; }

  .meta { gap: 8px; }

  .content blockquote { font-size: 15px; padding: 8px 16px; }
  .content ul, .content ol { margin-left: 28px; }
  .content pre { padding: 16px; font-size: 14px; }
  .content th { padding: 10px 14px; }
  .content td { padding: 8px 14px; }

  hr { margin: 14px 0 24px; }

  .back-to-top { bottom: 24px; right: 24px; }
}

/* ================================================================
   Responsive: desktop (>= 1024px)
   ================================================================ */
@media (min-width: 1024px) {
  .frame { width: 88%; padding: 24px 0 48px; }

  .site-title { font-size: 20px; }

  h2 { font-size: 23px; }
}
