/* =========================================================
   Queries & Walks -- stylesheet
   A personal engineering blog. Light, calm, a bit terminal-ish.
   ========================================================= */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }

/* ---------- Design tokens ---------- */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-alt: #eef0ec;
  --text: #23262b;
  --text-muted: #62676d;
  --text-faint: #8b9096;
  --border: #e1ded6;
  --border-strong: #cfcbc0;

  --accent: #3c7a6d;
  --accent-strong: #2b5b51;
  --accent-soft: #e3efec;
  --accent-soft-border: #cfe4de;

  --code-bg: #202325;
  --code-bg-header: #2a2e30;
  --code-text: #d6dbe0;
  --code-muted: #868f97;
  --code-accent: #8fd6c1;

  --radius: 8px;
  --radius-sm: 5px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;

  --container: 1080px;
  --content: 700px;
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

a.inline-link {
  color: var(--accent-strong);
  border-bottom: 1px solid var(--accent-soft-border);
}
a.inline-link:hover { border-bottom-color: var(--accent-strong); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: relative;
  z-index: 20;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 18px;
  padding-bottom: 18px;
  gap: 16px;
}
.brand {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.brand .brand-amp { color: var(--accent); }
.brand:hover { color: var(--accent-strong); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 0.95rem;
}
.site-nav a {
  color: var(--text-muted);
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  margin: -8px;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

/* ---------- Masthead (home only) ---------- */
.masthead {
  padding: 56px 0 40px;
  border-bottom: 1px solid var(--border);
}
.masthead h1 {
  font-size: 2.1rem;
  letter-spacing: -0.01em;
  font-family: var(--font-mono);
  font-weight: 600;
}
.masthead h1 .brand-amp { color: var(--accent); }
.masthead .tagline {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 1.08rem;
  max-width: 560px;
}

/* ---------- Page layout with sidebar ---------- */
.page-body {
  padding: 44px 0 64px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 56px;
  align-items: start;
}
.layout-main { min-width: 0; }

.section-heading {
  font-size: 1.4rem;
  margin-bottom: 22px;
  letter-spacing: -0.01em;
}

/* ---------- Sidebar / author card ---------- */
.sidebar {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

/* Author card: terminal window */
.author-card.terminal {
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--code-bg);
  border: 1px solid #14171a;
}
.terminal-bar {
  height: 32px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--code-bg-header);
  border-bottom: 1px solid #14171a;
}
.terminal-bar span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #474d50;
}
.terminal-body {
  padding: 18px 20px;
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.75;
}
.terminal-body .prompt { color: var(--code-accent); }
.terminal-body .output {
  color: var(--code-muted);
  padding-left: 15px;
}
.terminal-gap { height: 12px; }
.terminal-body .cursor {
  display: inline-block;
  width: 6px;
  height: 12px;
  background: var(--code-accent);
  vertical-align: -2px;
  animation: term-blink 1s infinite;
}
@keyframes term-blink {
  50% { opacity: 0; }
}
.status-card h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.status-card p {
  font-size: 0.92rem;
  color: var(--text);
}
.status-card p + h3 { margin-top: 16px; }
.sidebar-dog {
  display: flex;
  justify-content: center;
  padding: 6px 0 2px;
}
.sidebar-dog img { width: 92px; height: auto; opacity: 0.9; }

/* ---------- Post list / cards ---------- */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.post-card {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}
.post-list .post-card:first-child { padding-top: 0; }
.post-meta {
  font-size: 0.85rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.post-card h3 {
  font-size: 1.22rem;
  line-height: 1.4;
  margin-bottom: 8px;
}
.post-card h3 a:hover { color: var(--accent-strong); }
.post-card p.excerpt {
  color: var(--text-muted);
  margin-bottom: 12px;
}
.post-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid var(--accent-soft-border);
}
.tag.tag-muted {
  background: var(--surface-alt);
  color: var(--text-muted);
  border-color: var(--border);
}

.view-all {
  margin-top: 28px;
  display: flex;
  justify-content: flex-start;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  background: var(--surface);
}
.btn:hover { border-color: var(--accent); color: var(--accent-strong); }

/* ---------- Filters (articles page) ---------- */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.filter-btn {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface);
}
.filter-btn:hover { border-color: var(--accent); }
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.post-card[hidden] { display: none; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent-strong); }
.breadcrumb span.sep { color: var(--border-strong); }
.breadcrumb span.current { color: var(--text-faint); }

/* ---------- Article ---------- */
.article-header { max-width: var(--content); margin: 0 auto 36px; }
.article-header h1 {
  font-size: 2rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-bottom: 14px;
}
.article-meta .dot { color: var(--border-strong); }
.article-tags { display: flex; gap: 8px; flex-wrap: wrap; }

.article {
  max-width: var(--content);
  margin: 0 auto;
}
.article > p, .article > ul, .article > ol, .article > .callout, .article > figure, .article > table, .article > pre, .article > h2, .article > h3 {
  margin-bottom: 22px;
}
.article h2 {
  font-size: 1.4rem;
  margin-top: 40px;
  letter-spacing: -0.01em;
}
.article h3 {
  font-size: 1.15rem;
  margin-top: 30px;
}
.article p { color: var(--text); }
.article ul, .article ol {
  padding-left: 22px;
  color: var(--text);
}
.article ul { list-style: disc; }
.article ol { list-style: decimal; }
.article li { margin-bottom: 8px; }
.article li:last-child { margin-bottom: 0; }
.article strong { font-weight: 650; }
.article em { color: var(--text-muted); }

.article table {
  font-size: 0.92rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.article th, .article td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.article th {
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.article tr:last-child td { border-bottom: none; }
.article td code, .article p code, .article li code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-alt);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Callouts */
.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}
.callout p { margin: 0; color: var(--text); }
.callout p + p { margin-top: 10px; }
.callout .callout-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-strong);
  margin-bottom: 8px;
  display: block;
}
.callout.callout-story { border-left-color: var(--text-faint); }
.callout.callout-story .callout-label { color: var(--text-muted); }
.callout.callout-warn { border-left-color: #b5893f; }
.callout.callout-warn .callout-label { color: #8a6524; }

/* Code blocks (terminal style) */
.code-block {
  background: var(--code-bg);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid #14171a;
}
.code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--code-bg-header);
  border-bottom: 1px solid #14171a;
}
.code-block-lang {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--code-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.copy-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--code-muted);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #3a3f42;
}
.copy-btn:hover { color: var(--code-text); border-color: #575d61; }
.code-block pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
}
.code-block code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--code-text);
  white-space: pre;
}
.code-block .cm { color: var(--code-muted); }
.code-block .kw { color: var(--code-accent); }

.article figure { text-align: center; }
.article figcaption {
  font-size: 0.82rem;
  color: var(--text-faint);
  margin-top: 8px;
}

.article-footer {
  max-width: var(--content);
  margin: 48px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-strong);
  font-size: 0.95rem;
}
.back-link:hover { text-decoration: underline; }

/* ---------- About page specifics ---------- */
.about-lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 26px;
}
.stack-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.stack-item {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.about-photo-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 28px 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.about-photo-row img { width: 76px; height: 76px; }
.about-photo-row p { color: var(--text-muted); margin: 0; }

/* ---------- Infrastructure page ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.tab-btn {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 10px 16px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab-panel[hidden] { display: none; }

.infra-hint {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--text-faint);
}

/* Status tab */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.status-node {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
}
.status-node:hover { border-color: var(--border-strong); }
.status-node:focus { outline: none; border-color: var(--accent); }
.status-node-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
}
.status-dot.warn { background: #b5893f; }
.status-node-title {
  font-weight: 600;
  font-size: 0.95rem;
}
.status-node-sub {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 2px;
}
.status-detail {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 0.87rem;
  color: var(--text-muted);
}
.status-node.open .status-detail { display: block; }

/* Topology tab */
.topology-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.topo-svg { width: 100%; height: auto; display: block; }
.topo-link {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 2;
}
.topo-arrow { fill: var(--border-strong); }
.topo-node rect {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1.5;
  transition: fill .15s, stroke .15s;
}
.topo-node .topo-label {
  font-family: var(--font-mono);
  font-size: 12px;
  fill: var(--text);
}
.topo-node .topo-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--text-faint);
}
.topo-node { cursor: pointer; }
.topo-node:hover rect,
.topo-node.active rect {
  fill: var(--accent-soft);
  stroke: var(--accent);
}
.topo-node:focus { outline: none; }
.topo-node:focus rect { stroke: var(--accent); stroke-width: 2; }
.topo-caption {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 44px;
}
.topo-caption .inline-link { color: var(--accent-strong); border-bottom: 1px solid var(--accent-soft-border); }

/* Stack tab */
.stack-panel[hidden] { display: none; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 40px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.86rem;
  color: var(--text-faint);
}
.footer-nav { display: flex; gap: 18px; }
.footer-nav a { color: var(--text-faint); }
.footer-nav a:hover { color: var(--accent-strong); }

/* ---------- 404 ---------- */
.error-page {
  padding: 100px 0;
  text-align: center;
}
.error-code {
  font-family: var(--font-mono);
  font-size: 3.2rem;
  color: var(--accent);
  font-weight: 600;
}
.error-page h1 { margin-top: 8px; font-size: 1.4rem; }
.error-page p { color: var(--text-muted); margin-top: 10px; }
.error-dog { margin: 28px auto 0; width: 120px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; order: 2; }
  .layout-main { order: 1; }
  .layout.layout-reverse .sidebar { order: -1; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .container { padding: 0 18px; }
  .nav-toggle { display: flex; }
  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 6px 18px 14px;
    display: none;
  }
  .site-nav.open { display: flex; }
  .site-nav a { width: 100%; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .site-nav a:last-child { border-bottom: none; }
  .masthead { padding: 36px 0 28px; }
  .masthead h1 { font-size: 1.6rem; }
  .article-header h1 { font-size: 1.5rem; }
  .about-photo-row { flex-direction: column; text-align: center; }
}
