/* ============================================================
   QMD — Shared Stylesheet
   quivermutationdb.org
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Design tokens --- */
:root {
  --ink:         #1a1a1a;
  --ink-light:   #555;
  --rule:        #d4d0c8;
  --bg:          #faf9f6;
  --bg-card:     #ffffff;
  --accent:      #8b1a1a;
  --accent-soft: #f5eeee;
  --mono:        'JetBrains Mono', monospace;
  --serif:       'EB Garamond', Georgia, serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 17px; }

/* --- Base --- */
body {
  font-family: var(--serif);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
}

/* --- Navigation --- */
nav {
  border-bottom: 1px solid var(--rule);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 52px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .brand {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-decoration: none;
  text-transform: uppercase;
}
nav a {
  font-size: 0.88rem;
  color: var(--ink-light);
  text-decoration: none;
  transition: color 0.15s;
}
nav a:hover  { color: var(--accent); }
nav a.active { color: var(--accent); }
nav .spacer  { flex: 1; }
nav .nav-status {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-light);
  letter-spacing: 0.03em;
}

/* --- Page wrapper --- */
.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 3.5rem 2rem;
}
.page-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

/* --- Prose typography --- */
h1 {
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: 1rem;
}
h2 {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}
h3 {
  font-size: 1.05rem;
  font-weight: 500;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}
p  { margin-bottom: 1rem; font-size: 1rem; }
p:last-child { margin-bottom: 0; }
strong { font-weight: 500; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { margin: 0 0 1rem 1.5rem; }
li { margin-bottom: 0.35rem; font-size: 1rem; }

/* --- Page header (for browse/search/etc.) --- */
.page-header {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}
.page-header h1 { margin-bottom: 0.35rem; }
.page-header p  { font-size: 0.95rem; color: var(--ink-light); font-style: italic; margin: 0; }

/* --- Breadcrumb --- */
.breadcrumb {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-light);
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.breadcrumb a   { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { opacity: 0.4; }

/* --- Card / section box --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-light);
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}

/* --- Status box (e.g. "Under active development") --- */
.status-box {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  background: var(--bg-card);
  padding: 1.1rem 1.4rem;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}
.status-box p { margin-bottom: 0.5rem; }
.status-box p:last-child { margin-bottom: 0; }

/* --- Inline mono ID / tag --- */
.qid-tag {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-light);
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
  display: block;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  text-transform: uppercase;
}
.badge-closed { background: #e8f4e8; color: #2d6a2d; border: 1px solid #b8d8b8; }
.badge-open   { background: #fef3e8; color: #8a4f00; border: 1px solid #e8d0b0; }
.badge-dev    { background: var(--accent-soft); color: var(--accent); border: 1px solid #d4aaaa; }

/* --- Buttons --- */
.btn {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.45rem 1.1rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--bg); text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
}
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  background: var(--bg-card);
}
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead tr { border-bottom: 2px solid var(--rule); background: #f4f2ee; }
th {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-light);
  padding: 0.75rem 1rem;
  text-align: left;
  white-space: nowrap;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
th.sorted .sort-arrow { color: var(--accent); }
.sort-arrow { opacity: 0.4; margin-left: 0.25rem; }
th.sorted .sort-arrow { opacity: 1; }
tbody tr { border-bottom: 1px solid var(--rule); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--accent-soft); }
td { padding: 0.7rem 1rem; vertical-align: middle; }
td.mono { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-light); }
td a { font-family: var(--mono); font-size: 0.75rem; color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }

/* --- Matrix rendering --- */
.matrix-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
  gap: 0.5rem;
}
.matrix-bracket {
  font-size: 3rem;
  color: var(--ink-light);
  font-weight: 200;
  line-height: 1;
  font-family: 'Times New Roman', serif;
}
.matrix-grid {
  display: grid;
  gap: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.matrix-cell {
  padding: 0.4rem 0.75rem;
  text-align: right;
  border: 1px solid transparent;
  transition: background 0.1s;
}
.matrix-cell:hover  { background: var(--accent-soft); }
.matrix-cell.pos    { color: var(--accent); }
.matrix-cell.neg    { color: #1a4f8b; }
.matrix-cell.zero   { color: var(--rule); }

/* --- Meta list (key/value pairs) --- */
.meta-list { display: flex; flex-direction: column; gap: 0.6rem; }
.meta-row  { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.9rem; }
.meta-row .key { color: var(--ink-light); font-style: italic; }
.meta-row .val { font-family: var(--mono); font-size: 0.8rem; font-weight: 500; }
.meta-row .val a { color: var(--accent); text-decoration: none; }
.meta-row .val a:hover { text-decoration: underline; }

/* --- Filter bar --- */
.filters {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--rule);
}
.filter-group { display: flex; flex-direction: column; gap: 0.35rem; }
.filter-group label,
.field label {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-light);
}
.filter-group select,
.filter-group input,
.field select,
.field input {
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--ink);
  outline: none;
  min-width: 130px;
}
.filter-group select:focus,
.filter-group input:focus,
.field select:focus,
.field input:focus { border-color: var(--accent); }

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.page-btn {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--rule);
  background: var(--bg-card);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.78rem;
  transition: all 0.1s;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn:disabled  { opacity: 0.4; cursor: default; }
.page-btn.active    { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.page-info          { color: var(--ink-light); padding: 0 0.5rem; }

/* --- Tags / checkbox pills --- */
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--rule);
  color: var(--ink-light);
  background: var(--bg);
}
.checkbox-pill {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--rule);
  cursor: pointer;
  background: var(--bg);
  color: var(--ink-light);
  user-select: none;
  transition: all 0.1s;
}
.checkbox-pill input { display: none; }
.checkbox-pill:has(input:checked) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.checkbox-pill:hover:not(:has(input:checked)) { border-color: var(--accent); color: var(--accent); }

/* --- Active filter pills --- */
.active-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.filter-pill {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  background: var(--accent-soft);
  border: 1px solid #d4aaaa;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.filter-pill button { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.8rem; padding: 0; line-height: 1; }

/* --- Loading / empty states --- */
.state-msg {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--ink-light);
  font-style: italic;
  font-size: 1rem;
}
.state-msg .mono-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 0.5rem;
  color: var(--rule);
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 1rem;
}

/* --- Two / three column grid helpers --- */
.two-col   { display: grid; grid-template-columns: 1fr 1fr;   gap: 1.5rem; margin-bottom: 1.5rem; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
@media (max-width: 700px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
}

/* --- Stats row --- */
.stats-row {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-light);
}
.stats-row span b { color: var(--ink); font-weight: 500; }

/* --- Misc view toggle buttons --- */
.view-btn {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--rule);
  background: var(--bg-card);
  cursor: pointer;
  color: var(--ink-light);
  transition: all 0.1s;
}
.view-btn.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.view-btn:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* --- Canon row highlight in tables --- */
tr.is-canon td       { background: #fffdf0; }
tr.is-canon:hover td { background: #fff8d6; }
.canon-mark {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: #8a6500;
  background: #fffbee;
  border: 1px solid #e8d48b;
  padding: 0.1rem 0.4rem;
}

/* --- Matrix mini (grid view cards) --- */
.matrix-grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--rule);
}
.matrix-card {
  border: 1px solid var(--rule);
  padding: 1rem;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s;
}
.matrix-card:hover        { border-color: var(--accent); }
.matrix-card.is-canon     { border-color: #c8a820; background: #fffdf0; }
.matrix-card-id {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--ink-light);
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.matrix-card-id a { color: var(--accent); text-decoration: none; }
.matrix-mini      { font-family: var(--mono); font-size: 0.72rem; }
.matrix-mini .row { display: flex; gap: 0.25rem; justify-content: center; }
.matrix-mini .cell { min-width: 1.5rem; text-align: right; }
.matrix-mini .pos  { color: var(--accent); }
.matrix-mini .neg  { color: #1a4f8b; }
.matrix-mini .zero { color: var(--rule); }

/* --- Footer --- */
footer {
  border-top: 1px solid var(--rule);
  margin-top: 4rem;
  padding: 1.5rem 2rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
footer a { color: var(--ink-light); }
footer a:hover { color: var(--accent); text-decoration: none; }
