/* ==========================================================================
   NEXUS — Singularity / transhumanist theme
   Pure black · neon magenta · Space Mono · numbered post list
   Dark by default · light toggle via html[data-theme="light"]
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */

:root {
  --bg: #000000;
  --bg-soft: #0a0a0a;
  --txt: #f0f0f0;
  --muted: #555555;
  --line: rgba(255, 45, 120, 0.18);
  --accent: #ff2d78;
  --accent-soft: rgba(255, 45, 120, 0.08);
  --accent-2: #00e5ff;
  --code-2: #00e5ff;
  --dots: rgba(255, 45, 120, 0.2);

  --hl-red:     #ff2d78;
  --hl-green:   #00ff88;
  --hl-yellow:  #ffee55;
  --hl-blue:    #00aaff;
  --hl-cyan:    #00e5ff;
  --hl-magenta: #ff2d78;
  --hl-comment: #444444;

  --font: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

html[data-theme="light"] {
  --bg: #fafafa;
  --bg-soft: #f0f0f0;
  --txt: #0a0a0a;
  --muted: #888888;
  --line: rgba(180, 0, 70, 0.18);
  --accent: #cc003d;
  --accent-soft: rgba(180, 0, 70, 0.07);
  --accent-2: #0077bb;
  --code-2: #0077bb;
  --dots: rgba(180, 0, 70, 0.18);

  --hl-red:     #cc003d;
  --hl-green:   #007733;
  --hl-yellow:  #886600;
  --hl-blue:    #0055aa;
  --hl-cyan:    #007799;
  --hl-magenta: #cc003d;
  --hl-comment: #aaaaaa;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-soft: #0a0a0a;
    --txt: #f0f0f0;
    --muted: #555555;
  }
}

/* --- Scan line animation -------------------------------------------------- */

@keyframes scan {
  0%   { opacity: 0.35; }
  50%  { opacity: 1; }
  100% { opacity: 0.35; }
}

body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--accent);
  animation: scan 4s ease-in-out infinite;
  z-index: 9999;
  pointer-events: none;
}

/* --- Base ----------------------------------------------------------------- */

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

html { scroll-behavior: smooth; }

body {
  margin: 0 auto;
  max-width: 72ch;
  padding: 3.5rem 1.25rem 6rem;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font);
  line-height: 1.3;
  letter-spacing: 0.01em;
}

p { margin: 0 0 1rem; }

ul, ol { padding-left: 1.5rem; }

img { max-width: 100%; }

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

/* --- Header --------------------------------------------------------------- */

.site-header {
  margin-bottom: 4rem;
}

.site-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  font-family: var(--font);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--txt);
  text-decoration: none;
  text-transform: uppercase;
}

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

.site-tagline {
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin: 0.6rem 0 0;
  display: flex;
  align-items: center;
  gap: 0.6em;
}

.site-tagline::before,
.site-tagline::after {
  content: "──";
  color: var(--muted);
  letter-spacing: -0.05em;
}

/* --- Theme toggle --------------------------------------------------------- */

.theme-toggle {
  background: transparent;
  border: 1px solid var(--muted);
  border-radius: 2px;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
  padding: 0;
  transition: color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-icon { display: none; line-height: 1; }
.theme-icon-dark  { display: inline; }
.theme-icon-light { display: none; }

html[data-theme="light"] .theme-icon-dark  { display: none; }
html[data-theme="light"] .theme-icon-light { display: inline; }
html[data-theme="dark"]  .theme-icon-dark  { display: inline; }
html[data-theme="dark"]  .theme-icon-light { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-dark  { display: none; }
  :root:not([data-theme="light"]) .theme-icon-light { display: inline; }
}

/* --- Navigation ----------------------------------------------------------- */

.site-header nav {
  display: flex;
  gap: 2rem;
  margin-top: 2rem;
  font-size: 0.78rem;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.site-header nav a::before {
  content: "/";
  color: var(--accent);
}

.site-header nav a:hover {
  color: var(--txt);
}

.site-header nav a[aria-current="true"] {
  color: var(--txt);
}

/* --- Posts list ----------------------------------------------------------- */

.posts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-row {
  margin: 0;
}

.post-link {
  display: flex;
  align-items: baseline;
  gap: 1ch;
  text-decoration: none;
  color: var(--txt);
  padding: 0.65rem 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.post-link:hover {
  border-bottom-color: var(--line);
}

.post-num {
  color: var(--muted);
  font-size: 0.75rem;
  min-width: 2ch;
  flex-shrink: 0;
  user-select: none;
}

.post-title {
  flex-shrink: 0;
  transition: color 0.15s;
}

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

.post-dots {
  flex: 1;
  border-bottom: 1px dotted var(--dots);
  margin-bottom: 0.28em;
  min-width: 1ch;
}

.post-meta {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.post-description {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0.1rem 0 0.5rem calc(2ch + 1ch);
}

/* --- Draft badge ---------------------------------------------------------- */

.draft-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15em 0.45em;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 2px;
  vertical-align: middle;
  margin-left: 0.4em;
}

/* --- Post page ------------------------------------------------------------ */

.post-back {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 2.5rem;
  transition: color 0.15s;
}

.post-back:hover {
  color: var(--accent);
}

.post-head {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.post-head h1 {
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  margin: 0 0 1rem;
  line-height: 1.3;
}

.post-meta-line {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.post-meta-sep { opacity: 0.4; }

.post-tags {
  display: inline-flex;
  gap: 0.5rem;
  margin-left: 0.2rem;
}

.post-tag { color: var(--accent); }

.post p, .post li { line-height: 1.8; }

.post h2, .post h3 {
  margin-top: 2.5rem;
  letter-spacing: 0.02em;
  color: var(--txt);
}

.post h2::before {
  content: "## ";
  color: var(--accent);
  font-weight: 400;
}

.post h3::before {
  content: "### ";
  color: var(--muted);
  font-weight: 400;
}

.post img {
  border: 1px solid var(--line);
  border-radius: 2px;
}

.post blockquote {
  border-left: 2px solid var(--accent);
  margin-left: 0;
  padding-left: 1.25rem;
  color: var(--muted);
  font-style: italic;
}

/* --- Code ----------------------------------------------------------------- */

pre {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 0.8rem;
  line-height: 1.6;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--font);
}

code { font-family: var(--font); }

:not(pre) > code {
  background: var(--accent-soft);
  color: var(--code-2);
  border-radius: 2px;
  padding: 0.1em 0.35em;
  font-size: 0.875em;
}

.hljs-keyword, .hljs-selector-tag, .hljs-section, .hljs-link { color: var(--hl-magenta); }
.hljs-string, .hljs-attribute, .hljs-symbol, .hljs-bullet, .hljs-addition { color: var(--hl-green); }
.hljs-title, .hljs-name, .hljs-type { color: var(--hl-blue); }
.hljs-variable, .hljs-template-variable, .hljs-attr, .hljs-property { color: var(--hl-cyan); }
.hljs-number, .hljs-regexp, .hljs-literal { color: var(--hl-yellow); }
.hljs-built_in, .hljs-params { color: var(--hl-red); }
.hljs-comment, .hljs-quote, .hljs-deletion, .hljs-meta { color: var(--hl-comment); font-style: italic; }

/* --- Footer --------------------------------------------------------------- */

.site-footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-links a:hover { color: var(--accent); }

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 540px) {
  body { padding: 2rem 1rem 4rem; }

  .post-link { flex-wrap: wrap; }

  .post-meta { margin-left: calc(2ch + 1ch); }
}
