/* ==========================================================================
   XXXGames - component layer (prototype)
   ==========================================================================
   The components the redesigned pages are built from, on top of
   assets/css/tokens.css. Load order: bootstrap -> tokens.css -> styles.css ->
   xg-components.css.

   Everything is namespaced .xg-* so it cannot collide with styles.css, and every
   value comes from a token. This is the file that replaces the per-page recipes:
   ONE bar, ONE panel, ONE chip, ONE tile.

   Compounds used by the pages:
     body.xg-body              page shell: navbar/rail offsets + ambient backdrop
     .xg-shell                 max-width wrapper
     .xg-bar[--title|--sec]    section/heading bar (joins the panel below it)
     .xg-panel[--flush]        the surface a bar sits on
     .xg-chips > .xg-chip      chip row (filter chips use aria-pressed)
     .xg-btn[--primary|--ghost|--sm]  .xg-icon-btn
     .xg-grid > .xg-tile       poster grid + card
     .xg-field / .xg-input / .xg-select
     .xg-rail > .xg-rail__track
     .xg-faq / .xg-prose / .xg-note / .xg-proto / .xg-notes
   ========================================================================== */

/* ---- page shell ---- */
body.xg-body {
  padding-top: var(--xg-nav-h);
  min-height: 100vh;
  color: var(--xg-ink-1);
  background:
    radial-gradient(1100px 560px at 50% -8%, rgb(var(--xg-tint-a) / var(--xg-ambience-a)), transparent 68%) fixed,
    radial-gradient(820px 480px at 102% 2%, rgb(var(--xg-tint-b) / var(--xg-ambience-b)), transparent 70%) fixed,
    radial-gradient(760px 460px at -6% 26%, rgb(var(--xg-tint-a) / var(--xg-ambience-c)), transparent 72%) fixed,
    linear-gradient(180deg, var(--xg-canvas-top) 0%, rgb(var(--xg-canvas-rgb)) 42%, rgb(var(--xg-canvas-2-rgb)) 100%) fixed;
}

@media (min-width: 992px) {
  body.xg-body {
    padding-left: var(--xg-rail);
    padding-right: var(--xg-page-pad);
  }
}

.xg-shell {
  max-width: var(--xg-shell);
  margin-inline: auto;
  padding: var(--xg-space-5) var(--xg-space-4) var(--xg-space-7);
}

@media (min-width: 992px) {
  .xg-shell {
    padding-inline: 0;
  }
}

/* ---- 1. THE bar ---- */
.xg-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--xg-space-4);
  padding: var(--xg-space-3) var(--xg-space-4);
  background: rgb(var(--xg-glass-rgb) / var(--xg-glass-alpha));
  -webkit-backdrop-filter: blur(var(--xg-glass-blur));
  backdrop-filter: blur(var(--xg-glass-blur));
  border: var(--xg-hairline) solid var(--xg-line);
  border-bottom: 0;
  border-radius: var(--xg-radius-lg) var(--xg-radius-lg) 0 0;
  color: #fff;
}

[data-bs-theme="light"] .xg-bar {
  color: var(--xg-ink-1);
}

.xg-bar h1,
.xg-bar h2 {
  margin: 0;
  font-family: var(--xg-font-display);
  font-weight: 700;
  letter-spacing: var(--xg-tracking-label);
  line-height: 1.3;
  color: inherit;
}

.xg-bar--title h1 {
  font-size: var(--xg-text-h1);
}

.xg-bar--sec h2 {
  font-size: var(--xg-text-bar);
}

.xg-bar__title {
  display: flex;
  align-items: baseline;
  gap: var(--xg-space-3);
  flex-wrap: wrap;
  min-width: 0;
}

.xg-bar__stats {
  display: flex;
  align-items: center;
  gap: var(--xg-space-4);
  flex-wrap: wrap;
  font-size: var(--xg-text-sm);
  color: var(--xg-ink-3);
}

.xg-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--xg-font-display);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.xg-stat .bi-eye-fill {
  color: rgb(var(--xg-tint-a));
}

.xg-stat .bi-heart-fill {
  color: var(--xg-brand);
}

.xg-bar__actions {
  display: flex;
  align-items: center;
  gap: var(--xg-space-2);
  flex-shrink: 0;
}

/* sticky variant + progressive CTA */
.xg-bar--sticky {
  position: sticky;
  top: var(--xg-nav-h);
  z-index: var(--xg-z-bar);
}

.xg-bar--sticky.is-stuck {
  border-bottom: var(--xg-hairline) solid var(--xg-line);
  border-radius: var(--xg-radius-lg);
  box-shadow: var(--xg-shadow-2);
}

.xg-bar--sticky .xg-btn--peek {
  display: none;
}

.xg-bar--sticky.is-stuck .xg-btn--peek {
  display: inline-flex;
}

@media (max-width: 991.98px) {
  .xg-bar--sticky {
    position: static;
  }
}

/* ---- 2. panel ---- */
.xg-panel {
  padding: var(--xg-space-5);
  background: var(--xg-surface-1);
  border: var(--xg-hairline) solid var(--xg-line);
  border-radius: 0 0 var(--xg-radius-lg) var(--xg-radius-lg);
  box-shadow: var(--xg-shadow-1);
}

.xg-panel--flush {
  padding: var(--xg-space-3);
}

.xg-panel--boxed {
  border-radius: var(--xg-radius-lg);
}

.xg-panel--soft {
  background:
    radial-gradient(circle at 90% 0%, rgb(var(--xg-tint-b) / 0.10), transparent 38%),
    radial-gradient(circle at 0% 100%, rgb(var(--xg-tint-a) / 0.10), transparent 38%),
    var(--xg-surface-1);
}

.xg-sec {
  margin-top: var(--xg-space-6);
}

/* ---- 3. buttons ---- */
.xg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--xg-space-2);
  padding: 0.7rem 1.25rem;
  border-radius: var(--xg-radius-pill);
  border: var(--xg-hairline) solid transparent;
  font-family: var(--xg-font-display);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: var(--xg-tracking-label);
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--xg-dur-fast) var(--xg-ease), box-shadow var(--xg-dur-fast) var(--xg-ease), background var(--xg-dur-fast) var(--xg-ease);
}

.xg-btn--primary {
  background: linear-gradient(135deg, var(--xg-action) 0%, var(--xg-action-to) 100%);
  border-color: var(--xg-action-to);
  color: var(--xg-action-ink);
  box-shadow: 0 8px 26px rgb(var(--xg-action-rgb) / 0.28);
}

.xg-btn--primary:hover {
  transform: translateY(-1px);
  background: var(--xg-action-hover);
  color: var(--xg-action-ink);
  box-shadow: 0 12px 34px rgb(var(--xg-action-rgb) / 0.42);
}

.xg-btn--ghost {
  background: var(--xg-surface-2);
  border-color: var(--xg-line-strong);
  color: var(--xg-ink-1);
}

.xg-btn--ghost:hover {
  background: var(--xg-surface-3);
  color: var(--xg-ink-1);
}

.xg-btn--sm {
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
}

.xg-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--xg-radius-md);
  border: var(--xg-hairline) solid var(--xg-line);
  background: var(--xg-surface-2);
  color: var(--xg-ink-2);
  cursor: pointer;
  transition: background var(--xg-dur-fast) var(--xg-ease), color var(--xg-dur-fast) var(--xg-ease);
}

.xg-icon-btn:hover {
  background: var(--xg-surface-3);
  color: var(--xg-ink-1);
}

.xg-icon-btn[aria-pressed="true"] {
  color: var(--xg-brand);
  border-color: rgb(var(--xg-brand-rgb) / 0.45);
  background: var(--xg-brand-soft);
}

/* ---- 4. chips ---- */
.xg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--xg-space-2);
}

.xg-chips--scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.xg-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.4rem 0.85rem;
  border-radius: var(--xg-radius-pill);
  border: var(--xg-hairline) solid var(--xg-line);
  background: var(--xg-surface-2);
  color: var(--xg-ink-2);
  font-size: var(--xg-text-sm);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--xg-dur-fast) var(--xg-ease), color var(--xg-dur-fast) var(--xg-ease), border-color var(--xg-dur-fast) var(--xg-ease);
}

a.xg-chip:hover,
button.xg-chip:hover {
  background: var(--xg-surface-3);
  border-color: rgb(var(--xg-tint-a) / 0.5);
  color: var(--xg-ink-1);
}

.xg-chip[aria-pressed="true"] {
  background: rgb(var(--xg-tint-a) / 0.16);
  border-color: rgb(var(--xg-tint-a) / 0.55);
  color: var(--xg-ink-1);
}

.xg-chip__count {
  color: var(--xg-ink-3);
  font-size: var(--xg-text-xs);
}

/* ---- 5. tiles ---- */
.xg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--xg-space-3);
}

@media (max-width: 575.98px) {
  .xg-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

.xg-tile {
  display: flex;
  flex-direction: column;
  border: var(--xg-hairline) solid var(--xg-line);
  border-radius: var(--xg-radius-md);
  background: var(--xg-surface-2);
  overflow: hidden;
  text-decoration: none;
  color: var(--xg-ink-1);
  transition: transform 0.18s var(--xg-ease), border-color 0.18s var(--xg-ease), box-shadow 0.18s var(--xg-ease);
}

.xg-tile:hover,
.xg-tile:focus-visible {
  transform: translateY(-2px);
  border-color: rgb(var(--xg-tint-a) / 0.5);
  box-shadow: var(--xg-shadow-2);
  color: var(--xg-ink-1);
}

.xg-tile__media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  background: var(--xg-inset);
  overflow: hidden;
}

.xg-tile__media img,
.xg-tile__media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.xg-tile__media video {
  opacity: 0;
  transition: opacity 0.25s var(--xg-ease);
}

.xg-tile__media.is-playing video {
  opacity: 1;
}

.xg-tile__flag {
  position: absolute;
  top: var(--xg-space-2);
  left: var(--xg-space-2);
  z-index: 2;
  padding: 3px 8px;
  border-radius: var(--xg-radius-pill);
  background: rgb(var(--xg-tint-a) / 0.88);
  color: #fff;
  font-size: var(--xg-text-xs);
  font-weight: 700;
}

.xg-tile__title {
  flex: 1;
  padding: var(--xg-space-2) var(--xg-space-3) 0;
  font-family: var(--xg-font-body);
  font-size: var(--xg-text-tile);
  font-weight: 600;
  line-height: 1.35;
}

.xg-tile__meta {
  display: flex;
  align-items: center;
  gap: var(--xg-space-3);
  padding: var(--xg-space-1) var(--xg-space-3) var(--xg-space-3);
  color: var(--xg-ink-3);
  font-size: var(--xg-text-xs);
}

.xg-tile__meta .bi {
  font-size: 0.8rem;
}

/* ---- 6. form controls ---- */
.xg-field {
  display: flex;
  align-items: center;
  gap: var(--xg-space-2);
  padding: 0.55rem 0.9rem;
  border-radius: var(--xg-radius-pill);
  border: var(--xg-hairline) solid var(--xg-line);
  background: var(--xg-surface-2);
  color: var(--xg-ink-3);
  min-width: 0;
}

.xg-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  color: var(--xg-ink-1);
  font-size: var(--xg-text-sm);
}

.xg-field input::placeholder {
  color: var(--xg-ink-3);
}

.xg-select {
  padding: 0.55rem 2rem 0.55rem 1rem;
  border-radius: var(--xg-radius-pill);
  border: var(--xg-hairline) solid var(--xg-line);
  background: var(--xg-surface-2);
  color: var(--xg-ink-1);
  font-size: var(--xg-text-sm);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--xg-ink-3) 50%), linear-gradient(135deg, var(--xg-ink-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* ---- 7. horizontal rail ---- */.xg-rail {
  position: relative;
  margin-top: var(--xg-space-3);
}

.xg-rail__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(170px, 190px);
  gap: var(--xg-space-3);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-bottom: var(--xg-space-2);
  scrollbar-width: thin;
}

.xg-rail__track > * {
  scroll-snap-align: start;
}

/* ---- 8. text blocks ---- */
.xg-prose {
  max-width: 68ch;
  color: var(--xg-ink-2);
  line-height: var(--xg-leading-prose);
}

.xg-prose p {
  color: var(--xg-ink-2);
  margin-bottom: var(--xg-space-3);
}

.xg-prose p:last-child {
  margin-bottom: 0;
}

.xg-note {
  color: var(--xg-ink-3);
  font-size: var(--xg-text-sm);
  margin: var(--xg-space-2) 0 0;
}

.xg-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--xg-action-text);
  font-size: var(--xg-text-sm);
  font-weight: 600;
  cursor: pointer;
}

.xg-link:hover {
  text-decoration: underline;
}

/* ---- 9. FAQ ---- */
.xg-faq {
  border: var(--xg-hairline) solid var(--xg-line);
  border-radius: var(--xg-radius-md);
  background: var(--xg-surface-2);
  padding: var(--xg-space-4);
}

.xg-faq + .xg-faq {
  margin-top: var(--xg-space-2);
}

.xg-faq summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--xg-ink-1);
  list-style: none;
}

.xg-faq summary::-webkit-details-marker {
  display: none;
}

.xg-faq summary::after {
  content: "+";
  float: right;
  color: rgb(var(--xg-tint-a));
  font-weight: 700;
}

.xg-faq[open] summary::after {
  content: "-";
}

.xg-faq p {
  margin: var(--xg-space-3) 0 0;
  color: var(--xg-ink-2);
  line-height: 1.7;
}

/* ---- 10. prototype chrome ---- */
.xg-proto {
  display: flex;
  gap: var(--xg-space-3);
  align-items: flex-start;
  padding: var(--xg-space-3) var(--xg-space-4);
  margin-bottom: var(--xg-space-5);
  border: 1px dashed rgb(var(--xg-tint-b) / 0.5);
  border-radius: var(--xg-radius-md);
  background: rgb(var(--xg-tint-b) / 0.08);
  color: var(--xg-ink-2);
  font-size: var(--xg-text-sm);
  line-height: 1.6;
}

.xg-proto strong {
  color: var(--xg-ink-1);
}

.xg-notes {
  margin-top: var(--xg-space-4);
  border: var(--xg-hairline) solid var(--xg-line);
  border-radius: var(--xg-radius-md);
  background: var(--xg-surface-2);
  padding: var(--xg-space-4);
  color: var(--xg-ink-2);
  font-size: var(--xg-text-sm);
}

.xg-notes summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--xg-ink-1);
  list-style: none;
}

.xg-notes summary::-webkit-details-marker {
  display: none;
}

.xg-notes ul {
  margin: var(--xg-space-3) 0 0;
  padding-left: 1.1rem;
  line-height: 1.7;
}

.xg-notes li {
  margin-bottom: 6px;
}

.xg-notes code,
.xg-proto code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  color: rgb(var(--xg-tint-a));
}

/* ---- 11. focus + motion ---- */
.xg-btn:focus-visible,
.xg-icon-btn:focus-visible,
.xg-tile:focus-visible,
.xg-chip:focus-visible,
.xg-link:focus-visible,
.xg-select:focus-visible,
.xg-field:focus-within {
  outline: var(--xg-ring) solid var(--xg-focus);
  outline-offset: var(--xg-ring-offset);
}

@media (prefers-reduced-motion: reduce) {
  .xg-btn,
  .xg-tile,
  .xg-chip,
  .xg-tile__media video {
    transition: none;
  }
}

/* ---- 12. LEGACY BRIDGE: the live grid's hook classes ----
   assets/js/home-page.js emits .game-card-media / .game-card-img /
   .card-img-overlay-hover inside .xg-tile, because four scripts and two stylesheets
   hang off those class names (card-video-hover.js, image-shimmer.js, reveal.js,
   home-page.js + the shimmer/overlay rules in styles.css). Their site rules were
   written for the OLD 200px-tall card, so they are corrected here - this is the one
   and only place the old and new card recipes touch. Delete this block when
   home-page.js stops emitting the hook classes. */

.xg-tile {
  height: 100%;
  /* the ribbon / ad badge / new bubble are absolutely positioned siblings of the
     media and used to anchor to .game-card (which was position:relative) */
  position: relative;
}

.xg-tile .game-card-media {
  height: auto;
  /* styles.css pins this to 200px, which would defeat aspect-ratio */
  aspect-ratio: 16 / 10;
  background: var(--xg-inset);
}

/* Cover art comes in every ratio the itch pages ever produced (16:9, 5:4, square
   logos, 440x350 MP4s). Cropping it with cover chopped heads off, so the artwork is
   CONTAINED and the frame stays full-bleed because the same image sits behind it
   blurred. That backdrop is a real element - a url() inside a custom property
   resolves against THIS stylesheet, not the page, so an inline --xg-cover:url(...)
   resolved to assets/css/assets/img/... */
.xg-tile .game-card-media .xg-tile__bg {
  position: absolute;
  inset: -12%;
  z-index: 0;
  width: 124%;
  height: 124%;
  max-width: none;
  object-fit: cover;
  filter: blur(26px) saturate(1.35) brightness(0.62);
  pointer-events: none;
}

.xg-tile .game-card-media .game-card-img,
.xg-tile .game-card-media .card-img-top {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 0;
  /* styles.css adds 0.5rem for the old object-fit: contain look */
  object-fit: contain;
  border-radius: 0;
  background: transparent;
  filter: drop-shadow(0 8px 20px rgb(0 0 0 / 0.45));
}

/* the hover description panel */
.xg-tile .card-img-overlay-hover {
  display: flex;
  /* styles.css makes this a COLUMN flex box: flex-end/flex-start here mean
     bottom/left, and leave the copy sitting on the dark end of the scrim */
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  padding: var(--xg-space-3);
  /* a bottom-only fade left the top lines of a long description unreadable */
  background: linear-gradient(
    to top,
    rgb(4 3 8 / 0.95) 0%,
    rgb(4 3 8 / 0.9) 45%,
    rgb(4 3 8 / 0.74) 100%
  );
  opacity: 0;
  transition: opacity var(--xg-dur-base) var(--xg-ease);
}

.xg-tile .game-card-media:hover .card-img-overlay-hover,
.xg-tile .game-card-media:focus-within .card-img-overlay-hover {
  opacity: 1;
}

.xg-tile .card-text-overlay {
  margin: 0;
  color: #fff;
  font-size: var(--xg-text-sm);
  line-height: 1.45;
  text-align: left;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.6);
  /* keeps the copy inside the scrim instead of running up the artwork */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* badges that sit on the media */
.xg-tile .game-card-ribbon,
.xg-tile .game-card-ad-badge {
  z-index: 2;
}

.xg-tile .game-card-ribbon {
  background: linear-gradient(135deg, rgb(var(--xg-tint-a)), rgb(var(--xg-tint-b)));
  color: #fff;
  border-radius: var(--xg-radius-sm);
}

.xg-tile .game-card-ad-badge {
  background: rgb(var(--xg-glass-rgb) / 0.82);
  color: var(--xg-ink-2);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* stats + platform icons in the tile footer */
.xg-tile__meta .card-fav-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.xg-tile .card-fav-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--xg-ink-3);
  line-height: 1;
  cursor: pointer;
}

.xg-tile .card-fav-btn:hover,
.xg-tile .card-fav-btn.active {
  color: var(--xg-brand);
}

.xg-tile .card-fav-count,
.xg-tile .card-views-count {
  color: var(--xg-ink-3);
  font-size: var(--xg-text-xs);
}

.xg-tile__plat {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  color: var(--xg-ink-3);
}

.xg-tile__plat .bi {
  font-size: 0.8rem;
}

/* SmutStone's card is a transparent PNG logo, not cover art (currently hidden from
   the home grid via hideHome) - contain already gives it the whole frame */

/* The component layer hides .xg-tile__media video because the prototype pairs a
   poster <img> with a separate hover video. The live card has no second element:
   its <video> carries the poster attribute, so it IS the thing to show. */
.xg-tile .game-card-media video {
  opacity: 1;
}

/* the shimmer wrappers in styles.css are keyed to .game-card-media, which the new
   tiles still carry - only the placeholder ink needs the token version */
.xg-tile .game-card-media:has(img.img-shimmer:not(.img-loaded)) {
  background: linear-gradient(110deg, rgb(var(--xg-line-rgb) / 0.04) 25%, rgb(var(--xg-line-rgb) / 0.12) 37%, rgb(var(--xg-line-rgb) / 0.04) 50%), var(--xg-inset);
  background-size: 200% 100%;
}

.xg-tile .game-card-media img.img-shimmer:not(.img-loaded) {
  min-height: 0;
  /* styles.css reserves 200px for the old fixed-height card */
}

