/* Game Bank — static reference site
   Base: plain index-card aesthetic. One accent color for interactive
   affordances. Neo-brutalist accent limited to card / filter-panel borders
   and the group-format badge blocks. */

:root {
  --bg: #fdfdfc;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --line: #1a1a1a;
  --line-soft: #d9d9d6;
  --accent: #1f4fa3;
  --accent-ink: #ffffff;
  --radius: 6px;
  --maxw: 68rem;

  /* group-format badge colors — checked for WCAG AA with white text */
  --badge-whole-class: #1f4fa3;   /* 7.8:1 */
  --badge-small-groups: #9a4400;  /* 6.6:1 */
  --badge-pairs: #0f6d6f;         /* 6.1:1 */
  --badge-individual: #6a1b9a;    /* 9.4:1 */
}

* { box-sizing: border-box; }

/* author display rules below (e.g. .filter-panel) would otherwise win over
   the UA rule for the hidden attribute */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

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

/* focus visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
.card:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* the card itself carries the focus ring via :focus-within */
.card-link:focus-visible { outline: none; }

/* ---------- Browse: search ---------- */

.site-title {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 0 1.5rem;
  color: var(--ink-soft);
}

.search-wrap {
  max-width: 40rem;
  margin: 0 auto 1rem;
}

#search {
  width: 100%;
  font: inherit;
  font-size: 1.25rem;
  padding: 0.85rem 1rem;
  min-height: 44px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

#search::placeholder { color: #8a8a87; }

.result-count {
  text-align: center;
  color: var(--ink-soft);
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

/* ---------- Browse: filter ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* shared plain button — same quiet treatment the filter toggle already used */
.btn {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 1rem;
  min-height: 44px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  cursor: pointer;
}

.btn:hover { background: #f6f6f4; }

.btn--accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn--accent:hover { background: var(--accent); filter: brightness(1.08); }

.btn--sm {
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
  min-height: 36px;
}

#filter-toggle[aria-expanded="true"] {
  border-color: var(--line);
}

/* active preset mirrors the active-chip treatment, no new decoration */
#preset-peprally[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.filter-panel {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
  margin: 0 auto 1.75rem;
  max-width: 48rem;
  display: grid;
  gap: 1rem;
  background: var(--surface);
}

.filter-panel fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.filter-panel legend {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.85rem;
  min-height: 40px;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* ---------- Browse: cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
}

.card:hover { background: #f6f6f4; }

.card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  padding-right: 2.25rem; /* clear the shortlist star */
}

.card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* the title is the real link (keyboard + open-in-new-tab); a click anywhere
   else on the card is forwarded to it in JS, and the star is exempt */
.card-link { color: inherit; text-decoration: none; }

.star {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  z-index: 1;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  background: none;
  border: 0;
  border-radius: var(--radius);
  font-size: 1.35rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
}

.star:hover { background: #f0f0ee; }
.star[aria-pressed="true"] { color: var(--accent); }

.badge {
  align-self: flex-start;
  margin-top: auto;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  color: #fff;
}

.badge--whole-class { background: var(--badge-whole-class); }
.badge--small-groups { background: var(--badge-small-groups); }
.badge--pairs { background: var(--badge-pairs); }
.badge--individual { background: var(--badge-individual); }

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 2rem 0;
}

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

.shortlist-panel {
  max-width: 48rem;
  margin: 0 auto 1.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.shortlist-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
}

#shortlist-status {
  margin: 0;
  font-size: 0.95rem;
}

.shortlist-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.shortlist-list {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0.85rem 0 0;
  border-top: 1px solid var(--line-soft);
  display: grid;
  gap: 0.55rem;
}

.shortlist-list:empty {
  margin: 0;
  padding: 0;
  border-top: 0;
}

.shortlist-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.75rem;
  font-size: 0.92rem;
}

.shortlist-item-title { font-weight: 600; }
.shortlist-item-title a { color: inherit; text-decoration: none; }
.shortlist-item-title a:hover { text-decoration: underline; }

.shortlist-item-dur { color: var(--ink-soft); }

.shortlist-remove { margin-left: auto; }

/* built only for printing (see @media print) */
#print-shortlist { display: none; }

/* ---------- Detail view ---------- */

#detail-view {
  max-width: 44rem;
  margin: 0 auto;
}

.detail-back {
  display: inline-block;
  font-size: 0.95rem;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 1.5rem;
  padding: 0.4rem 0;
  min-height: 44px;
  line-height: 2;
}

.detail-back:hover { text-decoration: underline; }

.detail-title {
  margin: 0 0 0.4rem;
  font-size: 1.9rem;
  line-height: 1.2;
}

.detail-hook {
  margin: 0 0 1.25rem;
  font-size: 1.1rem;
  color: var(--ink-soft);
  font-weight: 400;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  padding: 0.9rem 0;
  margin: 0 0 1.5rem;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.92rem;
  color: var(--ink-soft);
  list-style: none;
}

.detail-meta li { white-space: nowrap; }
.detail-meta strong { color: var(--ink); font-weight: 600; }

.print-btn {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 1.1rem;
  min-height: 44px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 2rem;
}

.detail-summary {
  font-size: 1.02rem;
  margin: 0 0 1.75rem;
}

.detail-section {
  margin: 0 0 1.75rem;
}

.detail-section h3 {
  font-size: 1.1rem;
  margin: 0 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--line);
}

.detail-section ul,
.detail-section ol {
  margin: 0;
  padding-left: 1.4rem;
  max-width: 72ch;
}

.detail-section li {
  margin-bottom: 0.4rem;
  line-height: 1.55;
}

.detail-error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ink-soft);
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .chip, .btn, .card, .star {
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
  }
}

/* ---------- Print: detail view, or the shortlist ---------- */

@media print {
  @page { margin: 0.75in; size: letter; }

  :root { --ink: #000; --ink-soft: #000; }

  body { background: #fff; color: #000; font-size: 12pt; }

  main { max-width: none; padding: 0; }

  #browse-view,
  #search,
  .search-wrap,
  .filter-bar,
  .filter-panel,
  .card-grid,
  .site-title,
  .result-count,
  .detail-back,
  .print-btn {
    display: none !important;
  }

  #detail-view { max-width: none; margin: 0; }
  #detail-view[hidden] { display: none !important; }

  .detail-title { font-size: 20pt; }
  .detail-hook { font-size: 12pt; color: #000; }

  .detail-meta {
    color: #000;
    border-color: #000;
    font-size: 11pt;
  }

  .detail-summary { font-size: 12pt; }

  .detail-section {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .detail-section h3 {
    font-size: 13pt;
    border-bottom: 1px solid #000;
  }

  .detail-section li { font-size: 11pt; }

  a { color: #000; text-decoration: none; }

  /* Shortlist print: swap the single detail view for the multi-game document.
     Each .print-game reuses the .detail-* rules above and starts a new page. */
  body.printing-shortlist #detail-view { display: none !important; }
  body.printing-shortlist #print-shortlist { display: block !important; }

  .print-game {
    break-after: page;
    page-break-after: always;
  }

  .print-game:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}
