/* Collab Canvas — the front page.
 *
 * A dark page so the tiles, which are bright pixel-art scenes, are the only
 * thing that glows. Three tiles per row on a desktop, each wider than it is
 * tall, because the tiles are little animated landscapes and a landscape
 * wants a landscape frame.
 *
 * There is no build step and no framework. One stylesheet, one module.
 */

:root {
  --bg:        #0f1310;
  --bg-2:      #161c15;
  --ink:       #eef3ea;
  --ink-dim:   #9fae99;
  --ink-faint: #6c7a68;
  --line:      #26301f;
  --accent:    #7fc25c;

  --radius: 20px;
  --gap: clamp(1rem, 2.2vw, 1.75rem);
  --wrap: 1180px;

  /* Every tile is 2:1. Fixing it here rather than letting each image decide
     is what keeps the grid a grid when one app ships a tile of its own
     proportions. */
  --tile-aspect: 2 / 1;

  --ease: cubic-bezier(.22, .68, .3, 1);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;   /* keeps the footer at the bottom on a short list */
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter,
        Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* A very slow wash of colour behind everything. Static dark pages read as
   dead; this gives the background somewhere to go without ever asking for
   attention. */
.aurora {
  position: fixed;
  inset: -30vh -20vw auto;
  height: 120vh;
  z-index: -1;
  background:
    radial-gradient(46vw 46vw at 18% 8%,  rgba(111, 162, 81, .20), transparent 62%),
    radial-gradient(40vw 40vw at 86% 22%, rgba(88, 140, 175, .16), transparent 64%),
    radial-gradient(52vw 52vw at 52% 76%, rgba(160, 122, 200, .10), transparent 68%);
  filter: blur(28px);
  animation: drift 42s var(--ease) infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-3%, -2%, 0) scale(1); }
  to   { transform: translate3d( 3%,  3%, 0) scale(1.12); }
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2rem);
}

main.wrap { flex: 1; }

/* ---------------------------------------------------------------- masthead */

.masthead {
  padding-block: clamp(4rem, 12vh, 7.5rem) clamp(2.5rem, 6vh, 3.75rem);
}

.wordmark {
  margin: 0;
  font-size: clamp(2.6rem, 7.5vw, 4.5rem);
  line-height: .95;
  letter-spacing: -.035em;
  font-weight: 680;
}

.wordmark-a { color: var(--ink); }

.wordmark-b {
  background: linear-gradient(96deg, #8fd06a, #63b7c9 62%, #a98ada);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  margin: 1.1rem 0 0;
  max-width: 34rem;
  color: var(--ink-dim);
  font-size: clamp(1rem, 1.3vw, 1.1rem);
  text-wrap: pretty;
}

/* -------------------------------------------------------------------- grid */

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  padding-bottom: clamp(3rem, 8vh, 5rem);
}

@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr; } }

.tile {
  position: relative;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  isolation: isolate;
  transition: transform .34s var(--ease), border-color .34s var(--ease),
              box-shadow .34s var(--ease);
}

.tile:hover,
.tile:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in oklab, var(--tint, var(--accent)) 55%, var(--line));
  box-shadow:
    0 18px 40px -22px rgba(0, 0, 0, .9),
    0 0 0 1px color-mix(in oklab, var(--tint, var(--accent)) 22%, transparent),
    0 0 46px -18px color-mix(in oklab, var(--tint, var(--accent)) 60%, transparent);
}

.tile:focus-visible {
  outline: 2px solid var(--tint, var(--accent));
  outline-offset: 3px;
}

.shot {
  position: relative;
  aspect-ratio: var(--tile-aspect);
  overflow: hidden;
  background: linear-gradient(150deg,
              color-mix(in oklab, var(--tint, var(--accent)) 26%, #0d120c),
              #0d120c 78%);
}

.shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* The tiles are pixel art shown smaller than they were drawn. Smooth
     downscaling is right here; `pixelated` at a fractional ratio drops rows
     of pixels and makes the grass shimmer. */
  transform: scale(1.001);   /* hides a hairline seam at some zoom levels */
  transition: transform .5s var(--ease);
}

.tile:hover .shot img { transform: scale(1.035); }

/* The app's name sits on the image, over a gradient that only exists at the
   bottom, so a busy tile never eats the text. */
.shot::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 62%;
  background: linear-gradient(to top,
              rgba(8, 11, 7, .92), rgba(8, 11, 7, .55) 42%, transparent);
  pointer-events: none;
}

.shot .name {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: .7rem;
  z-index: 1;
  margin: 0;
  font-size: 1.22rem;
  font-weight: 640;
  letter-spacing: -.015em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .6);
}

.body {
  padding: .85rem 1rem 1.05rem;
}

.blurb {
  margin: 0;
  color: var(--ink-dim);
  font-size: .93rem;
  line-height: 1.5;
  text-wrap: pretty;
  /* Exactly two lines, always. Clamping alone is not enough — a one-line
     blurb would make its tile shorter than the rest of the row, and the
     ragged bottom edge is the first thing that makes a grid look unfinished. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 3em;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .7rem;
}

.tag {
  font-size: .7rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .12rem .5rem;
}

/* A tile whose app shipped no image still has to look deliberate. Two soft
   blobs in the app's own accent, plus its initial. */
.shot.placeholder {
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 90% at 22% 15%,
      color-mix(in oklab, var(--tint, var(--accent)) 42%, transparent), transparent 70%),
    radial-gradient(70% 100% at 82% 88%,
      color-mix(in oklab, var(--tint, var(--accent)) 24%, transparent), transparent 72%),
    #10160e;
}

.shot.placeholder .glyph {
  font-size: clamp(3rem, 7vw, 4.4rem);
  font-weight: 700;
  letter-spacing: -.04em;
  color: color-mix(in oklab, var(--tint, var(--accent)) 60%, #fff);
  opacity: .34;
  user-select: none;
}

/* ------------------------------------------------------------- skeleton */

.skeleton {
  aspect-ratio: var(--tile-aspect);
  border-radius: var(--radius);
  background: linear-gradient(100deg, #151b14 30%, #1d251b 50%, #151b14 70%)
              0 0 / 300% 100%;
  animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer { to { background-position: -300% 0; } }

/* ---------------------------------------------------------------- footer */

.empty, .foot {
  color: var(--ink-faint);
  font-size: .9rem;
}

.empty { padding-block: 3rem; }

.foot {
  border-top: 1px solid var(--line);
  padding-block: 1.4rem 3rem;
}

.foot p {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  /* An animated GIF cannot be paused by CSS. The script swaps in a still
     first frame instead when this is set — see app.js. */
}

/* Entrance: tiles rise in sequence as the list arrives. Cheap, and it makes
   a page that is fetched-then-drawn feel intentional rather than late. */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.grid .tile.in {
  animation: rise .5s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
