/* ============================================================
   Inkwell theme — "not-an-llm" synthwave/cyberpunk.
   Self-hosted fonts (no external requests, CSP-clean). The :root
   vars are driven live by synth.js (accent/type/glow/rain/scanlines).
   ============================================================ */

/* ---- self-hosted fonts (latin) ---------------------------- */
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/spacegrotesk-400.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/spacegrotesk-500.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/fonts/spacegrotesk-700.woff2) format('woff2'); }
@font-face { font-family: 'Space Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/spacemono-400.woff2) format('woff2'); }
@font-face { font-family: 'Space Mono'; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/fonts/spacemono-700.woff2) format('woff2'); }

:root {
  --bg:        #07060e;
  --bg-2:      #0c0a16;
  --fg:        #e6e8f4;
  --fg-dim:    #898ca8;
  --fg-faint:  #4b4e68;

  --accent:    #2ee6ff;   /* cyan, overridden by tweaks */
  --accent-2:  #ff3df0;   /* magenta */
  --line:      color-mix(in srgb, var(--accent) 20%, transparent);
  --line-soft: color-mix(in srgb, var(--accent) 10%, transparent);

  --glow-amt:    0.85;
  --scanline-amt: 0.5;
  --rain-amt:    0.4;

  --font-display: 'Space Mono', ui-monospace, monospace;
  --font-body:    'Space Grotesk', system-ui, sans-serif;

  --maxw: 760px;
  --fs:   15.5px;

  --glow: 0 0 calc(var(--glow-amt) * 14px) color-mix(in srgb, var(--accent) 65%, transparent);
  --glow-neon:
    0 0 calc(var(--glow-amt) * 8px)  color-mix(in srgb, var(--accent) 80%, transparent),
    0 0 calc(var(--glow-amt) * 20px) color-mix(in srgb, var(--accent) 45%, transparent),
    0 0 calc(var(--glow-amt) * 34px) color-mix(in srgb, var(--accent-2) 35%, transparent);

  /* --- aliases so the admin chrome (admin.css) reuses this palette --- */
  --background-color: var(--bg);
  --surface: var(--bg-2);
  --heading-color: var(--fg);
  --text-color: var(--fg);
  --muted-color: var(--fg-dim);
  --link-color: var(--fg);
  --visited-color: var(--fg-dim);
  --main-color: var(--accent);
  --accent-strong: var(--accent);
  --on-accent: #04121a;
  --border-color: color-mix(in srgb, var(--fg) 14%, transparent);
  --code-background-color: var(--bg-2);
  --code-color: var(--fg);
  --blockquote-color: var(--fg-dim);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 75% at 50% -12%, color-mix(in srgb, var(--accent) 14%, transparent) 0%, transparent 58%),
    radial-gradient(95% 60% at 100% 112%, color-mix(in srgb, var(--accent-2) 13%, transparent) 0%, transparent 52%),
    radial-gradient(80% 50% at 0% 108%, color-mix(in srgb, var(--accent) 9%, transparent) 0%, transparent 50%),
    var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs);
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- background layers ------------------------------------ */
#rain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: calc(var(--rain-amt) * 0.26);
  mix-blend-mode: screen;
  transition: opacity .4s ease;
}
.scanlines {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: repeating-linear-gradient(to bottom,
    transparent 0, transparent 2px, rgba(0,0,0,0.32) 3px, rgba(0,0,0,0.32) 3px);
  opacity: calc(var(--scanline-amt) * 0.5);
  mix-blend-mode: multiply;
}
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(130% 100% at 50% 40%, transparent 55%, rgba(0,0,0,0.55) 100%);
}

/* ---- shell ------------------------------------------------- */
.wrap {
  position: relative; z-index: 3;
  max-width: var(--maxw); margin: 0 auto;
  padding: clamp(2.4rem, 7vh, 5.5rem) clamp(1.25rem, 5vw, 2rem) 5rem;
}

/* ---- masthead --------------------------------------------- */
.mast {
  margin-bottom: 1.7rem;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "boot boot" "brand nav";
  align-items: baseline;
  column-gap: 1.5rem;
}
.boot {
  grid-area: boot; font-size: 0.74rem; color: var(--fg-faint);
  letter-spacing: 0.04em; margin: 0 0 0.55rem; text-transform: uppercase;
}
.boot b { color: color-mix(in srgb, var(--accent) 60%, var(--fg-faint)); font-weight: 500; }
.boot-error { color: color-mix(in srgb, var(--accent-2) 55%, var(--fg-faint)); }
.boot-error b { color: var(--accent-2); text-shadow: 0 0 calc(var(--glow-amt) * 6px) color-mix(in srgb, var(--accent-2) 45%, transparent); }
.brand {
  grid-area: brand; display: flex; align-items: baseline; gap: 0.1rem;
  font-family: var(--font-display); font-weight: 700; font-size: 1.5rem;
  letter-spacing: -0.01em; margin: 0; line-height: 1;
}
.brand a { color: var(--fg); text-decoration: none; text-shadow: var(--glow-neon); }
.cursor {
  display: inline-block; width: 0.62ch; height: 1.05em; margin-left: 0.18ch;
  transform: translateY(0.12em); background: var(--accent); box-shadow: var(--glow);
  animation: blink 1.15s steps(1) infinite;
}
@keyframes blink { 0%,55% { opacity: 1; } 56%,100% { opacity: 0; } }
.nav {
  grid-area: nav; justify-self: end; display: flex; gap: 1.4rem;
  font-size: 0.86rem; letter-spacing: 0.02em;
}
.nav a { color: var(--fg-dim); text-decoration: none; padding-bottom: 2px; position: relative; }
.nav a::after {
  content: ''; position: absolute; left: 0; right: 100%; bottom: -1px; height: 1px;
  background: var(--accent); box-shadow: var(--glow); transition: right .25s ease;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--fg); }
.nav a:hover::after, .nav a[aria-current="page"]::after { right: 0; }

/* ---- dividers --------------------------------------------- */
.rule {
  height: 1px; border: 0; margin: 1.6rem 0;
  background: linear-gradient(to right, transparent,
    color-mix(in srgb, var(--accent) 55%, transparent) 18%,
    color-mix(in srgb, var(--accent-2) 55%, transparent) 82%, transparent);
}
.rule.glow { box-shadow: 0 0 calc(var(--glow-amt) * 12px) color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---- post index ------------------------------------------- */
.index { display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: 7.5rem 1.2rem 1fr; align-items: baseline;
  gap: 0.6rem; padding: 0.62rem 0; text-decoration: none;
  border-bottom: 1px solid transparent; transition: border-color .2s ease;
}
.row + .row { border-top: 1px solid var(--line-soft); }
.row .date { color: var(--fg-dim); font-size: 0.82rem; white-space: nowrap; }
.row .num  { color: color-mix(in srgb, var(--accent) 60%, var(--fg-faint)); font-size: 0.74rem; text-shadow: 0 0 calc(var(--glow-amt) * 5px) color-mix(in srgb, var(--accent) 40%, transparent); }
.row .title { color: var(--fg); font-size: 0.98rem; transition: color .15s ease; }
.row .meta { display: block; color: var(--fg-faint); font-size: 0.74rem; margin-top: 0.1rem; letter-spacing: 0.02em; }
.row:hover .title { color: var(--accent); text-shadow: var(--glow-neon); }
.row:hover .num   { color: var(--accent-2); }
.year {
  font-family: var(--font-display); font-size: 0.8rem; color: var(--fg-faint);
  letter-spacing: 0.18em; margin: 1.8rem 0 0.2rem; display: flex; align-items: center; gap: 0.8rem;
}
.year::after { content:''; flex:1; height:1px; background: var(--line-soft); }

/* ---- article ---------------------------------------------- */
article { position: relative; }
.post-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin: 1.8rem 0 0.7rem;
}
.post-head .post-title { margin: 0; }
.post-head .backlink { margin: 0; flex-shrink: 0; white-space: nowrap; }
.post-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.45rem, 3vw, 1.7rem); line-height: 1.18; letter-spacing: -0.015em;
  margin: 1.8rem 0 0.7rem; color: var(--fg); text-shadow: var(--glow-neon);
}
.post-meta {
  color: var(--fg-dim); font-size: 0.82rem; letter-spacing: 0.03em; margin: 0 0 2rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; align-items: center;
}
.post-meta .dot { color: var(--accent); opacity: 0.7; }
.post-meta .tag {
  color: var(--accent); border: 1px solid var(--line); border-radius: 2px;
  padding: 0.05rem 0.5rem; font-size: 0.72rem; text-shadow: var(--glow); text-decoration: none;
}
.post-meta .tag:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* prose (rendered markdown) */
.prose p { margin: 0 0 1.35rem; max-width: 66ch; text-wrap: pretty; }
.prose a {
  color: var(--accent); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  padding-bottom: 1px; transition: color .15s, border-color .15s;
}
.prose a:hover { color: var(--fg); border-color: var(--accent); animation: glitch-link .4s steps(2) 1; }
.prose sup a { border: 0; font-size: 0.7em; }
.prose sup a::before { content: '['; }
.prose sup a::after  { content: ']'; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-display); color: var(--fg); line-height: 1.25;
  letter-spacing: -0.01em; margin: 2.2rem 0 0.8rem;
}
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.05rem; color: var(--accent); }
.prose ul, .prose ol { margin: 0 0 1.35rem; padding-left: 1.4rem; }
.prose li { margin: 0.3rem 0; }
.prose blockquote {
  margin: 1.5rem 0; padding: 0.2rem 0 0.2rem 1.1rem;
  border-left: 2px solid var(--accent); color: var(--fg-dim); font-style: italic;
}
.prose img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; }
.prose hr {
  height: 1px; border: 0; margin: 2.2rem 0;
  background: linear-gradient(to right, transparent,
    color-mix(in srgb, var(--accent) 55%, transparent) 18%,
    color-mix(in srgb, var(--accent-2) 55%, transparent) 82%, transparent);
}
.prose code {
  font-family: var(--font-display); font-size: 0.86em; color: var(--fg);
  background: color-mix(in srgb, var(--accent) 9%, var(--bg-2));
  border: 1px solid var(--line-soft); border-radius: 3px; padding: 0.05em 0.35em;
}
.prose pre, .prose .highlight {
  position: relative;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px;
  padding: 0.9rem 1rem; overflow-x: auto; font-size: 0.86rem; line-height: 1.5; margin: 0 0 1.4rem;
}
.prose pre code, .prose .highlight code { background: none; border: 0; padding: 0; }

/* Copy-to-clipboard button (revealed on hover), injected by prose.js. */
.copy-btn {
  position: absolute; top: 6px; right: 6px;
  font: inherit; font-size: 11px; line-height: 1; cursor: pointer;
  padding: 3px 8px; border-radius: 4px;
  color: var(--fg-dim); background: color-mix(in srgb, var(--bg) 75%, transparent);
  border: 1px solid var(--line); opacity: 0;
  transition: opacity .12s, color .12s, border-color .12s;
}
.prose pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Clickable heading anchors, injected by prose.js. */
.prose h2 .anchor, .prose h3 .anchor, .prose h4 .anchor {
  margin-left: 0.4rem; border: 0; font-weight: 400; text-decoration: none;
  color: var(--fg-dim); opacity: 0; transition: opacity .12s, color .12s;
}
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor { opacity: 0.65; }
.prose .anchor:hover { color: var(--accent); opacity: 1; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.4rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 0.4rem 0.6rem; text-align: left; }
.prose th { color: var(--fg); }

.footnotes { font-size: 0.82rem; color: var(--fg-dim); line-height: 1.65; }
.footnotes ol { padding-left: 1.4rem; margin: 0; }
.footnotes li { margin-bottom: 0.5rem; }
.footnotes a { color: var(--accent); }
.footnotes a:hover { color: var(--fg); animation: glitch-link .4s steps(2) 1; }
@keyframes glitch-link {
  0%,100% { text-shadow: var(--glow); }
  25%  { text-shadow: -2px 0 var(--accent), 2px 0 var(--accent-2); }
  50%  { text-shadow:  2px 0 var(--accent), -2px 0 var(--accent-2); }
  75%  { text-shadow: -1px 0 var(--accent-2), 1px 0 var(--accent); }
}

.backlink {
  display: inline-flex; align-items: center; gap: 0.5rem; margin-top: 2rem;
  color: var(--fg-dim); text-decoration: none; font-size: 0.84rem;
}
.backlink:hover { color: var(--accent); text-shadow: var(--glow); }

.draft-banner {
  border: 1px solid var(--accent); border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--fg); padding: 0.55rem 0.85rem; margin-bottom: 1.6rem; font-size: 0.82rem;
}

.pagination {
  display: flex; justify-content: space-between; margin-top: 2rem; font-size: 0.84rem;
}
.pagination a { color: var(--fg-dim); text-decoration: none; }
.pagination a:hover { color: var(--accent); text-shadow: var(--glow); }

/* ---- footer ----------------------------------------------- */
.foot {
  margin-top: 2.4rem; padding-top: 1.4rem; border-top: 1px solid var(--line-soft);
  color: var(--fg-faint); font-size: 0.72rem; letter-spacing: 0.05em;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
}
.foot b { color: color-mix(in srgb, var(--accent) 60%, var(--fg-faint)); font-weight: 400; }

/* ---- glitch (hover) --------------------------------------- */
.glitch { position: relative; }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; inset: 0; pointer-events: none;
  opacity: 0; clip-path: inset(0 0 0 0);
}
.glitch:hover::before { opacity: 0.85; color: var(--accent); animation: glitch-a .42s steps(2) 1; }
.glitch:hover::after  { opacity: 0.85; color: var(--accent-2); animation: glitch-b .42s steps(2) 1; }
@keyframes glitch-a {
  0% { transform: translate(0,0); clip-path: inset(0 0 70% 0); }
  30% { transform: translate(-2px,-1px); clip-path: inset(20% 0 40% 0); }
  60% { transform: translate(2px,1px); clip-path: inset(60% 0 10% 0); }
  100% { transform: translate(0,0); clip-path: inset(0 0 0 0); opacity: 0; }
}
@keyframes glitch-b {
  0% { transform: translate(0,0); clip-path: inset(70% 0 0 0); }
  30% { transform: translate(2px,1px); clip-path: inset(40% 0 20% 0); }
  60% { transform: translate(-2px,-1px); clip-path: inset(10% 0 60% 0); }
  100% { transform: translate(0,0); clip-path: inset(0 0 0 0); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .glitch:hover::before, .glitch:hover::after { animation: none; opacity: 0; }
  .prose a:hover, .footnotes a:hover { animation: none; }
  #rain { display: none; }
}

/* ---- generic elements + form controls (content & admin) --- */
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); color: var(--fg); line-height: 1.25; }
a { color: var(--accent); text-decoration: none; }
/* Public links rely on their own hover effects (glow / glitch / ::after); only
   the admin chrome uses a plain underline affordance. */
body.admin a:hover { text-decoration: underline; text-underline-offset: 2px; }
small { color: var(--fg-dim); }

input, textarea, select, button { font-family: var(--font-body); font-size: 0.95rem; }
input[type=text], input[type=password], input[type=email], input[type=number],
input:not([type]), textarea, select {
  background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--border-color); border-radius: 3px; padding: 0.45rem 0.55rem;
}
input:focus, textarea:focus, select:focus {
  outline: 1px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
button {
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: 3px;
  padding: 0.45rem 0.85rem; font-weight: 700; cursor: pointer;
}
button:hover { box-shadow: var(--glow); }
