/* ---------- tokens ---------- */
:root {
  --bg: #262626;
  --bg-alt: #1c1c1c;
  --bg-tab: #1c1c1c;
  --border: #444444;
  --fg: #d7dce1;
  --fg-muted: #8f8f8f;
  --accent-violet: #c07a7a;
  --accent-amber: #b4a26a;
  --accent-teal: #7fada0;
  --accent: var(--accent-teal);
  --font-mono: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-sans: 'Inter', -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
  --radius: 10px;
  --content-w: 960px;
  --prose-w: 42rem;
  --body-bg: var(--bg);
  --card-shadow: none;
}

/* ---------- light theme (soft-gradient, glass-card alt) ---------- */
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-alt: #ffffff;
  --bg-tab: #ffffffcc;
  --border: #e4e1f0;
  --fg: #2b2b35;
  --fg-muted: #6b6b78;
  --accent-violet: #7c6fe0;
  --accent-amber: #b8860b;
  --accent-teal: #1f9c8f;
  --radius: 16px;
  --card-shadow: 0 8px 30px rgba(90, 80, 160, 0.1);
  --body-bg:
    radial-gradient(ellipse 70% 50% at 15% 0%, rgba(124, 111, 224, 0.16), transparent),
    radial-gradient(ellipse 60% 45% at 85% 15%, rgba(31, 156, 143, 0.14), transparent),
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(184, 134, 11, 0.10), transparent),
    #f7f6fb;
}
:root[data-theme="light"] .terminal-card,
:root[data-theme="light"] .list-card {
  box-shadow: var(--card-shadow);
}
:root[data-theme="light"] .topbar {
  background: var(--bg-tab);
  backdrop-filter: blur(8px);
}
:root[data-theme="light"] .btn.primary {
  color: #ffffff;
}
:root[data-theme="light"] .tabs a.active {
  color: var(--accent-violet);
}
:root[data-theme="light"] .post-content details {
  background: #f7f6fb;
}
:root[data-theme="light"] code {
  background: #f2f1f8;
}
:root[data-theme="light"] pre {
  background: #f2f1f8;
}

/* ---------- reset ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--body-bg);
  background-attachment: fixed;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 {
  font-family: var(--font-mono);
  font-weight: 600;
  line-height: 1.25;
  color: var(--fg);
  margin: 0;
}
code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}
code {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}
pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
}
pre code { background: none; border: none; padding: 0; }
blockquote {
  margin: 1.25rem 0;
  padding: 0.25rem 1rem;
  border-left: 3px solid var(--accent-teal);
  color: var(--fg-muted);
}

.wrap {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 2rem;
}
.prose { max-width: var(--prose-w); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-teal);
  margin: 0 0 0.85rem;
}

/* ---------- blinking cursor ---------- */
.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent-teal);
  margin-left: 6px;
  vertical-align: -0.15em;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.accent { color: var(--accent-teal); }

/* ---------- topbar / editor tabs ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-tab);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  min-height: 64px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.dots { display: flex; gap: 7px; flex: 0 0 auto; }
.dots span { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dots span:nth-child(1) { background: var(--accent-violet); }
.dots span:nth-child(2) { background: var(--accent-amber); }
.dots span:nth-child(3) { background: var(--accent-teal); }

.logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  margin-right: auto;
}
.logo::before { content: "~/"; color: var(--fg-muted); font-weight: 500; }

.tabs { display: flex; gap: 1.5rem; }
.tabs a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--fg-muted);
  padding: 10px 0;
  white-space: nowrap;
  transition: color 0.15s;
}
.tabs a:hover { color: var(--fg); }
.tabs a.active { color: var(--accent-teal); }

@media (max-width: 640px) {
  .topbar-inner { row-gap: 4px; }
  .theme-toggle { order: 2; margin-left: 0; }
  .tabs { order: 3; flex-basis: 100%; gap: 1.1rem; }
  .tabs a { font-size: 0.8rem; padding: 4px 0 10px; }
}

.theme-toggle {
  margin-left: 0.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  color: var(--fg-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex: 0 0 auto;
  transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover { border-color: var(--accent-teal); color: var(--accent-teal); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }

/* ---------- sections ---------- */
section { padding: 4.5rem 0; }
.page-section { padding: 3.5rem 0; }
.hero { padding-top: 4.5rem; }
.latest-post { border-top: 1px solid var(--border); }
.latest-post h2 { font-size: 1.6rem; margin-bottom: 2rem; }
.latest-post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.latest-post-grid .terminal-card { height: 100%; display: flex; flex-direction: column; }
.latest-post-grid .card-body { flex: 1; display: flex; flex-direction: column; }
.latest-post-grid .card-link { margin-top: auto; padding-top: 0.5rem; }
@media (max-width: 800px) {
  .latest-post-grid { grid-template-columns: 1fr; }
}
.contact-teaser { border-top: 1px solid var(--border); text-align: center; }

/* ---------- hero ---------- */
.hero-inner {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 3rem;
  align-items: center;
}
.avatar-ring {
  width: 180px;
  height: 180px;
  flex: 0 0 auto;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(from 220deg, var(--accent-violet), var(--accent-amber), var(--accent-teal), var(--accent-violet));
}
.avatar {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
}
.avatar-pixel {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.prompt {
  font-family: var(--font-mono);
  color: var(--fg-muted);
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}
.hero-text h1 { font-size: clamp(1.8rem, 3.2vw, 2.6rem); }
.hero-text p { color: var(--fg-muted); max-width: 52ch; margin: 1.1rem 0 1.75rem; }
.hero-text .hero-subtitle {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent-teal);
  margin: 0.75rem 0 0;
}

@media (max-width: 640px) {
  .hero-inner { grid-template-columns: 1fr; text-align: center; }
  .avatar-ring { margin: 0 auto; }
  .hero-text p { margin-left: auto; margin-right: auto; }
  .btn-row { justify-content: center; }
}

/* ---------- buttons ---------- */
.btn-row { display: flex; gap: 0.85rem; flex-wrap: wrap; }
.btn {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: none;
  color: var(--fg);
  transition: transform 0.15s, border-color 0.15s, color 0.15s;
  display: inline-block;
}
.btn.primary {
  background: var(--accent-violet);
  color: var(--bg);
  border-color: var(--accent-violet);
  font-weight: 600;
}
.btn.primary:hover { transform: translateY(-1px); }
.btn.ghost:hover { border-color: var(--accent-teal); color: var(--accent-teal); }

/* ---------- terminal card ---------- */
.terminal-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.terminal-card .card-chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-tab);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--fg-muted);
}
.terminal-card .card-chrome .dots { margin-right: 6px; }
.terminal-card .card-body { padding: 1.75rem; }
.terminal-card .card-content { padding: 2rem; }
.terminal-card h3 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; margin: 0.6rem 0 1rem; }
.card-link { font-family: var(--font-mono); font-size: 0.88rem; color: var(--accent-teal); }
.card-link:hover { text-decoration: underline; }
.see-all { text-align: right; margin-top: 1rem; }

/* ---------- tags (post list / post header / home cards) ---------- */
.post-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-amber);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  text-transform: lowercase;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tag:hover {
  color: var(--bg);
  background: var(--accent-amber);
  border-color: var(--accent-amber);
  text-decoration: none;
}
.tag.active {
  color: var(--bg);
  background: var(--accent-teal);
  border-color: var(--accent-teal);
}
.tag.active:hover {
  background: var(--accent-teal);
  border-color: var(--accent-teal);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

/* ---------- post list ---------- */
.list-card {
  border-radius: var(--radius);
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
:root[data-theme="light"] .list-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 0.5rem 1.75rem;
}
.post-list { list-style: none; padding: 0; margin: 2rem 0 0; }
:root[data-theme="light"] .list-card .post-list { margin-top: 0; }
.post-list-item {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.75rem;
}
.post-list-item:first-child { padding-top: 0; }
.post-list-item:last-child { border-bottom: none; }
.post-list-title { color: var(--fg); font-weight: 500; flex: 1 1 auto; }
.post-list-title:hover { color: var(--accent-teal); }
.post-list-date { font-family: var(--font-mono); font-size: 0.8rem; color: var(--fg-muted); white-space: nowrap; }
.post-list-item .post-tags { flex-basis: 100%; }

/* ---------- single post ---------- */
.post-header { margin-bottom: 1.75rem; }
.post-header h1 { font-size: 1.85rem; margin-bottom: 0.6rem; }
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg-muted);
}
.post-cover {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 2rem;
}
.post-cover-badge {
  width: auto;
  max-width: 220px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  border-radius: 10px;
}
.post-content h2, .post-content h3 { margin-top: 2rem; margin-bottom: 0.75rem; }
.post-content p { margin: 0 0 1rem; }
.post-content a,
.page a {
  color: var(--accent-teal);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
}
.post-content a:hover,
.page a:hover {
  text-decoration-color: currentColor;
}
.post-content figure { margin: 1.5rem 0; }
.post-content figcaption {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-top: 0.4rem;
}
.post-back {
  margin-top: 2rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
.post-back a { color: var(--accent-teal); }
.post-back a:hover { text-decoration: underline; }

/* ---------- spoilers / details ---------- */
.post-content details {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-teal);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  margin: 1.25rem 0;
}
.post-content summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-teal);
}
.post-content details[open] summary { margin-bottom: 0.75rem; }
.post-content details > *:last-child { margin-bottom: 0; }

/* ---------- video embed ---------- */
.video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.video-embed iframe { width: 100%; height: 100%; border: 0; }

/* ---------- about / plain page ---------- */
.page h1 { font-size: 1.9rem; margin-bottom: 1.5rem; }
.page h3 {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--accent-teal);
  font-size: 1rem;
  letter-spacing: 0.03em;
}
.page p { margin: 0 0 1rem; }

/* ---------- contact teaser ---------- */
.contact-teaser h2 { font-size: 1.9rem; margin-bottom: 1rem; }
.contact-teaser .lead { color: var(--fg-muted); max-width: 46ch; margin: 0 auto 2rem; }
.contact-teaser .btn-row { justify-content: center; margin-bottom: 1.75rem; }
.socials { display: flex; gap: 1.25rem; justify-content: center; align-items: center; flex-wrap: wrap; font-family: var(--font-mono); font-size: 0.85rem; }
.socials-label { color: var(--fg-muted); opacity: 0.7; }
.socials a { color: var(--fg-muted); }
.socials a:hover { color: var(--accent-violet); }

/* ---------- footer ---------- */
footer {
  padding: 2rem 0 3rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--fg-muted);
}
.footer-tagline {
  margin: 0 0 0.5rem;
  opacity: 0.7;
  font-style: italic;
}

/* ---------- accessibility ---------- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-teal);
  outline-offset: 2px;
}
