/* BackgammonX v0.2.22 — 14-section-stack.css
   Owns: the TX-style centred brand header restyle, and the vertical
   section-stack shell (heading/toggle/move-buttons/menu) that
   js/28-section-stack.js builds at runtime by REPARENTING existing,
   untouched elements — never cloning them. No rule here changes any
   board, checker, hit-target, dice or rotation geometry; every selector
   below targets presentation chrome only (headers, section containers,
   buttons, menus).

   Palette: a new, BGX-owned warm brown/gold token set, scoped to this
   file and additive to (never replacing) the existing felt-green
   --felt- and --gold tokens in css/01-base-layout.css. Concrete values are
   carried over from the supplied TX reference's own layout.css (the
   handoff's explicit "visual reference" for this pass), not invented:
   headings #352416 on a page background of #1b140d-ish deep brown,
   borders #65492d, body text #e0bd86 / #bca17d, focus ring #f6cd65. */

:root {
  --bgx-css-14: 1;
  --bgx-stack-max-width: 1060px;
  --bgx-stack-bg: #241a12;
  --bgx-stack-heading-bg: #352416;
  --bgx-stack-body-bg: #2d2017;
  --bgx-stack-border: #65492d;
  --bgx-stack-text: #e0bd86;
  --bgx-stack-text-muted: #bca17d;
  --bgx-stack-button-bg: #302219;
  --bgx-stack-button-text: #dfc095;
  --bgx-stack-button-border: #705434;
  --bgx-stack-focus: #f6cd65;
}

/* ── Centred TX-style brand header (point A.1) ───────────────────────
   Restyles the EXISTING .x-header/.x-brand markup in place; no new
   header element is introduced and no click handler in js/05 is
   touched — only layout/colour declarations change.

   Independent-review Finding 3 correction: the previous version set
   justify-content:center on .x-header-primary, but that row's only
   flex child is .x-brand itself, which css/05-x-shell.css gives
   flex:1 — a flex:1 child already fills 100% of the row's own free
   space, so justify-content (which positions children WITHIN that
   free space) had nothing left to do; the brand text's real left-hand
   position came from css/05's inherited .x-brand { align-items:
   baseline }, which css/14 had changed the brand's flex-direction to
   column WITHOUT overriding — baseline on a column flex behaves like
   flex-start (left), not centered, which is what the review's
   screenshots show. --bgx-header-gutter reserves equal space on BOTH
   sides (matching the absolutely-positioned menu button's own
   footprint), so the brand's own flex:1 box is symmetric around the
   header's true centre before align-items:center (below) centres its
   text within that box — fixing both the "menu overlaps the brand"
   overlap and the plain off-centre text in one change. */
:root { --bgx-header-gutter: 64px; } /* 40px button + 2×space-3 clearance on each side */
body.bgx-v22-layout .x-header {
  background: var(--bgx-stack-bg);
  border-bottom: 1px solid var(--bgx-stack-border);
  /* was a fixed height (css/05's own height: var(--header-height)) —
     min-height lets a two-line brand (name + sub, now stacked) grow
     the header instead of overflowing/clipping it on narrow screens
     (independent review Finding 3's own "narrow-screen clipping"
     caution), while still matching the usual height exactly whenever
     the content fits it. */
  height: auto;
  min-height: var(--header-height);
}
body.bgx-v22-layout .x-header-primary {
  justify-content: center;
  position: relative;
  text-align: center;
  padding: var(--space-3) var(--bgx-header-gutter);
}
body.bgx-v22-layout .x-header-primary .x-icon-button[data-action="menu-open"] {
  position: absolute;
  left: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bgx-stack-button-bg);
  border: 1px solid var(--bgx-stack-button-border);
  color: var(--bgx-stack-button-text);
}
body.bgx-v22-layout .x-brand {
  flex-direction: column;
  align-items: center; /* overrides css/05's inherited align-items:baseline — see comment above */
  gap: 0;
  width: 100%;
}
body.bgx-v22-layout .x-brand-name {
  font-family: var(--font-brand);
  font-size: var(--fs-xl);
  letter-spacing: 0.04em;
  color: var(--bgx-stack-text);
}
body.bgx-v22-layout .x-brand-sub {
  font-size: var(--fs-sm);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bgx-stack-text-muted);
}
body.bgx-v22-layout .x-brand-version {
  display: none; /* moved into About / Build details — see Developer/Diagnostics */
}
body.bgx-v22-layout .x-channel-tag {
  display: none; /* same — build identity stays available, not on the masthead */
}
body.bgx-v22-layout .x-header-secondary {
  justify-content: center;
  text-align: center;
  color: var(--bgx-stack-text-muted);
  border-top: 1px solid var(--bgx-stack-border);
}

/* ── Page-sections menu (point A.7) ──────────────────────────────────
   The existing .x-drawer/.x-scrim and BGX.shell.menu()/onKey() own all
   open/close/focus/Escape behaviour unchanged; only the list CONTENTS
   (see js/28) and these cosmetic rules are new. */
body.bgx-v22-layout .x-drawer {
  background: var(--bgx-stack-bg);
  border-right: 1px solid var(--bgx-stack-border);
}
body.bgx-v22-layout .x-drawer-head {
  border-bottom: 1px solid var(--bgx-stack-border);
}
body.bgx-v22-layout .x-drawer-list button {
  color: var(--bgx-stack-button-text);
}
body.bgx-v22-layout .x-drawer-list button:focus-visible {
  outline: 2px solid var(--bgx-stack-focus);
  outline-offset: 2px;
}
body.bgx-v22-layout .x-bottom-nav {
  display: none !important; /* point A.7 — no permanent bottom strip */
}

/* ── Section stack (adapted from TX layout.css; same structural
   classes/behaviour, BGX's own colour tokens) ───────────────────────── */
.bgx-stack-toolbar, #bgx-section-stack {
  width: 100%;
  max-width: var(--bgx-stack-max-width);
  margin: var(--space-3) auto;
  box-sizing: border-box;
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}
.bgx-stack-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  color: var(--bgx-stack-text-muted);
  font-size: var(--fs-sm);
}
.bgx-stack-toolbar button {
  color: var(--bgx-stack-button-text);
  background: var(--bgx-stack-button-bg);
  border: 1px solid var(--bgx-stack-button-border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.bgx-stack-toolbar button:focus-visible {
  outline: 2px solid var(--bgx-stack-focus);
  outline-offset: 2px;
}
#bgx-section-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.bgx-stack-section {
  position: relative;
  min-width: 0;
  width: 100%;
  scroll-margin-top: var(--space-3);
}
.bgx-stack-heading {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 102px 0 var(--space-4);
  background: var(--bgx-stack-heading-bg);
  border: 1px solid var(--bgx-stack-border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.bgx-stack-section.bgx-stack-closed .bgx-stack-heading {
  border-radius: var(--radius-md);
}
.bgx-stack-toggle {
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.5;
  color: var(--bgx-stack-text);
  background: transparent !important;
  border: 0 !important;
  cursor: pointer;
  padding: var(--space-3) 0;
  letter-spacing: 0.04em;
}
span.bgx-stack-toggle { cursor: default; }
.bgx-stack-toggle:focus-visible {
  outline: 2px solid var(--bgx-stack-focus);
  outline-offset: 2px;
}
.bgx-stack-section > [hidden] { display: none !important; }
.bgx-stack-moves {
  position: absolute;
  z-index: 5;
  right: var(--space-2);
  top: 5px;
  display: flex;
  gap: 5px;
}
.bgx-stack-moves button {
  width: 38px;
  height: 38px;
  font-size: 19px;
  color: var(--bgx-stack-button-text);
  background: var(--bgx-stack-button-bg);
  border: 1px solid var(--bgx-stack-button-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.bgx-stack-moves button:disabled { opacity: 0.28; cursor: default; }
.bgx-stack-moves button:focus-visible {
  outline: 2px solid var(--bgx-stack-focus);
  outline-offset: 2px;
}
/* The BODY (unlike the heading) holds a mix of this file's own static
   notes AND pre-existing, theme-reactive content MOVED in from
   elsewhere (colour selects, Engine Lab/Settings buttons, etc.) whose
   own foreground colours are calibrated against the site's real
   light/dark --surface, not a fixed colour. Giving the body a FIXED
   brown background regardless of html[data-appearance] breaks that
   calibration in light mode (dark-on-dark or light-on-light text) --
   so the body uses the same theme-aware --surface/--line tokens every
   other real content surface on the page already uses, rather than
   the fixed --bgx-stack-* palette (kept for the heading/toolbar/menu
   chrome only, which holds nothing but this file's own, fully
   self-paired gold-on-brown text). */
.bgx-stack-body {
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  color: var(--text);
}
/* Board & Play is "always" (uncollapsible) and carries no HUD/body
   background of its own — the existing board-column keeps its own
   look unmodified; only the outer heading/frame gets the stack chrome. */
.bgx-stack-section[data-bgx-section="board"] > .bgx-stack-body {
  background: transparent;
  border: 0;
  padding: var(--space-2) 0 0;
}
.bgx-stack-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

@media (max-width: 600px) {
  .bgx-stack-toolbar { font-size: 11px; }
  .bgx-stack-heading { padding-left: var(--space-2); }
}

/* ── The original two-column .app-main/.panel-column shell is left in
   the DOM (js/28 drains its panel children into the new stack rather
   than deleting the container, mirroring the TX reference's own
   approach) but contributes nothing visually once the stack is
   active — grid-template-columns from css/01 would otherwise reserve
   an empty 280px column and padding for nothing.

   Exception: the pre-v0.2.22 Play Layout tool (js/25) still targets
   .board-stage/.dtf-hud/.panel-column as absolutely-positioned drag
   modules INSIDE .app-main, and sets data-bgx-layout="on" on .app-main
   itself for exactly as long as it is active (its own enterLayout()/
   exitLayout(), unchanged). Restoring .app-main's normal display for
   that one window is simpler and safer than teaching Play Layout a new
   coordinate system — see IMPLEMENTATION-NOTE.md. */
body.bgx-v22-layout > .app-main { display: none; }
body.bgx-v22-layout > .app-main[data-bgx-layout="on"] { display: grid; }

/* ── New small controls added inside reparented sections (js/28) ────── */
.bgx-board-size-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
  /* Board & Play's own body stays background:transparent (its real
     background is the ordinary page --bg behind it), so this row's
     text uses the same theme-aware --text-muted everything else on
     that transparent background uses, not the fixed stack palette. */
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.bgx-board-size-label { margin-right: var(--space-1); }
.bgx-board-size-slider { width: 140px; }
.bgx-board-size-pct { min-width: 3.5em; text-align: right; }

.bgx-setup-note { color: var(--text-muted); font-size: var(--fs-sm); margin: 0 0 var(--space-3); }

.bgx-updates-list { margin: 0; padding-left: 1.2em; line-height: 1.6; }
.bgx-updates-list li { margin-bottom: var(--space-2); }

.bgx-build-info { font-size: var(--fs-sm); color: var(--text-muted); margin: 0 0 var(--space-3); }
.bgx-migration-note {
  padding: var(--space-3);
  background: var(--bgx-stack-heading-bg);
  border: 1px solid var(--bgx-stack-border);
  border-radius: var(--radius-sm);
  color: var(--bgx-stack-text);
  font-size: var(--fs-sm);
}
.bgx-legacy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) 0;
  font-size: var(--fs-sm);
}
