/* springer1985 */

:root { /* the Windows 95 desktop */
  --bg: #008080;
  --ink: #0b0b1a;
  --side: #0b1240;
}

:root.night { /* outer space */
  --bg: #05060f;
  --ink: #000;
  --side: #1b2580;
}

:root.gameboy {
  --bg: #9bbc0f;
  --ink: #0f380f;
  --side: #0f380f;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- the playground ---------- */

#world {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pinch-zoom; /* one finger is for poking letters and painting; two still zoom */
}

.gameboy #world { image-rendering: pixelated; }

/* ---------- the name, before (or without) JavaScript ---------- */

.title {
  position: fixed;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Racing Sans One', 'Arial Black', sans-serif;
  font-weight: 400;
  font-size: clamp(30px, 9vw, 160px);
  line-height: 1;
  letter-spacing: .04em;
  white-space: nowrap;
  pointer-events: none;
}

.title span {
  -webkit-text-stroke: .07em var(--ink);
  paint-order: stroke fill;
  text-shadow: /* poor man's WordArt */
    .02em .025em 0 var(--side),
    .04em .05em 0 var(--side),
    .06em .075em 0 var(--side),
    .08em .1em 0 var(--ink);
}

/* same colour cycle as the canvas: blue, yellow, red */
.title span:nth-child(3n + 1) { color: #1f5fff; }
.title span:nth-child(3n + 2) { color: #ffcc00; }
.title span:nth-child(3n + 3) { color: #ff3b1f; }

/* With JavaScript the canvas draws the letters; this stays for screen readers.
   If the script never starts, the plain version shows up after a moment. */
.js .title {
  opacity: 0;
  animation: failsafe 0s 3.5s forwards;
}

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

.js.ready .title {
  inset: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  animation: none;
}

/* ---------- sound: a Windows 95 button ---------- */

.sound {
  position: fixed;
  z-index: 2;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 52px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #c0c0c0;
  color: #000;
  cursor: pointer;
  box-shadow:
    inset -1px -1px #0a0a0a,
    inset 1px 1px #ffffff,
    inset -2px -2px #808080,
    inset 2px 2px #dfdfdf;
}

/* pressed in while it's held, and stays pressed in while the sound is on */
.sound:active,
.sound.is-on {
  box-shadow:
    inset 1px 1px #0a0a0a,
    inset -1px -1px #ffffff,
    inset 2px 2px #808080,
    inset -2px -2px #dfdfdf;
}

.sound:active svg,
.sound.is-on svg { transform: translate(1px, 1px); }

.sound:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -6px;
}

.sound svg {
  width: 26px;
  height: 24px;
  fill: currentColor;
  shape-rendering: crispEdges;
}

.sound__waves { display: none; }
.sound.is-on .sound__waves { display: inline; }
.sound.is-on .sound__mute { display: none; }

.gameboy .sound {
  background: #8bac0f;
  color: #0f380f;
  box-shadow: inset -2px -2px #0f380f, inset 2px 2px #9bbc0f, inset -4px -4px #306230;
}

.gameboy .sound:active,
.gameboy .sound.is-on {
  box-shadow: inset 2px 2px #0f380f, inset -2px -2px #9bbc0f, inset 4px 4px #306230;
}

.gameboy .sound:focus-visible { outline-color: #0f380f; }

.js .sound {
  opacity: 0;
  animation:
    pop-in .45s 1.9s cubic-bezier(.3, 1.7, .5, 1) forwards,
    wiggle .6s 3.4s ease-in-out 2;
}

@keyframes pop-in {
  from { opacity: 0; scale: .3; }
  to   { opacity: 1; scale: 1; }
}

@keyframes wiggle {
  0%, 100% { rotate: 0deg; }
  25%      { rotate: -10deg; }
  75%      { rotate: 10deg; }
}

/* ---------- texture ---------- */

.grain {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: .06;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.night .grain {
  mix-blend-mode: screen;
  opacity: .04;
}

/* the Game Boy's dot-matrix screen */
.gameboy .grain {
  opacity: 1;
  background-image:
    linear-gradient(rgba(15, 56, 15, .12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 56, 15, .12) 1px, transparent 1px);
  background-size: 4px 4px;
}

/* ---------- less motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .js .sound {
    opacity: 1;
    animation: none;
  }
}
