/* =========================================================================
   Reusable components: buttons, search box, game cards, chips, filters,
   panels, empty states, alerts, loading and error states.
   ========================================================================= */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 10px 18px;
  border: 1px solid transparent; border-radius: var(--r-md);
  font-weight: 600; font-size: var(--fs-sm); line-height: 1.2;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.18); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-primary svg.fill { fill: currentColor; stroke: none; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--surface-2); }
.btn[aria-pressed="true"] .heart { fill: var(--accent-2); stroke: var(--accent-2); }
.btn-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; }

/* ---------- Search box ---------- */
.search { position: relative; }
.search input {
  width: 100%; min-height: 40px;
  padding: 9px 14px 9px 38px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  font-size: var(--fs-sm);
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:focus-visible { outline-offset: 1px; border-radius: 999px; }
.search svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; pointer-events: none;
}

/* ---------- Sections ---------- */
.section { display: grid; gap: var(--sp-4); margin-bottom: var(--sp-7); }
.section:last-child { margin-bottom: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.section-head a { font-size: var(--fs-sm); font-weight: 500; }
.section-intro { color: var(--muted); max-width: 65ch; }
.eyebrow { font-size: var(--fs-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.result-count { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.note { font-size: var(--fs-xs); color: var(--muted); }

/* ---------- Game cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-5); }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); } }

.card {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card:focus-within { border-color: var(--accent); }
.card-link { display: flex; flex-direction: column; flex: 1; color: inherit; text-decoration: none; }
.card-link:focus-visible { outline-offset: -3px; border-radius: var(--r-md); }
.thumb { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; background: var(--surface-2); }
.thumb-fallback {
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 2.6rem; color: var(--stage-text);
  background: linear-gradient(135deg, var(--cat, var(--cat-other)), var(--surface-2) 130%);
  text-shadow: 0 2px 0 rgb(0 0 0 / 0.25);
}
.card-body { display: grid; gap: 6px; padding: var(--sp-3) var(--sp-4) var(--sp-4); align-content: start; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.08rem; line-height: 1.2; overflow-wrap: anywhere; }
.card-desc {
  color: var(--muted); font-size: var(--fs-sm);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.fav {
  position: absolute; top: 8px; right: 8px;
  width: var(--tap); height: var(--tap); border-radius: 50%;
  display: grid; place-items: center;
  border: 0; background: rgb(10 14 14 / 0.72); cursor: pointer;
}
.fav svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; }
.fav[aria-pressed="true"] svg { fill: var(--accent-2); stroke: var(--accent-2); }
.fav:focus-visible { outline-offset: 1px; border-radius: 50%; }
.badge-new {
  position: absolute; top: 10px; left: 10px; pointer-events: none;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
  background: var(--accent); color: var(--accent-ink); padding: 2px 8px; border-radius: 999px;
}
@media (max-width: 520px) {
  .card-desc { display: none; }
  .card-body { padding: var(--sp-2) var(--sp-3) var(--sp-3); }
  .card-title { font-size: 0.98rem; }
}

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; width: fit-content; max-width: 100%;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  font-size: var(--fs-xs); font-weight: 600; text-decoration: none;
}
a.chip:hover { border-color: var(--muted); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cat, var(--cat-other)); flex: none; }
.chip-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- Filter buttons and selects ---------- */
.filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.filter {
  min-height: 36px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--text);
  font-size: var(--fs-sm); font-weight: 500; cursor: pointer; white-space: nowrap;
}
.filter:hover { border-color: var(--muted); }
.filter[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filter .x { margin-left: 4px; }
@media (max-width: 720px) {
  .filters.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .filters.scroll .filter { flex: none; }
}
.select {
  min-height: var(--tap); padding: 9px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm); font-size: var(--fs-sm);
}
.field-inline { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--muted); }

/* ---------- Panels ---------- */
.panel {
  display: grid; gap: var(--sp-3); align-content: start;
  padding: var(--sp-4); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md);
}
.panel p { font-size: var(--fs-sm); color: var(--muted); }

/* ---------- Empty states ---------- */
.empty {
  display: grid; justify-items: start; gap: var(--sp-3);
  padding: var(--sp-5); border: 1.5px dashed var(--line); border-radius: var(--r-md); color: var(--muted);
}
.empty strong { color: var(--text); font-family: var(--font-display); font-size: 1.1rem; }

/* ---------- Alerts and notices ---------- */
.alert {
  display: flex; gap: var(--sp-3); align-items: flex-start; flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: var(--fs-sm);
}
.alert > div { flex: 1 1 240px; min-width: 0; }
.alert-danger { border-color: var(--danger); }
.alert-danger strong { color: var(--danger); }
.alert-ok { border-color: var(--ok); }
.site-notice { background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.site-notice .wrap { padding-block: var(--sp-2); }

/* ---------- Loading / error states (game window, page loading) ---------- */
.state {
  display: grid; place-content: center; justify-items: center; gap: var(--sp-3);
  padding: var(--sp-5); text-align: center; min-height: 240px;
}
.state p { color: var(--muted); font-size: var(--fs-sm); max-width: 40ch; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

kbd {
  font-family: var(--font-body); font-size: var(--fs-xs); font-weight: 600;
  padding: 2px 7px; border-radius: 5px; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 3px;
}
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: var(--fs-sm); margin: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
