/* games.css: the games section. Same tokens as base.css, black and white
   interface; covers keep their own colour. */

:root { --r: 14px; --r-sm: 10px; }

/* ---------- top bar ---------- */

.g-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(140px, 460px) auto;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px var(--gutter);
  background: rgba(0, 0, 0, .9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.g-back { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); font-size: 15px; }
.g-back:hover { color: var(--hi); }
.g-back svg { width: 24px; height: 24px; }

.g-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: #0e0e0e;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  transition: border-color .16s var(--ease), background-color .16s var(--ease);
}
.g-search:focus-within { border-color: var(--hi); background: #141414; }
.g-search svg { flex: none; width: 16px; height: 16px; color: var(--dim); }
.g-search input {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  font-size: 14px;
  color: var(--hi);
  background: transparent;
  border: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.g-search input::placeholder { color: #6e6e6e; opacity: 1; }
.g-search input::-webkit-search-cancel-button { display: none; }

/* all / saved */
.g-tabs { display: flex; padding: 3px; background: #0e0e0e; border: 1px solid var(--line-2); border-radius: 999px; }
.g-tabs button {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--dim);
  background: none;
  border: 0;
  border-radius: 999px;
  transition: color .16s var(--ease), background-color .16s var(--ease);
}
.g-tabs button:hover { color: var(--hi); }
.g-tabs button[aria-pressed="true"] { color: var(--bg); background: var(--hi); }
.g-n:empty { display: none; }
.g-n { margin-left: 2px; font-size: 11px; opacity: .7; }

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

.g-view { padding: 22px var(--gutter) 70px; outline: none; }
.g-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 14px; }
.g-head h2 { margin: 0; font-size: 13px; font-weight: 500; letter-spacing: .14em; text-transform: lowercase; color: var(--dim); }
.g-head span { font-size: 12px; color: var(--mute); }
.g-empty { padding: 40px 0; text-align: center; color: var(--dim); font-size: 13px; }

.g-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  grid-auto-flow: dense;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Featured games get a big tile so the grid is not one repeated square. */
.g-card { position: relative; aspect-ratio: 1; }
.g-card.is-big { grid-column: span 2; grid-row: span 2; }
.g-card.is-wide { grid-column: span 2; aspect-ratio: 2 / 1; }

.g-open {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  text-align: left;
  background: #0d0d0d;
  border: 1px solid var(--line);
  border-radius: var(--r);
  transition: transform .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.g-open:hover, .g-open:focus-visible {
  transform: translateY(-3px);
  border-color: #6a6a6a;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .7);
}
.g-open:focus-visible { outline: 1px solid var(--hi); outline-offset: 3px; }
.g-cover {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s var(--ease);
}
.g-open:hover .g-cover { transform: scale(1.04); }
.g-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 12px 10px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--hi);
  background: linear-gradient(transparent, rgba(0, 0, 0, .88) 55%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.is-big .g-name { padding: 60px 16px 14px; font-size: 16px; }

/* save: a quiet heart that only shows on hover, and stays when saved */
.g-save {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--hi);
  background: rgba(0, 0, 0, .55);
  border: 0;
  border-radius: 50%;
  opacity: 0;
  transform: scale(.85);
  transition: opacity .16s var(--ease), transform .16s var(--ease), background-color .16s var(--ease);
}
.g-save svg { width: 16px; height: 16px; }
.g-card:hover .g-save,
.g-save:focus-visible,
.g-save[aria-pressed="true"] { opacity: 1; transform: none; }
.g-save:hover { background: rgba(0, 0, 0, .85); }
.g-save[aria-pressed="true"] svg { fill: currentColor; }
@media (hover: none) { .g-save { opacity: .8; transform: none; } }

.g-more {
  display: block;
  margin: 30px auto 0;
  padding: 11px 26px;
  font-size: 13px;
  color: var(--fg);
  background: #0e0e0e;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  transition: border-color .16s var(--ease), color .16s var(--ease);
}
.g-more:hover { color: var(--hi); border-color: var(--hi); }

/* ---------- player ---------- */

.g-player { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); }
.g-player[hidden] { display: none; }
.g-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 8px var(--gutter);
  border-bottom: 1px solid var(--line);
}
.g-bar strong { font-weight: 500; font-size: 14px; color: var(--hi); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-bar-r { display: flex; gap: 8px; }
.g-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 10px;
  font-size: 13px;
  color: var(--fg);
  background: #0e0e0e;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  transition: color .16s var(--ease), border-color .16s var(--ease);
}
.g-btn:hover { color: var(--hi); border-color: var(--hi); }
.g-btn svg { width: 16px; height: 16px; }
.g-icon { padding: 7px 10px; }
.g-icon[aria-pressed="true"] svg { fill: currentColor; }
#p-frame { flex: 1; width: 100%; border: 0; background: #000; }

/* the grain and scanline overlays would sit on top of the game */
.playing { overflow: hidden; }
.playing .fx { display: none; }

@media (max-width: 640px) {
  .g-top { grid-template-columns: auto 1fr; }
  .g-back span { display: none; }
  .g-tabs { grid-column: 1 / -1; justify-self: start; }
  .g-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .g-bar strong { display: none; }
  .g-bar { grid-template-columns: auto 1fr; }
  .g-bar-r { justify-self: end; }
  .g-btn span { display: none; }
  .g-btn { padding: 8px 10px; }
}
