/* RetroEnder coming-soon page: 8-bit theme */

:root {
  --ink: #0c0b1d;
  --night: #14123a;
  --panel: #1c1948;
  --panel-hi: #2a2668;
  --frame: #3d3896;
  --text: #e8e6ff;
  --muted: #a9a6d6;

  /* NES-style palette */
  --white: #fcfcfc;
  --red: #e40058;
  --orange: #fca044;
  --yellow: #f8b800;
  --green: #58d854;
  --cyan: #3cbcfc;
  --blue: #0058f8;
  --purple: #6844fc;
  --pink: #f878f8;

  --px: 4px;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --body: "VT323", ui-monospace, monospace;
  --wrap: 1080px;

  /* Pixel arrow, used as a mask so it takes the current text color */
  --arrow-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 4' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h7v1H0zM1 1h5v1H1zM2 2h3v1H2zM3 3h1v1H3z'/%3E%3C/svg%3E");
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 1.375rem;
  line-height: 1.35;
  overflow-x: hidden;
}

svg,
canvas {
  display: block;
}

a {
  color: var(--cyan);
}

h1,
h2 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 400;
  line-height: 1.4;
}

p {
  margin: 0;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  appearance: none;
}

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

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 16px;
}

@media (min-width: 600px) {
  .wrap {
    padding: 0 24px;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sprite {
  display: inline-block;
  flex-shrink: 0;
  line-height: 0;
}

.arrow {
  display: inline-block;
  width: 14px;
  height: 8px;
  background: currentColor;
  -webkit-mask: var(--arrow-down) no-repeat center / contain;
  mask: var(--arrow-down) no-repeat center / contain;
}

.c-retro {
  color: var(--cyan);
}

.c-ender {
  color: var(--yellow);
}

/* ---------- Pixel frames ----------
   Four offset shadows draw a border with notched corners. */

.dialog,
.loading-bar,
.world,
.toast {
  --fc: var(--frame);
  margin: var(--px);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--fc),
    0 var(--px) 0 0 var(--fc),
    calc(var(--px) * -1) 0 0 0 var(--fc),
    var(--px) 0 0 0 var(--fc);
}

.dialog {
  --fc: var(--white);
  background: #000;
  color: var(--white);
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  background: linear-gradient(var(--ink), #291c62);
}

.hero-sky {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding-top: 56px;
  padding-bottom: 120px;
  text-align: center;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 28px;
  color: var(--green);
  font-family: var(--pixel);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hud-secrets {
  color: var(--yellow);
}

.logo {
  font-size: clamp(1.5rem, 8.4vw, 4.5rem);
  line-height: 1.1;
  white-space: nowrap;
  cursor: default;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.logo .c-retro {
  text-shadow: 0.125em 0.125em 0 var(--blue), 0.25em 0.25em 0 #000;
}

.logo .c-ender {
  text-shadow: 0.125em 0.125em 0 var(--red), 0.25em 0.25em 0 #000;
}

/* Secret: palette swap */
.palette-swap .logo .c-retro {
  color: var(--green);
  text-shadow: 0.125em 0.125em 0 var(--purple), 0.25em 0.25em 0 #000;
  animation: swap-retro 0.36s steps(1) infinite;
}

.palette-swap .logo .c-ender {
  color: var(--pink);
  text-shadow: 0.125em 0.125em 0 var(--blue), 0.25em 0.25em 0 #000;
  animation: swap-ender 0.36s steps(1) infinite;
}

.soon {
  padding-left: 0.3em;
  font-family: var(--pixel);
  font-size: clamp(0.875rem, 3.2vw, 1.5rem);
  letter-spacing: 0.3em;
  text-shadow: 0.125em 0.125em 0 #000;
  text-transform: uppercase;
}

.soon .letter {
  animation: cycle 1.6s steps(1) infinite;
  animation-delay: calc(var(--i) * -0.1s);
}

/* NPC dialog: every line sits in one grid cell so the box keeps the height of the longest */
.npc {
  width: calc(100% - 8px);
  max-width: 640px;
}

.npc-say {
  position: relative;
  display: block;
  width: 100%;
  padding: 20px 24px 30px;
  font-size: 1.75rem;
  line-height: 1.25;
  text-align: left;
}

.npc-say:focus-visible {
  outline-offset: 10px;
}

.type {
  display: grid;
}

.type > span {
  grid-area: 1 / 1;
}

.type-ghost {
  visibility: hidden;
}

.npc-next {
  position: absolute;
  right: 18px;
  bottom: 12px;
  visibility: hidden;
}

.npc.is-waiting .npc-next {
  visibility: visible;
  animation: bob 0.8s linear infinite;
}

/* Loading bar that never quite finishes */
.loading {
  width: min(100%, 420px);
}

.loading-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--green);
  font-family: var(--pixel);
  font-size: 0.625rem;
  text-transform: uppercase;
}

.loading-bar {
  --fc: var(--white);
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #000;
}

.loading-bar i {
  flex: 1;
  height: 20px;
  background: var(--green);
  opacity: 0.15;
}

.loading-bar i.on {
  opacity: 1;
}

.loading-bar i.blink {
  opacity: 1;
  animation: blink 0.6s steps(1) infinite;
}

.loading-note {
  min-height: 1.35em;
  margin-top: 14px;
  color: var(--muted);
}

.scroll-cue {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  color: var(--white);
  font-family: var(--pixel);
  font-size: 0.625rem;
  text-decoration: none;
  text-transform: uppercase;
}

.scroll-cue:hover {
  color: var(--yellow);
}

.scroll-cue .arrow {
  animation: bob 1s linear infinite;
}

/* ---------- Level select ---------- */

.section {
  position: relative;
  padding: 88px 0;
}

/* Crenellated pixel edge where the section meets its neighbours */
.section-alt {
  z-index: 1;
  background: var(--night);
}

.section-alt::before,
.section-alt::after {
  content: "";
  position: absolute;
  right: 0;
  left: 0;
  height: 8px;
  background: repeating-linear-gradient(90deg, var(--night) 0 16px, transparent 16px 32px);
}

.section-alt::before {
  top: -8px;
}

.section-alt::after {
  bottom: -8px;
}

.eyebrow {
  margin-bottom: 16px;
  color: var(--green);
  font-family: var(--pixel);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h2 {
  margin-bottom: 40px;
  color: var(--white);
  font-size: clamp(1.125rem, 3.6vw, 1.75rem);
  text-shadow: 0.125em 0.125em 0 var(--purple);
}

.worlds {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 760px) {
  .worlds {
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
  }
}

.world {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  padding: 28px 12px 22px;
  background: var(--panel);
  text-align: center;
}

.world:hover {
  background: var(--panel-hi);
}

.world-art {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 72px;
  filter: grayscale(1) brightness(0.55);
}

.world:hover .world-art,
.world:focus-visible .world-art {
  filter: grayscale(0.5) brightness(0.8);
}

.world-num {
  color: var(--yellow);
  font-family: var(--pixel);
  font-size: 0.5rem;
  text-transform: uppercase;
}

.world-name {
  color: var(--white);
  font-family: var(--pixel);
  font-size: 0.6875rem;
  line-height: 1.6;
  text-transform: uppercase;
}

.lock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding: 5px 8px;
  box-shadow: inset 0 0 0 2px var(--frame);
  color: var(--muted);
  font-family: var(--pixel);
  font-size: 0.5rem;
  text-transform: uppercase;
}

.world.is-unlocked .world-art {
  filter: none;
}

.world.is-unlocked .lock {
  background: var(--green);
  box-shadow: none;
  color: var(--ink);
}

.world.shake {
  animation: shake 0.4s steps(4);
}

/* ---------- Footer ---------- */

.site-footer {
  padding: 48px 0;
  background: #070612;
  color: var(--muted);
  font-size: 1.125rem;
  text-align: center;
}

.site-footer .fine {
  margin-top: 8px;
  font-size: 1rem;
  opacity: 0.8;
}

/* ---------- Effects ---------- */

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.1) 2px 3px);
  pointer-events: none;
}

.toast {
  --fc: var(--white);
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 60;
  width: max-content;
  max-width: calc(100vw - 48px);
  padding: 16px 20px;
  background: #000;
  color: var(--yellow);
  font-family: var(--pixel);
  font-size: 0.75rem;
  line-height: 1.6;
  text-align: center;
  transform: translate(-50%, 200%);
  transition: transform 0.3s steps(4);
}

.toast.show {
  transform: translate(-50%, 0);
}

.coin-rain {
  position: fixed;
  inset: 0;
  z-index: 55;
  overflow: hidden;
  pointer-events: none;
}

.coin {
  position: absolute;
  top: -40px;
  animation-name: coin-fall;
  animation-timing-function: steps(20);
  animation-fill-mode: both;
}

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

@keyframes bob {
  0%,
  49.9% {
    transform: translateY(0);
  }
  50%,
  100% {
    transform: translateY(4px);
  }
}

@keyframes cycle {
  0% {
    color: var(--white);
  }
  25% {
    color: var(--cyan);
  }
  50% {
    color: var(--yellow);
  }
  75% {
    color: var(--pink);
  }
}

@keyframes shake {
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(6px);
  }
  75% {
    transform: translateX(-4px);
  }
}

@keyframes swap-retro {
  0% {
    color: var(--green);
    text-shadow: 0.125em 0.125em 0 var(--purple), 0.25em 0.25em 0 #000;
  }
  33% {
    color: var(--pink);
    text-shadow: 0.125em 0.125em 0 var(--red), 0.25em 0.25em 0 #000;
  }
  66% {
    color: var(--white);
    text-shadow: 0.125em 0.125em 0 var(--cyan), 0.25em 0.25em 0 #000;
  }
}

@keyframes swap-ender {
  0% {
    color: var(--pink);
    text-shadow: 0.125em 0.125em 0 var(--blue), 0.25em 0.25em 0 #000;
  }
  33% {
    color: var(--cyan);
    text-shadow: 0.125em 0.125em 0 var(--purple), 0.25em 0.25em 0 #000;
  }
  66% {
    color: var(--orange);
    text-shadow: 0.125em 0.125em 0 var(--red), 0.25em 0.25em 0 #000;
  }
}

@keyframes coin-fall {
  to {
    transform: translateY(calc(100vh + 80px));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
