:root {
  --bg: #0a0612;
  --bg-top: #150c26;
  --fg: #e6dcff;
  --fg-rgb: 230, 220, 255;
  --purple: #b06bff;
  --purple-rgb: 176, 107, 255;
  --purple-bright: #d9a8ff;
  --purple-dim: #6b3fa0;
  --cyan: #52f2ea;
  --magenta: #ff4fd8;
  --panel-rgb: 18, 11, 31;
  --dim-text: #9b8bb8;
  --muted: #7a7189;
}

/* shitty.engineer: same system, browner and shittier palette */
body.site-shitty {
  --bg: #120b06;
  --bg-top: #241708;
  --fg: #e8d9c0;
  --fg-rgb: 232, 217, 192;
  --purple: #d98a3d;
  --purple-rgb: 217, 138, 61;
  --purple-bright: #f5b860;
  --purple-dim: #7a4f22;
  --cyan: #b5a642;
  --magenta: #c1440e;
  --panel-rgb: 26, 16, 7;
  --dim-text: #a89484;
  --muted: #8a7863;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(ellipse at top, var(--bg-top) 0%, var(--bg) 60%);
  color: var(--fg);
  font-family: ui-monospace, "Cascadia Code", "Fira Code", "JetBrains Mono",
    Consolas, "SFMono-Regular", Menlo, monospace;
  min-height: 100vh;
}

a {
  color: var(--purple-bright);
}

/* ---------- CRT overlay layers ---------- */

.crt {
  position: relative;
  min-height: 100vh;
}

.crt__content {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
}

.crt__scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 2px,
    transparent 3px
  );
  mix-blend-mode: multiply;
  animation: scanline-scroll 8s linear infinite;
}

.crt__scanlines::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -120px;
  height: 120px;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(var(--purple-rgb), 0.06),
    transparent
  );
  animation: scan-sweep 9s linear infinite;
}

@keyframes scanline-scroll {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 0 100px;
  }
}

@keyframes scan-sweep {
  0% {
    top: -120px;
  }
  100% {
    top: 100%;
  }
}

.crt__vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  background: radial-gradient(
    ellipse at center,
    transparent 55%,
    rgba(0, 0, 0, 0.55) 100%
  );
}

.crt__flicker {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 11;
  background: rgba(var(--fg-rgb), 0.02);
  animation: flicker 6.5s infinite;
}

@keyframes flicker {
  0%,
  96%,
  100% {
    opacity: 1;
  }
  97% {
    opacity: 0.85;
  }
  98% {
    opacity: 1;
  }
  98.5% {
    opacity: 0.9;
  }
  99% {
    opacity: 1;
  }
}

/* grime layer: invisible on the clean sites, a smudged dust/coffee-ring
   texture on the shittier ones */
.crt__grime {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

.site-shitty .crt__grime {
  opacity: 0.5;
  mix-blend-mode: overlay;
  background-image: radial-gradient(
      circle at 12% 18%,
      rgba(0, 0, 0, 0.35) 0%,
      transparent 3%
    ),
    radial-gradient(circle at 82% 74%, rgba(0, 0, 0, 0.3) 0%, transparent 4%),
    radial-gradient(
      circle at 68% 22%,
      rgba(var(--fg-rgb), 0.06) 0%,
      transparent 5%
    ),
    radial-gradient(
      ellipse 220px 160px at 90% 8%,
      rgba(0, 0, 0, 0.18) 0%,
      transparent 70%
    ),
    radial-gradient(
      circle at 30% 88%,
      rgba(0, 0, 0, 0.25) 0%,
      transparent 6%
    );
  background-repeat: no-repeat;
}

/* ---------- header / glitch title ---------- */

.site-header {
  text-align: center;
  margin-bottom: 1rem;
}

.tagline {
  color: var(--dim-text);
  margin-top: 0.5rem;
}

.glitch {
  position: relative;
  display: inline-block;
  font-size: clamp(2rem, 8vw, 4.5rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--purple-bright);
  text-shadow: 0 0 8px var(--purple), 0 0 24px var(--purple-dim);
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  background: transparent;
}

.glitch::before {
  color: var(--cyan);
  animation: glitch-shift 4.5s infinite steps(2, end);
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  transform: translate(-2px, 0);
}

.glitch::after {
  color: var(--magenta);
  animation: glitch-shift 4.5s infinite steps(2, end) reverse;
  clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
  transform: translate(2px, 0);
}

/* shittier build: the wiring is worse, so it glitches more often */
.site-shitty .glitch::before {
  animation-duration: 2.2s;
}

.site-shitty .glitch::after {
  animation-duration: 2.2s;
}

@keyframes glitch-shift {
  0%,
  91%,
  100% {
    transform: translate(0, 0);
    opacity: 0;
  }
  92% {
    transform: translate(-3px, 1px);
    opacity: 0.8;
  }
  94% {
    transform: translate(3px, -1px);
    opacity: 0.8;
  }
  96% {
    transform: translate(-2px, 0);
    opacity: 0.6;
  }
  98% {
    transform: translate(2px, 1px);
    opacity: 0;
  }
}

/* ---------- terminal / bio block ---------- */

.terminal {
  background: rgba(var(--panel-rgb), 0.6);
  border: 1px solid var(--purple-dim);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin: 2.5rem 0;
  box-shadow: 0 0 24px rgba(var(--purple-rgb), 0.08) inset;
  max-height: 60vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--purple-dim) transparent;
  cursor: text;
}

.terminal:focus {
  outline: none;
  border-color: var(--purple-bright);
  box-shadow: 0 0 24px rgba(var(--purple-rgb), 0.08) inset,
    0 0 20px rgba(var(--purple-rgb), 0.25);
}

.terminal p {
  margin: 0 0 0.35rem 0;
}

/* shittier build: the terminal panel is held on with duct tape */
.site-shitty .terminal {
  border-style: dashed;
  transform: rotate(-0.35deg);
}

.prompt {
  color: var(--purple-bright);
}

.prompt-sep,
.prompt-dollar {
  color: var(--purple-dim);
}

.prompt-path {
  color: var(--cyan);
}

.output {
  margin: 0.25rem 0 1rem 0 !important;
  color: var(--fg);
  white-space: pre-wrap;
}

.output--dim {
  color: var(--muted);
  font-style: italic;
}

.output--error {
  color: var(--magenta);
}

.terminal__input-row {
  position: relative;
  margin: 0 0 0.35rem 0;
}

/* Invisible, non-interactive-by-pointer input that exists purely so
   touchscreens have a real editable control to focus — tapping a plain
   div never summons the on-screen keyboard. Overlaid on the input row so
   the browser's focus-scroll lands in the right place; JS decides when to
   focus it (see terminal.js), desktop mouse/keyboard use never touches it. */
.terminal-mobile-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 1.4em;
  border: none;
  outline: none;
  padding: 0;
  margin: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font: inherit;
  font-size: 16px; /* iOS Safari zooms the page on focus below 16px */
  opacity: 0;
  pointer-events: none;
}

.terminal-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  margin-left: 1px;
  background: var(--purple-bright);
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ---------- projects ---------- */

.projects h2 {
  color: var(--purple-dim);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.project-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: rgba(var(--panel-rgb), 0.5);
  border: 1px solid var(--purple-dim);
  border-radius: 6px;
  padding: 1.25rem;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.project-card:hover,
.project-card:focus-visible {
  border-color: var(--purple-bright);
  box-shadow: 0 0 20px rgba(var(--purple-rgb), 0.25);
  transform: translateY(-2px);
}

/* shittier build: the cards are taped on slightly crooked */
.site-shitty .project-card {
  border-style: dashed;
}

.site-shitty .project-card:nth-child(odd) {
  transform: rotate(-0.5deg);
}

.site-shitty .project-card:nth-child(even) {
  transform: rotate(0.4deg);
}

.site-shitty .project-card:hover,
.site-shitty .project-card:focus-visible {
  transform: translateY(-2px) rotate(0deg);
}

.project-card__header {
  font-weight: 700;
  color: var(--purple-bright);
  margin-bottom: 0.5rem;
}

.project-card__bracket {
  color: var(--purple-dim);
}

.project-card__desc {
  color: var(--fg);
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.project-card__meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--dim-text);
}

/* ---------- footer ---------- */

.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--purple-dim);
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- 404 ---------- */

.not-found {
  text-align: center;
  padding: 6rem 1rem;
}

.not-found h1 {
  font-size: 5rem;
  color: var(--magenta);
  text-shadow: 0 0 20px var(--magenta);
  margin: 0;
}

.back-link {
  display: inline-block;
  margin-top: 1.5rem;
}
