/* ==========================================================================
   blog.css — blog-specific layer on top of theme.css (vial design system).
   Every color comes from a theme token; no raw hex lives here.
   ========================================================================== */

/* One knob for the content column: nav, main and footer all align to it. */
:root {
  --shell: 1080px;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main.page-shell {
  flex: 1 0 auto;
  max-width: var(--shell);
  width: 100%;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

/* --- Top navigation ------------------------------------------------------ */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-2);
  border-bottom: 1px solid var(--ui);
}

.nav-inner {
  max-width: var(--shell);
  margin: 0 auto;
  min-height: var(--nav-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  color: var(--yellow);
  font-weight: 600;
  white-space: nowrap;
}

.brand:hover {
  color: var(--yellow);
}

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
}

.nav-links a {
  color: var(--tx-2);
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.nav-links a:hover {
  background: var(--ui);
  color: var(--tx);
}

.nav-links a.active {
  color: var(--cyan);
  border-color: color-mix(in srgb, var(--cyan) 40%, var(--ui-2));
  background: color-mix(in srgb, var(--cyan) 10%, var(--bg-2));
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.searchbox input {
  width: 120px;
  padding: 2px 8px;
  transition: width 0.12s ease;
}

.searchbox input:focus {
  width: 180px;
}

.theme-toggle {
  padding: 2px 8px;
  color: var(--tx-2);
  line-height: 1.6;
}

/* --- Page furniture ------------------------------------------------------ */
h1 {
  margin-bottom: 20px;
}

.lede {
  margin-top: -14px;
  margin-bottom: 20px;
}

.section {
  margin-top: 32px;
}

.section > h2 {
  margin-bottom: 12px;
}

.more-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--tx-2);
}

.more-link:hover {
  color: var(--cyan);
}

.footer {
  flex-shrink: 0;
  border-top: 1px solid var(--ui);
  background: var(--bg-2);
  margin-top: 40px;
}

.footer-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.9em;
}

/* --- Author card --------------------------------------------------------- */
.author-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.avatar {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border: 1px solid var(--ui-2);
  border-radius: var(--radius);
  object-fit: cover;
}

.author-name {
  color: var(--tx);
  font-weight: 600;
}

.author-headline {
  font-size: 0.92em;
}

.author-bio {
  margin: 8px 0 12px;
}

.author-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.author-links a::before {
  content: '>';
  color: var(--tx-3);
  margin-right: 6px;
  transition: color 0.1s ease;
}

.author-links a:hover::before {
  color: var(--cyan);
}

/* --- Post listings ------------------------------------------------------- */
.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.post-row {
  position: relative;
  padding-left: 18px;
}

.post-row::before {
  content: '>';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--tx-3);
  transition: color 0.1s ease;
}

.post-row:hover::before {
  color: var(--cyan);
}

.post-title {
  color: var(--tx);
  font-weight: 600;
}

.post-title:hover {
  color: var(--cyan);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  color: var(--tx-2);
  font-size: 0.88em;
  font-variant-numeric: tabular-nums;
}

.post-meta .sep {
  color: var(--tx-3);
}

.row-tags {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.post-desc {
  margin-top: 4px;
  color: var(--tx-2);
}

/* --- Tags ---------------------------------------------------------------- */
.tag {
  color: var(--purple);
}

.tag:hover {
  color: var(--cyan);
}

.tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.tag-list li {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border: 1px solid var(--ui-2);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: 3px 10px;
}

.tag-list li:hover {
  border-color: color-mix(in srgb, var(--cyan) 45%, var(--ui-2));
}

.tag-big {
  font-size: 1em;
}

.count {
  font-variant-numeric: tabular-nums;
  font-size: 0.85em;
}

/* --- Post page ----------------------------------------------------------- */
.post-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ui);
  margin-bottom: 24px;
}

.post-header h1 {
  margin-bottom: 8px;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--ui);
  font-size: 0.92em;
}

.post-nav-side {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 46%;
}

.post-nav-side.right {
  text-align: right;
  margin-left: auto;
}

/* --- Rendered markdown --------------------------------------------------- */
.prose {
  overflow-wrap: break-word;
}

.prose > * + * {
  margin-top: 16px;
}

.prose h2,
.prose h3,
.prose h4,
.prose h5 {
  margin-top: 32px;
  scroll-margin-top: calc(var(--nav-h) + 12px);
}

.prose h3 {
  font-size: 1rem;
}

.prose h4,
.prose h5 {
  font-size: 0.95rem;
  color: var(--tx-2);
}

/* Depth is signalled with the matching run of '#', mirroring the source. */
.prose h3::before {
  content: '## ';
  color: var(--tx-3);
}

.prose h4::before {
  content: '### ';
  color: var(--tx-3);
}

.prose h5::before {
  content: '#### ';
  color: var(--tx-3);
}

.prose ul,
.prose ol {
  padding-left: 24px;
}

.prose li + li {
  margin-top: 4px;
}

.prose ul {
  list-style: none;
}

.prose ul > li {
  position: relative;
}

.prose ul > li::before {
  content: '-';
  position: absolute;
  left: -16px;
  color: var(--tx-3);
}

.prose blockquote {
  border-left: 2px solid var(--yellow);
  background: color-mix(in srgb, var(--yellow) 8%, var(--bg-2));
  padding: 10px 14px;
  color: var(--tx-2);
}

.prose blockquote > * + * {
  margin-top: 8px;
}

.prose img {
  display: block;
  border: 1px solid var(--ui-2);
  border-radius: var(--radius);
  background: var(--bg-2);
  padding: 6px;
  margin: 20px auto;
}

.prose table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
}

.prose th,
.prose td {
  border: 1px solid var(--ui-2);
  padding: 4px 10px;
  text-align: left;
}

.prose th {
  background: var(--bg-2);
  color: var(--tx-2);
}

.prose tbody tr:nth-child(even) {
  background: var(--bg-2);
}

/* Inline code: a gentle tint, not a highlighter. */
.prose :not(pre) > code {
  background: var(--ui);
  border-radius: var(--radius);
  padding: 1px 4px;
  font-size: 0.94em;
}

:root[data-theme='light'] .prose :not(pre) > code {
  background: color-mix(in srgb, var(--ui) 60%, var(--bg-2));
}

.prose math {
  display: block;
  overflow-x: auto;
  margin: 20px 0;
  font-size: 1.15em;
}

.math-error {
  color: var(--red);
}

/* --- Code blocks --------------------------------------------------------- */
.codeblock {
  border: 1px solid var(--ui);
  border-radius: var(--radius);
  background: var(--code-bg);
  overflow: hidden;
}

.codeblock-head {
  display: flex;
  justify-content: flex-end;
  background: var(--bg-2);
  border-bottom: 1px solid var(--ui);
  padding: 1px 10px;
}

.code-lang {
  color: var(--tx-3);
  font-size: 0.8em;
  letter-spacing: 0.04em;
}

.code-lang::before {
  content: '// ';
}

.codeblock-body {
  display: flex;
  align-items: stretch;
}

.linenos {
  flex: 0 0 auto;
  padding: 10px 8px 10px 12px;
  color: var(--tx-3);
  text-align: right;
  user-select: none;
  -webkit-user-select: none;
  border-right: 1px solid var(--ui-2);
  white-space: pre;
  font-variant-numeric: tabular-nums;
}

.prose .code {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre;
  tab-size: 4;
  border: none;
  border-radius: 0;
  color: var(--code-fg);
}

/* --- syntect scope classes (Flexoki accents) ----------------------------- */
.s-punctuation {
  color: var(--tx-2);
}

.s-variable {
  color: var(--tx);
}

.s-storage,
.s-type {
  color: var(--yellow);
}

.s-keyword {
  color: var(--magenta);
}

.s-constant,
.s-numeric {
  color: var(--orange);
}

.s-support {
  color: var(--cyan);
}

.s-entity {
  color: var(--blue);
}

.s-string {
  color: var(--green);
}

.s-meta.s-preprocessor,
.s-preprocessor {
  color: var(--purple);
}

.s-comment {
  color: var(--tx-3);
}

.s-invalid {
  color: var(--red);
}

/* --- Search -------------------------------------------------------------- */
.search-input {
  width: 100%;
  margin-bottom: 12px;
}

#search-results:empty {
  display: none;
}

/* --- Responsive — the single 820px breakpoint ---------------------------- */
@media (max-width: 820px) {
  .nav-inner {
    flex-wrap: wrap;
    padding: 6px 12px;
    gap: 8px 12px;
  }

  .nav-links {
    order: 3;
    flex-basis: 100%;
  }

  .nav-actions {
    margin-left: auto;
  }

  .searchbox input,
  .searchbox input:focus {
    width: 110px;
  }

  .footer-inner {
    padding: 12px;
  }

  .author-card {
    flex-direction: column;
  }

  .post-nav {
    flex-direction: column;
    gap: 12px;
  }

  .post-nav-side,
  .post-nav-side.right {
    max-width: 100%;
    text-align: left;
    margin-left: 0;
  }

  .linenos {
    display: none;
  }
}
