/*
 * GAME CARD STYLES — loaded only by index.html, after site.css.
 *
 *   1. Card list and card
 *   2. Locked (teaser) card
 *   3. Badge, title, genres, description, Steam button
 *   4. Media gallery
 *   5. Fullscreen viewer
 *   6. Touch screens and phones
 */

/* ---------- 1. Card list and card ---------- */

.game-grid {
  display: grid;
  gap: 32px;
}
/* With media: gallery on the left, text on the right. Without: text only. */
.game-card {
  display: grid;
  gap: 36px;
  align-items: start;
  min-width: 0;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.game-card:has(> .game-gallery) {
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}
.game-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

/* ---------- 2. Locked (teaser) card: only a centered label ---------- */

.game-card--locked {
  justify-items: center;
  gap: 24px;
  padding: 56px 28px;
  font-family: var(--heading-font);
  font-size: 32px;
  line-height: 1.2;
  text-align: center;
}

/* ---------- 3. Badge, title, genres, description, Steam button ---------- */

/* `header` in content/games.js: a short line in its color, above the title. */
.game-badge {
  margin-bottom: 12px;
  color: var(--badge-color, var(--accent));
  font-family: var(--heading-font);
  font-size: 14px;
  letter-spacing: 0.02em;
}
.game-card h3 {
  margin: 0 0 10px;
  font-size: 34px;
  overflow-wrap: anywhere;
}
/* Genres: one small box each, like the tags on Steam's store page. */
.game-genre {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 24px;
  padding: 0;
  list-style: none;
}
.game-genre li {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.game-info p {
  margin: 0 0 24px;
}
/* "View on Steam": the one solid button on the card. */
.game-steam {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 15px;
}
a.game-steam:hover {
  background: color-mix(in srgb, var(--accent) 85%, white);
}
.game-steam img {
  width: 18px;
  height: 18px;
  filter: brightness(0); /* the Steam icon in the button's dark text color */
}
/* On the teaser card: the same button, not a link yet. */
.game-steam--unavailable {
  background: var(--panel-raised);
  color: var(--muted);
}
.game-steam--unavailable img {
  filter: brightness(0) invert(0.6);
}

/* ---------- 4. Media gallery: large media, thumbnails in a row under it ---------- */

.game-gallery {
  --control-size: 40px; /* arrows and close button */
  min-width: 0;
}
.game-media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: #000000;
}
/* One continuous strip: adjacent slides touch; a touchpad swipe snaps to a full slide. */
.media-band {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.media-band::-webkit-scrollbar {
  display: none;
}
/* Each slide is a button that opens the fullscreen viewer. */
.media-content {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 100%;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: zoom-in;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.media-content > img,
.media-content > video {
  pointer-events: none;
}
.media-content > img,
.media-content > video,
.media-viewer-content > img,
.media-viewer-content > video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* Shown when an image or video fails to load. */
.media-placeholder {
  display: grid;
  place-items: center;
}
.placeholder-logo {
  width: min(240px, 50%);
}

/* Thumbnail row */
.gallery-thumbnails {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
  /* No scrollbar: the picture's arrows and the arrow keys bring hidden thumbnails into view. */
  scrollbar-width: none;
}
.gallery-thumbnails::-webkit-scrollbar {
  display: none;
}
.gallery-thumbnail {
  position: relative;
  flex: 0 0 112px;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  background: var(--panel-raised);
  cursor: pointer;
  overflow: hidden;
  opacity: 0.6;
}
.gallery-thumbnail:hover {
  opacity: 1;
}
.gallery-thumbnail[aria-pressed='true'] {
  border-color: var(--accent);
  opacity: 1;
}
.gallery-thumbnail:focus-visible {
  outline-offset: -2px;
}
.gallery-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Play symbol over video pictures; hidden while the card's silent preview plays. */
.thumbnail-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ffffff;
}
.media-content.is-playing .thumbnail-play {
  display: none;
}

/* Previous / next arrows and the viewer's close button: the same round button everywhere. */
.media-arrow,
.media-viewer-arrow,
.media-viewer-close {
  position: absolute;
  display: grid;
  place-items: center;
  width: var(--control-size);
  height: var(--control-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #000000b3;
  color: #ffffff;
  cursor: pointer;
}
.media-arrow:hover,
.media-viewer-arrow:hover,
.media-viewer-close:hover {
  background: #000000;
}
.media-arrow,
.media-viewer-arrow {
  top: 50%;
  transform: translateY(-50%);
}
.media-arrow-previous {
  left: 10px;
}
.media-arrow-next {
  right: 10px;
}
/* The card's arrows appear when the pointer is over the picture (or a key reaches them). */
.media-arrow {
  opacity: 0;
  transition: opacity 0.15s;
}
.game-media:hover .media-arrow,
.media-arrow:focus-visible {
  opacity: 1;
}

/* ---------- 5. Fullscreen viewer (a <dialog>) ---------- */

.media-viewer {
  /* Width of the media: as large as fits the window (32px from its edges), at most 1440px. */
  --media-width: min(1440px, 100vw - 64px, (100vh - 64px) * 16 / 9);
  /* The buttons scale with the media and sit at fixed spots on it. */
  --control-size: max(32px, var(--media-width) * 0.035);
  --icon-size: calc(var(--control-size) * 0.55);
  --control-inset: calc(var(--media-width) * 0.012);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}
.media-viewer:focus {
  outline: none; /* js/gallery.js focuses the viewer when it opens */
}
.media-viewer::backdrop {
  background: #000000e6;
}
/* No page scrolling behind the open viewer. */
html:has(.media-viewer[open]) {
  overflow: hidden;
}
/* shortcut: sized for 16:9 media (Steam screenshots and trailers); other shapes get
   dark bars at the sides or top, switch to the media's own ratio if that happens. */
.media-viewer-content {
  display: grid;
  place-items: center;
  width: var(--media-width);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: #000000;
}
.media-viewer-previous {
  left: var(--control-inset);
}
.media-viewer-next {
  right: var(--control-inset);
}
.media-viewer-close {
  top: var(--control-inset);
  right: var(--control-inset);
}

/* ---------- 6. Touch screens and phones ---------- */

/* No pointer to hover with: the card's arrows stay visible (a swipe also works). */
@media (hover: none) {
  .media-arrow {
    opacity: 1;
  }
}
/* Phones: the gallery above the text, and the viewer nearly as wide as the screen. */
@media (max-width: 900px) {
  .game-card,
  .game-card:has(> .game-gallery) {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 16px;
  }
  .game-card h3 {
    font-size: 26px;
  }
  .game-card--locked {
    padding: 40px 16px;
    font-size: 24px;
  }
  .gallery-thumbnail {
    flex-basis: 88px;
  }
  .media-viewer {
    --media-width: min(100vw - 16px, (100vh - 64px) * 16 / 9);
  }
}
