/* The decided primary navigation: six existing overlays and the News drawer. */
/* panelInsets reads a numeric px custom property, so keep this resolved. */
:root { --nav-width: 72px; --inset-left: 96px; }
.campaign-nav {
  pointer-events: none;
  position: absolute;
  top: calc(var(--chrome-top) + 6px + env(safe-area-inset-top, 0px));
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  left: calc(8px + env(safe-area-inset-left, 0px));
  width: var(--nav-width);
  z-index: 65;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 5px 3px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.campaign-nav[hidden] { display: none; }
.campaign-nav .campaign-nav-button {
  pointer-events: auto;
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  background-color: var(--parchment);
  background-image: var(--paper);
  color: var(--ink);
  border: 2px solid var(--rule-strong);
  box-shadow: var(--panel-shadow);
}
/* A short desktop window has no room for six 64 px discs above the selection
   card: at 1280x720 the News disc ran 28 px under a province's title bar and
   more under an army's, which stands taller. 52 px discs with a 6 px gap end
   the rail at about 423 px, clear of both, and are still well over the 44 px
   touch floor. Always at this height, not only while something is selected,
   so the rail does not change size under the pointer (UI pass, 28 November 2026). */
@media (min-width: 1024px) and (max-height: 860px) {
  .campaign-nav { gap: 6px; }
  .campaign-nav .campaign-nav-button { width: 52px; height: 52px; }
  .campaign-nav .campaign-nav-button :is(img, svg) { max-width: 34px; max-height: 34px; }
}
.campaign-nav .campaign-nav-button.is-active { border-color: var(--gold); background-color: #e5c878; }
.campaign-nav .campaign-nav-button.is-atwar { border-color: var(--bad); }
.campaign-nav .campaign-nav-button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.campaign-nav .btn-badge { top: 1px; right: 0; }
/* The Academy stands idle: an amber empty hourglass on the Technology button,
   breathing slowly so a player busy at war still notices days going to waste. */
.campaign-nav .nav-idle-badge {
  position: absolute;
  bottom: -1px;
  right: -2px;
  display: none;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #c08a2a;
  color: #fff8e6;
  border: 1.5px solid #fff3d2;
  box-shadow: 0 1px 3px #0006;
}
.campaign-nav .campaign-nav-button.is-idle .nav-idle-badge { display: grid; animation: nav-idle-breathe 2.4s ease-in-out infinite; }
@keyframes nav-idle-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); box-shadow: 0 0 0 4px #c08a2a40; } }
@media (prefers-reduced-motion: reduce) { .campaign-nav .campaign-nav-button.is-idle .nav-idle-badge { animation: none; } }
.campaign-nav .ui-glyph { font-size: 32px; line-height: 1; }
.campaign-nav-visible .command-bar {
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  max-width: none;
}
/* Center commands against the screen, independent of either side rail. */
@media (min-width: 1024px) {
  .campaign-nav-visible .cmd-pane {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    pointer-events: none;
  }
  .campaign-nav-visible .cmd-pane > .cmd-info {
    grid-column: 1;
    width: min(492px, calc(100% - 12px));
    min-width: 0;
    overflow: auto;
    pointer-events: auto;
  }
  .campaign-nav-visible .cmd-pane > .cmd-act {
    grid-column: 2;
    width: min(660px, 40vw);
    min-width: 0;
    pointer-events: auto;
  }
  .campaign-nav-visible .cmd-switch { width: min(492px, calc(30vw - 20px)); }
  /* Wrapped, the identity and the figures stack, and the stack is taller than a
     card capped at `--cmd-h`. `.cmd-info-top` is `flex: 0 1 auto; min-height: 0`,
     so it shrank to what was left above the seam (126 of 258 px at 1100x760) while
     its children overflowed it visibly: Forage and Country split were drawn over
     Population, Walls and Militia (TODO §34). Keep its height; what then does not
     fit the card is paged by ui/fitPages.js (the `overflow: auto` above is only
     the safety net `scripts/check-no-scroll.mjs` reports on). */
  .campaign-nav-visible .cmd-info-top { flex-wrap: wrap; flex-shrink: 0; }
}
@media (max-width: 1023px) {
  .campaign-nav-visible .command-bar { max-height: min(70vh, calc(100dvh - var(--chrome-top) - 16px)); }
  .campaign-nav-visible .cmd-pane:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
  }
  .campaign-nav-visible .cmd-pane > .cmd-info {
    justify-self: start;
    align-self: start;
    width: min(492px, 100%);
    max-height: 140px;
    overflow: auto;
    flex: 0 1 auto;
    pointer-events: auto;
  }
  .campaign-nav-visible .cmd-pane > .cmd-act {
    width: min(660px, 100%);
    min-width: 0;
    align-self: center;
    justify-self: center;
    pointer-events: auto;
  }
  .campaign-nav-visible .cmd-switch { position: static; width: min(492px, 100%); }
  .campaign-nav-visible .cmd-panes { pointer-events: none; }
}
.campaign-nav-visible .overlay { padding-left: calc(var(--inset-left) + 12px); }
.campaign-nav-visible .column-right { max-width: calc(100% - var(--inset-left) - 12px); }
.campaign-nav-visible .battle-prompts {
  left: var(--inset-left);
  max-width: calc(100% - var(--inset-left) - 12px);
}
.campaign-nav-visible #directPanel { z-index: 60; }
.campaign-nav-visible #campaignHud .faction-banner { cursor: default; }
.campaign-nav-visible #campaignHud .faction-banner:hover { background: none; border-color: transparent; }
@media (max-width: 700px), (max-height: 600px) {
  :root { --nav-width: 56px; --inset-left: 80px; }
  .campaign-nav { gap: 6px; padding: 2px; }
  .campaign-nav .campaign-nav-button { width: 48px; height: 48px; }
  .campaign-nav .ui-icon { max-width: 27px; max-height: 27px; }
  .campaign-nav .hud-action-art { width: 30px; height: 30px; }
  .campaign-nav .ui-glyph { font-size: 27px; }
}

/* Treasury shares the primary rail and opens beside it. */
.campaign-nav .treasury-nav[hidden] { display: none; }
.campaign-nav-visible .stores-pop {
  left: calc(var(--inset-left) + env(safe-area-inset-left, 0px));
  right: auto;
  width: min(760px, calc(100vw - var(--inset-left) - 12px - env(safe-area-inset-left, 0px)));
  max-height: calc(100dvh - var(--chrome-top) - 20px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  z-index: 66;
}
/* **Stocks have one home — but not a scrollbar.**
   This block used to read "Scroll instead of dropping goods into Treasury" and
   did two things to get there: it made the strip `overflow-x: auto`, and it
   re-showed every tile the tier ladder hides, by out-specifying
   `.resource.res-t4 { display: none }` with an id. Both are now wrong.

   The player's rule of 17 October 2026 is that nothing in this game scrolls —
   not the page, not a panel, not a list — and that what does not fit is sized
   down, wrapped, paged, put behind a button or dropped. `styles.css` had
   already built the "dropped" answer and measured it: fourteen tiles need
   about 848 px, eleven 686, eight 524 and five 362. This override took it out
   again.

   What it cost, measured on an emulated Pixel 7 at 412 px on 21 October 2026:
   the strip is allotted **154 px** in the HUD row and laid out **434 px** of
   eleven tiles inside it. Nine were therefore clipped out of the scroller,
   and the three whose centres still fell inside the window hit-tested to
   whatever was painted over them — `resource under speed-btn`, `under
   ui-icon`, `under btn`. That is the whole of the browser gate's "4 controls
   are painted over", which TODO §45 recorded as "resource chips painted over
   by the speed buttons" and nobody traced to this rule.

   So the ladder is handed back its narrow widths. Treasury is still every
   good's home — `.stores-pop`, one tap from the rail — which is what makes
   dropping the tail from a 154 px strip an arrangement rather than a loss. */
#campaignHud #resourceBar { overflow: hidden; }
#campaignHud #resourceBar .resource { display: flex; }
/* **The ladder's numbers, measured against the strip rather than the window.**
   The four breakpoints below were 869/709/549 when the scroller was removed,
   because that is what `styles.css` had measured for a strip that owned its
   whole row. In the campaign HUD it does not: the banner, calendar, speed
   buttons and icons take a fixed share, and what is left for the strip is about
   **the window less 445 px** (1475 px of strip at 1920, 1005 at 1450, 615 at
   1060, 455 at 900). Tiles flex to fill that, down to a floor, and at the floor
   eleven of them need **680 px**, nine 592, eight 484 and five 430.

   So the ladder has to turn at the width where the *strip* runs out, not where
   the window does. Measured on 21 October 2026, the fewest tiers that have to
   leave for the content to fit the box: none at 1150 (689 px in 705), one at
   1100 (680 in 655), two at 900 (592 in 455), three at 870 (484 in 425), four
   at 580 (268 in 242). The numbers below are each the first round width at or
   above that turn, so every band has the measured margin and none clips:

   | window | tiles | content | strip box |
   |---|---|---|---|
   | 1200 and up | 11 | 739 | 755 |
   | 1000–1199 | 9 | 539–639 | 555–655 |
   | 900–999 | 8 | 439–489 | 455–505 |
   | 700–899 | 5 | 339–409 | 355–425 |
   | below 700 | 2 | 77–266 | 82–282 |

   Keeping 869/709/549 instead showed eleven tiles down to 870 and clipped two
   of them from 1149 px downwards — which the restored fit assertion in
   `scripts/check-stockpile-breakpoints.mjs` fails on, at 1060x900. */
@media (max-width: 1199px) { #campaignHud #resourceBar .resource.res-t4 { display: none; } }
@media (max-width: 999px) { #campaignHud #resourceBar .resource.res-t3 { display: none; } }
@media (max-width: 899px) { #campaignHud #resourceBar .resource.res-t2 { display: none; } }
/* **699, and a phone keeps coin and grain.**
   Tier 1 — timber, stone, iron — is the last to leave, and it has to leave
   earlier than 449: five tiles need 268 px at their floor and a 580 px window
   gives the strip 242. 699 is the first round width above that turn, and it
   keeps the five-tile band honest down to 700 (339 px in 355).

   What a phone shows is therefore **two goods, coin and grain**, at about 77 px
   each at 320 px and 126 px at 390 px — the widest either has ever been on a
   phone, and the same two the gate's own measurements have shown a phone
   showing all along. The other nine are one tap away on the rail, in Treasury
   (`.stores-pop`), which is what makes dropping the tail an arrangement rather
   than a loss. */
@media (max-width: 699px) { #campaignHud #resourceBar .resource.res-t1 { display: none; } }

/* **The stockpile after Supremacy 1914 (player, 20 November 2026).** "I want my
   resource amount next to icons and make the bar a bit thinner to make the
   playable area larger; also make the map view a dropdown clickable text."
   Supremacy's top bar (docs/measurements/supremacy1914-resource-bar-2026-11-20.md)
   puts each good's figure *beside* its round icon, the stock in bold over the
   hourly rate, in a single strip about 82 CSS px tall. Ours stacked disc, stock
   and rate in one 86 px column. Beside the disc the strip needs only the disc's
   height plus padding: 56 px, 30 px less map hidden under the chrome.
   From 700 px wide and 561 px tall only: below that the strip is 154 px of
   phone and a figure beside each disc would leave room for two goods; the
   compact stacked tile stays there. */
@media (min-width: 700px) and (min-height: 561px) {
  :root { --resource-h: 56px; --resource-disc: 34px; --map-controls-h: 0px; --chrome-top: calc(8px + var(--resource-h) + 6px); }
  #campaignHud { height: var(--resource-h); flex-wrap: nowrap; }
  #campaignHud #resourceBar, #campaignHud .topbar-left, #campaignHud .topbar-center, #campaignHud .topbar-right { height: var(--resource-h); }
  #campaignHud #resourceBar .resource {
    display: grid;
    grid-template-columns: var(--resource-disc) auto;
    grid-template-rows: auto auto;
    grid-template-areas: "disc amount" "disc delta";
    column-gap: 5px;
    row-gap: 1px;
    align-content: center;
    justify-content: start;
    justify-items: start;
    flex: 1 1 76px;
    min-width: 70px;
    max-width: 104px;
    padding: 2px 4px;
  }
  #campaignHud #resourceBar .resource-disc { grid-area: disc; align-self: center; }
  #campaignHud #resourceBar .resource-amount { grid-area: amount; align-self: end; margin: 0; font-size: 14px; line-height: 1; }
  #campaignHud #resourceBar .resource-delta { grid-area: delta; align-self: start; font-size: 10px; line-height: 1.1; }
  #campaignHud #resourceBar .resource-label { display: none; }
  /* The banner and the calendar give up their spare height with the strip. */
  #campaignHud .faction-banner { min-height: 0; padding: 3px 8px; }
  #campaignHud .faction-banner-sub { margin-top: 2px; }
  #campaignHud .topbar-center { --hud-control-height: 26px; grid-template-rows: 16px var(--hud-control-height); gap: 3px; }
  #campaignHud .calendar { height: 16px; }
  #campaignHud .calendar-date { line-height: 16px; }

  /* The map view: one line of text that opens its three choices. */
  #campaignHud .hud-map-controls { order: 2; position: relative; flex: 0 0 auto; height: auto; display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 0; }
}
/* Under 1440 px the strip has about 770 px for eleven goods (measured at
   1280 x 720): a 70 px tile clipped the last one and ran "600" into its disc.
   A 28 px disc and a 13 px figure make a 62 px tile, and all eleven fit. */
@media (min-width: 700px) and (min-height: 561px) and (max-width: 1439px) {
  :root { --resource-disc: 28px; }
  #campaignHud #resourceBar .resource { min-width: 60px; flex-basis: 64px; column-gap: 4px; padding: 2px 3px; }
  #campaignHud #resourceBar .resource-amount { font-size: 13px; }
  #campaignHud #resourceBar .resource-delta { font-size: 9px; }
}
/* **The drop ladder for tiles with their figures beside the disc.** A tile is
   about 64 px with its gap (62 under 1440, 76 above), and the strip gets the
   window less about 513 px of banner, map view, calendar and buttons
   (measured: 767 px at 1280, 511 at 1024). So fourteen goods want 1535 px of
   window, eleven 1220, eight 1000 at a 58 px floor, and five 840. Below each
   width the next tier goes to Treasury rather than being clipped. */
@media (min-width: 700px) and (min-height: 561px) and (max-width: 1534px) { #campaignHud #resourceBar .resource.res-t4 { display: none; } }
@media (min-width: 700px) and (min-height: 561px) and (max-width: 1219px) {
  #campaignHud #resourceBar .resource.res-t3 { display: none; }
  #campaignHud #resourceBar .resource { min-width: 56px; flex-basis: 58px; column-gap: 3px; padding-inline: 1px; }
  #campaignHud #resourceBar .resource-amount { font-size: 12px; }
}
@media (min-width: 700px) and (min-height: 561px) and (max-width: 999px) { #campaignHud #resourceBar .resource.res-t2 { display: none; } }
@media (min-width: 700px) and (min-height: 561px) and (max-width: 839px) { #campaignHud #resourceBar .resource.res-t1 { display: none; } }
/* The dropdown itself, at every size: the segmented buttons are gone. */
#campaignHud .hud-map-controls { position: relative; }
.hud-map-trigger {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.hud-map-trigger:hover, .hud-map-trigger.is-open { background: rgba(168, 132, 44, 0.14); border-color: var(--rule); }
.hud-map-trigger:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 1px; }
#campaignHud .hud-map-trigger .hud-map-caption { display: block; font: 500 10px/1.2 var(--font-head); color: var(--ink-soft); text-align: left; }
.hud-map-current { display: inline-flex; align-items: center; gap: 4px; font: 700 13px/1.2 var(--font-body); white-space: nowrap; }
.hud-map-caret { font-size: 10px; opacity: 0.75; }
.hud-map-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 70;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
}
.hud-map-menu[hidden] { display: none; }
.hud-map-option {
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink);
  font: 500 12px/1.2 var(--font-body);
  text-align: left;
  cursor: pointer;
}
.hud-map-option:hover { background: rgba(168, 132, 44, 0.14); }
.hud-map-option.is-active { font-weight: 700; background: rgba(168, 132, 44, 0.2); }
@media (pointer: coarse) { .hud-map-option { min-height: 44px; } .hud-map-trigger { min-height: 44px; } }

/* The goods sit centred between the realm's name and "Map view" (player,
   21 November 2026: "center the resources on the hud between map view and
   Rum text"). The tiles cap at 104 px, so on a wide window the spare width
   used to collect at the right, beside the map view. */
#campaignHud #resourceBar { justify-content: center; }
