/*
 * craegsdesk.com: a project select screen in the spirit of late-90s/2000s fighting and action
 * games. "Blue Steel": a deep blue stage with scrolling stripes, chrome-framed showcase and
 * portrait tiles, a red-and-gold 1P cursor, and a teleport (digital egg + beam of light) into
 * each project. The chrome pixel logo and Aqua-era gloss carry over from the earlier hub.
 */

@font-face {
  font-family: 'Press Start 2P';
  src: url('/fonts/press-start-2p.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #071634;
  --bg-deep: #050f26;
  --panel-top: #164096;
  --panel: #0f2d6b;
  --panel-deep: #0a1d47;
  --edge: #5f77a8;
  --screen: #061230;
  --text: #f2f6ff;
  --muted: #a9b9d8;
  --electric: #3fa9ff;
  --gold: #ffc20e;
  --red: #e8182c;
  /* Polished chrome, for frames: bright top, a dark band through the middle, bright bottom. */
  --chrome: linear-gradient(180deg, #ffffff, #9aa9c4 45%, #5d6f94 55%, #e9eef6);
  --chrome-light: #e9eef6;
  --chrome-dark: #5d6f94;
  --pixel: 'Press Start 2P', ui-monospace, 'Courier New', monospace;
  --sans: Verdana, Tahoma, 'Segoe UI', system-ui, sans-serif;
  --display: 'Arial Black', 'Helvetica Neue', Impact, system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: dark;
}

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

html {
  /* Keep the scrollbar's space reserved, so the page doesn't shift sideways if its height changes. */
  scrollbar-gutter: stable;
  background: var(--bg-deep);
}

/* Diagonal stripes drifting slowly across the stage, select-screen style. */
html::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: linear-gradient(
    45deg,
    rgb(255 255 255 / 0.028) 25%,
    transparent 25% 50%,
    rgb(255 255 255 / 0.028) 50% 75%,
    transparent 75%
  );
  background-size: 64px 64px;
  animation: stripes 4s linear infinite;
}

@keyframes stripes {
  to {
    background-position: 64px 0;
  }
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(60rem 26rem at 50% -6rem, rgb(40 110 255 / 0.45), transparent 70%),
    radial-gradient(40rem 30rem at 0% 100%, rgb(232 24 44 / 0.12), transparent 70%),
    radial-gradient(40rem 30rem at 100% 90%, rgb(63 169 255 / 0.1), transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
}

/* A glowing grid floor along the bottom. */
body::before {
  content: '';
  position: fixed;
  right: -50%;
  bottom: 0;
  left: -50%;
  z-index: -1;
  height: 38vh;
  background-image:
    linear-gradient(rgb(63 169 255 / 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgb(63 169 255 / 0.16) 1px, transparent 1px);
  background-size: 52px 52px;
  transform: perspective(380px) rotateX(64deg);
  transform-origin: bottom;
  mask-image: linear-gradient(to top, #000, transparent 85%);
  pointer-events: none;
}

:focus-visible {
  outline: 2px solid var(--electric);
  outline-offset: 3px;
}

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

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 22px 20px 0;
}

/* Chrome type with a highlight that glints across every few seconds. */
.logo {
  display: inline-block;
  margin: 0;
  font-family: var(--pixel);
  font-size: clamp(20px, 3.4vw, 32px);
  font-weight: 400;
  line-height: 1.2;
  color: transparent;
  background-image:
    linear-gradient(105deg, transparent 42%, rgb(255 255 255 / 0.95) 50%, transparent 58%),
    linear-gradient(180deg, #ffffff 0%, #d8e2f2 44%, #7c8fb8 50%, #b4c3dd 72%, #f2f6fc 100%);
  background-size:
    300% 100%,
    100% 100%;
  background-position:
    150% 0,
    0 0;
  background-clip: text;
  filter: drop-shadow(2px 2px 0 #0b2a6b) drop-shadow(0 0 12px rgb(63 169 255 / 0.5));
  animation: glint 7s ease-in-out 1s infinite;
}

@keyframes glint {
  0%,
  80% {
    background-position:
      150% 0,
      0 0;
  }

  100% {
    background-position:
      -50% 0,
      0 0;
  }
}

.tagline {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.topbar__right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.online {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 11px;
  font-family: var(--pixel);
  font-size: 8px;
  text-transform: uppercase;
  color: #8dffa0;
  background: rgb(125 255 140 / 0.08);
  border: 1px solid rgb(125 255 140 / 0.35);
  border-radius: 999px;
}

.led {
  width: 8px;
  height: 8px;
  background: #4dff6a;
  border-radius: 50%;
  box-shadow: 0 0 8px #4dff6a;
}

.toggles {
  display: flex;
  gap: 8px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-family: var(--pixel);
  font-size: 8px;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  background: linear-gradient(180deg, #1b3f8a, var(--panel-deep));
  border: 1px solid var(--edge);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.15);
  transition:
    color 0.15s ease-out,
    border-color 0.15s ease-out,
    box-shadow 0.15s ease-out;
}

.toggle[hidden] {
  display: none;
}

.toggle[aria-pressed='true'] {
  color: var(--gold);
  border-color: var(--gold);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.2),
    0 0 10px rgb(255 194 14 / 0.35);
}

.toggle__icon {
  width: 10px;
  height: 10px;
  background: currentColor;
}

/* A pixel speaker. */
.toggle__icon--sound {
  clip-path: polygon(0 30%, 30% 30%, 70% 0, 70% 100%, 30% 70%, 0 70%);
}

/* A pixel eighth note. */
.toggle__icon--music {
  clip-path: polygon(40% 0, 100% 0, 100% 30%, 60% 30%, 60% 100%, 0 100%, 0 60%, 40% 60%);
}

/* ---------- Select screen ---------- */

.select {
  flex: 1;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px;
}

/* A slanted banner across the top of the stage. */
.banner {
  position: relative;
  /* Its own stacking context, so the band behind it isn't painted under the page background. */
  isolation: isolate;
  width: fit-content;
  margin: 26px auto 22px;
  padding: 10px 28px;
  font-family: var(--pixel);
  font-size: clamp(9px, 1.5vw, 12px);
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 2px 2px 0 #7a0a14;
}

.banner::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    90deg,
    transparent,
    rgb(232 24 44 / 0.55) 20%,
    rgb(232 24 44 / 0.55) 80%,
    transparent
  );
  border-top: 1px solid rgb(255 255 255 / 0.25);
  border-bottom: 1px solid rgb(255 255 255 / 0.25);
  transform: skewX(-18deg);
}

.banner__arrow {
  display: inline-block;
  margin-right: 8px;
  animation: nudge 0.8s steps(1) infinite;
}

.banner__arrow--back {
  margin: 0 0 0 8px;
}

@keyframes nudge {
  50% {
    transform: translateX(3px);
  }
}

.banner__arrow--back {
  animation-name: nudge-back;
}

@keyframes nudge-back {
  50% {
    transform: translateX(-3px);
  }
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 1fr);
  gap: 32px;
  align-items: center;
}

/* ---------- Showcase (the big portrait) ---------- */

/* Every showcase sits in the same grid cell, so the stage is always as tall as the tallest one and
   nothing around it moves when a different project is picked. Only one is visible: without the
   script, the one in the URL's #hash, or the first; with it, the one the script picks (plus the
   one it's swapping out, for a moment). */
.showcases {
  display: grid;
}

.showcase {
  grid-area: 1 / 1;
  visibility: hidden;
}

.select:not(.is-enhanced) .showcases:not(:has(.showcase:target)) .showcase:first-child,
.select:not(.is-enhanced) .showcase:target,
.select.is-enhanced .showcase.is-active,
.select.is-enhanced .showcase.is-leaving {
  visibility: visible;
}

.select:not(.is-enhanced) .showcases:not(:has(.showcase:target)) .showcase:first-child,
.select:not(.is-enhanced) .showcase:target,
.select.is-enhanced .showcase.is-active {
  z-index: 1;
}

.showcase {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px 22px;
  background:
    linear-gradient(160deg, var(--panel-top) 0%, var(--panel) 45%, var(--panel-deep) 100%)
      padding-box,
    var(--chrome) border-box;
  border: 3px solid transparent;
  border-radius: 18px;
  box-shadow:
    0 0 0 1px #01060f,
    0 24px 50px rgb(0 0 0 / 0.45),
    0 0 40px rgb(40 110 255 / 0.3);
}

/* A glossy sheen over the top of the panel. */
.showcase::before {
  content: '';
  position: absolute;
  inset: 2px 2px 70%;
  background: linear-gradient(180deg, rgb(255 255 255 / 0.12), rgb(255 255 255 / 0));
  border-radius: 16px 16px 50% 50% / 16px 16px 20px 20px;
  pointer-events: none;
}

/* Swapping portraits: the new one glides in from the left as the old one slides off to the right,
   crossfading in place. */
.showcase.is-entering {
  animation: portrait-in 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.showcase.is-entering .showcase__name {
  animation: name-in 0.46s cubic-bezier(0.22, 1, 0.36, 1);
}

.showcase.is-entering .showcase__art {
  animation: screen-flash 0.4s ease-out;
}

.showcase.is-leaving {
  pointer-events: none;
  animation: portrait-out 0.16s ease-out forwards;
}

/* The new portrait is opaque early, so the old one barely shows through as it goes. */
@keyframes portrait-in {
  from {
    opacity: 0;
    transform: translateX(-24px) skewX(-3deg);
  }

  45% {
    opacity: 1;
  }
}

@keyframes portrait-out {
  to {
    opacity: 0;
    transform: translateX(16px) skewX(-3deg);
  }
}

@keyframes name-in {
  from {
    opacity: 0;
    transform: translateX(28px);
  }
}

@keyframes screen-flash {
  from {
    filter: brightness(1.9);
  }
}

.showcase.is-denied {
  animation: shake 0.3s;
}

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

  50% {
    transform: translateX(5px);
  }

  75% {
    transform: translateX(-3px);
  }
}

.showcase__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.showcase__no {
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-family: var(--pixel);
  font-size: 7px;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: 4px;
}

.status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: currentColor;
}

.status--live {
  color: #8dffa0;
  background: rgb(125 255 140 / 0.1);
  border: 1px solid rgb(125 255 140 / 0.4);
}

.status--live::before {
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}

.status--locked {
  color: var(--muted);
  background: rgb(169 185 216 / 0.08);
  border: 1px solid rgb(169 185 216 / 0.35);
}

/* Online but still being built: construction amber. */
.status--beta {
  color: #ffb347;
  background: rgb(255 154 60 / 0.1);
  border: 1px solid rgb(255 154 60 / 0.45);
}

/* The portrait itself: a big sprite on a screen with drifting speed lines. */
.showcase__art {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 58%, rgb(63 169 255 / 0.28), transparent 60%),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 0.035) 0 2px, transparent 2px 4px),
    var(--screen);
  border: 2px solid #2c56a8;
  border-radius: 12px;
  box-shadow: inset 0 0 24px rgb(0 0 0 / 0.6);
}

.showcase__art::before {
  content: '';
  position: absolute;
  inset: -50% -10%;
  background: repeating-linear-gradient(
    -20deg,
    transparent 0 38px,
    rgb(63 169 255 / 0.07) 38px 40px
  );
  animation: speed 1.2s linear infinite;
}

@keyframes speed {
  to {
    transform: translateX(-80px);
  }
}

.showcase__art .sprite {
  position: relative;
  width: clamp(120px, 15vw, 168px);
  height: clamp(120px, 15vw, 168px);
  filter: drop-shadow(0 6px 0 rgb(0 0 0 / 0.35));
  animation: bob 0.9s steps(1) infinite;
}

@keyframes bob {
  50% {
    transform: translateY(-5px);
  }
}

/* The project's name, set like a fighter's. */
.showcase__name {
  margin: 6px 0 0;
  font-family: var(--display);
  font-size: clamp(28px, 3.8vw, 44px);
  font-style: italic;
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  text-shadow:
    3px 3px 0 var(--red),
    6px 6px 0 rgb(0 0 0 / 0.35);
}

.showcase__blurb {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.showcase__meta {
  /* Takes up the slack in shorter showcases, so Start sits in the same place on every one. */
  flex-grow: 1;
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: rgb(169 185 216 / 0.75);
}

/* The under-construction notice on a beta project: a strip of hazard tape down the left. */
.showcase__warning {
  margin: 0;
  padding: 8px 10px 8px 18px;
  font-size: 13px;
  line-height: 1.4;
  color: #ffe2bf;
  background:
    repeating-linear-gradient(-45deg, #ffb347 0 6px, #1a1204 6px 12px) left / 8px 100% no-repeat,
    rgb(255 154 60 / 0.1);
  border: 1px solid rgb(255 154 60 / 0.4);
  border-radius: 6px;
}

.showcase__warning strong {
  font-family: var(--pixel);
  font-size: 8px;
  font-weight: normal;
  text-transform: uppercase;
  color: #ffb347;
}

/* An arcade start button: glossy gold, top half catching the light. */
.start {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding: 14px 26px;
  font-family: var(--pixel);
  font-size: 11px;
  line-height: 1.3;
  text-decoration: none;
  text-transform: uppercase;
  color: #2a1400;
  background: linear-gradient(180deg, #fff7c9 0%, #ffe066 46%, #ffbe1a 52%, #ffcf3a 100%);
  border: 1px solid #b07800;
  border-radius: 999px;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.9),
    inset 0 -3px 6px rgb(160 90 0 / 0.3),
    0 4px 0 #8a5c00,
    0 0 22px rgb(255 194 14 / 0.35);
  transition:
    filter 0.15s ease-out,
    transform 0.08s ease-out,
    box-shadow 0.08s ease-out;
}

.start::before {
  content: '▶';
  font-size: 10px;
  animation: nudge 0.8s steps(1) infinite;
}

.start:hover {
  filter: brightness(1.06);
}

.start:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.9),
    0 2px 0 #8a5c00;
}

.start--locked {
  color: var(--muted);
  background: repeating-linear-gradient(
    -45deg,
    rgb(169 185 216 / 0.14) 0 10px,
    rgb(169 185 216 / 0.04) 10px 20px
  );
  border-color: rgb(169 185 216 / 0.4);
  box-shadow: none;
}

.start--locked::before {
  content: '■';
  animation: none;
}

/* A locked fighter's showcase: the silhouette with a stamp across the screen. */
.showcase--locked {
  background:
    linear-gradient(160deg, #0d2459 0%, #0a1c45 45%, var(--panel-deep) 100%) padding-box,
    linear-gradient(180deg, #8f9bb3, #3d4a66 50%, #7d8aa3) border-box;
}

.showcase--locked .showcase__art .sprite {
  filter: brightness(0) invert(0.26) drop-shadow(0 0 12px rgb(63 169 255 / 0.25));
  animation: none;
}

.showcase--locked .showcase__name {
  color: rgb(242 246 255 / 0.75);
  text-shadow:
    3px 3px 0 #23407a,
    6px 6px 0 rgb(0 0 0 / 0.35);
}

.showcase__stamp {
  position: absolute;
  padding: 8px 14px;
  font-family: var(--pixel);
  font-size: clamp(14px, 2vw, 20px);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ff5a78;
  background: rgb(3 10 28 / 0.6);
  border: 3px solid #ff5a78;
  border-radius: 6px;
  transform: rotate(-8deg);
  box-shadow: 0 0 18px rgb(255 90 120 / 0.3);
}

/* While teleporting, the whole card turns into the egg: its contents blink out, then the glowing
   shell shrinks into an egg shape where it stands, and the egg sprite takes over at its centre. */
.showcase.is-launching {
  animation: card-to-egg 0.42s cubic-bezier(0.55, 0, 0.7, 0.4) forwards;
}

.showcase.is-launching > * {
  opacity: 0;
  transition: opacity 0.12s;
}

.showcase.is-launching::before {
  display: none;
}

@keyframes card-to-egg {
  30% {
    filter: brightness(1.8);
    border-radius: 40%;
  }

  85% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    filter: brightness(3.5);
    border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
    transform: scale(0.16, 0.22);
  }
}

/* ---------- Roster (the tile grid) ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Room for more projects: three across once there are five or more boxes, four across from nine
   (the full twelve-box roster is a 4×3 grid). */
.tiles:has(li:nth-child(5)) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tiles:has(li:nth-child(9)) {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tile {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  aspect-ratio: 1;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  background:
    radial-gradient(circle at 50% 45%, rgb(63 169 255 / 0.2), transparent 65%), var(--screen);
  /* A bevelled chrome frame: lit from the top left. */
  border: 3px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  border-radius: 12px;
  box-shadow: inset 0 0 18px rgb(0 0 0 / 0.5);
  transition:
    border-color 0.18s ease-out,
    box-shadow 0.18s ease-out,
    transform 0.18s ease-out;
}

/* The highlight: where the mouse or the arrow keys are pointing. It doesn't change the big card
   until the tile is picked. */
.tile:hover,
.tile.is-pointed {
  border-color: var(--electric);
  transform: translateY(-2px);
  box-shadow:
    inset 0 0 18px rgb(0 0 0 / 0.5),
    0 0 0 2px rgb(63 169 255 / 0.45),
    0 0 18px rgb(63 169 255 / 0.45);
}

.tile:hover .sprite,
.tile.is-pointed .sprite {
  animation: bob 0.9s steps(1) infinite;
}

/* A small cursor arrow over the pointed tile, like a select screen's second cursor. */
.tile.is-pointed:not(.is-active)::after,
.tile:hover:not(.is-active)::after {
  content: '▼';
  position: absolute;
  top: 4px;
  left: 50%;
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--electric);
  transform: translateX(-50%);
  animation: nudge-down 0.6s steps(1) infinite;
}

@keyframes nudge-down {
  50% {
    transform: translate(-50%, 3px);
  }
}

.tile:focus-visible {
  outline: none;
}

.tile__art {
  display: grid;
  place-items: center;
}

.tile__art .sprite {
  width: 46%;
  height: auto;
  aspect-ratio: 1;
}

.tile__name {
  padding: 7px 6px;
  overflow: hidden;
  font-family: var(--pixel);
  font-size: 7px;
  line-height: 1.4;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  background: rgb(0 0 0 / 0.35);
}

/* Locked fighters: a grey silhouette, a padlock and a dimmed name, like an unlockable. */
.tile--locked {
  background: radial-gradient(circle at 50% 45%, rgb(169 185 216 / 0.08), transparent 65%), #050d22;
  border-color: #4a5878 #2a3550 #2a3550 #4a5878;
}

.tile--locked .sprite {
  filter: brightness(0) invert(0.24);
}

.tile--locked .tile__name {
  color: rgb(169 185 216 / 0.55);
}

.tile__lock {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
}

.tile--locked .tile__lock .sprite {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 4px rgb(217 214 245 / 0.4));
}

/* Beta fighters are playable, with a traffic cone in the corner to say they're still being built. */
.tile__cone {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
}

.tile--beta .tile__cone .sprite {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 4px rgb(255 154 60 / 0.45));
}

/* A blank box waiting for a future project: a dim, empty screen with a question mark. */
.slot {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: radial-gradient(circle at 50% 45%, rgb(169 185 216 / 0.05), transparent 65%), #040b1d;
  border: 3px solid;
  border-color: #33405e #1f2840 #1f2840 #33405e;
  border-radius: 12px;
  box-shadow: inset 0 0 18px rgb(0 0 0 / 0.5);
}

.slot__mark {
  font-family: var(--pixel);
  font-size: clamp(14px, 2vw, 22px);
  color: rgb(169 185 216 / 0.22);
}

/* The 1P cursor: a flashing frame with a tag in the corner. */
.tile.is-active {
  border-color: var(--gold);
  transform: translateY(-3px);
  box-shadow:
    inset 0 0 18px rgb(0 0 0 / 0.5),
    0 0 0 3px var(--red),
    0 0 24px rgb(232 24 44 / 0.5);
  animation: cursor-flash 0.6s steps(1) infinite;
}

.tile.is-active::before {
  content: '1P';
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
  padding: 3px 5px;
  font-family: var(--pixel);
  font-size: 7px;
  color: #fff;
  background: #e8183f;
  border-radius: 3px;
  box-shadow: 0 2px 0 #7a0a20;
}

.tile.is-active .sprite {
  animation: bob 0.9s steps(1) infinite;
}

@keyframes cursor-flash {
  50% {
    border-color: #fff8d6;
  }
}

/* Without the script there's no cursor, so mark the one in the URL instead. */
.select:not(.is-enhanced) .tile:focus-visible {
  border-color: var(--electric);
}

/* ◀ ▶ buttons to pick the previous or next project, with a hint between them. */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 16px 0 0;
}

.pager[hidden] {
  display: none;
}

.pager__hint {
  margin: 0;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
}

.pager__hint strong {
  color: var(--gold);
}

.pager__button {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  cursor: pointer;
  background: linear-gradient(180deg, #1b3f8a, var(--panel-deep));
  border: 3px solid;
  border-color: var(--chrome-light) var(--chrome-dark) var(--chrome-dark) var(--chrome-light);
  border-radius: 10px;
  transition:
    border-color 0.15s ease-out,
    transform 0.08s ease-out;
}

.pager__button:hover {
  border-color: var(--electric);
}

.pager__button:active {
  transform: translateY(1px);
}

/* A pixel-art triangle: four 3px columns, stepping up 3px each. */
.pager__button::before {
  content: '';
  width: 12px;
  height: 21px;
  background: var(--gold);
  clip-path: polygon(
    100% 0,
    100% 100%,
    75% 100%,
    75% 85.71%,
    50% 85.71%,
    50% 71.43%,
    25% 71.43%,
    25% 57.14%,
    0 57.14%,
    0 42.86%,
    25% 42.86%,
    25% 28.57%,
    50% 28.57%,
    50% 14.29%,
    75% 14.29%,
    75% 0
  );
}

.pager__button--next::before {
  transform: scaleX(-1);
}

/* ---------- Teleport ---------- */

.teleport {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
}

.teleport[hidden] {
  display: none;
}

.teleport__egg {
  position: absolute;
  top: var(--y, 50%);
  left: var(--x, 50%);
  width: 72px;
  height: 99px;
  opacity: 0;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 14px var(--egg-glow, rgb(63 169 255 / 0.9)));
}

.teleport__egg .sprite {
  width: 100%;
  height: 100%;
  overflow: visible;
  image-rendering: pixelated;
}

/* The robotic egg, the same one that lands in every app. hub.js sets --egg-shell, --egg-shade and
   --egg-seam from the chosen project's egg in projects.json; the rest is the same for all. */
.egg-k {
  fill: #1b2a6b;
}
.egg-s {
  fill: #ffffff;
}
.egg-m {
  fill: var(--egg-shell, #eaf7ff);
}
.egg-d {
  fill: var(--egg-shade, #9fcff5);
}
.egg-a,
.egg-c {
  fill: var(--egg-seam, #6fd8ff);
}
.egg-l {
  fill: #0e1c40;
}
.egg-y {
  fill: var(--gold);
}
.egg-r {
  fill: #ff6b6b;
}
.egg-g {
  fill: #6fe0a8;
}

/* The egg pops in and wobbles... */
.teleport.is-egg .teleport__egg {
  animation: egg-pop 0.46s cubic-bezier(0.3, 1.6, 0.5, 1) forwards;
}

@keyframes egg-pop {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0);
  }

  55% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }

  72% {
    transform: translate(-50%, -50%) rotate(-10deg);
  }

  88% {
    transform: translate(-50%, -50%) rotate(7deg);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* ...then stretches into a streak and rides the beam off the top of the screen. */
.teleport.is-beam .teleport__egg {
  animation: egg-up 0.26s 0.08s cubic-bezier(0.6, 0, 0.9, 0.5) both;
}

@keyframes egg-up {
  from {
    opacity: 1;
    transform: translate(-50%, -50%);
  }

  to {
    opacity: 1;
    transform: translate(-50%, calc(-50% - 110vh)) scale(0.35, 3);
  }
}

.teleport__beam {
  position: absolute;
  top: 0;
  left: var(--x, 50%);
  width: 6px;
  height: calc(var(--y, 50%) + 50px);
  background: linear-gradient(
    90deg,
    transparent,
    rgb(170 240 255 / 0.85) 25%,
    #fff 50%,
    rgb(170 240 255 / 0.85) 75%,
    transparent
  );
  box-shadow: 0 0 30px 10px rgb(63 169 255 / 0.55);
  opacity: 0;
  transform: translateX(-50%) scaleX(0);
}

.teleport.is-beam .teleport__beam {
  animation: beam 0.42s ease-out forwards;
}

@keyframes beam {
  0% {
    opacity: 1;
    transform: translateX(-50%) scaleX(0);
  }

  30% {
    opacity: 1;
    transform: translateX(-50%) scaleX(16);
  }

  100% {
    opacity: 0.9;
    transform: translateX(-50%) scaleX(3);
  }
}

/* A white flash to finish, then the project loads. */
.teleport::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
}

.teleport.is-flash::after {
  animation: flash 0.18s ease-in forwards;
}

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

/* ---------- Footer, toast and the cheat code ---------- */

.footer {
  padding: 40px 16px 26px;
  font-size: 11px;
  text-align: center;
  color: var(--muted);
}

.footer p {
  margin: 0;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 40;
  margin: 0;
  padding: 10px 14px;
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--gold);
  white-space: nowrap;
  background: var(--panel-deep);
  border: 1px solid var(--gold);
  border-radius: 8px;
  box-shadow: 0 0 20px rgb(255 194 14 / 0.3);
  transform: translateX(-50%);
  animation: toast-in 0.25s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}

body.cheat .sprite {
  animation: hop 0.3s steps(2) 6;
}

body.cheat .logo {
  animation: rainbow 1.2s linear 2;
}

@keyframes hop {
  50% {
    transform: translateY(-10px);
  }
}

@keyframes rainbow {
  to {
    filter: drop-shadow(2px 2px 0 #0b2a6b) hue-rotate(360deg);
  }
}

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

.lost {
  display: grid;
  place-items: center;
  padding: 16px;
}

.lost__box {
  max-width: 420px;
  padding: 28px 26px;
  text-align: center;
  background:
    linear-gradient(160deg, var(--panel-top), var(--panel-deep)) padding-box,
    var(--chrome) border-box;
  border: 3px solid transparent;
  border-radius: 16px;
  box-shadow: 0 24px 50px rgb(0 0 0 / 0.45);
}

.lost__code {
  margin: 0 0 10px;
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--muted);
}

.lost__title {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 30px;
  font-style: italic;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 var(--red);
}

.lost__box p:not(.lost__code) {
  margin: 0 0 22px;
  color: var(--muted);
}

/* ---------- Smaller screens and reduced motion ---------- */

@media (max-width: 880px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  .tiles:has(li:nth-child(5)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* A full roster fits in two rows of six under the showcase. */
  .tiles:has(li:nth-child(9)) {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .tile__name {
    display: none;
  }

  .tile.is-active::before {
    top: 4px;
    left: 4px;
    font-size: 6px;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding-top: 16px;
  }

  .tagline {
    font-size: 12px;
  }

  .banner {
    margin: 18px auto 14px;
  }

  .showcase {
    padding: 14px 14px 18px;
  }

  /* Phones: three rows of four. */
  .tiles:has(li:nth-child(9)) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .start {
    align-self: stretch;
    justify-content: center;
  }
}

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

  /* No slide-out to wait for: the old portrait goes straight away. */
  .select.is-enhanced .showcase.is-leaving {
    visibility: hidden;
  }
}
