/* moodyjim.com — terminal/hacker dark
   palette tweakable via [data-accent] on <html> */

:root {
  --bg: #0b0d10;
  --bg-1: #11141a;
  --bg-2: #161a22;
  --line: #1f2630;
  --line-2: #2a3340;
  --fg: #e6e8eb;
  --fg-2: #b8bec8;
  --muted: #6b7484;
  --muted-2: #4a5260;
  --accent: #7dd3fc;
  --accent-soft: rgba(125, 211, 252, 0.14);
  --accent-strong: #38bdf8;
  --warn: #fbbf24;
  --danger: #f87171;
  --good: #a3e635;

  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  --font-alt: var(--font-mono);

  --maxw: 880px;
  --row: 1.55;
  --pad-y: 56px;

  color-scheme: dark;
}

html[data-accent="amber"] { --accent: #fbbf24; --accent-strong: #f59e0b; --accent-soft: rgba(251,191,36,.14); }
html[data-accent="green"] { --accent: #a3e635; --accent-strong: #84cc16; --accent-soft: rgba(163,230,53,.14); }
html[data-accent="magenta"]{ --accent: #f472b6; --accent-strong: #ec4899; --accent-soft: rgba(244,114,182,.14); }
html[data-accent="cyan"]  { --accent: #7dd3fc; --accent-strong: #38bdf8; --accent-soft: rgba(125,211,252,.14); }

html[data-font="ibm"]    { --font-mono: 'IBM Plex Mono', ui-monospace, monospace; }
html[data-font="geist"]  { --font-mono: 'Geist Mono', ui-monospace, monospace; }
html[data-font="jetbrains"] { --font-mono: 'JetBrains Mono', ui-monospace, monospace; }

html[data-density="compact"] { --row: 1.4; --pad-y: 36px; }
html[data-density="comfy"]   { --row: 1.75; --pad-y: 80px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: var(--row);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "ss02", "calt", "liga";
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* subtle scanline + vignette over the whole page */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(125,211,252,0.05), transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(0,0,0,0.6), transparent 60%);
  pointer-events: none;
  z-index: 1;
}
body[data-scanlines="on"]::after {
  content: "";
  position: fixed; inset: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,0.06) 0 1px,
      transparent 1px 3px
    ),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.35) 100%);
  pointer-events: none;
  z-index: 2;
}

/* selection */
::selection { background: var(--accent); color: #0b0d10; }

/* base typography */
a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  transition: color .12s, border-color .12s, background .12s;
}
a:hover { border-bottom-color: currentColor; }

h1, h2, h3, h4 {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 0;
}
h1 { font-size: 28px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }

p { margin: 0 0 1em; color: var(--fg-2); }
small { color: var(--muted); }
hr { border: none; border-top: 1px dashed var(--line-2); margin: 32px 0; }

/* main column */
.shell {
  position: relative;
  z-index: 3;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--pad-y) 28px 120px;
}

/* ─── header ─────────────────────────────────────────────── */
.site-head {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 22px;
  align-items: center;
  padding-bottom: 28px;
  border-bottom: 1px dashed var(--line-2);
}
.avatar {
  width: 84px;
  height: 84px;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: transparent;
}
.wordmark {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.wordmark .dot { color: var(--accent); }
.wordmark .cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--accent);
  margin-left: 4px;
  translate: 0 4px;
  animation: blink 1.05s steps(1) infinite;
}
@keyframes blink { 0%,49%{opacity:1} 50%,100%{opacity:0} }

.tag-line {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}
.tag-line .slash { color: var(--accent); margin-right: 6px; }

.head-nav {
  display: flex;
  gap: 18px;
  font-size: 13px;
  color: var(--muted);
  align-self: start;
  padding-top: 6px;
}
.head-nav a { color: var(--fg-2); }
.head-nav a:hover { color: var(--accent); }
.head-nav kbd {
  font: inherit;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
}

/* ─── section ────────────────────────────────────────────── */
.section { margin-top: 56px; }
.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 13px;
}
.section-head .label {
  color: var(--fg);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.section-head .label::before {
  content: "~/";
  color: var(--accent);
  margin-right: 1px;
}
.section-head .rule {
  flex: 1;
  border-top: 1px dashed var(--line-2);
}
.section-head .count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ─── article list ───────────────────────────────────────── */
.article-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.article-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 18px;
  padding: 14px 14px;
  border-radius: 4px;
  align-items: baseline;
  text-decoration: none;
  color: var(--fg);
  border-bottom: 1px solid transparent;
  transition: background .12s, border-color .12s;
}
.article-row:hover {
  background: var(--accent-soft);
}
.article-row:hover .ar-title { color: var(--accent); }
.article-row:hover .ar-arrow { transform: translateX(2px); color: var(--accent); }
.article-row .ar-date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.ar-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--fg);
  letter-spacing: -0.005em;
  transition: color .12s;
}
.ar-meta {
  margin-top: 4px;
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.ar-meta .tag::before { content: "#"; color: var(--accent); }
.ar-meta .dot { color: var(--muted-2); }
.ar-arrow {
  color: var(--muted);
  font-size: 14px;
  transition: transform .15s, color .12s;
  align-self: center;
}

.article-list .empty {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
}
.article-list .empty .blink {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--muted);
  margin-left: 4px;
  translate: 0 2px;
  animation: blink 1.05s steps(1) infinite;
}

/* ─── contact ─────────────────────────────────────────────── */
.contact {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 36px;
  margin-top: 6px;
}
@media (max-width: 720px) { .contact { grid-template-columns: 1fr; } }

.links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}
.links li { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: baseline; }
.links .k { color: var(--muted); }
.links .k::before { content: "$ "; color: var(--accent); }
.links a { color: var(--fg); }
.links a:hover { color: var(--accent); }
.links .v small { color: var(--muted); margin-left: 6px; }

/* contact form */
.note-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px;
  position: relative;
}
.note-form::before {
  content: "● ● ●";
  position: absolute;
  top: 10px; right: 12px;
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--muted-2);
}
.note-form .ff-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
.note-form .ff-label::before { content: "// "; color: var(--accent); }
.note-form input,
.note-form textarea {
  font: inherit;
  font-size: 13px;
  color: var(--fg);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-2);
  padding: 6px 0 6px 14px;
  outline: none;
  resize: none;
  position: relative;
}
.note-form .field {
  position: relative;
}
.note-form .field::before {
  content: "›";
  position: absolute;
  left: 0; top: 8px;
  color: var(--accent);
  font-size: 13px;
}
.note-form input:focus,
.note-form textarea:focus {
  border-bottom-color: var(--accent);
}
.note-form textarea { min-height: 78px; line-height: 1.5; }
.note-form button {
  align-self: flex-start;
  font: inherit;
  font-size: 13px;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 3px;
  padding: 8px 14px;
  cursor: default;
  font-weight: 600;
  margin-top: 6px;
  letter-spacing: 0.02em;
}
.note-form button:hover { background: var(--accent-strong); }
.note-form .status {
  font-size: 11px;
  color: var(--good);
  min-height: 14px;
}
.note-form .status[data-kind="err"] { color: var(--danger); }
.note-form button:disabled { opacity: 0.6; cursor: default; }

/* ─── footer ─────────────────────────────────────────────── */
.site-foot {
  margin-top: 80px;
  padding-top: 22px;
  border-top: 1px dashed var(--line-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 12px;
}
.site-foot .ascii {
  font-size: 10px;
  line-height: 1.1;
  color: var(--muted-2);
  white-space: pre;
}
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--accent); }

/* ─── command bar ─────────────────────────────────────────── */
.cmd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.62);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: none;
}
.cmd-backdrop[data-open="1"] { display: block; }

.cmd-bar {
  position: fixed;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(125,211,252,0.08);
  z-index: 51;
  display: none;
  overflow: hidden;
}
.cmd-bar[data-open="1"] { display: block; }
.cmd-bar .row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.cmd-bar .prompt { color: var(--accent); font-weight: 700; }
.cmd-bar input {
  flex: 1;
  font: inherit;
  font-size: 14px;
  color: var(--fg);
  background: transparent;
  border: none;
  outline: none;
}
.cmd-bar .esc {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line-2);
  padding: 2px 6px;
  border-radius: 3px;
}
.cmd-results {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 280px;
  overflow: auto;
}
.cmd-results li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: default;
  font-size: 13px;
  align-items: baseline;
}
.cmd-results li[data-active="1"] { background: var(--accent-soft); color: var(--fg); }
.cmd-results li[data-active="1"] .glyph { color: var(--accent); }
.cmd-results .glyph { color: var(--muted); }
.cmd-results .desc { color: var(--muted); font-size: 11px; }
.cmd-results .empty { color: var(--muted); text-align: center; padding: 14px; display:block; }

.cmd-hint {
  position: fixed;
  bottom: 16px;
  right: 16px;
  font-size: 11px;
  color: var(--muted-2);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 4px 8px;
  z-index: 40;
  user-select: none;
}
.cmd-hint kbd {
  color: var(--fg-2);
  font: inherit;
  font-size: 11px;
  padding: 0 4px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 2px;
  margin: 0 1px;
}

/* ─── article page ───────────────────────────────────────── */
.article {
  position: relative;
  z-index: 3;
  max-width: 760px;
  margin: 0 auto;
  padding: var(--pad-y) 28px 120px;
}
.crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 28px;
}
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--accent); }
.crumb .sep { color: var(--muted-2); }

.article h1 {
  font-size: 32px;
  letter-spacing: -0.015em;
  margin-bottom: 14px;
  text-wrap: balance;
}
.article .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 36px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--line-2);
}
.article .meta .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.article .meta .chip .k { color: var(--muted-2); }
.article .meta .chip .v { color: var(--fg-2); font-variant-numeric: tabular-nums; }
.article .meta .tag { color: var(--accent); }

.article .lede {
  font-size: 16px;
  color: var(--fg);
  border-left: 2px solid var(--accent);
  padding-left: 18px;
  margin: 0 0 36px;
}

.article p, .article ul, .article ol { font-size: 15px; color: var(--fg-2); }
.article ul, .article ol { padding-left: 22px; margin: 0 0 1em; }
.article ul li, .article ol li { margin-bottom: 4px; }
.article ul li::marker { color: var(--accent); }
.article ol li::marker { color: var(--accent); font-weight: 600; }

.article h2 {
  font-size: 20px;
  color: var(--fg);
  margin: 48px 0 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.article h2::before {
  content: counter(step,decimal-leading-zero);
  counter-increment: step;
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.04em;
  font-weight: 600;
  padding: 3px 7px;
  background: var(--accent-soft);
  border-radius: 3px;
  position: relative;
  top: -2px;
}
.article { counter-reset: step; }
.article h3 { font-size: 16px; margin: 28px 0 10px; color: var(--fg); }

.article strong { color: var(--fg); font-weight: 600; }
.article code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--accent);
}
.article pre {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 18px 18px 18px 18px;
  margin: 18px 0 24px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
}
.article pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--fg-2);
  font-size: inherit;
}
.article pre::before {
  /* shiki emits data-language; legacy hand-written blocks use data-lang */
  content: attr(data-language) attr(data-lang);
  position: absolute;
  top: -1px; right: -1px;
  font-size: 10px;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-top: 0;
  border-right: 0;
  padding: 3px 9px;
  border-bottom-left-radius: 4px;
  letter-spacing: 0.05em;
}
.article pre .code-copy {
  position: absolute;
  bottom: -1px; right: -1px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-right: 0;
  padding: 3px 9px;
  border-top-left-radius: 4px;
  cursor: pointer;
  transition: color 120ms;
  z-index: 1;
}
.article pre .code-copy:hover,
.article pre .code-copy:focus-visible {
  color: var(--accent);
  outline: none;
}
.article pre .code-copy[data-copied="1"] {
  color: var(--good);
}
.article pre .code-copy[data-copied="0"] {
  color: var(--danger);
}

/* syntax tokens */
.tk-c  { color: var(--muted); font-style: italic; }   /* comment */
.tk-k  { color: var(--accent); }                       /* keyword/command */
.tk-s  { color: var(--good); }                          /* string */
.tk-n  { color: var(--warn); }                          /* number/flag */
.tk-p  { color: var(--muted-2); }                       /* punctuation/prompt */
.tk-v  { color: #f472b6; }                              /* variable */
.tk-out{ color: var(--muted); }                         /* output */
.prompt-ps,
.shell-prompt { color: var(--accent); user-select: none; }

/* shiki output sits inside .article pre — kill its inline background so our
   --bg-1 wins (and follows any future theme tweaks consistently). */
.article pre.astro-code { background: var(--bg-1) !important; }
.article pre.astro-code code { background: transparent !important; }

/* callouts */
.callout {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  padding: 14px 16px;
  border-radius: 3px;
  margin: 18px 0 22px;
  font-size: 14px;
  color: var(--fg-2);
}
.callout.warn { border-left-color: var(--warn); }
.callout.warn .ic { color: var(--warn); }
.callout.tip  { border-left-color: var(--good); }
.callout.tip  .ic { color: var(--good); }
.callout .ic {
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  padding-top: 1px;
}
.callout p { margin: 0; }
.callout p + p { margin-top: 6px; }

/* tables (rare, but for compatibility matrix) */
.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 18px 0 22px;
  border: 1px solid var(--line);
}
.article th, .article td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.article th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--bg-1);
}
.article td { color: var(--fg-2); }
.article td code { font-size: 12px; }

/* article footer */
.article-foot {
  margin-top: 60px;
  padding-top: 22px;
  border-top: 1px dashed var(--line-2);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 10px;
}
.article-foot a { color: var(--fg-2); }
.article-foot a:hover { color: var(--accent); }

/* ─── Tweaks panel (hand-rolled) ──────────────────────────── */
.tweaks {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 260px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
  box-shadow: 0 18px 50px rgba(0,0,0,0.55);
  z-index: 100;
  display: none;
}
.tweaks[data-open="1"] { display: block; }
.tweaks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tweaks-head b { color: var(--fg); font-weight: 600; }
.tweaks-head b::before { content: "▸ "; color: var(--accent); }
.tweaks-x {
  background: none;
  border: none;
  color: var(--muted);
  cursor: default;
  font-size: 14px;
  padding: 0 4px;
}
.tweaks-x:hover { color: var(--accent); }
.tweaks-body { padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.tweaks-row { display: flex; flex-direction: column; gap: 6px; }
.tweaks-row > label { font-size: 11px; color: var(--muted); }
.tweaks-row > label::before { content: "$ "; color: var(--accent); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--c);
  cursor: default;
  padding: 0;
  position: relative;
}
.swatch[data-active="1"] {
  outline: 2px solid var(--c);
  outline-offset: 2px;
}
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  overflow: hidden;
}
.seg button {
  font: inherit;
  font-size: 11px;
  background: transparent;
  color: var(--fg-2);
  border: 0;
  border-right: 1px solid var(--line);
  padding: 6px 4px;
  cursor: default;
  letter-spacing: 0.02em;
}
.seg button:last-child { border-right: 0; }
.seg button[data-active="1"] {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}
