/*
  The shelf.

  The palette is the games' own (see any game's src/ui/palette.ts) so this
  page and the things on it belong together. The page itself stays neutral
  on purpose: every card carries its game's accent, and a shelf that also
  had an accent would compete with the games standing on it.

  Child first, parent second, which is a layout rule here and not a slogan:
  on each card the mark and the name are large enough to choose by across a
  room, and the two lines a parent reads are small, quiet, and underneath.
*/

:root {
  --paper: #FDFBF7;
  --card: #FFFFFF;
  --ink: #2A2622;
  --ink-soft: #7A736B;
  --edge: #E7E0D6;
  --shadow: 42 38 34;
  --lift: 0 2px 0 rgb(var(--shadow) / 0.06), 0 10px 24px -12px rgb(var(--shadow) / 0.3);
  --lift-hi: 0 2px 0 rgb(var(--shadow) / 0.08), 0 18px 34px -14px rgb(var(--shadow) / 0.38);
}

/*
  Dark is not an inversion. The paper tile behind each mark stays light,
  exactly as an app icon does on a dark home screen -- that tile is part of
  the mark, and the games' own README keeps it for this reason.
*/
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17150F;
    --card: #221F1A;
    --ink: #F4EFE6;
    --ink-soft: #A79D90;
    --edge: #332E26;
    --shadow: 0 0 0;
    --lift: 0 1px 0 rgb(255 255 255 / 0.03), 0 10px 24px -14px rgb(0 0 0 / 0.8);
    --lift-hi: 0 1px 0 rgb(255 255 255 / 0.05), 0 18px 34px -14px rgb(0 0 0 / 0.9);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  /*
    No min-height, and the footer is NOT pushed to the bottom of the
    viewport. With two games on the shelf that left a screen of nothing
    between the cards and the small print, which reads as a page that
    failed to load the rest of itself. The page is as tall as what is on
    it; when the shelf fills, the footer moves down on its own.
  */
  padding: clamp(1.25rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem) 3rem;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: clamp(1.75rem, 5vw, 3rem);
  align-items: center;
}

/* Visible the moment it is focused, and out of the way until then. */
.skip {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--lift-hi);
}
.skip:focus { left: 0.5rem; z-index: 10; }

.top {
  width: 100%;
  max-width: 62rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.toplogo {
  width: clamp(2.25rem, 7vw, 3rem);
  height: clamp(2.25rem, 7vw, 3rem);
  flex: none;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2rem);
  letter-spacing: -0.015em;
}

.sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

main { width: 100%; max-width: 62rem; }

.category + .category { margin-top: clamp(2rem, 5vw, 3rem); }

/*
  The category heading is for the adult: a pre-reader cannot use it, so it
  must not take space from the cards. Small, quiet, and clearly a label
  rather than a title.
*/
.catname {
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.shelf {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: clamp(0.9rem, 2.5vw, 1.25rem);
  /*
    auto-fit with a floor, not a fixed column count: a card never goes
    narrower than a thumb can hit comfortably, and the shelf grows to three
    and four across on its own as games are added.
  */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.game {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "mark name"
    "mark blurb"
    "meta meta";
  column-gap: clamp(0.9rem, 3vw, 1.25rem);
  row-gap: 0.15rem;
  align-items: center;
  padding: clamp(1rem, 3vw, 1.35rem);
  border: 1px solid var(--edge);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--lift);
  color: inherit;
  text-decoration: none;
  /* The whole card is the target, and it is never smaller than this. */
  min-height: 8.5rem;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.mark {
  grid-area: mark;
  display: block;
  /*
    Big, because a child picks by the mark and not by the name. This is the
    one element on the card sized for the person who cannot read it.
  */
  width: clamp(4.5rem, 17vw, 6rem);
  aspect-ratio: 1;
  padding: 12%;
  border-radius: 22%;
  /* The mark's own paper tile, light in both themes, as on a home screen. */
  background: #FDFBF7;
  border: 1px solid var(--edge);
}
.mark svg { width: 100%; height: 100%; display: block; }

/*
  Inside the tile the ink must be the LIGHT theme's ink whatever the page is
  doing, because the tile itself does not change. Letting --ink through put
  near-white shapes on near-white paper in dark mode: present, and invisible.
*/
.mark svg { --ink: #2A2622; }

.name {
  grid-area: name;
  font-size: clamp(1.25rem, 4.5vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  align-self: end;
}

.blurb {
  grid-area: blurb;
  font-size: 0.95rem;
  color: var(--ink-soft);
  align-self: start;
}

.meta {
  grid-area: meta;
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--edge);
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* The accent belongs to the game, so it only appears on its own card. */
.game:hover,
.game:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--lift-hi);
  border-color: var(--accent);
}
.game:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.game:active { transform: translateY(0); box-shadow: var(--lift); }

.foot {
  width: 100%;
  max-width: 62rem;
  margin-top: clamp(1.5rem, 5vw, 3rem);
  padding-top: clamp(1.5rem, 4vw, 2.5rem);
  border-top: 1px solid var(--edge);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.foot p { margin: 0 0 0.6rem; max-width: 46rem; }
.foot strong { color: var(--ink); }
.foot .quiet { margin-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  .game { transition: none; }
  .game:hover, .game:focus-visible, .game:active { transform: none; }
}
