:root {
  --void: #000000;
  --bone: #eef0f4;
  --ash: #8c93a0;
  --smoke: #3b3f47;
  --blood: #b3121f;
  --blood-deep: #5a0a10;

  --display: "Jacquard 24", "UnifrakturMaguntia", serif;
  --text: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

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

html {
  background: var(--void);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  /* faint pixel blood stains down both edges, pinned behind everything */
  background:
    url("/stains-l.svg") left top / clamp(110px, 24vw, 380px) auto repeat-y fixed,
    url("/stains-r.svg") right top / clamp(110px, 24vw, 380px) auto repeat-y fixed,
    var(--void);
  color: var(--bone);
  font-family: var(--text);
  font-size: 14px;
  line-height: 1.6;
  font-variation-settings: "wdth" 87.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 1px solid var(--bone);
  outline-offset: 4px;
}

::selection {
  background: var(--bone);
  color: var(--void);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 64px 20px 72px;
}

/* hero: the sigil, then the name underneath it */

.ward {
  text-align: center;
}

.sigil {
  display: block;
  width: min(84vw, 400px);
  height: auto;
  max-height: 58vh;
  margin: 0 auto;
  overflow: visible;
  /* slow double heartbeat in blood red */
  animation: beat 4.8s ease-out 1.2s infinite;
}

@keyframes beat {
  0%, 30%, 100% { filter: drop-shadow(0 0 6px rgb(var(--pulse) / 0.12)); }
  5% { filter: drop-shadow(0 0 22px rgb(var(--pulse) / 0.55)); }
  11% { filter: drop-shadow(0 0 8px rgb(var(--pulse) / 0.18)); }
  17% { filter: drop-shadow(0 0 18px rgb(var(--pulse) / 0.42)); }
}

/* the heartbeat takes the colour of hexx's Discord status */
body { --pulse: 179 18 31; }
.mood-online { --pulse: 35 165 90; }
.mood-idle { --pulse: 240 178 50; }
.mood-dnd { --pulse: 179 18 31; }

/* offline: no beat, just a slow grey flatline */
.mood-offline .sigil {
  animation: flatline 7s ease-in-out 1.2s infinite;
}

@keyframes flatline {
  0%, 100% { filter: drop-shadow(0 0 4px rgb(128 132 142 / 0.08)); }
  50% { filter: drop-shadow(0 0 10px rgb(128 132 142 / 0.22)); }
}

/* pixels pop in from the center outward, in hard steps, no fades */
.sigil .p {
  opacity: 0;
  /* jump-start: the pixel switches on the instant its delay ends, so float
     rounding at the end of the animation can never leave it hidden */
  animation: pop 1ms steps(1, jump-start) 0.95s forwards;
}

.sigil .d1 { animation-delay: 1.02s; }
.sigil .d2 { animation-delay: 1.09s; }
.sigil .d3 { animation-delay: 1.16s; }
.sigil .d4 { animation-delay: 1.23s; }
.sigil .d5 { animation-delay: 1.3s; }
.sigil .d6 { animation-delay: 1.37s; }
.sigil .d7 { animation-delay: 1.44s; }
.sigil .d8 { animation-delay: 1.51s; }
.sigil .d9 { animation-delay: 1.58s; }

/* summoning: black, then one red pixel flickers at the heart, then it burns in */
.sigil .seed {
  opacity: 0;
  animation: seed 1.25s steps(1, end) forwards;
}

@keyframes seed {
  0% { opacity: 0; }
  36% { opacity: 1; }
  50% { opacity: 0.3; }
  58% { opacity: 1; }
  99% { opacity: 1; }
  100% { opacity: 0; }
}

/* everything else rises up once the sigil is in */
.name,
.tagline,
.drawn,
.presence,
.work,
.elsewhere,
.souls,
.foot {
  animation: rise 0.5s steps(5, jump-start) 1.7s both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes pop {
  to {
    opacity: 1;
  }
}

.name {
  position: relative;
  margin: 18px 0 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(96px, 27vw, 156px);
  line-height: 0.82;
  letter-spacing: 0.01em;
}

/* smooth chrome, with a bright shine sweeping across every few seconds */
.name .chrome {
  position: relative;
  display: inline-block;
  background:
    linear-gradient(100deg, transparent 42%, rgba(255, 255, 255, 0.95) 50%, transparent 58%) no-repeat,
    linear-gradient(180deg, #ffffff 0%, #d4d8e0 36%, #5b616c 50%, #eef0f4 60%, #8c93a0 100%);
  background-size: 250% 100%, 100% 100%;
  background-position: 160% 0, 0 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #000) drop-shadow(0 0 16px #000);
  animation: shine 6.5s ease-in-out 1.8s infinite;
}

@keyframes shine {
  0% { background-position: 160% 0, 0 0; }
  28%, 100% { background-position: -60% 0, 0 0; }
}

/* glitch: for a split second the name tears into blood-red and white slices */
.name::before,
.name::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.name::before {
  color: var(--blood);
  animation: tear-red 7.3s steps(1, end) 3s infinite;
}

.name::after {
  color: var(--bone);
  animation: tear-white 7.3s steps(1, end) 3s infinite;
}

@keyframes tear-red {
  0%, 90%, 100% { opacity: 0; transform: none; clip-path: inset(0); }
  91% { opacity: 0.9; transform: translate(-6px, 0); clip-path: inset(12% 0 62% 0); }
  92% { opacity: 0.9; transform: translate(5px, 0); clip-path: inset(58% 0 18% 0); }
  93% { opacity: 0.9; transform: translate(-4px, 0); clip-path: inset(34% 0 44% 0); }
  94% { opacity: 0; }
}

@keyframes tear-white {
  0%, 91%, 100% { opacity: 0; transform: none; clip-path: inset(0); }
  92% { opacity: 0.7; transform: translate(4px, 0); clip-path: inset(70% 0 8% 0); }
  93% { opacity: 0.7; transform: translate(-3px, 0); clip-path: inset(20% 0 66% 0); }
  94% { opacity: 0; }
}

.tagline {
  margin: 18px 0 0;
  font-size: 16px;
  font-variation-settings: "wdth" 100;
}

.drawn {
  max-width: 34ch;
  margin: 28px auto 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ash);
  font-variation-settings: "wdth" 75;
}

/* projects */

.section-h {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--ash);
  font-variation-settings: "wdth" 75;
}

.work {
  margin-top: 88px;
}

.proj-list,
.elsewhere ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.proj {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  padding: 14px 0;
  text-decoration: none;
}

.proj-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 500;
  font-variation-settings: "wdth" 100;
}

/* a small thorn pointing at each project; it lunges when you hover */
.proj-name::before {
  content: "";
  flex: none;
  width: 12px;
  height: 5px;
  background: linear-gradient(90deg, var(--smoke), var(--bone));
  clip-path: polygon(0 0, 100% 50%, 0 100%, 18% 50%);
  transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.proj:hover .proj-name::before,
.proj:focus-visible .proj-name::before {
  width: 24px;
}

.proj-tag {
  align-self: center;
  font-size: 12px;
  color: var(--ash);
  font-variation-settings: "wdth" 75;
}

.proj-about {
  grid-column: 1 / -1;
  padding-left: 22px;
  font-size: 13px;
  color: var(--ash);
}

.proj:hover .proj-about,
.proj:focus-visible .proj-about {
  color: var(--bone);
}

/* discord status, from lanyard */

.presence {
  margin: 44px auto 0;
  max-width: 40ch;
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ash);
  font-variation-settings: "wdth" 75;
}

.presence p {
  margin: 0;
}

.presence-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--bone);
}

/* square pixel dot to match the sigil */
.presence-dot {
  width: 8px;
  height: 8px;
  background: var(--dot);
}

.presence-online { --dot: #23a55a; }
.presence-idle { --dot: #f0b232; }
.presence-dnd { --dot: #f23f43; }
.presence-offline { --dot: #80848e; }

.presence-handle {
  font-size: 14px;
  font-variation-settings: "wdth" 100;
  user-select: all;
  -webkit-user-select: all;
  cursor: text;
}

.presence-line {
  margin-top: 2px;
}

.presence-name,
.presence-line a {
  color: var(--bone);
}

.presence-line a {
  text-decoration-color: var(--smoke);
  text-underline-offset: 4px;
}

.presence-line a:hover {
  text-decoration-color: var(--bone);
}

.presence-detail {
  display: block;
}

.presence-custom {
  font-style: italic;
}

/* elsewhere */

.elsewhere {
  margin-top: 40px;
}

.elsewhere ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 28px;
}

.elsewhere a {
  font-size: 14px;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  text-decoration-color: var(--smoke);
}

.elsewhere a:hover {
  text-decoration-color: var(--bone);
}

/* footer: one quiet link */

.foot {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px 40px;
  text-align: center;
  font-size: 12px;
  font-variation-settings: "wdth" 75;
}

.foot a {
  color: var(--ash);
  text-decoration: none;
}

.foot a:hover,
.foot a:focus-visible {
  color: var(--bone);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* privacy page */

.policy {
  padding-top: 40px;
}

.policy .back {
  font-size: 12px;
  color: var(--ash);
  font-variation-settings: "wdth" 75;
  text-underline-offset: 4px;
}

.policy h1 {
  margin: 40px 0 4px;
  font-size: 24px;
  font-weight: 500;
  font-variation-settings: "wdth" 100;
}

.policy .updated {
  margin: 0 0 32px;
  font-size: 12px;
  color: var(--ash);
  font-variation-settings: "wdth" 75;
}

.policy h2 {
  margin: 36px 0 8px;
  font-size: 14px;
  font-weight: 500;
  font-variation-settings: "wdth" 100;
}

.policy p,
.policy li {
  font-size: 13px;
  line-height: 1.75;
  color: #c4c8d0;
}

.policy ul {
  margin: 8px 0;
  padding-left: 18px;
}

.policy strong {
  color: var(--bone);
  font-weight: 500;
}

.policy a {
  text-underline-offset: 4px;
}

@media (min-width: 640px) {
  body {
    font-size: 15px;
  }
  main {
    padding-top: 80px;
  }
}

/* cursor blood trail canvas (drawn by fx.js) */
.fx {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 5;
  image-rendering: pixelated;
}

/* splatters drawn by fx.js sit under the text, drops fly over it */
.fx-under {
  z-index: 0;
}

main,
.foot {
  position: relative;
  z-index: 1;
}

/* the curse: type the name */
html.cursed .sigil {
  animation: none;
  filter: sepia(1) saturate(8) hue-rotate(-45deg) drop-shadow(0 0 26px rgba(255, 42, 61, 0.9));
}

html.cursed body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: rgba(179, 18, 31, 0.3);
  animation: flash 900ms steps(3, end) forwards;
}

@keyframes flash {
  to {
    opacity: 0;
  }
}

/* witching hour (midnight to 3am, visitor's own clock): darker, redder, faster heart */
html.witching body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, transparent 35%, rgba(90, 10, 16, 0.5) 100%);
}

html.witching .sigil {
  animation-duration: 2.4s;
}

/* souls taken: a running visit count in the pixel blackletter */
.souls {
  margin: 36px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--ash);
  font-variation-settings: "wdth" 75;
}

.souls-n {
  display: block;
  margin-top: 2px;
  font-family: var(--display);
  font-size: 44px;
  line-height: 1;
  color: var(--bone);
  text-shadow: 0 0 12px rgb(179 18 31 / 0.5);
}

/* pixel dagger cursors: chrome normally, bloody over anything clickable */
html {
  cursor: url("/cursor.svg") 0 0, auto;
}

a,
button,
[role="button"] {
  cursor: url("/cursor-link.svg") 0 0, pointer;
}

/* hold to awaken: trembles while you hold, then rises, cracks and bleeds */
.sigil {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html .sigil.charging {
  animation: charge 0.12s steps(2, end) infinite;
}

@keyframes charge {
  0% { transform: translate(-1px, 0); filter: drop-shadow(0 0 14px rgb(179 18 31 / 0.5)); }
  100% { transform: translate(1px, -1px); filter: drop-shadow(0 0 20px rgb(179 18 31 / 0.7)); }
}

html .sigil.awaken {
  animation: awaken 2.4s steps(24, end) forwards;
}

@keyframes awaken {
  0% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 20px rgb(255 42 61 / 0.7)); }
  25% { transform: translateY(-22px) scale(1.07); filter: drop-shadow(0 0 40px rgb(255 42 61 / 0.95)) brightness(1.4); }
  32%, 60% { transform: translateY(-22px) scale(1.07); filter: sepia(1) saturate(8) hue-rotate(-45deg) drop-shadow(0 0 40px rgb(255 42 61 / 0.95)); }
  70% { transform: translateY(-22px) scale(1.07); filter: drop-shadow(0 0 30px rgb(179 18 31 / 0.8)); }
  100% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 6px rgb(179 18 31 / 0.12)); }
}

.elsewhere a:hover,
.elsewhere a:focus-visible {
  color: #ff3344;
  text-decoration-color: var(--blood);
}

@media (prefers-reduced-motion: reduce) {
  .sigil,
  .name .chrome,
  .name::before,
  .name::after {
    animation: none;
  }
  .sigil .p {
    animation: none;
    opacity: 1;
  }
  .sigil .seed {
    display: none;
  }
  .name,
  .tagline,
  .drawn,
  .presence,
  .work,
  .elsewhere,
  .souls,
  .foot {
    animation: none;
  }
  .proj-name::before {
    transition: none;
  }
}
