/* ─────────────────────────────────────────────────────────────
   alexarasfun: a grid of covers, neal.fun style.
   Each cover is drawn on a 570×214 stage and scaled to its tile.
   Covers are built from each game's own look: its type, colours,
   and real renders of its scenes (assets/covers/).
   ───────────────────────────────────────────────────────────── */

:root {
  color-scheme: light;
  --page: #ffffff;
  --ink: #0c0c0c;
  --muted: #6b6b6b;
  --accent: #e5783f;
  --radius: 15px;
  --spring: cubic-bezier(.2, .9, .3, 1.25);
  --out: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Geist, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* dragging across the page shouldn't paint a text selection */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
a { color: inherit; text-decoration: none; }
a, img { -webkit-user-drag: none; }

@media (prefers-reduced-motion: no-preference) { @view-transition { navigation: auto; } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .28s; }

/* ── Header & footer ─────────────────────────────────────────── */

.top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 20px 40px;
}
.top img { width: 30px; height: 30px; margin-top: -2px; }
.top h1:not(.lg) { margin: 0; font-size: 20px; font-weight: 400; letter-spacing: -.005em; }

.foot {
  padding: 56px 20px 48px;
  text-align: center;
  font-size: 15px;
  color: var(--muted);
}

/* ── Grid ────────────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  max-width: 1430px;
  margin: 0 auto;
  padding: 0 25px;
}
/* With six games or fewer, two big columns look better than a ragged three. */
.grid:not(:has(> .card:nth-child(7))) { grid-template-columns: repeat(2, 1fr); max-width: 1000px; }

@media (max-width: 1130px) { .grid { grid-template-columns: repeat(2, 1fr); max-width: 900px; gap: 16px 18px; } }
@media (max-width: 640px) {
  .grid, .grid:not(:has(> .card:nth-child(7))) { grid-template-columns: 1fr; gap: 12px; padding: 0 12px; }
  .top { padding: 30px 16px 26px; gap: 8px; }
  .top img { width: 26px; height: 26px; }
  .top h1:not(.lg) { font-size: 18px; }
  .foot { padding: 40px 16px 36px; }
}

/* ── Cards ───────────────────────────────────────────────────── */

.card {
  --delay: calc(var(--i, 0) * 70ms + 40ms);
  position: relative;
  display: block;
  aspect-ratio: 285 / 107;
  border-radius: var(--radius);
  overflow: hidden;
  background: #ececec;
  container-type: inline-size;
  isolation: isolate;
  cursor: pointer;
  transition:
    transform .22s var(--spring),
    box-shadow .22s ease-out,
    opacity .45s ease-out var(--delay),
    translate .8s var(--out) var(--delay),
    scale .8s var(--out) var(--delay);
}
/* neal.fun-style frame, drawn above the art so it never gets covered */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  border: 3px solid var(--edge, transparent);
  border-radius: inherit;
  pointer-events: none;
}
.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

@media (hover: hover) {
  .card:is(:hover, .hold) { transform: scale(1.023); box-shadow: 3px 7px 14px rgba(0, 0, 0, .14); }
}
.card:active { transform: scale(1.008); transition-duration: .08s; }

/* Entrance: tiles rise in once the cover fonts are ready (no flash of fallback type). */
.js .card { opacity: 0; translate: 0 18px; scale: .97; }
.js.ready .card { opacity: 1; translate: 0 0; scale: 1; }
.js.instant .card { transition: none; }

/* The stage: 570×214, scaled to the tile width without JS (tan(atan2()) turns a length ratio into a number). */
.b {
  position: absolute;
  left: 0;
  top: 0;
  width: 570px;
  height: 214px;
  overflow: hidden;
  transform-origin: 0 0;
  transform: scale(tan(atan2(100cqw, 570px)));
}
.b .t {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.ttl { display: block; line-height: .95; }

/* ── Older or Younger: the game's own title-screen pieces ───── */

.card:has(.oy) { --edge: #0b0b0d; }
.oy { background: radial-gradient(circle at 50% 48%, #1b1b21 0, #0b0b0d 62%); }
.oy .ph { position: absolute; top: 0; width: 158px; height: 214px; }
.oy .ph img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(.62) saturate(.9);
  transition: filter .4s ease-out, scale .9s var(--out);
}
.oy .ph.l { left: 0; }
.oy .ph.r { right: 0; }
.oy .ph.l img { -webkit-mask-image: linear-gradient(90deg, #000 50%, transparent); mask-image: linear-gradient(90deg, #000 50%, transparent); transform-origin: 0 50%; }
.oy .ph.r img { -webkit-mask-image: linear-gradient(270deg, #000 50%, transparent); mask-image: linear-gradient(270deg, #000 50%, transparent); transform-origin: 100% 50%; }
.oy .ph span {
  position: absolute;
  bottom: 14px;
  font: 500 30px/1 Fraunces, Georgia, serif;
  font-variation-settings: "opsz" 144;
  color: #ece6da;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .7);
  white-space: nowrap;
}
.oy .ph.l span { left: 14px; }
.oy .ph.r span { right: 14px; }
.oy .hg { width: 24px; margin-bottom: 4px; transition: rotate .8s cubic-bezier(.6, 0, .2, 1); }
.oy .w {
  font: 300 54px/.9 Fraunces, Georgia, serif;
  font-variation-settings: "opsz" 144, "SOFT" 0, "WONK" 0;
  letter-spacing: -.025em;
  color: #ece6da;
}
.oy .or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 5px 0 6px;
  font: italic 300 20px/1 Fraunces, Georgia, serif;
  color: #cfb075;
}
.oy .or::before, .oy .or::after { content: ""; width: 40px; height: 1px; background: rgba(236, 230, 218, .4); }
@media (hover: hover) { .card:is(:hover, .hold) .oy .ph img { filter: brightness(.82) saturate(1); scale: 1.05; } }
@media (hover: hover) { .card:is(:hover, .hold) .oy .hg { rotate: 180deg; } }

/* ── Time Stopper: its paper, its type, its reveal ruler ─────── */

.card:has(.stopper) { --edge: #151514; }
.stopper { background: #f3f1ec; }
.stopper .t { justify-content: flex-start; padding-top: 16px; }
.stopper .ttl {
  font: 800 60px/1 "Inter Tight", system-ui, sans-serif;
  letter-spacing: -.045em;
  word-spacing: .06em;
  color: #151514;
}
.stopper .ruler { position: absolute; left: 0; top: 0; width: 570px; height: 214px; }
.stopper .ticks line { stroke: #151514; stroke-width: 1.3; }
.stopper .ticks line.mn { stroke: #b9b4aa; stroke-width: 1; }
.stopper .ticks text { font: 500 8.5px "JetBrains Mono", ui-monospace, monospace; fill: #7c786f; }
.stopper .base { stroke: #d9d5cc; stroke-width: 1.4; }
.stopper .late { stroke: #e2461b; stroke-width: 1.4; }
.stopper .late.thick { stroke: #ff5a1f; stroke-width: 3.4; stroke-linecap: round; }
.stopper .late.thin { stroke-width: 1.2; }
.stopper .dim text { font: 700 17px "JetBrains Mono", ui-monospace, monospace; fill: #e2461b; }
.stopper .dim .u { font-size: 10px; }
.stopper .dim .w { font: 500 11px "Inter Tight", system-ui, sans-serif; fill: #7c786f; }
.stopper .target line { stroke: #151514; stroke-width: 1.6; }
.stopper .target path { fill: #151514; }
.stopper .you circle { fill: #f3f1ec; stroke: #ff5a1f; stroke-width: 2.4; }
.stopper .you text { font: 500 9px "JetBrains Mono", ui-monospace, monospace; fill: #e2461b; }
/* hover replays the reveal: the gap opens from the target out to where you stopped */
.stopper .gap rect, .stopper .gap line:not(.thick) { transform-box: fill-box; transform-origin: 0 50%; }
.stopper .dim { transition: opacity .3s ease-out; }
@media (hover: hover) { .card:is(:hover, .hold) .stopper .gap rect, .card:is(:hover, .hold) .stopper .gap line:not(.thick) { animation: open 1s var(--out) both; } }
@media (hover: hover) { .card:is(:hover, .hold) .stopper .you { animation: slide 1s var(--out) both; } }
@media (hover: hover) { .card:is(:hover, .hold) .stopper .dim { animation: fade-in 1.3s ease-out both; } }
@keyframes open { from { scale: 0 1; } }
@keyframes slide { from { translate: -192.7px 0; } }
@keyframes fade-in { 0%, 55% { opacity: 0; } }

/* ── GeoHopper: its atlas page, a real render of a journey ───── */

.card:has(.geo) { --edge: #3a2817; }
.geo { background: #ddd3b6; }
.geo .map {
  position: absolute;
  left: 0;
  top: -16px;
  width: 655px;
  height: 246px;
  transform-origin: 70% 40%;
  transition: scale 1.4s var(--out), filter .6s ease-out;
}
/* The title sits out in the Atlantic, like a cartographer's title on an old chart. */
.geo .t { right: auto; width: 310px; padding: 0 0 8px 16px; }
.geo .t::before {
  content: "";
  position: absolute;
  inset: 34px 10px 30px;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(246, 237, 216, .92), rgba(246, 237, 216, .7) 55%, rgba(246, 237, 216, 0));
}
.geo .ttl {
  font: 400 52px/1 "IM Fell English", Georgia, serif;
  letter-spacing: -.01em;
  color: #3a2817;
}
.geo .ttl::first-letter { color: #a8291a; }
.geo .rule {
  display: block;
  width: 170px;
  height: 5px;
  margin-top: 8px;
  border-top: 1px solid rgba(58, 40, 23, .55);
  border-bottom: 1px solid rgba(58, 40, 23, .55);
}
@media (hover: hover) { .card:is(:hover, .hold) .geo .map { scale: 1.05; filter: saturate(1.15); } }

/* ── Jackpot: a frame from the back room ──────────────────────── */

.card:has(.jack) { --edge: #050403; }
.jack { background: #050403; }
.jack .scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: 70% 22%;
  scale: 1.07;
  transition: scale 1.6s var(--out), filter .5s ease-out;
}
.jack .t { right: auto; left: 14px; width: 222px; }
.jack .ttl {
  font: 400 46px/1 Limelight, Georgia, serif;
  letter-spacing: .01em;
  color: #f7c15a;
  text-shadow: 0 0 22px rgba(255, 168, 64, .45), 0 2px 0 #4a2200;
}
.jack .pips { display: flex; gap: 5px; margin-top: 14px; }
.jack .pips i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff3c4, #f0a530 60%, #9b5a10);
  box-shadow: 0 0 8px rgba(255, 170, 60, .7);
}
.jack .pips i.off { background: #2a2219; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .8); }
@media (hover: hover) { .card:is(:hover, .hold) .jack .scene { scale: 1.13; filter: brightness(1.18); } }
@media (hover: hover) { .card:is(:hover, .hold) .jack .pips i:not(.off) { animation: bulb 1.2s steps(1) infinite; animation-delay: calc(var(--n, 0) * 90ms); } }
@media (hover: hover) { .card:is(:hover, .hold) .jack .pips i.off { animation: last 1.2s ease-in-out infinite; } }
.jack .pips i:nth-child(2) { --n: 1; } .jack .pips i:nth-child(3) { --n: 2; } .jack .pips i:nth-child(4) { --n: 3; }
.jack .pips i:nth-child(5) { --n: 4; } .jack .pips i:nth-child(6) { --n: 5; } .jack .pips i:nth-child(7) { --n: 6; }
.jack .pips i:nth-child(8) { --n: 7; } .jack .pips i:nth-child(9) { --n: 8; }
@keyframes bulb { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes last { 0%, 100% { background: #2a2219; } 50% { background: #6b4a1c; } }

/* ── Launch: the tile grows to fill the screen, then the game fades in ── */

.launch { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.launch-fill { position: absolute; inset: 0; }
.card.lifted { z-index: 101; }
.card.snap, .card.snap * { transition: none !important; }

/* ── Reduced motion ──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .card, .oy .ph img, .oy .hg, .geo .map, .jack .scene { transition: none !important; }
  .js .card { translate: none; scale: none; }
  .card:is(:hover, .hold) { transform: none; }
  .card:is(:hover, .hold) * { animation: none !important; }
  .card:is(:hover, .hold) .oy .hg { rotate: none; }
  .card:is(:hover, .hold) .oy .ph img, .card:is(:hover, .hold) .geo .map, .card:is(:hover, .hold) .jack .scene { scale: none; }
}
