/* ──────────────────────────────────────────────
   Shared game-table system (.gt-*)
   ──────────────────────────────────────────────
   Previously duplicated inline in six game templates (312 rules total),
   which is how the status badges drifted apart — "in progress" ended up
   emerald in two games, gold in two, and rose in a third. This file is
   the single source of truth; the per-game <style> blocks now only carry
   genuinely game-specific rules (their own modals, flashcards' mastery
   bars, etc.).

   Status pills use semantic tokens so they resolve in both themes:
     in progress -> --gold     completed -> --emerald
     not started -> --text-muted
────────────────────────────────────────────── */

.gt-toolbar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 16px;
  }

.gt-search {
    flex: 1; min-width: 180px;
    padding: 8px 14px;
    background: rgba(var(--overlay-rgb), 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px; outline: none;
  }

.gt-search::placeholder { color: var(--text-muted); }

.gt-search:focus { border-color: rgba(var(--overlay-rgb), 0.2); }

.gt-status-filter, .gt-subject-filter { position: relative; display: inline-block; }

.gt-status-trigger, .gt-subject-trigger {
    display: flex; align-items: center; gap: 4px;
    background: none; border: none; padding: 0; margin: 0;
    font: inherit; text-transform: inherit; letter-spacing: inherit;
    color: inherit; cursor: pointer;
  }

.gt-status-trigger:hover, .gt-subject-trigger:hover { color: var(--text-secondary); }

.gt-status-chevron, .gt-subject-chevron { font-size: 9px; color: var(--text-muted); transition: transform 0.15s; }

.gt-status-filter.is-open .gt-status-chevron,
  .gt-subject-filter.is-open .gt-subject-chevron { transform: rotate(180deg); }

.gt-status-filter.is-filtered .gt-status-trigger-label,
  .gt-subject-filter.is-filtered .gt-subject-trigger-label { color: var(--indigo); }

.gt-status-dropdown, .gt-subject-dropdown {
    position: fixed;
    min-width: 180px;
    background: var(--bg-surface); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md); box-shadow: 0 12px 32px rgba(0,0,0,0.35);
    padding: 8px; z-index: 100;
    text-transform: none; letter-spacing: normal; font-weight: 400;
  }

.gt-subject-dropdown { min-width: 220px; max-width: 280px; }

.gt-subject-search {
    width: 100%; box-sizing: border-box; padding: 7px 10px; margin-bottom: 6px;
    background: rgba(var(--overlay-rgb), 0.04); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm); color: var(--text-primary); font-size: 12px; outline: none;
  }

.gt-status-list, .gt-subject-list { max-height: 220px; overflow-y: auto; }

.gt-status-option, .gt-subject-option {
    padding: 7px 10px; border-radius: var(--radius-sm); font-size: 12px;
    color: var(--text-secondary); cursor: pointer; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    display: flex; align-items: center; gap: 8px;
  }

.gt-status-option:hover, .gt-subject-option:hover { background: rgba(var(--overlay-rgb), 0.06); color: var(--text-primary); }

.gt-status-option.is-active { background: rgba(var(--indigo-rgb), 0.12); color: var(--indigo); font-weight: 600; }

.gt-subject-option.is-active { color: var(--text-primary); font-weight: 600; }

.gt-subject-option-check {
    width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0;
    border: 1px solid var(--border-subtle); background: transparent;
  }

.gt-subject-option.is-active .gt-subject-option-check {
    background: var(--indigo); border-color: var(--indigo);
  }

.gt-subject-empty { padding: 7px 10px; font-size: 12px; color: var(--text-muted); }

.gt-hidden { display: none !important; }

.gt-wrap {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
  }

.gt-table {
    width: 100%; border-collapse: collapse;
    font-size: 13px;
  }

.gt-table thead { background: rgba(var(--overlay-rgb), 0.04); }

.gt-table th {
    padding: 11px 16px;
    text-align: left;
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.5px; text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-subtle);
    user-select: none;
  }

.gt-table th.sortable { cursor: pointer; }

.gt-table th.sortable:hover { color: var(--text-primary); }

.gt-table th .sort-icon { display: inline-block; margin-left: 4px; font-size: 10px; color: var(--text-secondary); }

.gt-table th.sort-asc .sort-icon::after { content: ' ↑'; }

.gt-table th.sort-desc .sort-icon::after { content: ' ↓'; }

.gt-table th:not(.sort-asc):not(.sort-desc) .sort-icon::after { content: ' ↕'; }

.gt-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.12s;
  }

.gt-table tbody tr:last-child { border-bottom: none; }

.gt-table tbody tr:hover { background: rgba(var(--overlay-rgb), 0.03); }

.gt-table tbody tr.locked { opacity: 0.55; }

.gt-table td { padding: 12px 16px; vertical-align: middle; color: var(--text-primary); }

.gt-name { font-weight: 600; }

.gt-col-order { color: var(--text-muted); }

@keyframes pulse {
    0%, 100% { opacity: 1; } 50% { opacity: 0.3; }
  }

.gt-col-chevron { display: none; flex-shrink: 0; color: var(--text-muted); font-size: 16px; }

.gt-pager {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 8px; padding: 14px 16px;
    border-top: 1px solid var(--border-subtle);
    font-size: 12px; color: var(--text-muted);
  }

.gt-pager-btn {
    padding: 4px 12px;
    background: rgba(var(--overlay-rgb), 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer; font-size: 12px;
  }

.gt-pager-btn:disabled { opacity: 0.35; cursor: default; }

.gt-pager-btn:not(:disabled):hover { background: rgba(var(--overlay-rgb), 0.1); }

.gt-empty { padding: 48px 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Mobile detail modal, reusing the exact recipe already proven in
     story_mode/book_map.html (.sm-modal-*) and match_maker/home.html (.mm-modal-*). */
  .ci-modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: var(--scrim-bg); backdrop-filter: blur(4px);
    align-items: center; justify-content: center; padding: 24px;
  }

@media (max-width: 640px) {
  .gt-table { display: block; }
  .gt-table thead { display: none; }
  .gt-table tbody { display: block; }
  .gt-table tr {
    display: flex; flex-wrap: wrap; align-items: center;
    padding: 12px 16px; gap: 4px 8px;
    border-bottom: 1px solid var(--border-subtle);
  }
  .gt-table tr:last-child { border-bottom: none; }
  .gt-table tr:hover { background: rgba(var(--overlay-rgb), 0.03); }
  .gt-table tr.locked { opacity: 0.55; }
  .gt-table td { display: none; padding: 0; }
  .gt-table td.gt-name {
    display: flex; align-items: center; flex: 1;
    min-width: 0; font-size: 13px; gap: 4px; flex-wrap: wrap;
  }
  /* Games that surface stats inline on mobile rather than in a tap modal. */
  .gt-table td.gt-mobile-stat {
    display: inline-flex; align-items: center;
    gap: 4px; font-size: 11px; color: var(--text-secondary);
  }
  .gt-table td.gt-col-action { display: flex; align-items: center; }
  .gt-col-chevron { display: inline-block; }
}

/* ── Status pills — one canonical set ── */
.gt-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-full);
  white-space: nowrap;
}

.gt-badge-progress {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-full);
  background: rgba(var(--gold-rgb), 0.12);
  color: var(--gold);
  border: 1px solid rgba(var(--gold-rgb), 0.25);
  white-space: nowrap;
}
.gt-badge-progress::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.4s infinite;
}

/* .gt-badge-done is a legacy alias kept so existing markup keeps working. */
.gt-badge-complete,
.gt-badge-done {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-full);
  background: rgba(var(--emerald-rgb), 0.12);
  color: var(--emerald);
  border: 1px solid rgba(var(--emerald-rgb), 0.25);
  white-space: nowrap;
}

/* Replaces the three different bare em-dash renderings for "not started". */
.gt-badge-notstarted {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--radius-full);
  background: rgba(var(--overlay-rgb), 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.gt-badge-subject {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--radius-full);
  margin: 2px 4px 2px 0;
  background: rgba(var(--overlay-rgb), 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* A small "Source" pill linking to a category's optional reading material —
   clickable, so it needs its own hover state distinct from the static badges
   above. */
.gt-badge-source {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: var(--radius-full);
  margin-left: 6px;
  background: rgba(var(--indigo-rgb), 0.12);
  color: var(--indigo);
  border: 1px solid rgba(var(--indigo-rgb), 0.3);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.gt-badge-source:hover {
  background: rgba(var(--indigo-rgb), 0.22);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}
