/* Site header/footer styling for the archived forum pages under /community/.
 *
 * WHY THIS FILE EXISTS, rather than loading the site's Bootstrap 5:
 * the archive keeps XenForo's own stylesheets, which still include
 * Bootstrap 3 with UNSCOPED rules - measured in the shipped CSS:
 * 87 `.btn` rules, 57 `.navbar-nav`, 51 `.dropdown-menu`, 43
 * `.form-control`, plus bare `html`, `body`, `a`, `a:hover`, `a:visited`.
 * The chrome's markup uses exactly those class names. Worse, the injection
 * point (<!--site:head-->) is the LAST thing in <head>, so a Bootstrap 5
 * link there would win on equal specificity and restyle the forum itself.
 *
 * So the chrome reuses the same Jinja partials as the rest of the site
 * (one source of truth for the links), and gets its appearance from here
 * instead. Every selector is scoped under `.ir-chrome`:
 *   - nothing here can leak out and restyle the forum, and
 *   - `.ir-chrome .btn` (0,2,0) outranks the archive's `.btn` (0,1,0),
 *     so the forum's Bootstrap 3 cannot reach in either.
 * Keep it that way: never add an unscoped selector to this file.
 *
 * TWO TRAPS, both found by measuring the rendered pages rather than by
 * reading the CSS (scripts/compare_chrome.py does that measuring, and
 * tests/test_community_chrome_parity.py runs it):
 *
 * 1. NEVER USE `rem` IN THIS FILE. Bootstrap 3's reboot sets
 *    `html { font-size: 10px }`, and `rem` is always relative to <html> -
 *    scoping cannot shield it. Every `rem` here rendered at 0.625x: the
 *    brand came out 12.5px instead of 20px. Use px, and keep the numbers
 *    equal to what Bootstrap 5 resolves to on the main site (1rem = 16px).
 *
 * 2. SCOPING IS NOT ALWAYS ENOUGH. A handful of Bootstrap 3 rules are
 *    themselves (0,3,0) or carry `!important`, so they outrank a plain
 *    `.ir-chrome X`. They are collected in the "outranking Bootstrap 3"
 *    section at the end, each with the rule it is fighting - keep them
 *    there rather than scattering !important through the file.
 *
 * The values below mirror Bootstrap 5.3 + base.html's overrides as they
 * actually render. To check, run `python -m scripts.compare_chrome`: it
 * renders the header and footer on both the main site and an archived page
 * and reports any element whose box, font, colour or spacing differs.
 */

.ir-chrome {
  /* The brand palette, mirroring base.html's :root block. */
  --irc-red-700: #7a1c20;
  --irc-red-600: #9c232a;
  --irc-red-500: #c1272d;
  --irc-red-400: #d8474d;
  --irc-ink: #212529;
  --irc-muted: #6c757d;
  --irc-line: #dee2e6;
  --irc-bg-light: #f8f9fa;
  --irc-gutter: 12px;
  /* Bootstrap's translucent border, used by dropdowns. */
  --irc-line-translucent: rgba(0, 0, 0, .175);

  /* The forum's own html/body rules set font and colour, and they are
   * inherited here - so state them explicitly rather than inheriting
   * XenForo's. */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--irc-ink);
  text-align: start;
  box-sizing: border-box;
}
.ir-chrome *,
.ir-chrome *::before,
.ir-chrome *::after { box-sizing: border-box; }

.ir-chrome a { color: var(--irc-red-500); text-decoration: none; }
.ir-chrome a:hover { color: var(--irc-red-600); text-decoration: underline; }
/* The forum underlines links with `a, a:visited { text-decoration: underline }`,
 * which ties with our `.ir-chrome a` on specificity, so cancel it explicitly.
 * NEVER set `color` here. `:visited` adds a pseudo-class, making this (0,2,1),
 * which outranks every component colour below at (0,2,0) - a `color` on this
 * rule turned the brand and the footer headings red as soon as the visitor had
 * been to those pages, while an unvisited browser looked perfectly fine.
 * Bootstrap does not style `:visited` at all. */
.ir-chrome a:visited { text-decoration: none; }
/* XenForo gives some links a ::before icon; it must not follow them here. */
.ir-chrome a::before, .ir-chrome a::after { content: none; }

/* Bootstrap 5's .container is a responsive ladder, not one width. Getting
 * this wrong is why the archive's header ran edge to edge while the main
 * site's stopped at 1140px. */
.ir-chrome .container {
  width: 100%;
  max-width: none;
  margin-inline: auto;
  padding-inline: var(--irc-gutter);
}
@media (min-width: 576px)  { .ir-chrome .container { max-width: 540px; } }
@media (min-width: 768px)  { .ir-chrome .container { max-width: 720px; } }
@media (min-width: 992px)  { .ir-chrome .container { max-width: 960px; } }
@media (min-width: 1200px) { .ir-chrome .container { max-width: 1140px; } }
@media (min-width: 1400px) { .ir-chrome .container { max-width: 1320px; } }

/* ---------------------------------------------------------------- navbar */

.ir-chrome .navbar {
  display: flex;
  align-items: center;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--irc-line);
  border-radius: 0;          /* BS3 rounds .navbar; Bootstrap 5 does not. */
  padding: 8px 0;
  min-height: 0;
  margin: 0;
}
.ir-chrome .navbar > .container {
  display: flex;
  flex-wrap: inherit;
  align-items: center;
  justify-content: space-between;
}
.ir-chrome .navbar-brand {
  float: none;
  height: auto;
  padding: 5px 0;
  margin: 0 16px 0 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.5;
  color: #000;
  white-space: nowrap;
}
.ir-chrome .navbar-brand:hover { color: #000; text-decoration: none; }
.ir-chrome .navbar-brand .brand-accent { color: var(--irc-red-500); }

.ir-chrome .navbar-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0;
}
.ir-chrome .navbar-nav .nav-item { position: relative; list-style: none; }
.ir-chrome .nav-link {
  display: block;
  padding: 8px;
  color: var(--irc-red-700);
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
}
.ir-chrome .nav-link:hover { color: var(--irc-red-500); text-decoration: none; }
/* `me-auto` on the nav list is what pushes the search form to the far
 * right. Bootstrap ships its utilities with !important; matching that
 * keeps the override order the same as on the main site. */
.ir-chrome .me-auto { margin-right: auto !important; }
/* The caret, which Bootstrap draws with a pseudo-element. */
.ir-chrome .dropdown-toggle::after {
  content: "";
  display: inline-block;
  margin-left: .255em;
  vertical-align: .255em;
  border-top: .3em solid currentColor;
  border-right: .3em solid transparent;
  border-left: .3em solid transparent;
}

/* --------------------------------------------------------------- dropdown */

.ir-chrome .dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  min-width: 160px;
  margin: 0;
  padding: 8px 0;
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
  list-style: none;
  background: #fff;
  border: 1px solid var(--irc-line-translucent);
  border-radius: 6px;
  box-shadow: none;
}
.ir-chrome .dropdown-menu.show { display: block; }
.ir-chrome .dropdown-menu li { list-style: none; margin: 0; }
.ir-chrome .dropdown-item {
  display: block;
  width: 100%;
  padding: 4px 16px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--irc-ink);
  white-space: nowrap;
}
.ir-chrome .dropdown-item:hover {
  background: var(--irc-bg-light);
  color: var(--irc-red-600);
  text-decoration: none;
}
.ir-chrome .dropdown-divider {
  height: 0;
  color: inherit;
  margin: 8px 0;
  border: 0;
  border-top: 1px solid var(--irc-line-translucent);
  opacity: 1;
}

/* ------------------------------------------------------- search + buttons */

.ir-chrome form.d-flex { display: flex; align-items: center; }
.ir-chrome .me-2 { margin-right: 8px !important; }
.ir-chrome .form-control {
  display: block;
  width: auto;
  min-width: 0;
  height: auto;
  padding: 6px 12px;
  font: inherit;
  line-height: 1.5;
  color: var(--irc-ink);
  background: #fff;
  border: 1px solid var(--irc-line);
  border-radius: 6px;
  box-shadow: none;
}
.ir-chrome .form-control:focus {
  border-color: var(--irc-red-400);
  outline: 2px solid rgb(193 39 45 / 25%);
  outline-offset: 0;
}
.ir-chrome .btn {
  display: inline-block;
  padding: 6px 12px;
  font: inherit;
  line-height: 1.5;
  text-align: center;
  white-space: nowrap;
  border-radius: 6px;
  cursor: pointer;
  text-shadow: none;
  background-image: none;
  box-shadow: none;
}
.ir-chrome .btn-outline-danger {
  color: var(--irc-red-500);
  background: transparent;
  border: 1px solid var(--irc-red-500);
}
.ir-chrome .btn-outline-danger:hover {
  color: #fff;
  background: var(--irc-red-500);
  border-color: var(--irc-red-500);
  text-decoration: none;
}

/* ------------------------------------------------------- mobile collapse */

.ir-chrome .navbar-toggler {
  display: none;
  padding: 4px 12px;
  font-size: 20px;
  line-height: 1;
  color: var(--irc-red-700);
  background: transparent;
  border: 1px solid rgba(0, 0, 0, .15);
  border-radius: 6px;
  cursor: pointer;
}
/* Bootstrap 5's own burger glyph, so the two sites draw the same icon. */
.ir-chrome .navbar-toggler-icon {
  display: inline-block;
  width: 1.5em;
  height: 1.5em;
  vertical-align: middle;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100%;
}
.ir-chrome .navbar-collapse {
  display: flex;
  flex-basis: auto;
  flex-grow: 1;
  align-items: center;
  padding: 0;
  margin: 0;
  border-top: 0;
  /* BS3 puts an inset white hairline and a -15px bottom margin here while
   * the navbar is collapsed; neither exists in Bootstrap 5. */
  box-shadow: none;
}

/* Below the `navbar-expand-md` breakpoint Bootstrap stacks the nav, drops
 * each menu into the normal flow (so it pushes the page down rather than
 * overlaying it) and removes the horizontal padding from the links. */
@media (max-width: 767.98px) {
  .ir-chrome .navbar-toggler { display: block; }
  .ir-chrome .navbar-collapse { width: 100%; flex-direction: column; align-items: stretch; }
  .ir-chrome .navbar-nav { flex-direction: column; align-items: stretch; width: 100%; }
  .ir-chrome .nav-link { padding-right: 0; padding-left: 0; }
  .ir-chrome .dropdown-menu { position: static; }
  .ir-chrome form.d-flex { width: 100%; }
  .ir-chrome .form-control { flex: 1 1 auto; }
}

/* ---------------------------------------------------------------- footer */

.ir-chrome footer {
  border-top: 3px solid var(--irc-red-500);
  background: var(--irc-bg-light);
  margin-top: 48px;
  padding: 24px 0;
}
.ir-chrome .row {
  display: flex;
  flex-wrap: wrap;
  margin-inline: calc(var(--irc-gutter) * -1);
}
.ir-chrome .row > * { padding-inline: var(--irc-gutter); }
.ir-chrome .col-md-3 { flex: 0 0 auto; width: 25%; }
.ir-chrome .mb-3 { margin-bottom: 16px !important; }
.ir-chrome footer h5 {
  font-size: 20px;
  font-weight: 500;
  line-height: 1.2;
  margin: 0 0 8px;
}
/* Bootstrap's utilities all carry !important, and that is load-bearing, not
 * noise: it is what keeps `.text-body` winning over `a:hover` in the footer
 * headings. Mirror it so the override order matches the main site's. */
.ir-chrome .text-decoration-none { text-decoration: none !important; }
.ir-chrome .text-body { color: var(--irc-ink) !important; }
.ir-chrome .list-unstyled {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}
.ir-chrome .list-unstyled li { list-style: none; margin-bottom: 0; }

@media (max-width: 767.98px) {
  .ir-chrome .col-md-3 { width: 100%; }
}
@media (min-width: 576px) and (max-width: 767.98px) {
  .ir-chrome .col-sm-6 { width: 50%; }
}

/* ------------------------------------------------ outranking Bootstrap 3
 * Scoping normally wins on specificity, but these Bootstrap 3 rules are
 * (0,3,0) or carry !important, so a plain `.ir-chrome X` loses to them.
 * Each rule below names the one it is fighting. Nothing here is a style
 * decision - the values just restore what Bootstrap 5 would have done.
 */

/* BS3: `.navbar > .container .navbar-brand { margin-left: -15px }` (0,3,0)
 * pulled the brand off the left edge of the page, clipping it. */
.ir-chrome .navbar > .container .navbar-brand { margin-left: 0; }

/* BS3: `.navbar-nav > li > .dropdown-menu { border-top-*-radius: 0 }`
 * (0,2,2) squared off the top of every menu. */
.ir-chrome .navbar-nav > li > .dropdown-menu { border-radius: 6px; }

/* BS3 (>=768px): `.navbar-collapse.collapse { display: block !important;
 * height: auto !important; overflow: visible !important }`. Our nav needs
 * to be a flex row, so match the !important and beat it on specificity. */
.ir-chrome .navbar-collapse.collapse { display: flex !important; }
@media (max-width: 767.98px) {
  .ir-chrome .navbar-collapse.collapse { display: none !important; }
  .ir-chrome .navbar-collapse.collapse.show { display: flex !important; }
}

/* --------------------------------------- the reaches into the forum itself
 * Everything above is scoped under .ir-chrome and cannot affect XenForo.
 * These two rules deliberately do, so the header does not sit at odds with
 * the page under it. Keep the list this short, and document any addition.
 */

/* 1. Every archived page carries `style="margin-top: 51px"` on
 * .p-pageWrapper, reserved for the old site's FIXED header. That header is
 * gone and ours sits in normal flow, so the 51px is just a gap above the
 * forum. It is an inline style, so overriding it needs !important. */
.p-pageWrapper[style] { margin-top: 0 !important; }

/* 2. XenForo centres its nav and body on `max-width: 1200px; padding: 0 10px`,
 * while the site's container is Bootstrap's stepped one. At 1280px that put
 * the forum's text 32px left of our header's, which read as a misalignment on
 * every page. Give XenForo the same ladder (and the same 12px gutter on the
 * body) so the two line up at every width. Both properties are declared once
 * in the archive's CSS with no media-query variants, so this is safe to
 * override wholesale - check that again if the archive is ever rebuilt from a
 * different XenForo style.
 *
 * The trade-off: at 992-1199px the forum narrows from the full viewport to
 * 960px. That is exactly what the main site does with its own content, which
 * is the point - but it IS a change to how the archived forum looked. */
.p-nav-inner,
.p-body-inner { max-width: 100%; }
.p-body-inner { padding-left: 12px; padding-right: 12px; }
@media (min-width: 576px)  { .p-nav-inner, .p-body-inner { max-width: 540px; } }
@media (min-width: 768px)  { .p-nav-inner, .p-body-inner { max-width: 720px; } }
@media (min-width: 992px)  { .p-nav-inner, .p-body-inner { max-width: 960px; } }
@media (min-width: 1200px) { .p-nav-inner, .p-body-inner { max-width: 1140px; } }
@media (min-width: 1400px) { .p-nav-inner, .p-body-inner { max-width: 1320px; } }
