/*!
 * Roundtable — Bootstrap 6 community forum
 *
 * Design language: a noticeboard. Dense rows, hairline rules, one blue accent
 * on votes and links, and a right rail that stops being a rail on narrow
 * screens rather than shrinking into uselessness.
 *
 * The structural idea carrying the identity is the ranking. Forum templates
 * ship Hot / New / Top as three tabs over one hardcoded order. Here every
 * thread carries its votes and age, the sort is computed, and a checkbox prints
 * the score on each row so you can watch the formula do the work.
 */

:root {
  --brand: oklch(52% 0.16 250);
  --rt-rule: color-mix(in oklab, var(--bs-fg-body), transparent 88%);
  --rt-hot: oklch(62% 0.17 45);
  --rt-ok: oklch(58% 0.13 155);
}

[data-bs-theme="light"] {
  --bs-bg-body: oklch(99% 0.002 250);
  --bs-bg-2: oklch(96.5% 0.005 250);
}

[data-bs-theme="dark"] {
  --bs-bg-body: oklch(18% 0.01 250);
  --bs-bg-2: oklch(21.5% 0.012 250);
}

.wrap { max-width: 72rem; margin-inline: auto; padding-inline: 1rem; }

.vote-n, .cat-n, .rail-stats dd { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------
   Header + footer
   --------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: color-mix(in oklab, var(--bs-bg-body), transparent 12%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rt-rule);
}

.head-in { display: flex; align-items: center; gap: 1rem; padding-block: 0.65rem; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--bs-fg-body);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.wordmark-mark { color: var(--bs-primary-base); font-size: 1.15rem; }

.head-nav { gap: 0.2rem; margin-left: 0.75rem; }

.head-link {
  padding: 0.35rem 0.65rem;
  border-radius: var(--bs-radius-4);
  color: var(--bs-fg-2, inherit);
  text-decoration: none;
  font-size: 0.9rem;
}

.head-link:hover { background-color: color-mix(in oklab, var(--bs-fg-body), transparent 94%); }
.head-link.is-active { color: var(--bs-primary-fg-emphasis); font-weight: 650; }

.search-field { max-width: 16rem; }
.head-in .btn-solid { text-decoration: none; white-space: nowrap; }

.site-footer { padding-block: 2rem; border-top: 1px solid var(--rt-rule); margin-top: 3rem; }

/* ---------------------------------------------------------------
   Board layout
   --------------------------------------------------------------- */

.page { padding-block: 1.75rem 0; }

.board { display: grid; gap: 2rem; align-items: start; }

@media (width >= 992px) { .board { grid-template-columns: minmax(0, 1fr) 18rem; } }

.page-title { font-size: 1.6rem; font-weight: 650; letter-spacing: -0.025em; }
.page-sub { color: var(--bs-fg-3, inherit); }

/* ---------------------------------------------------------------
   Sorter
   --------------------------------------------------------------- */

.sorter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.sort-btn {
  padding: 0.35rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 100px;
  background-color: transparent;
  color: var(--bs-fg-2, inherit);
  font-size: 0.88rem;
  font-weight: 650;
  cursor: pointer;
}

.sort-btn:hover { background-color: color-mix(in oklab, var(--bs-fg-body), transparent 94%); }

.sort-btn.is-on {
  background-color: var(--bs-primary-base);
  color: var(--bs-white);
}

.sort-show {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
  margin-bottom: 0;
  font-size: 0.82rem;
  color: var(--bs-fg-3, inherit);
  cursor: pointer;
}

/* ---------------------------------------------------------------
   Threads
   --------------------------------------------------------------- */

.thread-list { list-style: none; padding-left: 0; margin-bottom: 0; border-top: 1px solid var(--rt-rule); }

.thread {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr) auto;
  gap: 0.25rem 0.9rem;
  align-items: center;
  padding-block: 0.85rem;
  border-bottom: 1px solid var(--rt-rule);
}

.vote { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }

.vote-btn {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.4rem;
  border: 0;
  border-radius: var(--bs-radius-3, 5px);
  background-color: transparent;
  color: var(--bs-fg-3, inherit);
  cursor: pointer;
}

.vote-btn:hover { background-color: color-mix(in oklab, var(--bs-primary-base), transparent 88%); color: var(--bs-primary-base); }
.vote-btn.is-on { color: var(--bs-primary-base); }

.vote-n { font-size: 0.85rem; font-weight: 700; }
.vote-sm .vote-n { font-size: 0.78rem; }

.thread-main { min-width: 0; }

.thread-title { font-size: 1rem; font-weight: 600; line-height: 1.35; }
.thread-title a { color: var(--bs-fg-body); text-decoration: none; }
.thread-title a:hover { color: var(--bs-primary-fg); }

.thread-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--bs-fg-2, inherit);
}

.thread-cat { color: var(--bs-primary-fg); text-decoration: none; font-weight: 600; }

.thread-replies {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--bs-fg-3, inherit);
  white-space: nowrap;
}

.thread-rank {
  grid-column: 2 / -1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--bs-primary-fg);
  background-color: color-mix(in oklab, var(--bs-primary-base), transparent 93%);
  padding: 0.15rem 0.45rem;
  border-radius: var(--bs-radius-3, 5px);
  justify-self: start;
}

.flag {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.4rem;
  border-radius: 100px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.flag-solved { background-color: color-mix(in oklab, var(--rt-ok), transparent 85%); color: color-mix(in oklab, var(--rt-ok), black 22%); }
.flag-hot { background-color: color-mix(in oklab, var(--rt-hot), transparent 85%); color: color-mix(in oklab, var(--rt-hot), black 22%); }
.flag-pinned { background-color: color-mix(in oklab, var(--bs-fg-body), transparent 90%); color: var(--bs-fg-2, inherit); }

[data-bs-theme="dark"] .flag-solved { color: var(--rt-ok); }
[data-bs-theme="dark"] .flag-hot { color: var(--rt-hot); }

.board-note {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--rt-rule);
  border-radius: var(--bs-radius-5);
  font-size: 0.85rem;
  color: var(--bs-fg-2, inherit);
}

.board-note code { font-size: 0.85em; }

/* ---------------------------------------------------------------
   Rail
   --------------------------------------------------------------- */

.rail { display: grid; gap: 1rem; }

@media (width >= 992px) { .rail { position: sticky; top: 4.5rem; } }

.rail-card {
  padding: 1.1rem;
  border: 1px solid var(--rt-rule);
  border-radius: var(--bs-radius-6);
  background-color: var(--bs-bg-2);
}

.rail-title { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--bs-fg-3, inherit); margin-bottom: 0.75rem; }

.rail-list { list-style: none; padding-left: 0; margin-bottom: 0; }

.rail-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding-block: 0.4rem;
  border-bottom: 1px solid var(--rt-rule);
  font-size: 0.88rem;
}

.rail-list li:last-child { border-bottom: 0; }
.rail-list a { color: var(--bs-fg-body); text-decoration: none; }
.rail-list a:hover { color: var(--bs-primary-fg); }

.rail-card .btn-outline { text-decoration: none; }

.rail-rules { padding-left: 1.1rem; margin-bottom: 0; font-size: 0.85rem; color: var(--bs-fg-2, inherit); }
.rail-rules li { margin-bottom: 0.4rem; }

.rail-stats { margin-bottom: 0; }

.rail-stats > div {
  display: flex;
  justify-content: space-between;
  padding-block: 0.35rem;
  border-bottom: 1px solid var(--rt-rule);
  font-size: 0.85rem;
}

.rail-stats > div:last-child { border-bottom: 0; }
.rail-stats dt { color: var(--bs-fg-3, inherit); margin-bottom: 0; font-weight: 500; }
.rail-stats dd { margin-bottom: 0; font-weight: 650; }

/* ---------------------------------------------------------------
   Thread page
   --------------------------------------------------------------- */

.crumbs { font-size: 0.85rem; }
.crumbs a { color: var(--bs-primary-fg); text-decoration: none; }

.op { padding-bottom: 1.5rem; border-bottom: 1px solid var(--rt-rule); margin-bottom: 1.75rem; }
.op-head { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr); gap: 0.9rem; margin-bottom: 1.25rem; }
.op-title { font-size: 1.45rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; text-wrap: balance; }

/* .prose is a v6 component: a flex column driven by --bs-content-gap with
   margin-block:0 on children. Colour only — margins here would add to the gap. */
.op-body { max-width: 42rem; }
.op-body p { color: var(--bs-fg-2, inherit); }

.replies-title { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--bs-fg-3, inherit); margin-bottom: 1rem; }

.reply-list { list-style: none; padding-left: 0; margin-bottom: 2.5rem; }

/* Depth is a custom property on the element, so nesting is one variable rather
   than a wrapper per level — a flat list renders as a threaded one. */
.reply {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0.75rem;
  padding-block: 0.9rem;
  margin-left: calc(var(--depth, 0) * 1.75rem);
  border-top: 1px solid var(--rt-rule);
}

.reply[style*="--depth:0"] { border-top-color: color-mix(in oklab, var(--bs-fg-body), transparent 78%); }

@media (width < 576px) { .reply { margin-left: calc(var(--depth, 0) * 0.75rem); } }

.reply-meta { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; }
.reply-body { font-size: 0.92rem; color: var(--bs-fg-2, inherit); text-wrap: pretty; }
.reply-actions { display: flex; gap: 0.85rem; }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--bs-fg-3, inherit);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover { color: var(--bs-primary-fg); }

.composer { padding: 1.25rem; border: 1px solid var(--rt-rule); border-radius: var(--bs-radius-6); background-color: var(--bs-bg-2); }

/* ---------------------------------------------------------------
   Categories
   --------------------------------------------------------------- */

.cat-list { list-style: none; padding-left: 0; margin-bottom: 0; border-top: 1px solid var(--rt-rule); }

.cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: 1.1rem;
  border-bottom: 1px solid var(--rt-rule);
}

.cat-name { font-size: 1.05rem; font-weight: 650; }
.cat-name a { color: var(--bs-fg-body); text-decoration: none; }
.cat-name a:hover { color: var(--bs-primary-fg); }
.cat-n { font-size: 1.1rem; font-weight: 700; text-align: right; white-space: nowrap; }
.cat-n .fg-3 { font-size: 0.72rem; font-weight: 500; }
