A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
ui: keyboard focus kept and returned, focus text and lit rung at 4.5:1, Cabinet orders line (refs #41) (#517)
Eyal Golan5ac1104aeca6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 96fa376f5..8f0173a0a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -373,6 +373,14 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBIt decodes to the same bytes, so the terrain is unchanged (#44).### Fixed+- Keyboard play, small fixes from the accessibility audit (refs #41): a Budget + or - keeps the focus on its button, as+ the rows are now updated in place (H2). Closing the start screen, answering the last open event and Escape from a+ screen no longer leave nothing focused: the focus goes to End Turn, End Turn, and the screen's top-bar button (M1).+ Text on the keyboard focus fill is a warm near-white, 5.7:1 where the gold was 3.7:1 (M3). The lit escalation rung's+ turn line is ink, 6.4:1 where it was 3.3:1, and the plain rungs' a lighter muted, 6.3:1 where it was 5.0:1 (M4). The+ Cabinet's "Ordered:" line wraps, and on short windows the Prime Minister's portrait gives way, framed again for its new+ height, so the candidate list keeps two rows; at 32:9 the list's floor follows the room left (M7). Presentation only:+ no golden moves.- "The Mediator Assassinated" cites the Official Gazette text of the Prevention of Terrorism Ordinance for its number,No. 33 of 1948, which no source on the card gave. Comment and source row only (refs #442).- Five recorded contradictions settled from primary sources. "The Second Truce": the Acting Mediator's report ofdiff --git a/unity/Assets/Scripts/UI/BudgetPresenter.cs b/unity/Assets/Scripts/UI/BudgetPresenter.csindex ca75bac5a..bb80b2912 100644--- a/unity/Assets/Scripts/UI/BudgetPresenter.cs+++ b/unity/Assets/Scripts/UI/BudgetPresenter.cs@@ -100,30 +100,47 @@ namespace Statecraft.Game.UIbridge.Queue(new AllocateBudget(new Dictionary<string, double>(draft)));}+ /// <summary>One budget line's row: the ministry and its minister, -, the share, +, and the effect multiplier.</summary>+ VisualElement Row(string office)+ {+ var row = new VisualElement { name = "budget-" + office };+ row.AddToClassList("row");+ var name = new Label { name = "budget-" + office + "-name" };+ name.AddToClassList("grow");+ row.Add(name);+ row.Add(new Button(() => Change(office, -Step)) { name = "budget-" + office + "-down", text = "-" });+ row.Add(new Label { name = "budget-" + office + "-share" });+ row.Add(new Button(() => Change(office, +Step)) { name = "budget-" + office + "-up", text = "+" });+ var factor = new Label { name = "budget-" + office + "-factor" };+ factor.AddToClassList("muted");+ row.Add(factor);+ return row;+ }+public void Render(){var c = bridge.Content; var s = bridge.State;var rows = screen.Q<ScrollView>("budget-rows");- rows.Clear();+ // The rows are made once per set of lines and updated in place, so the + or - button that has the keyboard focus+ // keeps it across a step (accessibility audit #41, H2), as CabinetPresenter does for its cards.+ var lines = c.Rules.BudgetStart.Keys.ToList();+ if (rows.childCount != lines.Count || lines.Where((office, i) => rows[i].name != "budget-" + office).Any())+ {+ rows.Clear();+ foreach (var office in lines) rows.Add(Row(office));+ }// A budget line is keyed by its own id; the office that owns it today can change (rules.yaml budget_owners, #108).- foreach (var office in c.Rules.BudgetStart.Keys)+ for (int i = 0; i < lines.Count; i++){+ var office = lines[i]; var row = rows[i];var o = c.Offices.First(x => x.Id == (Offices.BudgetOwner(c, office, s.Date) ?? office));var share = draft.TryGetValue(office, out var v) ? v : 0;- var row = new VisualElement { name = "budget-" + office };- row.AddToClassList("row");// A budget line can run before its ministry exists (Education from 10 March 1949): say so, not "vacant".var who = o.From.HasValue && s.Date < o.From.Value ? text.Format("budget.not_established", PlayerText.Date(o.From.Value)): Cabinet.Holder(c, s, o.Id)?.Name ?? text["budget.vacant"];- row.Add(new Label(text.Format("budget.office", o.Title, who)) { name = "budget-" + office + "-name" });- row[0].AddToClassList("grow");- row.Add(new Button(() => Change(office, -Step)) { name = "budget-" + office + "-down", text = "-" });- row.Add(new Label(text.Format("budget.share", PlayerText.Percent(share))) { name = "budget-" + office + "-share" });- row.Add(new Button(() => Change(office, +Step)) { name = "budget-" + office + "-up", text = "+" });- var factor = EffectsSystem.BudgetFactor(draft, office);- row.Add(new Label(text.Format("budget.factor", PlayerText.Percent(factor))) { name = "budget-" + office + "-factor" });- row[4].AddToClassList("muted");- rows.Add(row);+ ((Label)row[0]).text = text.Format("budget.office", o.Title, who);+ ((Label)row[2]).text = text.Format("budget.share", PlayerText.Percent(share));+ ((Label)row[4]).text = text.Format("budget.factor", PlayerText.Percent(EffectsSystem.BudgetFactor(draft, office)));}var leg = Offices.Legislature(c, s.Date);var (seats, size) = PoliticsSystem.CoalitionSeats(c, s.Date);diff --git a/unity/Assets/Scripts/UI/CabinetPresenter.cs b/unity/Assets/Scripts/UI/CabinetPresenter.csindex 2590e4513..97855eb45 100644--- a/unity/Assets/Scripts/UI/CabinetPresenter.cs+++ b/unity/Assets/Scripts/UI/CabinetPresenter.cs@@ -27,8 +27,12 @@ namespace Statecraft.Game.UIpublic static readonly Color CoalitionColour = new Color32(92, 138, 200, 255), OppositionColour = new Color32(186, 180, 168, 255);readonly VisualElement screen; readonly SimBridge bridge; readonly UiText text; readonly PortraitCatalog? portraits;- readonly Button pmCard; readonly System.Action onPm;+ readonly Button pmCard; readonly System.Action onPm; readonly EventCallback<GeometryChangedEvent> onPmGeometry;+ string? pmId; VisualElement? pmPortrait;readonly ScrollView list, candidates; readonly VisualElement pmOffices, chips; readonly Hemicycle hemicycle;+ readonly VisualElement side, pick, status; readonly EventCallback<GeometryChangedEvent> onSideGeometry;+ /// <summary>The candidate list's floor where the side column has room: its heading and two rows (#41 M7).</summary>+ public const float PickFloor = 220f;readonly Dictionary<string, Button> cards = new Dictionary<string, Button>();List<string> cardOrder = new List<string>(), pmOrder = new List<string>();readonly Dictionary<string, (Button appoint, Label reason)> rows = new Dictionary<string, (Button, Label)>();@@ -44,9 +48,13 @@ namespace Statecraft.Game.UIhemicycle = screen.Q<Hemicycle>("cabinet-hemicycle");onPm = () => Select(PrimeMinister);pmCard.clicked += onPm;+ onPmGeometry = _ => FramePm();screen.Q<Label>("cabinet-house-unit").text = text["cabinet.members_unit"];bridge.Changed += OnChanged;ScreenNav.OnOpened(screen, () => { if (dirty) Render(); });+ side = screen.Q<VisualElement>("cabinet-side"); pick = screen.Q<VisualElement>("cabinet-pick"); status = screen.Q<VisualElement>("cabinet-status");+ onSideGeometry = _ => FitPick();+ foreach (var e in new[] { side, pmOffices, status }) e.RegisterCallback(onSideGeometry);Render();}@@ -55,6 +63,8 @@ namespace Statecraft.Game.UI{bridge.Changed -= OnChanged;pmCard.clicked -= onPm;+ pmPortrait?.UnregisterCallback(onPmGeometry); pmPortrait = null;+ foreach (var e in new[] { side, pmOffices, status }) e.UnregisterCallback(onSideGeometry);if (screen.userData is System.Action) screen.userData = null;list.Clear(); candidates.Clear(); pmOffices.Clear(); chips.Clear(); PersonCard.Clear(pmCard);cards.Clear(); rows.Clear(); cardOrder.Clear(); pmOrder.Clear(); pickFor = null; chipsFor = "";@@ -120,6 +130,8 @@ namespace Statecraft.Game.UIvar offices = pm == null ? pmSeat.Office.Title: string.Join(text["card.offices_separator"], lineup.Where(x => x.Office.Id == PrimeMinister || HeldByPm(x)).Select(x => x.Office.Title));PersonCard.Fill(pmCard, "seat-" + PrimeMinister, c, s, pm, offices, pmSeat.Appointed, text, portraits, PmPortrait, partyLabel: true);+ pmId = pm?.Id;+ FramePm();}var pmHeld = lineup.Where(HeldByPm).ToList();if (!pmHeld.Select(x => x.Office.Id).SequenceEqual(pmOrder))@@ -166,6 +178,40 @@ namespace Statecraft.Game.UIscreen.Q<Label>("cabinet-status").text = string.Join("\n", queued);}+ /// <summary>The candidate list's floor (#41 M7): PickFloor where the side column has room; on a shorter one (32:9 is+ /// 764 logical px), whatever the Prime Minister's card at its smallest (its text, Statecraft.uss .pm-card min-height),+ /// his other offices and the orders line leave, so the orders line is never pushed out of the screen. Above the floor+ /// the portrait gives way first (Statecraft.uss). Setting it moves only the list and the card, never the column, the+ /// offices or the orders line, so it cannot loop.</summary>+ void FitPick()+ {+ var h = side.contentRect.height;+ if (float.IsNaN(h) || h <= 0) return;+ static float Outer(VisualElement e) => e.resolvedStyle.display == DisplayStyle.None || float.IsNaN(e.layout.height) ? 0f+ : e.layout.height + e.resolvedStyle.marginTop + e.resolvedStyle.marginBottom;+ var card = pmCard.resolvedStyle.minHeight.value + pmCard.resolvedStyle.marginTop + pmCard.resolvedStyle.marginBottom;+ var floor = Mathf.Clamp(h - card - Outer(pmOffices) - Outer(status), 0f, PickFloor);+ if (Mathf.Abs(pick.resolvedStyle.minHeight.value - floor) > 0.5f) pick.style.minHeight = floor;+ }++ /// <summary>The Prime Minister's portrait gives way on a short window (Statecraft.uss, #41 M7), so its framing follows+ /// the box it has now and the face stays in view. It listens on the portrait itself: the box also changes when the+ /// card's text gains or loses a line inside a card of the same height.</summary>+ void FramePm()+ {+ var portrait = pmCard.Q("seat-" + PrimeMinister + "-portrait");+ if (portrait != pmPortrait)+ {+ pmPortrait?.UnregisterCallback(onPmGeometry);+ pmPortrait = portrait;+ pmPortrait?.RegisterCallback(onPmGeometry);+ }+ var entry = portraits?.Find(pmId);+ if (portrait == null || entry == null) return;+ var size = portrait.layout.size;+ PersonCard.Frame(portrait, entry.Value, float.IsNaN(size.x) || size.x <= 0 || size.y <= 0 ? PmPortrait : size);+ }+/// <summary>One card per holder: an office with several holders today (#277: Minister without Portfolio) gets a card for/// each, in Seat.Holders order, named office, office-2, office-3...; every other office one card, named by its id.</summary>static List<(string key, Seat seat, Person? holder)> Cards(IEnumerable<Seat> seats) =>diff --git a/unity/Assets/Scripts/UI/EventCardPresenter.cs b/unity/Assets/Scripts/UI/EventCardPresenter.csindex e18fb4e0a..dbdc4960f 100644--- a/unity/Assets/Scripts/UI/EventCardPresenter.cs+++ b/unity/Assets/Scripts/UI/EventCardPresenter.cs@@ -48,6 +48,7 @@ namespace Statecraft.Game.UI/// <summary>Events whose clip failed this session: they show the photograph and no switch.</summary>readonly System.Collections.Generic.HashSet<string> failed = new System.Collections.Generic.HashSet<string>();readonly System.Action onSwitch;+ readonly PressSource presses;/// <summary>The event the player collapsed the card on (Hide), or null; a different event opens the card again.</summary>string? collapsedFor;/// <summary>The event whose first option last took the focus, so an event already open never takes it again.</summary>@@ -92,6 +93,7 @@ namespace Statecraft.Game.UIforeach (var e in new[] { band, credit, head, scroll, options }) e.RegisterCallback<GeometryChangedEvent>(OnPhotoGeometry);layer.RegisterCallback<GeometryChangedEvent>(OnColumnGeometry);card.RegisterCallback<GeometryChangedEvent>(OnCardGeometry);+ presses = new PressSource(options);bridge.Changed += Render;Render();}@@ -109,6 +111,7 @@ namespace Statecraft.Game.UIforeach (var e in new[] { band, credit, head, scroll, options }) e.UnregisterCallback<GeometryChangedEvent>(OnPhotoGeometry);layer.UnregisterCallback<GeometryChangedEvent>(OnColumnGeometry);card.UnregisterCallback<GeometryChangedEvent>(OnCardGeometry);+ presses.Dispose();card.Q<VisualElement>("event-options")?.Clear(); card.style.display = DisplayStyle.None;reopen.style.display = DisplayStyle.None;hudRoot.RemoveFromClassList(OpenClass);@@ -364,8 +367,10 @@ namespace Statecraft.Game.UIvoid Choose(GameEvent e, EventOption o){- // The bridge raises Refused (the toast shows it) or Changed (the toast clears); nothing more to do here.+ // The bridge raises Refused (the toast shows it) or Changed (the toast clears and Render shows the next event,+ // which takes the focus). Answered from the keyboard with no event left, the focus goes to End Turn (#41 M1).bridge.Queue(new ChooseEventOption(e.Id, o.Id));+ if (Shown == null && presses.ByKeyboard) FocusReturn.To(hudRoot.Q<Button>("end-turn"));}}}diff --git a/unity/Assets/Scripts/UI/FocusReturn.cs b/unity/Assets/Scripts/UI/FocusReturn.csnew file mode 100644index 000000000..10762dff2--- /dev/null+++ b/unity/Assets/Scripts/UI/FocusReturn.cs@@ -0,0 +1,50 @@+#nullable enable+using UnityEngine.UIElements;++namespace Statecraft.Game.UI+{+ /// <summary>Gives the keyboard focus to a sensible control when the one that had it goes away (accessibility audit,+ /// #41 M1): the start screen closing, the last open event answered, Escape from a screen. Without it nothing has the+ /// focus and the next Tab starts again at Cabinet.</summary>+ public static class FocusReturn+ {+ /// <summary>Focuses <paramref name="target"/> now, and once more when styles have resolved if by then nothing has the+ /// focus (a control that was hidden or disabled a moment ago cannot take it yet). A control that takes the focus+ /// meanwhile (the decision card when its cover closes) keeps it.</summary>+ public static void To(VisualElement? target)+ {+ if (target?.panel == null) return;+ target.Focus();+ target.schedule.Execute(() => { if (target.panel != null && target.focusController?.focusedElement == null) target.Focus(); });+ }+ }++ /// <summary>Whether the last press inside an element came from the keyboard (Enter or Space: NavigationSubmitEvent) or+ /// the pointer. A pointer press moves no focus anywhere (PointerBlur's rule: a mouse click leaves no focus fill behind),+ /// so a presenter asks this before it hands the focus on.</summary>+ public sealed class PressSource : System.IDisposable+ {+ readonly VisualElement scope;+ readonly EventCallback<PointerDownEvent> onPointer;+ readonly EventCallback<NavigationSubmitEvent> onSubmit;+ bool pointer;++ public PressSource(VisualElement scope)+ {+ this.scope = scope;+ onPointer = _ => pointer = true;+ onSubmit = _ => pointer = false;+ scope.RegisterCallback(onPointer, TrickleDown.TrickleDown);+ scope.RegisterCallback(onSubmit, TrickleDown.TrickleDown);+ }++ /// <summary>True unless the last press in the element was a pointer press.</summary>+ public bool ByKeyboard => !pointer;++ public void Dispose()+ {+ scope.UnregisterCallback(onPointer, TrickleDown.TrickleDown);+ scope.UnregisterCallback(onSubmit, TrickleDown.TrickleDown);+ }+ }+}diff --git a/unity/Assets/Scripts/UI/FocusReturn.cs.meta b/unity/Assets/Scripts/UI/FocusReturn.cs.metanew file mode 100644index 000000000..e42c5a4da--- /dev/null+++ b/unity/Assets/Scripts/UI/FocusReturn.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 7315b19cd29b4e8aae7e9ee077b8286ediff --git a/unity/Assets/Scripts/UI/PersonCard.cs b/unity/Assets/Scripts/UI/PersonCard.csindex 8a691b975..f54c587e8 100644--- a/unity/Assets/Scripts/UI/PersonCard.cs+++ b/unity/Assets/Scripts/UI/PersonCard.cs@@ -57,8 +57,7 @@ namespace Statecraft.Game.UIif (tex != null){portrait.style.backgroundImage = new StyleBackground(tex);- portrait.style.backgroundPositionY = new BackgroundPosition(BackgroundPositionKeyword.Top,- new Length(PortraitFraming.PositionYPercent(tex.width, tex.height, portraitSize.x, portraitSize.y, entry!.Value.focusY), LengthUnit.Percent));+ Frame(portrait, entry!.Value, portraitSize);}else portrait.style.backgroundImage = StyleKeyword.None;portrait.style.display = tex != null ? DisplayStyle.Flex : DisplayStyle.None; // never an invented portrait@@ -84,6 +83,11 @@ namespace Statecraft.Game.UISetStat(card, prefix + "-loyalty", person.Loyalty);}+ /// <summary>Keeps the face in view in a portrait box of <paramref name="size"/> logical pixels (PortraitFraming).</summary>+ public static void Frame(VisualElement portrait, PortraitCatalog.Entry entry, Vector2 size) =>+ portrait.style.backgroundPositionY = new BackgroundPosition(BackgroundPositionKeyword.Top,+ new Length(PortraitFraming.PositionYPercent(entry.image.width, entry.image.height, size.x, size.y, entry.focusY), LengthUnit.Percent));+/// <summary>Empties a card (a disposed screen keeps no stale person or texture).</summary>public static void Clear(VisualElement card) => card.Clear();diff --git a/unity/Assets/Scripts/UI/ScreenNav.cs b/unity/Assets/Scripts/UI/ScreenNav.csindex 1755e097b..62cb28676 100644--- a/unity/Assets/Scripts/UI/ScreenNav.cs+++ b/unity/Assets/Scripts/UI/ScreenNav.cs@@ -96,11 +96,17 @@ namespace Statecraft.Game.UIDisableCovered(root);}- /// <summary>Closes the open screen (Escape); false when none was open.</summary>+ /// <summary>Closes the open screen (Escape); false when none was open. When the focus was on the screen's contents it+ /// goes to the screen's top-bar button, so the next Tab carries on from there (#41 M1); an open decision card+ /// takes it instead (EventCardPresenter, when its cover closes).</summary>public bool Close(){if (Current == null) return false;+ var screen = root.Q<VisualElement>("screen-" + Current); var button = root.Q<Button>("nav-" + Current);+ var focused = root.panel?.focusController?.focusedElement as VisualElement;+ var inside = focused != null && (focused == screen || screen.Contains(focused));Open(null);+ if (inside && !(root.Q("root") ?? root).ClassListContains(EventCardPresenter.ModalClass)) FocusReturn.To(button);return true;}diff --git a/unity/Assets/Scripts/UI/StartScreenPresenter.cs b/unity/Assets/Scripts/UI/StartScreenPresenter.csindex f330a730c..d3d609a6c 100644--- a/unity/Assets/Scripts/UI/StartScreenPresenter.cs+++ b/unity/Assets/Scripts/UI/StartScreenPresenter.cs@@ -50,6 +50,7 @@ namespace Statecraft.Game.UIreadonly EventCallback<NavigationCancelEvent> onCancel;readonly EventCallback<GeometryChangedEvent> onGeometry;readonly Action onContinue, onNewGame, onStarted;+ readonly PressSource presses;/// <summary>Continue is offered: the session continues the autosave.</summary>public bool Resumed { get; private set; }@@ -81,6 +82,7 @@ namespace Statecraft.Game.UIonGeometry = _ => Fit();screen.RegisterCallback(onGeometry);panel.RegisterCallback(onGeometry); // the panel's height decides where it goes+ presses = new PressSource(screen);}public bool IsOpen => hudRoot.ClassListContains(OpenClass);@@ -101,15 +103,22 @@ namespace Statecraft.Game.UIshownChanged?.Invoke(true);}- /// <summary>Hides the screen; the game is on the map. Safe to call when it is not open.</summary>- public void Close()+ /// <summary>Hides the screen; the game is on the map. Safe to call when it is not open. Closed from the keyboard, the+ /// focus goes to End Turn (#41 M1), unless a decision card is open: the card takes it (EventCardPresenter).</summary>+ public void Close() => Hide(giveFocus: true);++ void Hide(bool giveFocus){if (!IsOpen) return;recording?.Stop();hudRoot.RemoveFromClassList(OpenClass);ScreenNav.DisableCovered(hudRoot);var focused = screen.focusController?.focusedElement as VisualElement;- if (focused != null && screen.Contains(focused)) focused.Blur();+ if (focused != null && screen.Contains(focused))+ {+ focused.Blur();+ if (giveFocus && presses.ByKeyboard && !hudRoot.ClassListContains(EventCardPresenter.OpenClass)) FocusReturn.To(hudRoot.Q<Button>("end-turn"));+ }shownChanged?.Invoke(false);}@@ -167,7 +176,8 @@ namespace Statecraft.Game.UIpublic void Dispose(){- Close();+ Hide(giveFocus: false);+ presses.Dispose();continueButton.clicked -= onContinue;newGameButton.clicked -= onNewGame;newGame.Started -= onStarted;diff --git a/unity/Assets/Tests/EditMode/DecisionCardTests.cs b/unity/Assets/Tests/EditMode/DecisionCardTests.csindex 143221e77..57d654734 100644--- a/unity/Assets/Tests/EditMode/DecisionCardTests.cs+++ b/unity/Assets/Tests/EditMode/DecisionCardTests.cs@@ -302,4 +302,57 @@ public class DecisionCardTestsAssert.IsFalse(r.Card.Escape(), "under a screen Escape is the screen's");Assert.IsFalse(r.Card.Collapsed);}++ /// <summary>#41 M1: the last open event answered with the mouse hands no focus on (PointerBlur's rule), so End Turn is+ /// not lit.</summary>+ [UnityTest]+ public IEnumerator AnsweringTheLastEventWithThePointerFocusesNothing()+ {+ using var r = new Rig(1920, 1080, "law_of_return");+ yield return Frames(4);+ PressWithPointer(r.FirstOption);+ yield return Frames(3);+ Assert.IsNull(r.Card.Shown, "precondition: the click answered the only event");+ Assert.AreNotSame(r.Root.Q<Button>("end-turn"), r.Focused, "End Turn is not lit by a mouse click");+ }++ /// <summary>A mouse press as the player makes it: pointer down (which also gives the button the focus), then the+ /// button's Clickable fires `clicked` on pointer up. UiTestKit.Press is the keyboard's Submit instead.</summary>+ static void PressWithPointer(Button b)+ {+ b.Focus();+ using (var down = PointerDownEvent.GetPooled()) { down.target = b; b.SendEvent(down); }+ using var click = ClickEvent.GetPooled();+ click.target = b;+ typeof(Clickable).GetMethod("Invoke", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic,+ null, new[] { typeof(EventBase) }, null)!.Invoke(b.clickable, new object[] { click });+ }++ /// <summary>#41 M1: Escape from a screen over an open card gives the card the focus (not the screen's button), and the+ /// last open event answered from the keyboard gives it to End Turn, so the next Enter or Tab goes on from there.</summary>+ [UnityTest]+ public IEnumerator AnsweringTheLastEventByKeyboardFocusesEndTurn()+ {+ using var r = new Rig(1920, 1080, "law_of_return");+ yield return Frames(4);+ r.Nav.Open("budget");+ yield return Frames(3);+ var reset = r.Root.Q<Button>("budget-reset");+ reset.Focus();+ yield return Frames(2);+ Assert.AreSame(reset, r.Focused, "precondition: a control on the screen has the focus");+ using (var cancel = NavigationCancelEvent.GetPooled()) { cancel.target = reset; reset.SendEvent(cancel); }+ yield return Frames(3);+ Assert.IsNull(r.Nav.Current);+ Assert.AreSame(r.CardElement, r.Focused, "the open card takes the focus when the screen over it closes");++ var option = r.FirstOption;+ option.Focus();+ yield return Frames(2);+ Assert.AreSame(option, r.Focused, "precondition: an option has the focus");+ Press(option);+ yield return Frames(3);+ Assert.IsNull(r.Card.Shown, "the only event is answered");+ Assert.AreSame(r.Root.Q<Button>("end-turn"), r.Focused, "End Turn has the focus");+ }}diff --git a/unity/Assets/Tests/EditMode/KeyboardFocusTests.cs b/unity/Assets/Tests/EditMode/KeyboardFocusTests.csnew file mode 100644index 000000000..9db32c1ad--- /dev/null+++ b/unity/Assets/Tests/EditMode/KeyboardFocusTests.cs@@ -0,0 +1,325 @@+#nullable enable+using System;+using System.Collections;+using System.Collections.Generic;+using System.Linq;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;+using Object = UnityEngine.Object;++/// <summary>The small fixes from the accessibility audit (docs/accessibility-audit-2026-10-14.md, #41): a Budget step keeps+/// the focus on its button (H2); Escape from a screen gives the focus to its top-bar button (M1); text on the keyboard+/// focus fill and the lit escalation rung's turn line reach 4.5:1 (M3, M4); the Cabinet's orders line is not cut off and+/// its candidate list keeps two rows at the playtest window, 1568x752 (M7). The start screen and the decision card's own+/// cases of M1 are in StartScreenTests and DecisionCardTests.</summary>+public class KeyboardFocusTests+{+ static readonly Content C = ContentLoader.Load(Paths.Content);+ static UiText Text => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);++ /// <summary>Game.uxml on a panel that renders into a texture of the window's size, so layout, style and focus run as in+ /// a player once frames pass.</summary>+ sealed class Panel : IDisposable+ {+ readonly GameObject go; readonly PanelSettings ps; readonly RenderTexture rt;+ public readonly VisualElement Root;+ public readonly List<IDisposable> Owned = new List<IDisposable>();++ public Panel(int w = 1920, int h = 1080)+ {+ rt = new RenderTexture(w, h, 0);+ ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));+ ps.targetTexture = rt;+ go = new GameObject("KeyboardFocusTest");+ go.SetActive(false);+ var doc = go.AddComponent<UIDocument>();+ doc.panelSettings = ps;+ doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml);+ go.SetActive(true);+ Root = doc.rootVisualElement;+ Root.Q("root").RemoveFromClassList("loading");+ }++ public T Q<T>(string name) where T : VisualElement+ {+ var e = Root.Q<T>(name);+ Assert.IsNotNull(e, name);+ return e;+ }++ public Focusable? Focused => Root.panel.focusController.focusedElement;++ public void Dispose()+ {+ for (int i = Owned.Count - 1; i >= 0; i--) Owned[i].Dispose();+ Object.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt);+ }+ }++ static IEnumerator Frames(int n) { for (int i = 0; i < n; i++) yield return null; }++ static IEnumerator FocusOn(Panel p, VisualElement e)+ {+ e.Focus();+ for (int i = 0; i < 10 && p.Focused != e; i++) { yield return null; e.Focus(); }+ }++ /// <summary>H2: Enter on a Budget + or - moves the share and leaves the focus on the same button, so a second Enter+ /// steps again and Tab carries on from the row (it used to start again at Cabinet).</summary>+ [UnityTest]+ public IEnumerator ABudgetStepKeepsTheFocusOnItsButton()+ {+ using var p = new Panel();+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);+ p.Owned.Add(new BudgetPresenter(p.Root, bridge, Text));+ var nav = new ScreenNav(p.Root); p.Owned.Add(nav);+ nav.Open("budget");+ yield return Frames(4);+ var share = p.Q<Label>("budget-education_minister-share");+ foreach (var name in new[] { "budget-education_minister-up", "budget-education_minister-down" })+ {+ var b = p.Q<Button>(name);+ yield return FocusOn(p, b);+ Assert.AreSame(b, p.Focused, name + ": precondition, focused");+ for (int press = 1; press <= 2; press++)+ {+ var before = share.text;+ UiTestKit.Press((Button)p.Focused!);+ yield return Frames(2);+ Assert.AreNotEqual(before, share.text, $"{name}, press {press}: the share moved");+ Assert.AreSame(share, p.Root.Q<Label>("budget-education_minister-share"), "the row is updated in place");+ Assert.AreSame(b, p.Root.Q<Button>(name), $"{name}, press {press}: the button is the same element");+ Assert.AreSame(b, p.Focused, $"{name}, press {press}: and keeps the focus");+ }+ }+ }++ /// <summary>M1: Escape from a screen whose contents had the focus gives it to the screen's top-bar button, so Tab carries+ /// on from there; Escape with the focus on the top bar leaves it where it is.</summary>+ [UnityTest]+ public IEnumerator EscapeFromAScreenGivesTheFocusToItsButton()+ {+ using var p = new Panel();+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);+ p.Owned.Add(new BudgetPresenter(p.Root, bridge, Text));+ p.Owned.Add(new DefencePresenter(p.Root, bridge, Text));+ var nav = new ScreenNav(p.Root); p.Owned.Add(nav);+ foreach (var screen in new[] { "budget", "defence" })+ {+ nav.Open(screen);+ yield return Frames(4);+ var inside = p.Root.Q("screen-" + screen).Query<Button>().ToList().First(b => b.enabledInHierarchy);+ yield return FocusOn(p, inside);+ Assert.AreSame(inside, p.Focused, screen + ": precondition, a control on the screen has the focus");+ using (var e = NavigationCancelEvent.GetPooled()) { e.target = inside; inside.SendEvent(e); }+ yield return Frames(3);+ Assert.IsNull(nav.Current, screen + ": Escape closed it");+ Assert.AreSame(p.Q<Button>("nav-" + screen), p.Focused, screen + ": its top-bar button has the focus");+ }+ var endTurn = p.Q<Button>("end-turn");+ nav.Open("budget");+ yield return Frames(3);+ yield return FocusOn(p, endTurn);+ Assert.IsTrue(nav.Close());+ yield return Frames(3);+ Assert.AreSame(endTurn, p.Focused, "the focus was on the top bar: it stays there");+ }++ /// <summary>WCAG relative luminance, sRGB.</summary>+ static float Lum(Color c)+ {+ float Ch(float v) => v <= 0.04045f ? v / 12.92f : Mathf.Pow((v + 0.055f) / 1.055f, 2.4f);+ return 0.2126f * Ch(c.r) + 0.7152f * Ch(c.g) + 0.0722f * Ch(c.b);+ }++ static float Ratio(Color a, Color b) { float x = Lum(a), y = Lum(b); return (Mathf.Max(x, y) + 0.05f) / (Mathf.Min(x, y) + 0.05f); }++ /// <summary>What shows behind <paramref name="e"/>: its own background and every ancestor's, composited in linear light+ /// (the project's colour space) down to the first opaque one, or the HUD's navy.</summary>+ static Color Backdrop(VisualElement e)+ {+ var layers = new List<Color>();+ for (var v = e; v != null; v = v.parent)+ {+ var bg = v.resolvedStyle.backgroundColor;+ if (bg.a <= 0f) continue;+ layers.Add(bg);+ if (bg.a >= 1f) break;+ }+ var under = new Color(9 / 255f, 14 / 255f, 26 / 255f).linear;+ for (int i = layers.Count - 1; i >= 0; i--)+ {+ var l = layers[i]; var lin = l.linear;+ under = new Color(lin.r * l.a + under.r * (1 - l.a), lin.g * l.a + under.g * (1 - l.a), lin.b * l.a + under.b * (1 - l.a));+ }+ return under.gamma;+ }++ /// <summary>Computed contrast the focus-fill text must reach: 4.5:1 plus a margin, because anti-aliasing on the canvas+ /// takes about 0.4 off (ink at 4.60:1 computed measured 4.16 to 4.21:1 on the audit's captures).</summary>+ const float FocusTextRatio = 5f;++ /// <summary>M3: the label of every kind of button is at least 4.5:1 on the keyboard focus fill, with margin+ /// (FocusTextRatio), the gold ones (End Turn, Decision waiting, the Illustration switch) included, and every text on a+ /// focused Cabinet card too, its stat numbers included.</summary>+ [UnityTest]+ public IEnumerator TextOnTheFocusFillIsAtLeastFourPointFiveToOne()+ {+ using var p = new Panel();+ var host = new VisualElement();+ host.style.position = Position.Absolute; host.style.left = 40; host.style.top = 200;+ p.Q<VisualElement>("root").Add(host);+ var kinds = new[] { "", "end-turn", "event-reopen", "event-illustration", EventCardPresenter.OptionClass, "pm-office" };+ var buttons = kinds.Select(k =>+ {+ var b = new Button { text = "Focused " + k, name = "probe-" + (k == "" ? "plain" : k) };+ if (k != "") b.AddToClassList(k);+ // Decision waiting and the Illustration switch are hidden and absolutely placed by the stylesheet until shown.+ b.style.display = DisplayStyle.Flex; b.style.position = Position.Relative;+ host.Add(b);+ return b;+ }).ToList();+ yield return Frames(3);+ foreach (var b in buttons)+ {+ yield return FocusOn(p, b);+ yield return Frames(2);+ Assert.AreSame(b, p.Focused, b.name + ": focused");+ var fill = b.resolvedStyle.backgroundColor;+ Assert.AreEqual(1f, fill.a, 0.001f, b.name + ": the focus fill is opaque");+ var ratio = Ratio(b.resolvedStyle.color, fill);+ Assert.GreaterOrEqual(ratio, FocusTextRatio, $"{b.name}: its label is {ratio:0.00}:1 on the focus fill");+ }++ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);+ p.Owned.Add(new CabinetPresenter(p.Root, bridge, Text, null));+ var nav = new ScreenNav(p.Root); p.Owned.Add(nav);+ nav.Open("cabinet");+ yield return Frames(4);+ foreach (var name in new[] { "seat-prime_minister", "seat-finance_minister" })+ {+ var card = p.Q<Button>(name);+ yield return FocusOn(p, card);+ yield return Frames(2);+ var fill = card.resolvedStyle.backgroundColor;+ foreach (var label in card.Query<Label>().ToList().Where(l => !string.IsNullOrEmpty(l.text) && l.resolvedStyle.display == DisplayStyle.Flex+ && l.GetFirstAncestorOfType<VisualElement>()?.ClassListContains("card-plate") != true))+ {+ var ratio = Ratio(label.resolvedStyle.color, fill);+ Assert.GreaterOrEqual(ratio, FocusTextRatio, $"{name}: '{label.text}' is {ratio:0.00}:1 on the focus fill");+ }+ }+ }++ /// <summary>M4: on the lit (current) escalation rung both the rung's name and its turn length are at least 4.5:1; on+ /// every plain rung the 15 px turn length is at least 5.5:1 computed, the margin anti-aliasing takes from it (ink-dim's+ /// 5.0:1 measured 4.0 to 4.2:1).</summary>+ [UnityTest]+ public IEnumerator TheLitRungsTextIsAtLeastFourPointFiveToOne()+ {+ using var p = new Panel();+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);+ p.Owned.Add(new DefencePresenter(p.Root, bridge, Text));+ var nav = new ScreenNav(p.Root); p.Owned.Add(nav);+ nav.Open("defence");+ yield return Frames(4);+ var rung = p.Q<VisualElement>("rung-" + bridge.State.Rung);+ Assert.IsTrue(rung.ClassListContains("rung-current"), "precondition: today's rung is lit");+ var back = Backdrop(rung);+ foreach (var part in new[] { "name", "turn" })+ {+ var label = p.Q<Label>($"rung-{bridge.State.Rung}-{part}");+ var ratio = Ratio(label.resolvedStyle.color, back);+ Assert.GreaterOrEqual(ratio, 4.5f, $"the lit rung's {part} '{label.text}' is {ratio:0.00}:1");+ }+ for (int n = 1; n <= 5; n++)+ {+ if (n == bridge.State.Rung) continue;+ var plain = p.Q<VisualElement>("rung-" + n);+ var turn = p.Q<Label>($"rung-{n}-turn");+ var ratio = Ratio(turn.resolvedStyle.color, Backdrop(plain));+ Assert.GreaterOrEqual(ratio, 5.5f, $"rung {n}'s turn '{turn.text}' is {ratio:0.00}:1");+ }+ }++ /// <summary>M7: at the playtest window (1568x752) and four others, with an appointment ordered, the "Ordered:" line wraps+ /// inside the side column and the screen instead of being cut off, and the candidate list shows at least two rows; on+ /// the shortest the HUD supports (5120x1440, 32:9, 764 logical px) at least one. The Prime Minister's card never runs+ /// into the line under it. At 764 the card's text, his other offices and the orders line leave the list less than a+ /// row; it still shows some and scrolls.</summary>+ [UnityTest]+ public IEnumerator TheCabinetsOrdersLineAndCandidatesHaveRoom()+ {+ foreach (var (w, h, rowsShown) in new[] { (1568, 752, 2), (1531, 784, 2), (1920, 1080, 2), (2560, 1080, 2), (5120, 1440, 0) })+ {+ using var p = new Panel(w, h);+ var where = $"{w}x{h}";+ for (int i = 0; i < 20 && !(p.Root.Q("top-bar").worldBound.width > 0); i++) yield return null;+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);+ p.Owned.Add(new HudPresenter(p.Root, bridge, Text));+ var portraits = AssetDatabase.LoadAssetAtPath<PortraitCatalog>("Assets/UI/Portraits/PortraitCatalog.asset");+ Assert.IsNotNull(portraits, "the portrait catalogue");+ var cabinet = new CabinetPresenter(p.Root, bridge, Text, portraits); p.Owned.Add(cabinet);+ var nav = new ScreenNav(p.Root); p.Owned.Add(nav);+ nav.Open("cabinet");+ cabinet.Select("finance_minister");+ yield return Frames(4);+ var appoint = p.Q<ScrollView>("cabinet-candidates").Query<Button>().ToList().First(b => b.enabledSelf);+ UiTestKit.Press(appoint);+ Assert.AreEqual(1, bridge.Queued.OfType<Appoint>().Count(), where + ": precondition, an appointment is ordered");+ yield return Frames(4);++ var status = p.Q<Label>("cabinet-status");+ StringAssert.StartsWith("Ordered: ", status.text);+ var side = p.Q<VisualElement>("cabinet-side").worldBound;+ var screenEl = p.Q<VisualElement>("screen-cabinet");+ var s = screenEl.resolvedStyle;+ var inner = screenEl.worldBound;+ var bottom = inner.yMax - s.borderBottomWidth - s.paddingBottom;+ var r = status.worldBound;+ var sizes = $"side {side.height:0}, card {p.Q<VisualElement>("seat-" + CabinetPresenter.PrimeMinister).worldBound.height:0}, offices {p.Q<VisualElement>("cabinet-pm-offices").worldBound.height:0}, pick {p.Q<VisualElement>("cabinet-pick").worldBound.height:0}, status {r.height:0}";+ where += $" ({sizes})";+ Assert.LessOrEqual(r.xMax, side.xMax + 0.5f, $"{where}: the orders line {r} runs out of the side column {side}");+ Assert.LessOrEqual(r.yMax, bottom + 0.5f, $"{where}: the orders line {r} runs below the screen's content ({bottom:0})");+ var width = status.contentRect.width;+ var natural = status.MeasureTextSize(status.text, width, VisualElement.MeasureMode.Exactly, 0, VisualElement.MeasureMode.Undefined);+ Assert.LessOrEqual(natural.y, status.contentRect.height + 1f, $"{where}: '{status.text}' needs {natural.y:0} px and has {status.contentRect.height:0}");+ var oneLine = status.MeasureTextSize(status.text, 0, VisualElement.MeasureMode.Undefined, 0, VisualElement.MeasureMode.Undefined);+ if (oneLine.x > width + 1f) Assert.AreEqual(WhiteSpace.Normal, status.resolvedStyle.whiteSpace, $"{where}: a line wider than the column wraps");++ var list = p.Q<ScrollView>("cabinet-candidates");+ var view = list.contentViewport.worldBound;+ if (rowsShown > 0)+ {+ var rows = list.Query<VisualElement>(className: "candidate").ToList().Take(rowsShown).ToList();+ Assert.AreEqual(rowsShown, rows.Count);+ var need = rows[rowsShown - 1].worldBound.yMax - rows[0].worldBound.yMin;+ Assert.GreaterOrEqual(view.height + 0.5f, need, $"{where}: the candidate list is {view.height:0} px tall and {rowsShown} rows need {need:0}");+ }+ else Assert.GreaterOrEqual(view.height, 40f, $"{where}: the candidate list still shows part of a row");+ var pmCard = p.Q<VisualElement>("seat-" + CabinetPresenter.PrimeMinister);+ var lastLine = pmCard.Children().Where(e => e.resolvedStyle.display == DisplayStyle.Flex).Last().worldBound;+ Assert.LessOrEqual(lastLine.yMax, pmCard.worldBound.yMax + 0.5f, $"{where}: the Prime Minister's card text {lastLine} runs out of the card {pmCard.worldBound}");+ Assert.LessOrEqual(pmCard.worldBound.yMax, p.Q<VisualElement>("cabinet-pm-offices").worldBound.yMin + 0.5f, $"{where}: the card runs into his other offices");+ Assert.LessOrEqual(view.yMax, r.yMin + 0.5f, $"{where}: the list runs into the orders line");++ // A portrait that gave way is framed for the box it has, so the face stays in view.+ var pm = Cabinet.Holder(C, bridge.State, CabinetPresenter.PrimeMinister)!;+ var entry = portraits.Find(pm.Id);+ Assert.IsNotNull(entry, "precondition: the Prime Minister has a portrait");+ var portrait = p.Q<VisualElement>("seat-" + CabinetPresenter.PrimeMinister + "-portrait");+ var box = portrait.layout.size;+ if (box.y >= 1f) // at 764 the portrait has given way entirely: nothing to frame+ {+ var expected = PortraitFraming.PositionYPercent(entry!.Value.image.width, entry.Value.image.height, box.x, box.y, entry.Value.focusY);+ Assert.AreEqual(expected, portrait.style.backgroundPositionY.value.offset.value, 0.5f, $"{where}: the portrait is framed for its {box} box");+ }+ }+ }+}diff --git a/unity/Assets/Tests/EditMode/KeyboardFocusTests.cs.meta b/unity/Assets/Tests/EditMode/KeyboardFocusTests.cs.metanew file mode 100644index 000000000..d0175d45f--- /dev/null+++ b/unity/Assets/Tests/EditMode/KeyboardFocusTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 8c8ff980541440598920945b26b8cfeadiff --git a/unity/Assets/Tests/EditMode/StartScreenTests.cs b/unity/Assets/Tests/EditMode/StartScreenTests.csindex 230510ed0..266b662d0 100644--- a/unity/Assets/Tests/EditMode/StartScreenTests.cs+++ b/unity/Assets/Tests/EditMode/StartScreenTests.cs@@ -358,6 +358,52 @@ public class StartScreenTestsAssert.IsTrue(rig.Ui.Q<Button>("end-turn").canGrabFocus, "the HUD is back");}+ /// <summary>#41 M1: closed from the keyboard (New Game with no save, or Continue), the screen gives the focus to End Turn+ /// rather than to nothing, so the next Tab or Enter goes on from the top bar.</summary>+ [UnityTest]+ public IEnumerator ClosingItFromTheKeyboardFocusesEndTurn()+ {+ foreach (var save in new[] { false, true })+ {+ using var rig = new Rig(save ? WithSave(TempStore(), 1) : TempStore());+ yield return null; yield return null;+ var name = save ? "start-continue" : "start-new-game";+ var button = rig.Ui.Q<Button>(name);+ button.Focus();+ yield return null;+ Assert.AreSame(button, rig.Ui.Root.focusController?.focusedElement, name + ": precondition, focused");+ rig.Ui.Press(name);+ yield return null; yield return null; yield return null;+ Assert.IsFalse(rig.Start.IsOpen, name + ": closed");+ Assert.AreSame(rig.Ui.Q<Button>("end-turn"), rig.Ui.Root.focusController?.focusedElement, name + ": End Turn has the focus");+ }+ }++ /// <summary>#41 M1: closed with the mouse, the screen hands no focus on (PointerBlur's rule: a click leaves no focus+ /// fill behind), so End Turn is not lit.</summary>+ [UnityTest]+ public IEnumerator ClosingItWithThePointerFocusesNothing()+ {+ using var rig = new Rig(TempStore());+ yield return null; yield return null;+ PressWithPointer(rig.Ui.Q<Button>("start-new-game"));+ yield return null; yield return null; yield return null;+ Assert.IsFalse(rig.Start.IsOpen, "precondition: the click closed the screen");+ Assert.AreNotSame(rig.Ui.Q<Button>("end-turn"), rig.Ui.Root.focusController?.focusedElement, "End Turn is not lit by a mouse click");+ }++ /// <summary>A mouse press as the player makes it: pointer down (which also gives the button the focus), then the+ /// button's Clickable fires `clicked` on pointer up. UiTestKit.Press is the keyboard's Submit instead.</summary>+ static void PressWithPointer(Button b)+ {+ b.Focus();+ using (var down = PointerDownEvent.GetPooled()) { down.target = b; b.SendEvent(down); }+ using var click = ClickEvent.GetPooled();+ click.target = b;+ typeof(Clickable).GetMethod("Invoke", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic,+ null, new[] { typeof(EventBase) }, null)!.Invoke(b.clickable, new object[] { click });+ }+/// <summary>#400: a turn-1 save keeps the build buttons disabled anyway, so the test above cannot see them. With a save/// from after August 1950, a selected hex and an event waiting, the build buttons and the event's options are live, and/// still none of them takes the focus under the start screen.diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex 203844085..d221acd3f 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -14,6 +14,7 @@--up: rgb(126, 196, 120);--down: rgb(222, 120, 104);--focus: rgb(120, 98, 58); /* keyboard focus fill: >= 3:1 against --navy-deep (WCAG 2.4.13) */+ --focus-ink: rgb(255, 252, 244); /* text on the focus fill: 5.7:1 on it (ink is 4.6, gold-light 3.7; #41 M3) */}.root {@@ -60,7 +61,7 @@}Button:hover { border-color: var(--gold); background-color: var(--navy-raised); }/* Keyboard focus shows as a bright gold edge (navigation with Tab and the arrow keys). */-Button:focus { border-color: var(--gold-light); background-color: var(--focus); }+Button:focus { border-color: var(--gold-light); background-color: var(--focus); color: var(--focus-ink); }Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4); background-color: var(--navy-deep); }/* A screen button stays transparent around its disc in every state. */.nav-button:disabled, .nav-button:focus { background-color: rgba(0, 0, 0, 0); border-width: 0; }@@ -361,8 +362,9 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);.seat-selected { border-color: var(--gold-light); background-color: var(--navy-raised); }.seat-vacant .card-name { color: var(--ink-dim); }.appointed { color: var(--gold); }-/* A keyboard-focused card takes the warm focus fill (Button:focus); its dim and gold text turn ink to stay legible on it. */-.seat:focus .card-name, .seat:focus .card-office, .seat:focus .card-party, .seat:focus .card-stat-name, .seat:focus .card-initials { color: var(--ink); }+/* A keyboard-focused card takes the warm focus fill (Button:focus); its dim and gold text turn light to stay legible on it. */+.seat:focus .card-name, .seat:focus .card-office, .seat:focus .card-party, .seat:focus .card-stat-name, .seat:focus .card-stat-value,+.seat:focus .card-initials { color: var(--focus-ink); }/* The Cabinet: the Prime Minister's card and the appointment list at the side; the house and the cards in the main column. */.cabinet-side { width: 300px; flex-shrink: 0; margin-right: 14px; }@@ -375,10 +377,18 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);.pm-card .card-stat { height: 26px; padding: 0 16px; }.pm-card .card-stat-name { font-size: 16px; width: 96px; }.pm-card .ui-bar { height: 10px; }-#cabinet-pick { flex-shrink: 1; min-height: 0; }+/* On a short window (1568x752 is 997 logical px tall) the side column is full. The orders line wraps and is never+ squeezed; the candidate list keeps its heading and two rows (220 px), and the Prime Minister's portrait gives way,+ down to the card's text. On a shorter one (32:9 is 764 px) CabinetPresenter.FitPick lowers the list's floor to the room+ left (#41 M7). */+.pm-card { flex-shrink: 1; min-height: 160px; }+.pm-card > * { flex-shrink: 0; }+.pm-card .card-plate { flex-shrink: 1; min-height: 0; }+#cabinet-pick { flex-grow: 1; flex-shrink: 1; min-height: 220px; }+#cabinet-status { white-space: normal; flex-shrink: 0; }/* The Appoint heading wraps rather than run past the 300 px side column (B5; PromoHudTests.TheAppointHeadingHasRoom). */#cabinet-pick-title { white-space: normal; }-.pm-offices { flex-direction: row; flex-wrap: wrap; margin: -2px 0 8px 0; }+.pm-offices { flex-direction: row; flex-wrap: wrap; margin: -2px 0 8px 0; flex-shrink: 0; }.pm-office { font-size: 15px; padding: 3px 10px; margin: 0 6px 4px 0; border-color: rgba(196, 160, 92, 0.6); }.cabinet-house {flex-direction: row; flex-wrap: wrap; align-items: center; flex-shrink: 0; margin: 0 5px 8px 5px; padding: 10px 14px;@@ -422,8 +432,13 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);.rung { flex-direction: row; align-items: center; padding: 8px 10px; margin: 2px 0; border-left-width: 3px; border-color: rgba(0, 0, 0, 0); background-color: rgba(255, 255, 255, 0.03); }.rung-name { white-space: normal; font-size: 18px; flex-shrink: 1; min-width: 0; }.rung-turn { font-size: 15px; margin-left: 8px; flex-shrink: 0; }+/* The turn length is a lighter muted than --ink-dim: 15 px text loses about a fifth of its contrast to anti-aliasing, and+ ink-dim's 5.0:1 on a plain rung measured 4.0 to 4.2:1 (#41 re-check). This is 6.3:1, still quieter than ink. */+.rung .rung-turn { color: rgb(190, 184, 170); }.rung-current { border-color: var(--gold-light); background-color: rgba(196, 160, 92, 0.20); }.rung-current .rung-name { color: var(--gold-light); }+/* The muted turn length is 3.3:1 on the lit rung; ink is 6.4:1 (#41 M4). */+.rung-current .rung-turn { color: var(--ink); }/* The level an order will move to at End Turn: a dashed-looking ink edge, distinct from the lit current level. */.rung-target { border-color: var(--ink); border-left-width: 3px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; }.big-figure { -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); font-size: 44px; color: var(--ink); padding: 0; margin: 0 0 4px 0; }