/* enjin.games - dark/purple theme inspired by Enjin's brand palette */

:root {
  --purple-700: #4c3aa3;
  --purple-600: #6350c4;
  --purple-500: #7866d5;
  --purple-400: #9a86ee;
  --purple-300: #bcaaff;
  --cyan-400: #56d6e0;

  --bg: #08070f;
  --bg-elevated: #100e1b;
  --surface: #14111f;
  --surface-hover: #1b1730;
  --line: #262138;
  --line-strong: #3a3155;

  --text: #f2eefd;
  --text-muted: #a49dbd;
  --text-faint: #6f688a;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --header-h: 68px;
  --edge: clamp(16px, 2.2vw, 40px);

  --shadow: 0 18px 50px -20px rgb(0 0 0 / 80%);
  --shadow-purple: 0 20px 60px -25px rgb(120 102 213 / 65%);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

/* Beats the class-level display rules below, so [hidden] always wins. */
[hidden] {
  display: none !important;
}

a {
  color: var(--purple-300);
  text-decoration: none;
}

a:hover {
  color: var(--text);
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.875em;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.15em 0.45em;
  color: var(--purple-300);
}

:focus-visible {
  outline: 2px solid var(--purple-400);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Full-bleed: just enough breathing room that content never touches the window edge. */
.shell {
  width: 100%;
  padding-inline: var(--edge);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 100;
  background: var(--purple-500);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: 16px;
}

.icon {
  width: 1em;
  height: 1em;
  flex: none;
}

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

.button {
  --btn-bg: linear-gradient(135deg, var(--purple-500), var(--purple-700));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--btn-bg);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}

.button:hover {
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-purple);
}

.button--ghost {
  --btn-bg: rgb(255 255 255 / 3%);
  border-color: var(--line-strong);
  color: var(--text);
}

.button--ghost:hover {
  --btn-bg: rgb(120 102 213 / 16%);
  border-color: var(--purple-500);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  background: rgb(8 7 15 / 82%);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 440px) 1fr;
  align-items: center;
  gap: 16px;
  padding-block: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.125rem;
}

.brand__dot {
  color: var(--purple-400);
}

.brand--sm {
  font-size: 1rem;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.search__icon {
  position: absolute;
  left: 15px;
  font-size: 1.125rem;
  color: var(--text-faint);
  pointer-events: none;
}

.search__input {
  width: 100%;
  min-width: 0;
  padding: 10px 42px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search__input::placeholder {
  color: var(--text-faint);
}

.search__input:focus {
  outline: none;
  border-color: var(--purple-500);
  box-shadow: 0 0 0 4px rgb(120 102 213 / 18%);
}

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

.search__clear {
  position: absolute;
  right: 12px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--line);
  color: var(--text-muted);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
}

.search__clear:hover {
  background: var(--line-strong);
  color: var(--text);
}

/* Placeholder for sign-in - inert until there's an account system behind it. */
.avatar {
  justify-self: end;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-faint);
  font-size: 1.375rem;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease), background 0.18s var(--ease);
}

.avatar:hover {
  border-color: var(--purple-500);
  background: var(--surface-hover);
  color: var(--text);
}

/* ---------- Browse rows ---------- */

.rows {
  padding: 28px 0 64px;
}

.row + .row {
  margin-top: 34px;
}

.row__title {
  margin: 0 0 12px;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Scrolls edge to edge while its first tile still lines up with the title. */
/* A real scroll container: wheel, trackpad and touch all work, and the row
   advances itself via requestAnimationFrame when nobody is interacting. */
.row__viewport {
  padding-block: 14px 18px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  cursor: grab;
}

.row__viewport::-webkit-scrollbar {
  display: none;
}

.row__viewport.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.row__strip {
  display: flex;
  gap: 16px;
  width: max-content;
}

.row__strip > .tile {
  flex: 0 0 clamp(230px, 20vw, 300px);
}

/* ---------- Grid + tiles ---------- */

.grid {
  /* Column count is stepped so tiles stay roughly 230-300px wide at every size,
     rather than letting auto-fill shrink them. */
  --columns: 2;
  display: grid;
  grid-template-columns: repeat(var(--columns), 1fr);
  gap: 16px;
  margin: 32px 0 72px;
}

@media (min-width: 700px) {
  .grid {
    --columns: 3;
  }
}

@media (min-width: 1000px) {
  .grid {
    --columns: 4;
  }
}

@media (min-width: 1500px) {
  .grid {
    --columns: 5;
  }
}

/* Six across once the screen is wide enough for six *large* tiles. */
@media (min-width: 1850px) {
  .grid {
    --columns: 6;
  }
}

@media (min-width: 2300px) {
  .grid {
    --columns: 7;
  }
}

.tile {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: transform 0.22s var(--ease), border-color 0.22s var(--ease), box-shadow 0.22s var(--ease);
}

.tile:hover,
.tile:focus-within {
  z-index: 5;
  transform: translateY(-3px) scale(1.015);
  border-color: var(--purple-400);
  box-shadow:
    0 0 0 2px rgb(120 102 213 / 85%),
    0 10px 22px -12px rgb(0 0 0 / 85%);
}

.tile__art {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--purple-700), #241d40);
}

.tile__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Sits above the artwork, below the click target. */
.tile__info {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 2;
  padding: 26px 13px 11px 13px;
  background: linear-gradient(to top, rgb(6 5 12 / 97%) 35%, rgb(6 5 12 / 80%) 65%, transparent);
  transform: translateY(101%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s var(--ease), opacity 0.18s var(--ease);
}

.tile:hover .tile__info,
.tile:focus-within .tile__info {
  transform: none;
  opacity: 1;
}

.tile__name {
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.tile--no-art .tile__name {
  display: none;
}

.tile__meta {
  /* Only this line runs under the play button, so only it needs the inset. */
  margin: 3px 0 0;
  padding-right: 48px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.tile__hit {
  position: absolute;
  inset: 0;
  z-index: 3;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.tile__play {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 8px 20px -8px rgb(0 0 0 / 80%);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.tile__play:hover,
.tile__play:focus-visible {
  color: #fff;
  transform: scale(1.09);
  box-shadow: var(--shadow-purple);
}

/* Touch devices have no hover, so the details stay put. */
@media (hover: none) {
  .tile__info {
    transform: none;
    opacity: 1;
  }
}

/* ---------- Empty state ---------- */

.empty {
  margin: 0 0 72px;
  padding: 56px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  text-align: center;
}

.empty p {
  color: var(--text-muted);
  margin: 10px 0 20px;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-elevated);
  padding: 44px 0;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  justify-content: space-between;
}

.site-footer__note {
  max-width: 52ch;
  margin: 14px 0 0;
  color: var(--text-faint);
  font-size: 0.8125rem;
}

.site-footer__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 16px;
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 24px;
  font-size: 0.875rem;
}

.site-footer__links a {
  color: var(--text-muted);
}

.site-footer__enjin {
  opacity: 0.6;
  transition: opacity 0.18s var(--ease);
}

.site-footer__enjin:hover {
  opacity: 1;
}

.site-footer__enjin img {
  width: 132px;
  height: auto;
}

/* ---------- Modal ---------- */

.modal {
  width: min(760px, calc(100vw - 32px));
  max-height: min(88vh, 900px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: visible;
}

.modal::backdrop {
  background: rgb(4 3 9 / 78%);
  backdrop-filter: blur(4px);
}

.modal__inner {
  max-height: min(88vh, 900px);
  overflow-y: auto;
  border-radius: var(--radius-lg);
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgb(8 7 15 / 80%);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal__close:hover {
  border-color: var(--purple-500);
  background: var(--surface-hover);
}

.detail__media {
  position: relative;
  aspect-ratio: 16 / 7;
  background: linear-gradient(135deg, var(--purple-700), #241d40);
}

.detail__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg-elevated), transparent 70%);
}

.detail__body {
  padding: 0 clamp(20px, 4vw, 36px) clamp(24px, 4vw, 36px);
  margin-top: -44px;
  position: relative;
}

.detail__title {
  font-size: clamp(1.5rem, 4vw, 2.125rem);
  font-weight: 800;
}

.detail__dev {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.detail__description {
  margin: 20px 0 0;
  color: var(--text-muted);
}

.detail__section {
  margin-top: 26px;
}

.detail__section h3 {
  margin-bottom: 10px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
}

.link-pill:hover {
  border-color: var(--purple-500);
  background: var(--surface-hover);
  color: #fff;
}

.link-pill--primary {
  background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
  border-color: transparent;
  color: #fff;
}

.detail__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin: 26px 0 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.detail__meta div {
  min-width: 0;
}

.detail__meta dt {
  color: var(--text-faint);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail__meta dd {
  margin: 4px 0 0;
  font-size: 0.9375rem;
}

.detail__edit {
  display: inline-block;
  margin-top: 22px;
  color: var(--text-faint);
  font-size: 0.8125rem;
}

.detail__edit:hover {
  color: var(--purple-300);
}

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

@media (max-width: 720px) {
  .site-header__inner {
    grid-template-columns: 1fr auto;
    row-gap: 10px;
  }

  .brand {
    grid-area: 1 / 1;
  }

  .avatar {
    grid-area: 1 / 2;
  }

  .search {
    grid-area: 2 / 1 / auto / 3;
  }

  .site-footer__right {
    align-items: flex-start;
  }

  .site-footer__links {
    justify-content: flex-start;
  }

  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Cover fallback + "add a game" card ---------- */

.media-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
  text-wrap: balance;
  font-size: clamp(1.0625rem, 2.4vw, 1.375rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: rgb(242 238 253 / 92%);
  background: radial-gradient(120% 120% at 20% 0%, rgb(155 134 238 / 45%), transparent 60%);
}

.detail__media .media-fallback {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

.card--cta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  min-height: 260px;
  padding: 32px 26px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  color: var(--text);
  text-align: center;
  align-items: center;
  transition: border-color 0.22s var(--ease), transform 0.22s var(--ease), background 0.22s var(--ease);
}

.card--cta:hover {
  transform: translateY(-4px);
  border-color: var(--purple-500);
  background: var(--surface-hover);
  color: var(--text);
}

.card--cta__plus {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgb(120 102 213 / 16%);
  border: 1px solid var(--purple-700);
  color: var(--purple-300);
  font-size: 1.5rem;
  line-height: 1;
}

.card--cta__title {
  font-size: 1.0625rem;
  font-weight: 700;
}

.card--cta__text {
  max-width: 28ch;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}
