/*===============================================*\
|| TerraLoc: the forum in TerraLoc's look         ||
|| Loaded after plugins/forum/assets/css/forum.css ||
\*===============================================*/

/*
 * THE FORUM IS JSCMS'S, NOT OURS. Its files are byte-identical to the cms
 * repo and stay that way, so its look changes here and nowhere else. Linked
 * on the forum's three pages right after its own stylesheet, by
 * scripts/build_pages.php on the Mac and by the terraloc update on a server.
 *
 * Most of the work is the forum's own --fr-* tokens pointed at TerraLoc's,
 * which also brings the night face for free. The rest puts the forum's pieces
 * into the shapes the other list pages use: the hero becomes the page head
 * with its kicker, title and sentence, the three counters become the KPI
 * band, rows are hairline cards, a tag is a small mono badge.
 *
 * EVERY RULE STARTS WITH :root body. The forum's head hook links forum.css a
 * second time, after the page's stylesheets, so a rule here at the forum's
 * own specificity loses to it. The prefix adds (0,1,1), which also beats the
 * forum's [data-bs-theme="dark"] .forum-shell rules.
 *
 * Three rules the stock forum broke here:
 *   - Bootstrap's primary is TerraLoc's CTA orange, so every link, active tag
 *     and unread title came out orange. Orange is the one action on a screen
 *     (New discussion, Reply); everything else that is "current" is green.
 *   - Pinned and the reading rail were amber. Amber means live and nothing
 *     else, so pinned is ink and the rail is green.
 *   - Soft shadows and 16px radii: TerraLoc cards are hairline, near square.
 */

:root body .forum-shell,
:root body .forum-modal,
:root body .forum-bell-dropdown,
:root body .forum-mention-popover,
:root body .forum-reaction-popover,
:root body .fr-section-shell {
  --fr-accent:            var(--tl-accent);
  --fr-accent-rgb:        var(--tl-accent-rgb);
  --fr-accent-ink:        var(--tl-accent-ink);
  --fr-accent-soft:       rgba(var(--tl-accent-rgb), 0.10);
  --fr-accent-soft-hover: rgba(var(--tl-accent-rgb), 0.16);

  --fr-ink:               var(--tl-ink);
  --fr-ink-strong:        var(--tl-ink);
  --fr-muted:             var(--tl-dim);
  --fr-muted-strong:      var(--tl-muted);

  --fr-surface:           var(--tl-panel);
  --fr-surface-soft:      var(--tl-paper-deep);
  --fr-surface-tint:      var(--tl-paper-deep);

  --fr-border:            var(--tl-hairline);
  --fr-border-strong:     var(--tl-hairline-strong);
  --fr-divider:           var(--tl-hairline);

  --fr-shadow-sm:         none;
  --fr-shadow-md:         none;
  --fr-shadow-lg:         0 18px 40px rgba(20, 24, 15, 0.14);

  --fr-pinned:            var(--tl-ink);
  --fr-pinned-soft:       transparent;
  --fr-best:              var(--tl-success);
  --fr-best-soft:         rgba(var(--tl-success-rgb), 0.08);
  --fr-locked:            var(--tl-warning);
  --fr-danger:            var(--tl-danger);

  --fr-radius-sm:         6px;
  --fr-radius:            10px;
  --fr-radius-lg:         10px;

  --fr-font-mono:         var(--tl-font-mono);
}

/* ------------------------------------------------------------ the frame */

/* The block's root is a <section class="pb-5">, which the stock template
   pads 7.5rem at the top. The page frame every TerraLoc page uses instead. */
:root body section:has(> .forum-shell) {
  padding-top: var(--tl-page-top);
  padding-bottom: var(--tl-page-bottom);
}
:root body .forum-shell.container {
  max-width: 1240px;
  padding-left: var(--tl-page-gutter);
  padding-right: var(--tl-page-gutter);
}

/* ------------------------------------------- the hero is the page head */

/* A <section> too, so it carried the template's 7.5rem as well. */
:root body .forum-hero,
:root[data-bs-theme="dark"] body .forum-hero {
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin-bottom: 1.5rem;
}
:root body .forum-hero-body { flex-direction: column; align-items: stretch; gap: 1.25rem; }
:root body .forum-hero-text { flex: 0 0 auto; }

:root body .forum-hero-eyebrow {
  display: block;
  padding: 0;
  margin: 0;
  background: none;
  border-radius: 0;
  font-family: var(--tl-font-mono);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  color: var(--tl-cta);
}
:root body .forum-hero-eyebrow i { display: none; }

:root body .forum-hero-title {
  margin: 0.35rem 0 0;
  font-family: var(--tl-font-display);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--tl-ink);
}
:root body .forum-hero-subtitle {
  margin: 0.5rem 0 0;
  max-width: 60ch;
  font-size: 0.95rem;
  color: var(--tl-muted);
}

/* The three counters: the KPI band of every list page. */
:root body .forum-hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  width: 100%;
  border: 1px solid var(--tl-hairline);
  border-radius: 10px;
  background: var(--tl-hairline);
  overflow: hidden;
}
:root body .forum-hero-stat {
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: 0.3rem;
  min-width: 0;
  padding: 0.9rem 1.1rem;
  border: 0;
  border-radius: 0;
  background: var(--tl-paper-deep);
}
:root body .forum-hero-stat-icon { display: none; }
:root body .forum-hero-stat-num {
  font-family: var(--tl-font-display);
  font-size: clamp(1.3rem, 2.6vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--tl-ink);
}
:root body .forum-hero-stat-label {
  margin: 0;
  font-family: var(--tl-font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--tl-dim);
}
@media (max-width: 480px) {
  :root body .forum-hero-stat { padding: 0.75rem 0.8rem; }
}

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

/* Not a card: a list beside the content, as the profile's sidebar is. */
:root body .forum-sidebar {
  gap: 1px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
:root body .forum-sidebar-item {
  gap: 0.7rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  color: var(--tl-muted);
  font-size: 0.9rem;
}
:root body .forum-sidebar-item:hover { background: var(--tl-paper-deep); color: var(--tl-ink); }
:root body .forum-sidebar-item.active {
  background: rgba(var(--tl-accent-rgb), 0.10);
  color: var(--tl-ink);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--tl-accent);
}

/* The tile is quiet and the icon carries the tag's colour, so a dozen
   colours down the side read as marks, not as a dozen buttons. */
:root body .forum-sidebar-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--tl-panel);
  border: 1px solid var(--tl-hairline);
  color: var(--fr-tag-color, var(--tl-accent));
  font-size: 0.74rem;
}
:root body .forum-sidebar-item:hover .forum-sidebar-icon,
:root body .forum-sidebar-item.active .forum-sidebar-icon {
  background: var(--fr-tag-color, var(--tl-accent));
  border-color: transparent;
  color: #fff;
  opacity: 1;
}
:root body .forum-sidebar-count {
  padding: 0;
  background: none;
  font-family: var(--tl-font-mono);
  font-size: 0.7rem;
  color: var(--tl-dim);
}
:root body .forum-sidebar-item.active .forum-sidebar-count { background: none; color: var(--tl-accent); }

/* A tag on a row or a discussion: a small mono badge in the tag's colour,
   the shape of the badges on a segment board. The colour is the forum's
   inline background and stays. */
:root body .forum-tag-chip,
:root body .forum-tag-picker-chip {
  border-radius: 5px;
  box-shadow: none;
}
:root body .forum-tag-chip {
  height: 20px;
  padding: 0 7px;
  font-family: var(--tl-font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}
:root body .forum-tag-chip i { font-size: 0.6rem; }

/* A discussion in another language than the page: the tag badge's shape,
   outlined in the hairline so it never reads as one more tag. */
:root body .forum-lang-badge {
  height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  border-color: var(--tl-hairline-strong);
  color: var(--tl-muted);
  font-family: var(--tl-font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}
:root body .forum-lang-badge i { font-size: 0.58rem; }
/* Locked on a discussion and a flag's reason for the moderators: the same
   mono badge, outlined in the forum's warning and danger. The pin keeps the
   forum's own mark, in ink (--fr-pinned above), never amber. */
:root body .forum-detail-locked,
:root body .forum-flag-reason {
  padding: 0 7px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  font-family: var(--tl-font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
:root body .forum-lang-empty {
  border-color: var(--tl-hairline-strong);
  border-radius: 8px;
  color: var(--tl-dim);
}

/* ---------------------------------------------------------- the toolbar */

:root body .forum-search-input.form-control,
:root body .forum-toolbar-sort.form-select {
  height: 38px;
  border-radius: 6px;
  background-color: var(--tl-panel);
  box-shadow: none;
}
:root body .forum-search-input.form-control:focus,
:root body .forum-toolbar-sort.form-select:focus {
  box-shadow: 0 0 0 3px rgba(var(--tl-accent-rgb), 0.18);
}
:root body .forum-toolbar .btn { height: 38px; display: inline-flex; align-items: center; }

/* The language filter wears the header's language switcher (app-chrome.css):
   globe or flag, the code in mono, a small caret; at the toolbar's height. */
:root body .forum-lang-filter-toggle {
  gap: .375rem;
  height: 38px;
  padding: 0 .625rem 0 .75rem;
  border: 1px solid var(--tl-hairline);
  border-radius: 6px;
  background: var(--tl-panel);
  box-shadow: none;
  color: var(--tl-muted);
  font-family: var(--tl-font-mono);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .12em;
  line-height: 1;
}
:root body .forum-lang-filter-toggle .forum-lang-filter-mark { font-size: .8125rem; }
:root body .forum-lang-filter-toggle::after {
  margin-left: .125rem;
  border-top-width: .28em;
  border-right-width: .24em;
  border-left-width: .24em;
  color: var(--tl-dim);
}
:root body .forum-lang-filter-toggle:hover,
:root body .forum-lang-filter-toggle[aria-expanded="true"],
:root body .forum-lang-filter.is-filtered .forum-lang-filter-toggle { color: var(--tl-ink); border-color: var(--tl-dim); }
:root body .forum-lang-filter-toggle:focus-visible { box-shadow: 0 0 0 3px rgba(var(--tl-accent-rgb), 0.18); }
/* Its list: the header's, each language in its own name, its code beside
   it, a check in a fixed slot on the one shown. */
:root body .forum-lang-filter .dropdown-menu {
  min-width: 11rem;
  margin-top: .375rem !important;
  padding: .25rem 0;
  border: 1px solid var(--tl-hairline);
  border-radius: var(--tl-radius);
  background: var(--tl-panel);
  box-shadow: var(--tl-lift);
}
:root body .forum-lang-filter .dropdown-item {
  gap: .75rem;
  padding: .5rem .875rem;
  color: var(--tl-ink);
  font-size: .875rem;
  background: transparent;
}
:root body .forum-lang-filter .dropdown-item::before {
  content: "";
  flex: none;
  width: .75rem;
  margin-right: -.25rem;
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: .6875rem;
}
:root body .forum-lang-filter .dropdown-item.active::before { content: "\f00c"; color: var(--tl-accent); }
:root body .forum-lang-filter .dropdown-item .forum-lang-filter-mark { font-size: 1rem; }
:root body .forum-lang-filter .dropdown-item .forum-lang-filter-code {
  font-family: var(--tl-font-mono);
  font-size: .625rem;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--tl-dim);
}
:root body .forum-lang-filter .dropdown-item:hover,
:root body .forum-lang-filter .dropdown-item:focus { background: var(--tl-paper-deep); color: var(--tl-accent); }
:root body .forum-lang-filter .dropdown-item.active { color: var(--tl-accent); font-weight: 600; }

/* New discussion and Reply are the action on the screen: CTA orange and
   flat, the theme's own primary button. The forum gave it a gradient and a
   glow in its accent, which here would make it green. */
:root body .forum-shell .btn-primary,
:root body .forum-modal .btn-primary,
:root[data-bs-theme="dark"] body .forum-shell .btn-primary {
  background: var(--tl-cta);
  color: var(--tl-cta-ink);
  border: 0;
  box-shadow: none;
  font-weight: 600;
}
:root body .forum-shell .btn-primary:hover,
:root body .forum-modal .btn-primary:hover {
  background: var(--tl-cta-hover);
  color: var(--tl-cta-ink);
  transform: none;
  box-shadow: none;
  filter: none;
}
:root body .forum-shell .btn-primary:focus { box-shadow: 0 0 0 3px rgba(var(--tl-cta-rgb), 0.25); }

/* ------------------------------------------------------------- the list */

:root body .forum-list { gap: 0.6rem; }
:root body .forum-discussion-row {
  padding: 0.9rem 1.1rem;
  background: var(--tl-panel);
  transition: border-color 0.15s ease, background 0.15s ease;
}
:root body .forum-discussion-row:hover { transform: none; background: var(--tl-white); }
:root body .forum-discussion-row::before { border-left-width: 2px; }

/* Pinned: ink on the edge, no tint. */
:root body .forum-discussion-row.is-pinned { background: var(--tl-panel); }
:root body .forum-discussion-row.is-pinned:hover { background: var(--tl-white); }

/* Unread: the title is bold ink, the green edge says why. */
:root body .forum-discussion-row.is-unread .forum-disc-title { color: var(--tl-ink); font-weight: 700; }

:root body .forum-disc-avatar-img { width: 40px; height: 40px; border: 1px solid var(--tl-hairline); }
:root body .forum-disc-title { font-size: 1rem; font-weight: 600; color: var(--tl-ink); }
:root body .forum-disc-sub { font-size: 0.8rem; color: var(--tl-dim); }
:root body .forum-disc-stat { font-family: var(--tl-font-mono); font-size: 0.74rem; }
:root body .forum-disc-aside-name { color: var(--tl-ink); }
:root body .forum-disc-aside-time { font-family: var(--tl-font-mono); font-size: 0.68rem; color: var(--tl-dim); }

/* ------------------------------------------------------- a discussion */

:root body .forum-back-link { font-family: var(--tl-font-mono); font-size: 0.72rem; letter-spacing: 0.06em; color: var(--tl-muted); }
:root body .forum-back-link:hover { color: var(--tl-accent); }
:root body .forum-detail-title {
  font-family: var(--tl-font-display);
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--tl-ink);
}
:root body .forum-detail-header { border-bottom-color: var(--tl-hairline); }

:root body .forum-post-avatar-img,
:root[data-bs-theme="dark"] body .forum-post-avatar-img {
  width: 48px;
  height: 48px;
  border: 1px solid var(--tl-hairline);
  box-shadow: none;
}
:root body .forum-post-badge {
  border-radius: 5px;
  font-family: var(--tl-font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}
:root body .forum-post-badge--op { background: rgba(var(--tl-accent-rgb), 0.12); color: var(--tl-accent); }
:root body .forum-post-time { font-family: var(--tl-font-mono); font-size: 0.72rem; color: var(--tl-dim); }
:root body .forum-post-content { font-size: 0.98rem; line-height: 1.6; }

/* Action buttons: quiet hairline chips. The flag keeps no yellow: it is a
   rare act, not a warning on every post. */
:root body .forum-post-actions .btn {
  border-radius: 6px;
  border-color: var(--tl-hairline);
  background: var(--tl-panel);
  color: var(--tl-muted);
}
:root body .forum-post-actions .btn:hover {
  border-color: var(--tl-hairline-strong);
  background: var(--tl-white);
  color: var(--tl-ink);
}
:root body .forum-post-actions .btn-outline-danger:hover { color: var(--tl-danger); border-color: var(--tl-danger); }

:root body .forum-post.is-best { border-radius: 10px; border-left-width: 2px; }
:root body .forum-post.is-best::after {
  border-radius: 5px;
  box-shadow: none;
  font-family: var(--tl-font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
}

/* The reading rail: green, never amber. */
:root body .forum-rail-thumb {
  width: 3px;
  left: -2.5px;
  background: var(--tl-accent);
  box-shadow: none;
}
:root body .forum-rail-track { border-left-color: var(--tl-hairline); }
:root body .forum-rail-end { font-family: var(--tl-font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--tl-muted); }
:root body .forum-rail-meta-count { font-family: var(--tl-font-mono); font-size: 0.85rem; }
:root body .forum-rail-meta-date { font-family: var(--tl-font-mono); font-size: 0.7rem; color: var(--tl-dim); }

/* ----------------------------------------------------- composer, modals */

:root body .forum-composer {
  border-radius: 10px;
  background: var(--tl-panel);
  box-shadow: none;
}
:root body .forum-composer .wysiwyg-editor,
:root body .forum-modal .wysiwyg-editor { background: var(--tl-white); border-radius: 6px; }

:root body .forum-modal .modal-content { border-radius: 10px; border: 1px solid var(--tl-hairline); background: var(--tl-panel); }
:root body .forum-modal-header-icon { border-radius: 8px; background: rgba(var(--tl-accent-rgb), 0.12); color: var(--tl-accent); }
