/* Thalweg reference — theme bridge.
 *
 * The main documentation site (docs/site/index.html) is a bespoke, hand-authored
 * page: a paper background, an iron sidebar and verdigris accents in a condensed
 * display face. mdBook ships its own palettes (light/rust/coal/navy/ayu); left
 * alone the reference book looks like a different product from the landing page.
 *
 * This file re-skins mdBook's LIGHT theme to the landing-page palette and injects
 * a persistent Thalweg header bar (populated by custom/thalweg.js) that links back
 * to the main docs — so main + reference + crate docs read as one site. It is
 * loaded via `additional-css` in book.toml, and lives OUTSIDE src/ so the
 * gen-reference-book.sh regeneration (which wipes and rebuilds src/) never touches
 * it. ADR-0059. */

:root {
  --twg-iron:#1c2024; --twg-iron-2:#272c31; --twg-slate-line:#464e57;
  --twg-paper:#f3efe6; --twg-paper-2:#e9e3d6; --twg-ink:#20242a; --twg-ink-soft:#5b636d;
  --twg-verdigris:#4a9782; --twg-verdigris-bright:#6fc0a7; --twg-verdigris-deep:#2f6b5c;
  --twg-disp:'Arial Narrow','Helvetica Neue Condensed','Segoe UI',system-ui,sans-serif;
  --twg-sans:'Segoe UI',system-ui,-apple-system,sans-serif;
  --twg-bar:46px;
}

/* Re-skin the light theme (the enforced default, see book.toml) to the landing
 * palette. Kept scoped to .light so the alternate themes still work if toggled. */
.light, html:not(.js) {
  --bg: var(--twg-paper);
  --fg: var(--twg-ink);

  --sidebar-bg: var(--twg-iron);
  --sidebar-fg: #aeb7c0;
  --sidebar-non-existant: #6a747e;
  --sidebar-active: var(--twg-verdigris-bright);
  --sidebar-spacer: var(--twg-slate-line);

  --scrollbar: #8a929b;

  --icons: #6a747e;
  --icons-hover: var(--twg-ink);

  --links: var(--twg-verdigris-deep);

  --inline-code-color: var(--twg-verdigris-deep);

  --theme-popup-bg: #fff;
  --theme-popup-border: #d8d1c1;
  --theme-hover: var(--twg-paper-2);

  --quote-bg: #ece7db;
  --quote-border: #d8d1c1;

  --table-border-color: #d8d1c1;
  --table-header-bg: var(--twg-paper-2);
  --table-alternate-bg: #ece7db;

  --searchbar-border-color: #cfc7b6;
  --searchbar-bg: #fff;
  --searchbar-fg: var(--twg-ink);
  --searchbar-shadow-color: #b7ae9c;
  --searchresults-header-fg: var(--twg-ink-soft);
  --searchresults-border-color: #cfc7b6;
  --searchresults-li-bg: #e5efe9;
  --search-mark-bg: var(--twg-verdigris-bright);

  --color-scheme: light;
}

/* Typography: the landing page uses a condensed display face for headings and a
 * system sans for body. Bring both across so the reference reads the same. */
.content main { font-family: var(--twg-sans); }
.content h1, .content h2, .content h3,
.menu-title {
  font-family: var(--twg-disp);
  text-transform: uppercase;
  letter-spacing: .01em;
}
.content h1 { color: var(--twg-ink); border-bottom: 2px solid var(--twg-ink); padding-bottom: .2em; }
.content h2 { color: var(--twg-ink); }
.sidebar .sidebar-title, .brand { font-family: var(--twg-disp); }

/* Menu bar tinted to the iron/verdigris scheme so it sits under the brand bar as
 * one header rather than a second, differently-styled strip. */
.menu-bar, .menu-bar.sticky {
  background: var(--twg-paper);
  border-bottom: 2px solid var(--twg-ink);
}
.menu-title { color: var(--twg-ink); }

/* --- Persistent Thalweg brand bar (markup injected by custom/thalweg.js) ------
 * Fixed to the top on every page; the mdBook layout is pushed down by --twg-bar
 * so the bar never overlaps the sidebar or the sticky menu bar. This is the
 * back-to-main-docs control. */
.twg-topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--twg-bar);
  z-index: 1100;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 18px;
  background: var(--twg-iron); color: #fff;
  border-bottom: 1px solid #000;
  font-family: var(--twg-sans);
}
.twg-topbar .twg-brand {
  display: inline-flex; align-items: baseline; gap: 8px;
  color: #fff; text-decoration: none;
  font-family: var(--twg-disp); text-transform: uppercase; letter-spacing: .14em;
}
.twg-topbar .twg-word { font-weight: 700; font-size: 18px; }
.twg-topbar .twg-dot { color: var(--twg-verdigris-bright); }
.twg-topbar .twg-ctx {
  font-size: 11px; letter-spacing: .22em; color: var(--twg-verdigris-bright);
}
.twg-topbar .twg-back {
  color: #cfd6dd; text-decoration: none; font-size: 13px; white-space: nowrap;
  border: 1px solid var(--twg-slate-line); border-radius: 4px; padding: 5px 12px;
}
.twg-topbar .twg-back:hover { color: #fff; background: var(--twg-iron-2); border-color: var(--twg-verdigris); }

/* Push the whole mdBook chrome below the fixed bar. The sidebar and the sticky
 * menu bar are positioned independently of document flow, so each needs its own
 * offset. */
#body-container { padding-top: var(--twg-bar); }
.sidebar { top: var(--twg-bar) !important; }
.menu-bar.sticky { top: var(--twg-bar) !important; }
html { scroll-padding-top: calc(var(--twg-bar) + 50px); }

@media (max-width: 700px) {
  .twg-topbar .twg-ctx { display: none; }
}
