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

:root {
  --bg: #0d1117;
  --fg: #e6edf3;
  --muted: #8b949e;
  --dim: #6e7681;
  --accent: #58a6ff;
  --scanline: rgba(255, 255, 255, 0.03);
  --dot: rgba(255, 255, 255, 0.08);
  --code-bg: rgba(255, 255, 255, 0.05);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #ffffff;
    --fg: #0d0d0d;
    --muted: #555555;
    --dim: #888888;
    --accent: #0969da;
    --scanline: rgba(0, 0, 0, 0.02);
    --dot: rgba(0, 0, 0, 0.06);
    --code-bg: rgba(0, 0, 0, 0.05);
  }
}

[data-theme="light"] {
  --bg: #ffffff;
  --fg: #0d0d0d;
  --muted: #555555;
  --dim: #888888;
  --accent: #0969da;
  --scanline: rgba(0, 0, 0, 0.02);
  --dot: rgba(0, 0, 0, 0.06);
  --code-bg: rgba(0, 0, 0, 0.05);
}

body {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Cascadia Code', 'JetBrains Mono', monospace;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  position: relative;
}

body.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* CRT scanlines */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    var(--scanline) 2px,
    var(--scanline) 4px
  );
  pointer-events: none;
  z-index: 10;
}

/* Constellation dots — positioned by JS */
.dot {
  position: fixed;
  width: 2px;
  height: 2px;
  background: var(--dot);
  border-radius: 50%;
  animation: drift linear infinite;
}

@keyframes drift {
  0%   { transform: translate(0, 0); opacity: 0.4; }
  25%  { opacity: 0.8; }
  50%  { transform: translate(var(--dx), var(--dy)); opacity: 0.4; }
  75%  { opacity: 0.7; }
  100% { transform: translate(0, 0); opacity: 0.4; }
}

.content {
  text-align: center;
  z-index: 5;
  padding: 2rem;
}

.name {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  display: inline-block;
  position: relative;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

/* Glitch effect */
.name::before,
.name::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.name::before {
  animation: glitch-1 4s infinite linear;
  clip-path: inset(0 0 80% 0);
  color: var(--accent);
  opacity: 0;
}

.name::after {
  animation: glitch-2 4s infinite linear;
  clip-path: inset(80% 0 0 0);
  color: var(--accent);
  opacity: 0;
}

@keyframes glitch-1 {
  0%, 89%, 91%, 100% { opacity: 0; transform: none; }
  90% { opacity: 0.8; transform: translateX(-3px); }
}

@keyframes glitch-2 {
  0%, 93%, 95%, 100% { opacity: 0; transform: none; }
  94% { opacity: 0.8; transform: translateX(3px); }
}

/* Blinking cursor */
.cursor {
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--accent);
  margin-left: 4px;
  vertical-align: text-bottom;
  animation: blink 1.1s step-end infinite;
}

@keyframes blink {
  0%, 40% { opacity: 1; }
  50%, 90% { opacity: 0; }
}

.links {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.links a {
  color: var(--muted);
  text-decoration: none;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.links a svg {
  width: 1em;
  height: 1em;
  fill: currentColor;
  flex-shrink: 0;
}

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

/* Landing nav, revealed by clicking the name. The 0fr → 1fr row lets the
   height animate so the name glides up instead of jumping. */
.reveal {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows 0.5s ease, opacity 0.5s ease, visibility 0s;
}

.reveal > div {
  min-height: 0;
  overflow: hidden;
}

/* Only hidden when JS is running, so the links still show without it */
.js:not(.nav-open) .reveal {
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
  transition: grid-template-rows 0.5s ease, opacity 0.5s ease, visibility 0s 0.5s;
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .js:not(.nav-open) .reveal {
    transition: none;
  }
}

.now-playing {
  color: var(--muted);
  font-size: clamp(0.75rem, 2vw, 0.85rem);
  transition: color 0.2s;
}

.now-playing .note {
  display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.scrobbles {
  color: var(--dim);
  font-size: clamp(0.65rem, 1.8vw, 0.75rem);
  opacity: 0.7;
}

.now-game {
  color: var(--muted);
  font-size: clamp(0.75rem, 2vw, 0.85rem);
  transition: color 0.2s;
}

.game-stats {
  color: var(--dim);
  font-size: clamp(0.65rem, 1.8vw, 0.75rem);
  opacity: 0.7;
}

.fingerprint {
  margin-top: 2.5rem;
  padding: 0 1.5rem 2rem;
  font-size: 0.65rem;
  color: var(--dim);
  opacity: 0.5;
  letter-spacing: 0.05em;
  text-align: center;
}

/* Long-form prose layout */
.prose {
  max-width: 65ch;
  margin: 6rem auto 4rem;
  padding: 0 1.5rem;
  position: relative;
  z-index: 5;
}

.prose h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: var(--fg);
  font-weight: 600;
}

.prose h2 {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  letter-spacing: -0.01em;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--fg);
  font-weight: 600;
}

.post-date,
.page-subtitle {
  color: var(--muted);
  font-size: clamp(0.75rem, 2vw, 0.85rem);
  margin-bottom: 2rem;
}

.prose p {
  line-height: 1.65;
  margin-bottom: 1.25rem;
  color: var(--fg);
}

.prose a {
  color: var(--accent);
  text-decoration: none;
}

.prose a:hover {
  text-decoration: underline;
}

.prose code {
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.prose pre {
  background: var(--code-bg);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  border-radius: 4px;
  margin-bottom: 1.25rem;
}

.prose pre code {
  background: none;
  padding: 0;
}

.prose ul,
.prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.prose li {
  line-height: 1.65;
  margin-bottom: 0.4rem;
}

.prose blockquote {
  border-left: 3px solid var(--dim);
  padding-left: 1rem;
  margin-left: 0;
  margin-bottom: 1.25rem;
  font-style: italic;
  color: var(--muted);
}

/* Back-home link on long-form pages */
.back-home {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 15;
  color: var(--muted);
  text-decoration: none;
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Cascadia Code', 'JetBrains Mono', monospace;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  transition: color 0.2s;
}

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

/* /projects entries */
.project h2 a {
  color: var(--fg);
}

.project h2 a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Marks the heading as an outbound link */
.project h2 a::after {
  content: ' ↗';
  font-size: 0.7em;
  color: var(--muted);
}

.prose .project-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: -0.75rem;
}

/* ◐ theme switch (scripts/theme.js), mirroring the back-home link */
.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 15;
  font: inherit;
  font-size: clamp(1rem, 3vw, 1.2rem);
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0.25rem;
  cursor: pointer;
  transition: color 0.2s;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--accent);
}

/* PGP key block on /verify */
.pgp {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--dot);
}

.pgp h2 {
  margin-top: 0;
}

.pgp-fpr {
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.prose .pgp-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

/* ØØ Void easter egg (scripts/void.js) */
.name.void-peek::before,
.name.void-peek::after {
  animation-duration: 0.9s;
}

html.void body::after {
  content: '';
  position: fixed;
  inset: 0;
  /* The vignette closes in on every swell of the drone */
  background: radial-gradient(
    ellipse at center,
    transparent calc(35% - var(--void-amp, 0.5) * 20%),
    rgba(40, 0, 6, 0.65) 60%,
    #000 88%
  );
  pointer-events: none;
  z-index: 9;
  animation: void-dim 4s ease-out forwards;
}

/* Force the dark palette while the drone plays, whatever the theme */
html.void:root {
  --bg: #000;
  --fg: #e6edf3;
  --muted: #8b949e;
  --dim: #6e7681;
  --accent: #c8102e;
  --scanline: rgba(255, 255, 255, calc(0.02 + var(--void-amp, 0.5) * 0.06));
  --dot: rgba(255, 255, 255, 0.12);
}

/* Scoped to the effect so normal theme toggles stay instant */
html.void body,
html.void-out body {
  transition: background-color 3s ease, color 3s ease;
}

/* Dots fall into the centre, then drift back out; timings are set per dot in void.js */
.dot {
  transition-property: left, top, opacity;
  transition-timing-function: ease-out;
}

html.void .dot {
  animation: none;
  opacity: 0;
  transition-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
}

@media (prefers-reduced-motion: no-preference) {
  html.void .dot {
    left: 50vw !important;
    top: 50vh !important;
  }
}

/* Stage fog, thickening and thinning with the drone */
.void-fog {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  z-index: 6;
  animation: void-dim 4s ease-out forwards;
}

html.void-out .void-fog {
  animation: void-undim 3s ease-in forwards;
}

.void-fog::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 40% 30% at 30% 60%, rgba(120, 10, 24, 0.22), transparent 70%),
    radial-gradient(ellipse 35% 25% at 70% 40%, rgba(180, 185, 200, 0.15), transparent 70%),
    radial-gradient(ellipse 50% 20% at 50% 85%, rgba(90, 0, 14, 0.25), transparent 70%);
  opacity: calc(0.3 + var(--void-amp, 0.5) * 0.7);
  animation: void-fog-drift 40s ease-in-out infinite alternate;
}

@keyframes void-fog-drift {
  from { transform: translate(-4%, 2%) scale(1); }
  to   { transform: translate(4%, -2%) scale(1.15); }
}

@keyframes void-undim {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Smaller and capped so the motto breaks after "=" and fits on phones */
html.void .name {
  font-size: clamp(1.25rem, 5vw, 2.5rem);
  max-width: 19ch;
  animation: void-breathe 6s ease-in-out infinite;
}

/* Red and cyan split apart on the swells, like a failing CRT */
html.void .name,
html.void .prose h1 {
  text-shadow:
    calc(var(--void-amp, 0.5) * 5px) 0 rgba(200, 16, 46, 0.8),
    calc(var(--void-amp, 0.5) * -3px) 0 rgba(0, 255, 255, 0.25);
}

/* Bass tremor */
@media (prefers-reduced-motion: no-preference) {
  html.void .content,
  html.void .prose {
    transform: translate(
      calc((var(--void-amp, 0.5) - 0.5) * 3px),
      calc((0.5 - var(--void-amp, 0.5)) * 2px)
    );
  }
}

@keyframes void-dim {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes void-breathe {
  0%, 100% { letter-spacing: -0.02em; }
  50%      { letter-spacing: 0.08em; }
}

.void-caption {
  position: fixed;
  bottom: 2rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  z-index: 11;
  animation: void-dim 4s ease-out forwards;
}

.void-caption a {
  color: var(--fg);
}

@media (prefers-reduced-motion: reduce) {
  html.void .name { animation: none; }
  .void-fog::before { animation: none; }
}
