/* theme.css and data-page.css load as separate <link> tags before this one
   (parallel, render-blocking) — never @import, which painted the page
   unstyled on slow connections. Order: theme -> data-page -> this file.

   The header, toolbar, tabs, inputs and the whole CRT/scanline system come
   from the shared files; per CLAUDE.md a module must never re-implement
   those. The modal and sync-line chrome do NOT — despite appearances they
   live in bookshelf/styles.css, so they are copied at the bottom of this
   file with the reasoning there.

   Steam's library capsules are 600x900, the same 2:3 as a book cover, so the
   grid geometry carries straight over from the bookshelf. */

/* Gameshelf-only variables. These are NOT in theme.css — the bookshelf
   declares its own copies too. Kept local rather than promoted to the shared
   file: moving them would touch a stylesheet four pages depend on, for two
   values, and the shared palette is deliberately about colour rather than
   geometry. */
:root {
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  /* Flows through --radius-scale like every other radius on the site,
     so a preset that squares its corners squares these too. It is
     geometry, but geometry a theme is allowed to have an opinion on. */
  --radius: calc(10px * var(--radius-scale));
  /* No page-width cap: a cover grid should use an ultrawide, not centre a
     column in it. */
  --page-max: none;
}

.ascii-banner {
  /* 74 monospace chars (~44.4em at 0.6em/char) — the widest banner on the
     site, since "STEAM GAMESHELF" is two words where the others are one.
     Same rule as the rest: scale with the viewport, cap at 16px. */
  font-size: min(16px, calc((100vw - 2.5rem) / 44.4));
}

/* ---------- Grid ---------- */

.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.6rem 1.1rem;
  margin-top: 1.25rem;
}

.game-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 0.4rem;
  text-decoration: none;
  color: inherit;
}

.cover-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: calc(6px * var(--radius-scale));
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 1;
}
/* A capsule that 404s reveals the placeholder underneath rather than the
   browser's broken-image glyph. */
.cover-img.cover-failed { display: none; }

.cover-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--text-muted);
}

/* Achievement progress, pinned to the bottom of the capsule. Always visible
   rather than hover-only: completion is the "how far did I get" half of the
   page's whole question. */
.ach-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.55);
}
.ach-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.game-title {
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--text);
  /* Two lines max: a long title must not push the row out of alignment. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-meta {
  font-size: 0.7rem;
  color: var(--text-faint);
}

/* ---------- Genre lanes ---------- */

.lane { margin-top: 1.4rem; }

.lane-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  text-align: left;
}
.lane-name { color: var(--text); }
.lane-count { color: var(--text-faint); }
.lane-caret { margin-left: auto; color: var(--text-faint); }

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

.detail {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.4rem;
}
@media (max-width: 620px) {
  .detail { grid-template-columns: 1fr; }
  .detail-cover { max-width: 190px; }
}

.detail-cover .cover-img {
  border-radius: calc(6px * var(--radius-scale));
  border: 1px solid var(--border);
  aspect-ratio: 2 / 3;
}

.detail-title { margin: 0 0 0.3rem; font-size: 1.15rem; }
.detail-facts { margin: 0 0 0.8rem; color: var(--text-muted); font-size: 0.8rem; }

.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin: 0 0 0.9rem;
  font-size: 0.82rem;
  color: var(--text);
}
.detail-status { color: var(--accent); }

.detail-genres { margin: 0 0 0.9rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.genre-chip {
  font-size: 0.68rem;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: calc(999px * var(--radius-scale));
  color: var(--text-muted);
}

.detail-desc {
  margin: 0 0 1.1rem;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.detail-ach {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  margin-bottom: 1rem;
}
.ach-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 0.45rem;
}
.ach-pct { color: var(--accent); font-variant-numeric: tabular-nums; }
/* In the modal the bar is a standalone element, not an overlay on a capsule. */
.detail-ach .ach-bar { position: static; height: 4px; border-radius: calc(2px * var(--radius-scale)); }

.ach-rarest { margin: 0.7rem 0 0; font-size: 0.8rem; color: var(--text-muted); }
.ach-rarest strong { color: var(--text); font-weight: 600; }

/* Progress comes from an out-of-band scrape and may legitimately be weeks
   old; saying so is more honest than a silently ageing number. */
.ach-asof { margin: 0.3rem 0 0; font-size: 0.7rem; color: var(--text-faint); }

.detail-links { margin: 0; font-size: 0.8rem; }
.detail-links a { color: var(--accent); text-decoration: none; }
.detail-links a:hover { text-decoration: underline; }

/* ---------- Sync line + modal ----------
   Copied from bookshelf/styles.css rather than shared. With plain <script>
   and <link> tags there is no module system to import from, and this is the
   second page to need them, not the third — extracting a fourth shared
   stylesheet for two components would cost every page a request to save one
   duplication. Revisit if a third page needs a modal. */

.sync-status .sync-label { color: var(--text-muted); }
.sync-source.stale,
.sync-source.error {
  color: var(--warn);
  font-weight: 600;
}

body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  z-index: 100;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  position: relative;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(14px * var(--radius-scale));
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  width: min(820px, 100%);
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  padding: 2rem 2.25rem 2.25rem;
}
.modal:focus, .modal:focus-visible { outline: none; }

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  margin: -0.5rem -0.5rem 0 0;
  padding: 0.2rem 0.4rem;
  font: inherit;
  font-size: 0.95rem;
  border: none;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  z-index: 3;
}
.modal-close:hover { color: var(--accent); }

/* The page-level scanline overlay is behind the backdrop, so the modal
   paints its own. */
.modal::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: var(--scan-heavy);
}

/* Owned DLC and Workshop mods — both only appear after the out-of-band
   session run, so these blocks are absent rather than empty until then. */
.detail-owned { margin: 0 0 1rem; }
.owned-head {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}
.owned-head span { color: var(--text-faint); }
.owned-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-muted);
  /* A Paradox game can carry dozens; scroll rather than stretch the modal. */
  max-height: 9rem;
  overflow-y: auto;
}
