/* Catalog, category and 404 pages: intro, search, Rung feature, game tiles, filters.
   Loaded after landing-site.css, which holds the tokens. */

main.shell {
  padding: var(--space-6) 0 var(--space-7);
}

h1 {
  margin: 0;
  font-size: var(--text-display);
  line-height: 1.1;
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  max-width: 100%;
  min-height: var(--target-min);
  padding: 0 var(--space-4);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background-color var(--motion) var(--ease), border-color var(--motion) var(--ease), color var(--motion) var(--ease);
}

.button:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button.ghost {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.button.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.button[hidden] {
  display: none;
}

.button svg,
.more-link svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--motion) var(--ease);
}

.featured:hover .button svg,
.more-link:hover svg {
  transform: translateX(3px);
}

/* ---------- Intro and search ---------- */

.intro {
  margin-bottom: var(--space-5);
}

.lede {
  max-width: 620px;
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: var(--text-lg);
  line-height: var(--leading);
  text-wrap: pretty;
}

.eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.hero-actions[hidden],
.row[hidden],
#browse[hidden],
.empty[hidden] {
  display: none;
}

.search {
  position: relative;
}

.search-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-1);
}

.search-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.surprise-button {
  min-height: var(--target-min);
  padding: 0 0 0 var(--space-3);
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
}

.surprise-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.search-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search svg {
  position: absolute;
  top: 50%;
  left: var(--space-3);
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2.2;
  stroke-linecap: round;
  transform: translateY(-50%);
  pointer-events: none;
}

.search input {
  width: 100%;
  min-height: 48px;
  padding: 0 44px 0 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-md);
}

.search input::placeholder {
  color: var(--text-muted);
}

.search input::-webkit-search-cancel-button {
  display: none;
}

.search input:focus-visible {
  border-color: var(--accent);
  outline-offset: 1px;
}

.search-row .button {
  min-height: 48px;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 2px;
  display: grid;
  place-items: center;
  width: 40px;
  height: var(--target-min);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--text-2xl);
  transform: translateY(-50%);
  cursor: pointer;
}

.search-clear[hidden] {
  display: none;
}

.search-clear:hover {
  background: var(--surface-2);
}

.search-clear:focus-visible {
  outline-offset: -3px;
}

.search-unavailable {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

:where(.landing) button:disabled,
.landing input:disabled {
  cursor: default;
}

/* ---------- Category heading ---------- */

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-5);
}

.count {
  flex: 0 0 auto;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

/* ---------- Sections ---------- */

.row {
  margin-top: var(--space-6);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.section-head h2 {
  margin: 0;
  font-size: var(--text-xl);
}

.section-head .n {
  margin-left: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
}

#results-count {
  min-height: 1.5em;
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.more-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  flex: 0 0 auto;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.more-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.empty {
  margin: 0;
  color: var(--text-muted);
}

/* ---------- Cards: game tiles and the Rung feature ---------- */

.game-card,
.featured {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--motion) var(--ease), box-shadow var(--motion) var(--ease), transform var(--motion) var(--ease);
}

.game-card:hover,
.featured:hover {
  border-color: var(--border-strong);
  box-shadow: var(--elev-1);
  transform: translateY(-2px);
}

.game-card[hidden] {
  display: none;
}

.thumb-wrap {
  position: relative;
  background: var(--board);
  overflow: hidden;
}

.game-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--motion-max) var(--ease);
}

.game-card:hover .game-thumb {
  transform: scale(1.03);
}

.game-title {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
}

.game-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
}

.game-card {
  display: flex;
  flex-direction: column;
}

.game-card .thumb-wrap {
  aspect-ratio: 16 / 10;
}

/* Play mark over the artwork for pointer users; the whole tile is the link. */
.game-card .thumb-wrap::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23176a51' d='M9 6.2v11.6a.6.6 0 0 0 .92.5l9-5.8a.6.6 0 0 0 0-1l-9-5.8a.6.6 0 0 0-.92.5z'/%3E%3C/svg%3E") center / 18px no-repeat;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.25);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--motion) var(--ease), transform var(--motion) var(--ease);
}

.game-card:hover .thumb-wrap::after,
.game-card:focus-visible .thumb-wrap::after {
  opacity: 1;
  transform: none;
}

/* New / Resume. The only pill shape in the system. */
.badge {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--highlight);
  color: var(--neutral-900);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  line-height: 1.4;
}

.game-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
}

.game-meta {
  margin: auto 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.game-meta b {
  color: var(--text);
  font-weight: var(--weight-medium);
}

.game-mode {
  display: block;
  font-size: var(--text-xs);
}

/* "Solo" only repeats "1 player"; the mode line stays where it adds something. */
.game-card[data-modes="solo"] .game-mode {
  display: none;
}

/* Rung feature */
.featured {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
}

.featured .thumb-wrap {
  aspect-ratio: 16 / 10;
}

.featured .game-thumb {
  object-fit: contain;
  object-position: center;
}

.featured .thumb-wrap::after {
  display: none;
}

.featured-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4) var(--space-6);
  padding: var(--space-5);
}

.featured-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.featured .eyebrow {
  margin: 0;
  color: var(--accent);
}

.featured .game-title {
  font-size: var(--text-2xl);
  letter-spacing: var(--tracking-tight);
}

.featured .game-copy {
  max-width: 440px;
  font-size: var(--text-md);
}

/* ---------- Landing ---------- */

.landing main.shell {
  padding-top: var(--space-6);
}

.landing .intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: center;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.landing .hero-actions {
  display: block;
  margin: 0;
}

.landing .row {
  margin-top: var(--space-6);
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
}

.recent-link,
.recent-placeholder {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 56px;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.recent-link {
  transition: border-color var(--motion) var(--ease);
}

.recent-link:hover {
  border-color: var(--border-strong);
}

.recent-link img {
  flex: 0 0 auto;
  width: 64px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--board);
  object-fit: cover;
}

.recent-link span:first-of-type {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.recent-link .resume-label {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

html[data-recent-count] #recent[hidden] { display: block; }
html[data-recent-count="0"] #recent[hidden] { display: none; }
html[data-recent-count="1"] .recent-placeholder:nth-child(n+2),
html[data-recent-count="2"] .recent-placeholder:nth-child(n+3),
html[data-recent-count="3"] .recent-placeholder:nth-child(n+4) { display: none; }
html[data-query-mode] #browse { display: none; }
html[data-query-mode] #results[hidden] { display: block; }
html[data-query-mode] .landing .catalog-about,
html[data-query-mode] .landing .site-footer { visibility: hidden; }

.landing .footer-grid {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
}

/* ---------- Text under the games ---------- */

.catalog-about {
  max-width: 65ch;
  margin-top: var(--space-7);
}

.catalog-about h2 {
  margin: var(--space-6) 0 var(--space-2);
  font-size: var(--text-lg);
}

.catalog-about h2:first-child {
  margin-top: 0;
}

.catalog-about h3 {
  margin: var(--space-5) 0 var(--space-1);
  font-size: var(--text-md);
}

.catalog-about p {
  margin: 0 0 var(--space-3);
  color: var(--text-muted);
  line-height: 1.6;
}

.catalog-about p a {
  color: var(--accent);
  font-weight: var(--weight-medium);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
}

.catalog-about p a:hover {
  text-decoration-color: currentColor;
}

.cat-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cat-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.cat-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Breadcrumbs ---------- */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.crumbs a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.crumbs [aria-current] {
  color: var(--text);
  font-weight: var(--weight-medium);
}

/* ---------- Category filters ---------- */

.catalog-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.catalog-tools[hidden] {
  display: none;
}

.catalog-tools label,
.category-search {
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.category-search {
  flex: 1 1 250px;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--space-2);
}

.category-search label {
  grid-column: 1 / -1;
}

.catalog-tools input,
.catalog-tools select {
  min-width: 0;
  min-height: var(--target-min);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background-color: var(--surface);
  color: var(--text);
  font-size: var(--text-md);
  font-weight: var(--weight-regular);
}

/* The arrow comes from a token, so it follows the theme. */
.catalog-tools select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 40px;
  background-image: var(--icon-chevron);
  background-position: right 14px center;
  background-size: 12px 12px;
  background-repeat: no-repeat;
}

.catalog-tools input:focus-visible,
.catalog-tools select:focus-visible {
  outline-offset: 2px;
}

.catalog-count {
  margin: var(--space-3) 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

@media (forced-colors: active) {
  .catalog-tools select {
    -webkit-appearance: auto;
    appearance: auto;
    padding-right: var(--space-3);
    background-image: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1023px) {
  .games-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .featured {
    grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
  }

  .featured-body {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
  }
}

@media (max-width: 767px) {
  main.shell,
  .landing main.shell {
    padding: var(--space-5) 0 var(--space-6);
  }

  .landing .intro {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }

  .lede {
    font-size: var(--text-md);
  }

  .row,
  .landing .row {
    margin-top: var(--space-5);
  }

  .games-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }

  .recent-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
  }

  .featured {
    grid-template-columns: minmax(0, 116px) minmax(0, 1fr);
  }

  .featured .thumb-wrap {
    display: flex;
    align-items: center;
    aspect-ratio: auto;
  }

  .featured .game-thumb {
    height: auto;
  }

  .featured-body {
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
  }

  .featured .game-title {
    font-size: var(--text-xl);
  }

  .featured .game-copy {
    font-size: var(--text-sm);
  }

  .category-search {
    flex-basis: 100%;
  }

  .catalog-tools {
    gap: var(--space-3);
  }

  .landing .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .landing .footer-brand {
    grid-column: 1 / -1;
  }
}

/* Phones: two-up tiles show artwork, name and type only. */
@media (max-width: 479px) {
  .game-card .game-copy {
    display: none;
  }

  .recent-link img {
    width: 48px;
    height: 30px;
  }
}

@media (max-width: 360px) {
  .featured {
    grid-template-columns: minmax(0, 90px) minmax(0, 1fr);
  }

  .search-row .button {
    padding-inline: var(--space-3);
  }
}

/* Touch screens have no hover, so the play mark would only flash on tap. */
@media (hover: none) {
  .game-card .thumb-wrap::after {
    display: none;
  }

  .game-card:hover,
  .featured:hover {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button,
  .game-card,
  .featured,
  .game-thumb,
  .recent-link,
  .game-card .thumb-wrap::after,
  .button svg,
  .more-link svg {
    transition: none;
  }

  .game-card:hover,
  .featured:hover,
  .game-card:hover .game-thumb {
    transform: none;
  }
}
