@font-face {
  font-family: "InterVariable";
  src: url("fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --gray: #262626;
  --accent: #e73b3b;
  --glitch-blend: hard-light;
  --duration-right: 440ms;
  --duration-left: 300ms;
  --delay-left: 480ms;
  --delay-third: 820ms;
  --sequence-duration: 780ms;
  --offset-left: 0.205em;
  --offset-down: 0.085em;
  --offset-right: 0.205em;
  --offset-up: 0.095em;
}

* {
  box-sizing: border-box;
}

body {
  --surface: var(--gray);
  --logo-ink: var(--accent);
  isolation: isolate;
  min-height: 100svh;
  margin: 0;
  background-color: var(--surface);
  font-family: "InterVariable", sans-serif;
  font-feature-settings:
    "cv11" 1,
    "tnum" 1,
    "ss03" 1;
  transition: background-color 0.5s ease-in-out;
}

/* One static grain layer covers the background, logo, and text. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.085;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22256%22%20height%3D%22256%22%20viewBox%3D%220%200%20256%20256%22%3E%3Cfilter%20id%3D%22grain%22%20x%3D%220%22%20y%3D%220%22%20width%3D%22100%25%22%20height%3D%22100%25%22%3E%3CfeTurbulence%20type%3D%22fractalNoise%22%20baseFrequency%3D%220.8%22%20numOctaves%3D%223%22%20seed%3D%2217%22%20stitchTiles%3D%22stitch%22%2F%3E%3CfeColorMatrix%20type%3D%22saturate%22%20values%3D%220%22%2F%3E%3C%2Ffilter%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20filter%3D%22url%28%23grain%29%22%2F%3E%3C%2Fsvg%3E");
  background-size: 256px 256px;
  background-repeat: repeat;
}

main {
  background-color: var(--surface);
  transition: background-color 0.5s ease-in-out;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: 24px;
}

.svg-container {
  position: relative;
  display: block;
  width: 200px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--logo-ink);
  font-size: inherit;
  cursor: pointer;
  animation: fade-in 1.5s ease-in-out backwards;
  transition: color 0.5s ease-in-out;
  -webkit-tap-highlight-color: transparent;
}

.svg-container svg {
  display: block;
  width: 100%;
  height: auto;
  fill: currentColor;
}

.svg-container:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 10px;
}

.branding-text {
  margin: 1rem 0;
  color: var(--gray);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.025rem;
}

/* One shared state works with a mouse, keyboard, and a touch screen. */
body.is-inverted {
  --surface: var(--accent);
  --logo-ink: var(--gray);
}

/* Fill the original vector directly; the RGB copies stay hidden while inverted. */
.svg-container .logo-base {
  fill: var(--logo-ink);
  transition: fill 0.5s ease-in-out;
}

.logo-base path,
.logo-base polygon,
.logo-base rect {
  transition: fill 0.5s ease-in-out;
}

body.is-inverted .glitch-layer {
  animation: none !important;
  opacity: 0;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Both ghost logos blend over the stationary original; grain remains above all. */
.logo-base {
  position: relative;
  z-index: 0;
}

.svg-container .glitch-layer {
  mix-blend-mode: var(--glitch-blend);
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.glitch-layer--cool {
  z-index: 1;
  color: color-mix(in srgb, var(--accent) 65%, #8be9ff);
}

.glitch-layer--warm {
  z-index: 2;
  color: color-mix(in srgb, var(--accent) 65%, #ff90be);
}

.is-glitching .glitch-layer--cool {
  animation: glitch-upper-right var(--duration-right) steps(1, end);
}

.is-glitching .glitch-layer--warm {
  animation: glitch-lower-left var(--duration-left) var(--delay-left) steps(1, end);
}

@keyframes glitch-upper-right {
  0%,
  100% {
    opacity: 0;
    transform: none;
  }
  10% {
    opacity: 0.7;
    transform: translate(var(--offset-right), calc(-1 * var(--offset-up)));
  }
  30% {
    opacity: 0.5;
    transform: translate(var(--offset-right), calc(-1 * var(--offset-up)));
  }
  48% {
    opacity: 0.65;
    transform: translate(var(--offset-right), calc(-1 * var(--offset-up)));
  }
  72% {
    opacity: 0.35;
    transform: translate(var(--offset-right), calc(-1 * var(--offset-up)));
  }
  88% {
    opacity: 0.2;
    transform: translate(calc(var(--offset-right) / 2), calc(var(--offset-up) / -2));
  }
}

@keyframes glitch-lower-left {
  0%,
  100% {
    opacity: 0;
    transform: none;
  }
  10% {
    opacity: 0.6;
    transform: translate(calc(-1 * var(--offset-left)), var(--offset-down));
  }
  30% {
    opacity: 0.4;
    transform: translate(calc(-1 * var(--offset-left)), var(--offset-down));
  }
  48% {
    opacity: 0.55;
    transform: translate(calc(-1 * var(--offset-left)), var(--offset-down));
  }
  72% {
    opacity: 0.3;
    transform: translate(calc(-1 * var(--offset-left)), var(--offset-down));
  }
  88% {
    opacity: 0.15;
    transform: translate(calc(var(--offset-left) / -2), calc(var(--offset-down) / 2));
  }
}

@media (prefers-reduced-motion: reduce) {
  .is-glitching .glitch-layer {
    animation: none !important;
  }
}

.glitch-layer--third {
  z-index: 3;
  color: #7194ff;
}

[data-effect="rgb"] .glitch-layer--cool {
  color: #ff425d;
}
[data-effect="rgb"] .glitch-layer--warm {
  color: #33e6ac;
}
[data-effect="rgb"] .glitch-layer--third {
  color: #5486ff;
}
.is-glitching[data-effect="rgb"] .glitch-layer--third {
  animation: glitch-upper-right var(--duration-right) var(--delay-third) steps(1, end);
}

@media (prefers-reduced-motion: reduce) {
  .is-glitching .glitch-layer {
    animation: none !important;
  }
}
