/* DRMLess — raw table UI (retro / compact) */

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

html {
  scrollbar-gutter: stable;
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 100;
  padding: 0.35rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 0.8125rem;
}
.skip-link:focus { top: 0.5rem; }

.site {
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}
@media (min-width: 640px) {
  .site { padding-left: 1.5rem; padding-right: 1.5rem; }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* Header — brand left, controls right, always one row */
.topbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1.25rem;
}
.brand {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
}
.brand__less { color: var(--accent); }

.topbar__meta {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.4rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.topbar__meta .live { color: var(--accent); }
#updated {
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cur-select { display: inline-flex; }
.select--compact {
  height: 32px;
  min-width: 3.75rem;
  padding-left: 0.4rem;
  font-size: 0.75rem;
}
@media (max-width: 640px) {
  .brand { font-size: 1.35rem; }
  .select--compact { height: 32px; min-width: 3.5rem; }
  .icon-btn { width: 32px; height: 32px; }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }

.theme-wrap { position: relative; }
.theme-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  min-width: 8rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.theme-menu button {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 0 0.65rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
}
.theme-menu button:hover,
.theme-menu button.is-active {
  background: var(--accent-soft);
  color: var(--text);
}

/* Lead */
.lead {
  margin: 0 0 1.25rem;
}
.lead h1 {
  margin: 0 0 0.35rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}
.live-stats__summary {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

#live-stats {
  width: 100%;
  margin: -0.9rem 0 1.25rem;
}

/* Coverage bar — platforms / no DRM-free / pending */
.cov-bar {
  margin: 0 0 1.25rem;
}
.cov-bar__track {
  display: flex;
  width: 100%;
  height: 0.65rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
}
.cov-bar__seg {
  display: block;
  min-width: 2px;
  height: 100%;
  border-right: 1px solid color-mix(in srgb, var(--bg) 35%, transparent);
  pointer-events: none;
  user-select: none;
}
.cov-bar__seg:last-child { border-right: none; }
.cov-bar__seg--gog { background: var(--gog); }
.cov-bar__seg--itch { background: var(--itch); }
.cov-bar__seg--official { background: var(--official); }
.cov-bar__seg--none { background: var(--no-alt); }
.cov-bar__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin-top: 0.55rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.cov-bar__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: inherit;
  font: inherit;
}
.cov-bar__chip--static { cursor: default; }
.cov-bar__n {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.cov-bar__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  flex-shrink: 0;
}
.cov-bar__dot--gog { background: var(--gog); }
.cov-bar__dot--itch { background: var(--itch); }
.cov-bar__dot--official { background: var(--official); }
.cov-bar__dot--none { background: var(--no-alt); }
.cov-bar__progress {
  margin: 0.55rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.cov-bar__progress strong {
  color: var(--text-secondary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Search */
.search {
  position: relative;
  margin-bottom: 1rem;
}
.search__icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.15rem;
  height: 1.15rem;
  color: var(--text-muted);
  pointer-events: none;
}
.search__input {
  width: 100%;
  height: 48px;
  padding: 0 1rem 0 2.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.search__input::placeholder { color: var(--text-muted); }
.search__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select {
  -webkit-appearance: none;
  appearance: none;
  height: 36px;
  padding: 0 1.85rem 0 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%237C879F' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.4rem center;
  background-repeat: no-repeat;
  background-size: 1rem;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
}

/* Table */
html { overflow-y: scroll; }
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.game-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.game-table__game-col { width: 68%; }
.game-table__alts-col { width: 32%; }
.game-table thead {
  background: var(--surface);
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.game-table th {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.game-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.game-table tbody tr:hover { background: var(--surface-raised); }
.game-table tbody tr:last-child td { border-bottom: none; }

.cell-game {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  width: 100%;
}
.cell-game__text {
  flex: 1 1 auto;
  min-width: 0;
}
.thumb {
  flex-shrink: 0;
  width: 69px;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-raised);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.game-name {
  display: block;
  font-weight: 550;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-name:hover { color: var(--accent); }
.game-meta {
  margin-top: 0.1rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.steam-price {
  flex-shrink: 0;
  margin-left: auto;
  color: var(--text-secondary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
}
.cell-alts {
  vertical-align: middle;
  overflow: hidden;
}

.alts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.25rem;
  max-width: 22rem;
  align-items: center;
}
.alt {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
  min-width: 5.5rem;
  min-height: 1.5rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.6875rem;
  font-weight: 600;
}
.alt:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--text);
}
.alt--gog { border-color: color-mix(in srgb, var(--gog) 40%, transparent); background: color-mix(in srgb, var(--gog) 12%, transparent); color: var(--gog); }
.alt--itch { border-color: color-mix(in srgb, var(--itch) 40%, transparent); background: color-mix(in srgb, var(--itch) 12%, transparent); color: var(--itch); }
.alt--official { border-color: color-mix(in srgb, var(--official) 40%, transparent); background: color-mix(in srgb, var(--official) 12%, transparent); color: var(--official); }
.alt__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.alt__price {
  flex-shrink: 0;
  font-weight: 400;
  opacity: 0.75;
  white-space: nowrap;
}
.no-alt { font-size: 0.75rem; color: var(--text-muted); }

/* Mobile: stack row so DRM-free badges stay visible */
@media (max-width: 640px) {
  .game-table thead { display: none; }
  .game-table,
  .game-table tbody,
  .game-table tr,
  .game-table td {
    display: block;
    width: 100%;
  }
  .game-table tr {
    padding: 0.75rem 0.65rem;
    border-bottom: 1px solid var(--border);
  }
  .game-table td {
    padding: 0;
    border-bottom: none;
  }
  .game-table tbody tr:last-child { border-bottom: none; }
  .cell-game { max-width: none; }
  .thumb { width: 72px; height: 34px; }
  .steam-price { font-size: 0.8125rem; }
  .cell-alts { margin-top: 0.5rem; }
  .alts { max-width: none; }
  .alt { min-width: 0; flex: 1 1 auto; }
  .pager {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .pager__btns { justify-content: space-between; }
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.pager__btns { display: flex; align-items: center; gap: 0.25rem; }
.pager button {
  height: 32px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}
.pager button:hover:not(:disabled) { background: var(--surface-raised); color: var(--text); }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }

.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.empty p { margin: 0 0 0.35rem; }
.empty .muted { font-size: 0.875rem; color: var(--text-muted); }

.site-footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.site-footer p { margin: 0 0 0.5rem; max-width: 40rem; }
.site-footer a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

#results { min-height: 40vh; }

/* Detail dialog (kept minimal) */
.dialog-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.5);
  justify-content: flex-end;
}
.dialog-backdrop.is-open { display: flex; }
.dialog {
  width: min(100%, 26rem);
  max-height: 100%;
  overflow: auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 1.25rem;
}
.dialog__close { float: right; }
.dialog__cover {
  width: 100%;
  aspect-ratio: 460 / 215;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  margin-bottom: 1rem;
}
.dialog__cover img { width: 100%; height: 100%; object-fit: cover; }
.dialog__title { margin: 0 0 0.25rem; font-size: 1.25rem; font-weight: 600; }
.dialog__studio { margin: 0 0 1rem; color: var(--text-secondary); font-size: 0.875rem; }
body.dialog-open { overflow: hidden; }
