/*
 * Page-level compositions: feeds, thread pages, sections, tags, search,
 * the role ladder and the error states.
 */

/* ------------------------------------------------------------------ home */

.hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-bottom: var(--space-8);
  margin-bottom: var(--space-8);
  border-bottom: var(--border-width) solid var(--line);
}

.hero__title {
  max-width: 18ch;
}

.hero__lead {
  max-width: var(--measure);
  font-family: var(--font-reading);
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.hero__stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
  margin-top: var(--space-2);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat__value {
  font-family: var(--font-reading);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat__label {
  font-size: var(--text-2xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ------------------------------------------------------------ thread feed */

.thread-list {
  display: flex;
  flex-direction: column;
  border-top: var(--border-width) solid var(--line);
}

.thread-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-4) var(--space-1);
  border-bottom: var(--border-width) solid var(--line);
  transition: background var(--duration-fast) var(--easing);
}

.thread-row:hover {
  background: color-mix(in oklab, var(--surface-sunken) 60%, transparent);
}

.thread-row__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.thread-row__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
}

.thread-row__title {
  font-family: var(--font-reading);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  color: var(--text-primary);
  text-decoration: none;
}

.thread-row__title:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.thread-row__excerpt {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thread-row__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.thread-row__counts {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.thread-row--pinned {
  background: color-mix(in oklab, var(--accent-soft) 45%, transparent);
}

/* --------------------------------------------------------------- sections */

.section-grid {
  display: grid;
  gap: var(--space-4);
}

@media (min-width: 44rem) {
  .section-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.section-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-decoration: none;
  transition: border-color var(--duration-fast) var(--easing),
    box-shadow var(--duration-fast) var(--easing);
}

.section-card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-md);
}

.section-card__title {
  font-family: var(--font-reading);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.section-card__summary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  flex: 1;
}

.section-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding-top: var(--space-2);
  border-top: var(--border-width) solid var(--line);
}

/* ------------------------------------------------------------------ tags */

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tag-card {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none;
  color: var(--text-primary);
  font-size: var(--text-sm);
}

.tag-card:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.tag-card__count {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- thread */

.thread-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-bottom: var(--space-5);
  border-bottom: var(--border-width) solid var(--line);
  margin-bottom: var(--space-6);
}

.thread-head__title {
  font-size: var(--text-2xl);
}

.thread-head__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.thread-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-bottom: var(--border-width) solid var(--line);
  margin-bottom: var(--space-6);
}

.thread-summary {
  padding: var(--space-4) var(--space-5);
  border: var(--border-width) solid var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  margin-bottom: var(--space-6);
}

.thread-summary__label {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-2);
}

/* -------------------------------------------------------------- post tree */

.post-tree {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.post {
  scroll-margin-top: calc(56px + var(--space-4));
}

/*
 * Reply depth uses a left rule rather than a wide indent, so a deep branch
 * stays readable on a phone. The indent step shrinks as depth grows.
 */
.post--depth-1 { margin-left: var(--space-4); }
.post--depth-2 { margin-left: calc(var(--space-4) + var(--space-3)); }
.post--depth-3 { margin-left: calc(var(--space-4) + (2 * var(--space-3))); }
.post--depth-4 { margin-left: calc(var(--space-4) + (3 * var(--space-3))); }
.post--depth-5 { margin-left: calc(var(--space-4) + (3.5 * var(--space-3))); }
.post--depth-6 { margin-left: calc(var(--space-4) + (4 * var(--space-3))); }

.post[class*="post--depth-"]:not(.post--depth-0) {
  padding-left: var(--space-4);
  border-left: var(--border-strong-width) solid var(--line);
}

@media (min-width: 48rem) {
  .post--depth-1 { margin-left: var(--space-8); }
  .post--depth-2 { margin-left: calc(var(--space-8) + var(--space-6)); }
  .post--depth-3 { margin-left: calc(var(--space-8) + (2 * var(--space-6))); }
  .post--depth-4 { margin-left: calc(var(--space-8) + (3 * var(--space-6))); }
  .post--depth-5 { margin-left: calc(var(--space-8) + (3.5 * var(--space-6))); }
  .post--depth-6 { margin-left: calc(var(--space-8) + (4 * var(--space-6))); }
}

.post__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.post__identity {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.post__author {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  text-decoration: none;
}

.post__author:hover {
  color: var(--accent);
}

.post__timestamp {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.post__spacer { flex: 1; }

.post__number {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.post__number:hover {
  color: var(--accent);
}

.post--accepted {
  border-left-color: var(--positive) !important;
}

.post--tombstone .post__body {
  color: var(--text-muted);
  font-style: italic;
}

.post__footer {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.post-tombstone {
  color: var(--text-muted);
  font-style: italic;
}

/* --------------------------------------------------------------- search */

.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.search-form__input {
  flex: 1 1 260px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

/* ----------------------------------------------------------- role ladder */

.role-ladder {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.role-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-4);
  padding: var(--space-5);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.role-step__rank {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  border: var(--border-width) solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
}

.role-step--current {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.role-step--current .role-step__rank {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
}

.role-step__name {
  font-family: var(--font-reading);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.role-step__benefits {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.role-step__benefits li {
  display: flex;
  gap: var(--space-2);
}

.role-step__benefits li::before {
  content: "";
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  margin-top: 0.55em;
  border-radius: 50%;
  background: var(--accent);
}

.role-step__action {
  margin-top: var(--space-4);
}

/* -------------------------------------------------------------- checkout */

.checkout__summary {
  margin-bottom: var(--space-5);
}

.checkout__facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0 0;
}

.checkout__facts dt {
  color: var(--text-secondary);
}

.checkout__facts dd {
  margin: 0;
}

.checkout__purchase,
.checkout__outcome {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.checkout__outcome:empty {
  display: none;
}

/* ------------------------------------------------------------ error pages */

.status-page {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  max-width: var(--measure);
  padding-block: var(--space-12);
}

.status-page__code {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--accent);
  line-height: 1;
}

.status-page__body {
  color: var(--text-secondary);
  font-size: var(--text-md);
}

/* -------------------------------------------------------------- prose */

.prose {
  max-width: var(--measure);
  font-family: var(--font-reading);
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
}

.prose > * + * {
  margin-top: var(--space-4);
}

.prose h2,
.prose h3 {
  margin-top: var(--space-8);
  font-size: var(--text-xl);
}

.prose ul,
.prose ol {
  padding-left: var(--space-6);
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }

.prose li + li {
  margin-top: var(--space-2);
}

/* ------------------------------------------------------------ auth pages */

/* A single-purpose form reads better as a centred column than as a narrow
   strip pinned to the left of a wide shell. */
.auth-page {
  max-width: 34rem;
  margin-inline: auto;
}

.auth-page .page-header {
  margin-bottom: var(--space-6);
}

/* --------------------------------------------------------- account pages */

.account-card {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-5);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.account-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.account-card__name {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.account-card__handle {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.panel__title {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.panel__lead {
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  max-width: var(--measure);
}

/* --------------------------------------------------------- session list */

.session-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  max-width: 44rem;
}

.session {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-4);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

/* The device in front of the reader is marked so ending the wrong one takes
   deliberate effort. */
.session--current {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.session__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.session__device {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--weight-medium);
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------- member page */

.member-page {
  max-width: var(--shell-narrow);
}

.member-header {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
}

.member-header__body {
  min-width: 0;
}

.member-header .page-header {
  margin-bottom: var(--space-3);
}

.member-page__bio {
  margin-bottom: var(--space-6);
}

.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-5);
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
}

.detail-list__term {
  color: var(--text-muted);
}

.detail-list__value {
  overflow-wrap: anywhere;
}

@media (max-width: 34rem) {
  .detail-list {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .detail-list__value {
    margin-bottom: var(--space-2);
  }
}

/* ------------------------------------------------------------ moderation */

/*
 * The panel an action form opens into.
 *
 * It sits inside the post or the report it acts on rather than in a dialog,
 * so the thing being edited, hidden or reported stays on screen while the
 * decision is made.
 */
.action-panel {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: var(--border-width) solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.action-panel__title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.muted {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* A moderator control is marked, because acting on someone else's words
   should never feel like the same gesture as replying to them. */
.button--staff {
  color: var(--critical);
}

.button--staff:hover:not(:disabled) {
  background: var(--critical-soft);
}

.revision-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-4);
}

.revision {
  padding-left: var(--space-4);
  border-left: var(--border-strong-width) solid var(--line-strong);
}

.revision__meta {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.report-list {
  margin: 0 0 var(--space-8);
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-5);
}

.report {
  padding: var(--space-5);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.report--open {
  border-left: var(--border-strong-width) solid var(--caution);
}

.report__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}

.report__note {
  margin: 0 0 var(--space-3);
}

/* The reported text, set apart so a moderator can never mistake it for the
   forum speaking. */
.report__content {
  margin: var(--space-3) 0;
  padding: var(--space-3) var(--space-4);
  border-left: var(--border-strong-width) solid var(--line-strong);
  background: var(--surface-sunken);
  font-size: var(--text-sm);
}

.report__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.moderation-log {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-3);
}

.moderation-log__entry {
  padding-bottom: var(--space-3);
  border-bottom: var(--border-width) solid var(--line);
  font-size: var(--text-sm);
}

.moderation-log__line {
  margin: 0 0 var(--space-1);
}

/* -------------------------------------------------------- administration */

.account-list,
.role-list,
.grant-list {
  margin: 0 0 var(--space-6);
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-2);
}

.account-row,
.role-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

/* A suspended account is marked where it is listed, not only where it is
   opened: an administrator scanning the list should see it without clicking. */
.account-row--suspended {
  border-left: var(--border-strong-width) solid var(--critical);
}

.role-row--disabled {
  opacity: 0.7;
  border-left: var(--border-strong-width) solid var(--line-strong);
}

.account-row__identity,
.role-row__identity {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1 1 16rem;
}

.account-row__name,
.role-row__name {
  font-weight: var(--weight-semibold);
}

.account-row__badges,
.role-row__counts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.account-detail {
  margin: var(--space-6) 0 var(--space-8);
  padding: var(--space-5);
  border: var(--border-width) solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.grant-list li {
  font-size: var(--text-sm);
}

/* ---------------------------------------------------------------- wallet */

.wallet__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.wallet__balance {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.wallet__balance-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Tabular figures so a column of amounts lines up on the decimal point
   instead of shifting with the digits. */
.wallet__balance-amount {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.wallet__history {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.wallet__entry {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: var(--border-width) solid var(--line);
}

.wallet__entry:last-child {
  border-bottom: none;
}

.wallet__entry-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.wallet__entry-kind {
  font-weight: var(--weight-medium);
}

.wallet__entry-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* A credit is marked, a debit is left in the ordinary text colour. Colour is
   not the only signal: the sign is always printed. */
.wallet__entry-amount.is-positive {
  color: var(--positive);
}
