/* Metacritic AI Watch — dark game catalogue. One file, no build step. */

:root {
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1e222d;
  --line: #2a2f3d;
  --text: #e6e9f0;
  --muted: #98a1b3;
  --accent: #8b5cf6;
  --accent-soft: #2a2145;

  /* Metacritic score colours, kept dark-text for contrast on the badge. */
  --good: #58c322;
  --mixed: #f2c94c;
  --bad: #ef4444;
  --tbd: #3a4051;

  --radius: 10px;
  --gap: 1rem;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

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

.wrap { width: min(1180px, 100% - 2rem); margin-inline: auto; }

:where(a, button, input, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ chrome */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap); min-height: 60px;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-weight: 700; font-size: 1.05rem; letter-spacing: 0.01em; text-decoration: none;
  white-space: nowrap;  /* "Metacritic AI Watch" must never break across lines */
  min-width: 0;
}
.brand__mark {
  width: 12px; height: 22px; border-radius: 3px;
  background: linear-gradient(180deg, var(--good), var(--accent));
}
.brand__dim { color: var(--muted); font-weight: 500; }

.footer {
  margin-top: 3rem; padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem;
}

#main { padding-block: 1.5rem 1rem; }

/* ------------------------------------------------------------------- panel */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.panel__row { display: flex; flex-wrap: wrap; gap: var(--gap); }
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 180px; }
.field--grow { flex: 1 1 260px; }
.field__label {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
}
.field__input {
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
.field__input::placeholder { color: #6b7383; }

.platforms {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin: 1rem 0 0; padding: 0; border: 0;
}
.platforms .field__label { flex-basis: 100%; margin-bottom: 0.15rem; padding: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: 36px; padding: 0.3rem 0.7rem;
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 0.88rem; cursor: pointer;
  transition: border-color 200ms, background-color 200ms;
}
.chip:hover { border-color: var(--accent); }
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.chip input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0.4rem 0.9rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--accent); color: #fff;
  font: inherit; text-decoration: none; cursor: pointer;
  transition: background-color 200ms, border-color 200ms;
}
.btn--ghost { background: var(--surface-2); color: var(--text); }
.btn--ghost:hover { border-color: var(--accent); }

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

.results__count { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.9rem; }

.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.grid--tight { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.75rem;
  transition: border-color 200ms, background-color 200ms;
}
.card:hover { border-color: var(--accent); background: var(--surface-2); }
.card__link { text-decoration: none; cursor: pointer; }
.card__title { margin: 0.6rem 0 0; font-size: 0.98rem; line-height: 1.35; }
.card__meta { margin: 0.25rem 0 0.6rem; color: var(--muted); font-size: 0.82rem; }

.cover {
  position: relative;
  container-type: inline-size;  /* lets the placeholder letter scale with the card */
  aspect-ratio: 3 / 4;
  background: var(--surface-2);
  border-radius: 8px;
  overflow: hidden;
}
.cover__img { width: 100%; height: 100%; object-fit: cover; }
.cover__empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.45rem; height: 100%; padding: 0.6rem; text-align: center;
}
.cover__empty-letter {
  font-size: clamp(2rem, 18cqw, 3rem); font-weight: 700; line-height: 1; color: #4a5164;
}
.cover__empty-note {
  font-size: 0.7rem; line-height: 1.3; color: var(--muted); text-wrap: balance;
}
.cover--lg .cover__empty-letter { font-size: 3.5rem; }
.cover--lg .cover__empty-note { font-size: 0.8rem; }
.cover--lg { aspect-ratio: 3 / 4; width: 260px; max-width: 100%; flex: none; }
.cover__score {
  position: absolute; left: 8px; bottom: 8px;
  min-width: 40px; height: 40px;
  font-size: 1.15rem; font-weight: 700;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.45);
}

/* ------------------------------------------------------------------ scores */

.score {
  display: inline-grid; place-items: center;
  min-width: 30px; min-height: 26px; padding: 0 0.4rem;
  border-radius: 6px;
  color: #0d1016; font-weight: 700; font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.score--good  { background: var(--good); }
.score--mixed { background: var(--mixed); }
.score--bad   { background: var(--bad); color: #fff; }
.score--tbd   { background: var(--tbd); color: var(--muted); font-weight: 600; }

.badges { list-style: none; margin: auto 0 0; padding: 0; display: grid; gap: 0.3rem; }
.badge {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.78rem; color: var(--muted);
}
.badge__name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge .score { min-width: 28px; min-height: 22px; font-size: 0.75rem; }

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

.game__head { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1rem; }
.game__facts { flex: 1 1 320px; }
.game__title { margin: 0 0 0.8rem; font-size: clamp(1.5rem, 3.5vw, 2.1rem); line-height: 1.2; }
.game__links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0 0; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.85rem; }
.facts dd { margin: 0; }

.section { margin-top: 2rem; }
.section__title {
  margin: 0 0 0.8rem; padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.1rem;
}
.prose { margin: 0; max-width: 72ch; white-space: pre-line; color: #cdd3df; }

.video { position: relative; aspect-ratio: 16 / 9; max-width: 760px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius); }

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { padding: 0.55rem 0.6rem; text-align: left; border-bottom: 1px solid var(--line); }
.table thead th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table tbody th { font-weight: 500; }

.summaries { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.summary {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem;
}
.summary__title { margin: 0 0 0.7rem; font-size: 1rem; }
.summary__label { margin: 0.8rem 0 0.3rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.summary__label--plus { color: var(--good); }
.summary__label--minus { color: var(--mixed); }
.summary__list { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.25rem; }
.summary__text { margin: 0.9rem 0 0; color: #cdd3df; }
.summary__meta { margin: 0.9rem 0 0; color: var(--muted); font-size: 0.78rem; }

.details {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.6rem 1rem; margin-bottom: 0.6rem;
}
.details__summary { cursor: pointer; font-weight: 600; padding: 0.3rem 0; min-height: 32px; }
.reviews { list-style: none; margin: 0.5rem 0 0.4rem; padding: 0; display: grid; gap: 1rem; }
.review { border-top: 1px solid var(--line); padding-top: 0.8rem; }
.review__head { display: flex; align-items: center; gap: 0.45rem; margin: 0 0 0.35rem; font-size: 0.85rem; }
.review__author { font-weight: 600; }
.review__date { color: var(--muted); }
.review__text { margin: 0; color: #cdd3df; font-size: 0.92rem; max-width: 80ch; }

.empty { color: var(--muted); margin: 0; }
.dot { color: var(--line); margin-inline: 0.35rem; }

/* ------------------------------------------------------------------ pager */

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.75rem; }
.pager__btn {
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; cursor: pointer; transition: border-color 200ms;
}
.pager__btn:hover { border-color: var(--accent); }
.pager__btn.is-disabled { opacity: 0.4; pointer-events: none; }
.pager__pos { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

/* HTMX: dim the results while a request is in flight, without shifting layout. */
#results.htmx-request { opacity: 0.55; transition: opacity 150ms; }

/* Narrow screens: the nav keeps its full width, the brand gives up its suffix. */
@media (max-width: 560px) {
  .brand__dim { display: none; }
  .nav__link { padding: 0 0.55rem; }

  .cover--lg { width: 100%; max-width: 220px; margin-inline: auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* Phones: one card per row. At 375px the content box is 343px, which would otherwise
   still fit two 150px columns (2*150 + 16 gap = 316). */
@media (max-width: 430px) {
  .grid, .grid--tight { grid-template-columns: 1fr; }
  /* A full-width 3:4 cover would be ~457px tall, so cap and centre it instead of
     cropping the portrait art. Scoped to list cards; the game page hero is separate. */
  .card .cover { max-width: 190px; margin-inline: auto; }
  .card__title, .card__meta { text-align: center; }
  .badges { max-width: 280px; margin-inline: auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ----------------------------------------------------------------- monitor */

.nav { display: flex; align-items: center; gap: 0.4rem; flex: none; }
.nav__link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 0.8rem;
  border-radius: 8px; text-decoration: none; color: var(--muted);
  transition: color 200ms, background-color 200ms;
}
.nav__link:hover { color: var(--text); background: var(--surface-2); }

.mon__head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--gap); margin-bottom: 0.5rem;
}
.mon__title { margin: 0; font-size: 1.6rem; }
.mon__actions { display: flex; align-items: center; gap: 0.75rem; }
.mon__msg { margin: 0 0 0.5rem; min-height: 1.4em; font-size: 0.9rem; }
.mon__msg--ok { color: var(--good); }
.mon__msg--warn { color: var(--mixed); }
.mon__line { margin: 0.35rem 0; color: var(--muted); font-size: 0.9rem; }

.conn { font-size: 0.8rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.4rem; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tbd); }
.conn--live::before { background: var(--good); }
.conn--down::before { background: var(--bad); }

.workers { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.worker {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.85rem 1rem;
}
.worker__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tbd); flex: none; }
.worker__dot--busy { background: var(--good); }
.worker__dot--idle { background: var(--accent); }
.worker__dot--off { background: var(--tbd); }
.worker__name { margin: 0; font-weight: 600; }
.worker__state { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.82rem; }

.bar { width: 100%; max-width: 520px; height: 10px; display: block; }
.bar::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
.bar::-webkit-progress-value { background: var(--good); border-radius: 999px; }
.bar::-moz-progress-bar { background: var(--good); border-radius: 999px; }

.stats { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.8rem 1rem;
}
.stat__num { display: block; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat__label { color: var(--muted); font-size: 0.8rem; }

.pill {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 0.75rem; background: var(--surface-2); color: var(--muted);
}
.pill--ok { background: rgb(88 195 34 / 0.18); color: var(--good); }
.pill--running { background: rgb(139 92 246 / 0.2); color: #c4b5fd; }
.pill--partial { background: rgb(242 201 76 / 0.18); color: var(--mixed); }
.pill--failed { background: rgb(239 68 68 / 0.18); color: #fca5a5; }
.pill--aborted { background: rgb(249 115 22 / 0.18); color: #fdba74; }

.log {
  list-style: none; margin: 0; padding: 0.5rem 0.75rem;
  max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 0.84rem; font-variant-numeric: tabular-nums;
}
.log__row { display: grid; grid-template-columns: 4.5rem 8.5rem 1fr; gap: 0.5rem;
  padding: 0.25rem 0; border-bottom: 1px solid rgb(42 47 61 / 0.5); }
.log__row:last-child { border-bottom: 0; }
.log__at { color: var(--muted); }
.log__type { color: var(--accent); }
.log__msg { color: #cdd3df; overflow-wrap: anywhere; }
.log__row--error .log__type, .log__row--llm_error .log__type, .log__row--game_failed .log__type { color: var(--bad); }
.log__row--run_start .log__type, .log__row--run_end .log__type { color: var(--good); }

@media (max-width: 560px) {
  .log__row { grid-template-columns: 4.5rem 1fr; }
  .log__type { grid-column: 2; }
  .log__msg { grid-column: 1 / -1; }
}

/* ---------------------------------------------------------------- let's play */

.letsplay { display: flex; flex-wrap: wrap; gap: var(--gap); }
.letsplay__thumb {
  position: relative; flex: none; width: 320px; max-width: 100%;
  border-radius: var(--radius); overflow: hidden; line-height: 0; cursor: pointer;
  border: 1px solid var(--line); transition: border-color 200ms;
}
.letsplay__thumb:hover { border-color: var(--accent); }
.letsplay__thumb img { width: 100%; height: auto; object-fit: cover; }
.letsplay__play {
  position: absolute; inset: 0; margin: auto; width: 54px; height: 38px;
  border-radius: 8px; background: rgb(0 0 0 / 0.65);
}
.letsplay__play::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 0; height: 0;
  border-style: solid; border-width: 9px 0 9px 15px;
  border-color: transparent transparent transparent #fff;
}
.letsplay__body { flex: 1 1 280px; min-width: 0; }
.letsplay__title { margin: 0 0 0.3rem; font-size: 1rem; line-height: 1.35; }
.letsplay__title a { text-decoration: none; }
.letsplay__title a:hover { text-decoration: underline; }
.letsplay__meta { margin: 0 0 0.8rem; color: var(--muted); font-size: 0.85rem; }
.letsplay__verdict { margin: 0 0 0.6rem; color: #cdd3df; }

@media (max-width: 430px) {
  .letsplay__thumb { width: 100%; }
}

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

.tags {
  list-style: none; margin: 0.5rem 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.25rem;
}
.tag {
  padding: 0.1rem 0.45rem; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid var(--line);
  color: #c4b5fd; font-size: 0.7rem; white-space: nowrap;
}

/* -------------------------------------------------------------- refresh strip */

.refresh { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 1rem 0 0; }
.refresh__state { color: var(--muted); font-size: 0.82rem; }
.refresh__state--busy { color: var(--mixed); }
.refresh__msg { font-size: 0.82rem; }
.refresh__msg--ok { color: var(--good); }
.refresh__msg--warn { color: var(--mixed); }
