/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --bg: #0c0a10;        /* near-black with a violet cast */
  --surface: #15121c;
  --border: #2a2436;
  --text: #ece8f4;
  --muted: #968fa6;
  --accent: #b18cff;    /* violet: links, brand, UI */
  --accent-hi: #d9c8ff;
  --code: #ffc861;      /* gold: code, the counter-color to violet */
  --term: #000;         /* true black, as in The Dark Side */

  --col: min(42rem, 90%);
  --radius: 6px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr var(--col) 1fr;
  background: var(--bg);
  color: var(--text);
  font: 1.1rem/1.7 var(--sans);
}
body > * { grid-column: 2; }

::selection { background: var(--accent); color: var(--bg); }

/* ---------- Scrollbar ---------- */
/* Chrome, Edge, Safari */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 3px solid var(--bg);        /* makes the thumb look thin and floating */
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
::-webkit-scrollbar-corner { background: var(--bg); }

/* Firefox (only where the webkit selectors don't exist, so Chrome keeps the nicer version) */
@supports not selector(::-webkit-scrollbar) {
  html { scrollbar-width: thin; scrollbar-color: var(--border) var(--bg); }
}

/* ---------- Header ---------- */
.site-header {
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 2rem;
  /* line the header content up with the text column */
  padding: 1.75rem calc((100% - var(--col)) / 2);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

/* Brand: a shell prompt, sh0ds@devblog:~$ (the :~$ is added by CSS).
   On hover a band of 0s and 1s runs through it (bit flip, see template) */
.brand {
  display: inline-block;
  color: var(--text);
  text-decoration: none;
  font: 700 clamp(1.8rem, 5vw, 2.4rem)/1.2 var(--mono);
  letter-spacing: -.04em;
  white-space: nowrap;
  font-variant-numeric: slashed-zero;
}
/* on load the prompt prints left to right: sh0ds, then @devblog, then :~$ */
.brand,
.brand span,
.brand::after { animation: settle .5s var(--ease) backwards; }
.brand span   { animation-delay: .12s; }
.brand::after { animation-delay: .24s; }

.brand span {
  display: inline-block;
  color: var(--muted);
  font-weight: 400;
  transition: color .25s var(--ease);
}
.brand::after {
  content: ":~$";
  display: inline-block;
  color: var(--accent);
  font-weight: 400;
  transition: color .25s var(--ease);
}
.brand:is(:hover, :focus-visible) span   { color: var(--accent-hi); }
.brand:is(:hover, :focus-visible)::after { color: var(--accent-hi); }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }

/* Nav: lowercase paths, "./blog". The ./ lights up on hover and on the current page */
.site-header ul {
  display: flex;
  gap: 2.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 1.3rem;
}
.site-header nav a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  text-transform: lowercase;
  transition: color .2s var(--ease);
}
.site-header nav a::before {             /* the ./ prefix */
  content: "./";
  content: "./" / "";
  display: inline-block;
  color: var(--border);
  transition: color .2s var(--ease), transform .25s var(--ease);
}
.site-header nav a::after {              /* underline under the word only (./ is 2ch wide) */
  content: "";
  position: absolute;
  left: 2ch;
  right: 0;
  bottom: -.3em;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .3s var(--ease);
}
.site-header nav a:hover,
.site-header nav a:focus-visible,
.site-header nav a[aria-current="page"] { color: var(--text); }
.site-header nav a:hover::before,
.site-header nav a:focus-visible::before,
.site-header nav a[aria-current="page"]::before {
  color: var(--accent);
  transform: translateX(-.25em);
}
.site-header nav a:hover::after,
.site-header nav a:focus-visible::after,
.site-header nav a[aria-current="page"]::after { transform: scaleX(1); }
.site-header nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ---------- Main & footer ---------- */
main { padding-top: 2rem; animation: rise .6s var(--ease) both; }

.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font: .85rem var(--mono);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-footer p { margin: 0; }
.site-footer small { font-size: inherit; }
.site-footer ul {
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------- Type ---------- */
h1, h2, h3, h4 {
  font-family: var(--mono);
  line-height: 1.2;
  letter-spacing: -.02em;
  overflow-wrap: break-word;
}
h1 { font-size: clamp(1.9rem, 5vw, 2.4rem); }
h2 { font-size: 1.6rem; margin-top: 3rem; }
h3 { font-size: 1.25rem; margin-top: 2.25rem; }

p { margin: 1.25rem 0; }

/* Links in content: faint underline at rest. On hover a solid line
   grows outward from the center over it, and pulls back in on leave */
main a,
.site-footer a {
  color: var(--accent);
  text-decoration: none;
  padding-bottom: .12em;
  background:
    linear-gradient(var(--accent-hi) 0 0) no-repeat 50% 100% / 0% 2px,
    linear-gradient(color-mix(in srgb, var(--accent) 35%, transparent) 0 0) no-repeat 0 100% / 100% 1px;
  box-decoration-break: clone;
  transition: background-size .3s var(--ease), color .2s var(--ease);
}
main a:hover,
main a:focus-visible,
.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--accent-hi);
  background-size: 100% 2px, 100% 1px;
}
main a:focus-visible,
.site-footer a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

blockquote {
  margin: 2rem 0;
  padding: .25rem 1.25rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }

/* ---------- Code ---------- */
code, pre { font-family: var(--mono); font-size: .9em; }

code {
  color: var(--code);
  background: color-mix(in srgb, var(--code) 12%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--code) 28%, transparent);
  padding: .1em .4em;
  border-radius: 4px;
}

/* Code blocks: a small terminal window. The title bar shows a file name
   that follows the language of the block (```c → ~/snippet.c) */
pre {
  margin: 2rem 0;
  padding: 0 1.35rem 1.1rem;
  overflow-x: auto;
  background: var(--term);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent),
              0 12px 32px -16px color-mix(in srgb, var(--accent) 35%, transparent);
  font-size: .88rem;
  line-height: 1.6;
}
pre::before {
  content: "~/snippet";
  display: block;
  position: sticky;
  left: 0;
  margin: 0 -1.35rem 1rem;
  padding: .45rem 1.35rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: .8rem;
}
pre:has(> code.language-c)::before       { content: "~/snippet.c"; }
pre:has(> code.language-h)::before       { content: "~/snippet.h"; }
pre:has(> code.language-bash)::before,
pre:has(> code.language-sh)::before,
pre:has(> code.language-shell)::before   { content: "~$"; color: var(--code); }
pre:has(> code.language-css)::before     { content: "~/styles.css"; }
pre:has(> code.language-html)::before    { content: "~/index.html"; }
pre:has(> code.language-js)::before,
pre:has(> code.language-javascript)::before { content: "~/snippet.js"; }
pre:has(> code.language-python)::before  { content: "~/snippet.py"; }
pre:has(> code.language-makefile)::before { content: "~/Makefile"; }

pre code {
  display: block;
  padding: 0;
  background: none;
  border: 0;
  font-size: inherit;
  color: #f0f0f0;
}

/* ---------- Syntax highlighting (highlight.js classes) ----------
   Colors from the Zed theme "The Dark Side" by Sai Gokula Krishnan.
   Like the original, most tokens are italic. */
.hljs-comment,
.hljs-quote             { color: #7f848e; font-style: italic; }
.hljs-keyword,
.hljs-selector-tag,
.hljs-tag,
.hljs-name,
.hljs-meta,
.hljs-meta .hljs-keyword { color: #7725ee; font-style: italic; }
.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-meta .hljs-string { color: #e1ab32; font-style: italic; }
.hljs-char.escape_,
.hljs-subst             { color: #ea76cb; font-style: italic; }
.hljs-number,
.hljs-literal           { color: #e5c07b; font-style: italic; }
.hljs-title.function_,
.hljs-variable.constant_,
.hljs-deletion          { color: #dc143c; font-style: italic; }
.hljs-type,
.hljs-title.class_,
.hljs-title             { color: #9a77cf; font-style: italic; }
.hljs-built_in,
.hljs-variable.language_,
.hljs-params            { color: #ff6700; font-style: italic; }
.hljs-variable,
.hljs-template-variable,
.hljs-attr,
.hljs-attribute,
.hljs-selector-class,
.hljs-selector-id       { color: #df881d; }
.hljs-operator,
.hljs-punctuation       { color: #7755ee; }

/* ---------- Media & tables ---------- */
img, video { max-width: 100%; height: auto; border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); text-align: left; }
th { font-family: var(--mono); color: var(--muted); font-weight: 600; }

/* ---------- Motion ---------- */
@keyframes settle {                  /* each part rises into place */
  from { opacity: 0; transform: translateY(.45em); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  .site-header { padding-block: 1.1rem; }
  .site-footer { flex-direction: column; text-align: center; }
}
