/* ------------------------------------------------------------------------ *
 * Games: hub (_layouts/games-index.html) and game page (_layouts/game.html)
 * Scoped with .games-page / .game so the rest of the site is untouched.
 * ------------------------------------------------------------------------ */

.games-page,
.game {
  --game-ink: #0f172a;
  --game-muted: #64748b;
  --game-soft: #94a3b8;
  --game-line: #e2e8f0;
  --game-line-strong: #cbd5e1;
  --game-surface: #ffffff;
  --game-tint: #f8fafc;
  --game-accent: #2563eb;
  --game-accent-dark: #1d4ed8;
  --game-radius: 14px;
  --game-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --game-shadow-md: 0 1px 2px rgba(15, 23, 42, 0.06), 0 14px 30px -18px rgba(15, 23, 42, 0.35);
  --game-dark: #0b1120;

  color: var(--game-ink);
}

.games-page :focus-visible,
.game :focus-visible {
  outline: 2px solid var(--game-accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.games-page h1,
.game h1 {
  margin: 0 0 0.35rem;
  padding: 0;
  border-bottom: 0;
  font-size: 2rem;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.games-page .games-sub {
  margin: 0;
  max-width: 62ch;
  font-size: 0.98rem;
  color: var(--game-muted);
}

.games-empty {
  margin: 1.5rem 0;
  padding: 1rem 1.15rem;
  color: var(--game-muted);
  background: var(--game-tint);
  border: 1px dashed var(--game-line-strong);
  border-radius: var(--game-radius);
}

/* ------------------------------------------------------------- hub filter */

.game-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.6rem;
  margin: 1.3rem 0 0;
}

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

.game-filter-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--game-soft);
}

.game-filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.6rem;
}

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

.game-filter-count {
  margin-left: 0.4em;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.game-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.game-filter-chip {
  margin: 0;
  padding: 0.25rem 0.7rem;
  font: inherit;
  font-size: 0.82rem;
  color: #334155;
  background: var(--game-surface);
  border: 1px solid var(--game-line-strong);
  border-radius: 999px;
  cursor: pointer;
}

.game-filter-chip:hover {
  color: var(--game-accent-dark);
  border-color: var(--game-accent);
}

.game-filter-chip[aria-pressed="true"] {
  font-weight: 600;
  color: #fff;
  background: var(--game-accent);
  border-color: var(--game-accent);
}

.game-filter-clear {
  margin: 0 0 0 auto;
  padding: 0.2rem 0.35rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--game-accent-dark);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.game-filter-clear:hover {
  color: var(--game-accent);
}

.game-none {
  margin: 1.25rem 0 2rem;
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--game-muted);
  background: var(--game-tint);
  border: 1px dashed var(--game-line-strong);
  border-radius: var(--game-radius);
}

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

.game-reset {
  margin: 0 0 0 0.35rem;
  padding: 0.2rem 0.5rem;
  font: inherit;
  font-size: 0.88rem;
  color: var(--game-accent-dark);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.game-reset:hover {
  color: var(--game-accent);
}

/* ------------------------------------------------------------- hub cards */

ul.game-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.35rem 0 2rem;
  padding: 0;
  list-style: none;
}

ul.game-list > li {
  margin: 0;
  padding: 0;
  list-style: none;
}

ul.game-list > li[hidden] {
  display: none;
}

.game-card {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  height: 100%;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  background: var(--game-surface);
  border: 1px solid var(--game-line);
  border-radius: var(--game-radius);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.game-card:hover {
  color: inherit;
  text-decoration: none;
  border-color: var(--game-line-strong);
  box-shadow: var(--game-shadow-md);
  transform: translateY(-2px);
}

.game-card-art {
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--game-dark);
}

.game-card-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem 1.1rem 1.1rem;
}

.game-card-title {
  font-size: 1.12rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.game-card-summary {
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--game-muted);
}

.game-card-meta,
.game-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.game-card-meta {
  padding-top: 0.5rem;
}

.game-card-cta {
  margin-top: auto;
  padding-top: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--game-accent-dark);
}

.game-card:hover .game-card-cta {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ------------------------------------------------------------------ chips */

.game-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  padding: 0.14em 0.6em;
  font-size: 0.76rem;
  line-height: 1.5;
  color: #475569;
  white-space: nowrap;
  background: var(--game-tint);
  border: 1px solid var(--game-line);
  border-radius: 999px;
}

.game-chip-version {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.game-chip-status {
  text-transform: capitalize;
  color: #065f46;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.game-chip-tag {
  color: #6b21a8;
  background: #faf5ff;
  border-color: #e9d5ff;
}

a.game-chip {
  text-decoration: none;
}

a.game-chip:hover {
  filter: brightness(0.97);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ------------------------------------------------------------ game page */

.game-back {
  margin: 0 0 1rem;
  font-size: 0.88rem;
}

.game-back a {
  color: var(--game-muted);
  text-decoration: none;
}

.game-back a:hover {
  color: var(--game-accent-dark);
  text-decoration: underline;
}

.game-summary {
  margin: 0 0 0.5rem;
  max-width: 62ch;
  font-size: 1rem;
  color: var(--game-muted);
}

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.35rem 0 0.9rem;
}

/* Player: fixed aspect box; poster until the visitor asks for the game. */

.game-player {
  position: relative;
  aspect-ratio: var(--game-aspect, 16 / 9);
  overflow: hidden;
  background: var(--game-dark);
  border-radius: var(--game-radius);
  box-shadow: var(--game-shadow-md);
}

.game-frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.game-poster {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  box-sizing: border-box;
  margin: 0;
  padding: 1rem;
  font: inherit;
  color: #e2e8f0;
  background: var(--game-dark);
  border: 0;
  cursor: pointer;
}

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

.game-poster-art {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
}

.game-poster-shade {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(11, 17, 32, 0.1), rgba(11, 17, 32, 0.85));
}

.game-poster-play {
  position: relative;
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  padding-left: 0.25rem;
  font-size: 1.5rem;
  color: #fff;
  background: rgba(37, 99, 235, 0.95);
  border-radius: 999px;
  box-shadow: 0 12px 30px -10px rgba(37, 99, 235, 0.85);
  transition: transform 0.15s ease, background 0.15s ease;
}

.game-poster:hover .game-poster-play {
  background: var(--game-accent-dark);
  transform: scale(1.06);
}

.game-poster-label {
  position: relative;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.game-poster:hover .game-poster-label {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.game-player-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  color: #cbd5e1;
  background: var(--game-dark);
}

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

.game-player-missing {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 1rem;
  text-align: center;
  color: #cbd5e1;
}

.game-player-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  align-items: center;
  margin: 0.75rem 0 0.25rem;
}

.game-link {
  font-size: 0.88rem;
  color: var(--game-accent-dark);
  text-decoration: none;
}

.game-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.game-button {
  margin: 0;
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  background: var(--game-surface);
  border: 1px solid var(--game-line-strong);
  border-radius: 9px;
  cursor: pointer;
}

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

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

.game-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--game-soft);
}

/* Body: description and any free-form notes. */

.game-body {
  max-width: 72ch;
  margin: 1.6rem 0 0;
}

.game-body h2 {
  margin: 2rem 0 0.6rem;
  padding-top: 1.2rem;
  font-size: 1.05rem;
  border-top: 1px solid var(--game-line);
}

.game-body h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.game-body h3 {
  margin: 1.4rem 0 0.4rem;
  font-size: 0.92rem;
  color: #334155;
}

.game-body ul,
.game-body ol {
  margin: 0.3rem 0 0.9rem;
  padding-left: 1.25rem;
}

.game-body li {
  margin: 0.15rem 0;
  color: #334155;
}

.game-body p {
  color: #334155;
}

.game-body > *:last-child {
  margin-bottom: 0;
}

/* Changelog and credits (rendered from front matter). */

.game-changelog,
.game-credits {
  max-width: 72ch;
  margin: 2rem 0 0;
}

.game-changelog h2,
.game-credits h2 {
  margin: 0 0 0.75rem;
  padding-top: 1.2rem;
  font-size: 1.05rem;
  border-top: 1px solid var(--game-line);
}

.game-version {
  margin: 0 0 0.5rem;
  background: var(--game-surface);
  border: 1px solid var(--game-line);
  border-radius: 10px;
}

.game-version > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  color: #334155;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.game-version > summary::-webkit-details-marker {
  display: none;
}

.game-version > summary::before {
  content: "▸";
  font-size: 0.7rem;
  color: var(--game-soft);
  transition: transform 0.15s ease;
}

.game-version[open] > summary::before {
  transform: rotate(90deg);
}

.game-version > summary:hover {
  color: var(--game-accent-dark);
}

.game-version-date {
  font-size: 0.8rem;
  color: var(--game-muted);
}

.game-version-changes {
  margin: 0.1rem 0 0.8rem;
  padding-left: 2.2rem;
}

.game-version-changes li {
  margin: 0.15rem 0;
  color: #334155;
}

.game-credits ul {
  margin: 0.3rem 0 0;
  padding-left: 1.25rem;
}

.game-credits li {
  margin: 0.15rem 0;
  color: #334155;
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 640px) {
  .games-page h1,
  .game h1 {
    font-size: 1.65rem;
  }

  .game-player {
    border-radius: 10px;
  }

  .game-poster-play {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.2rem;
  }

  ul.game-list {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-card,
  .game-poster-play,
  .game-version > summary::before {
    transition: none;
  }

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