/* Sellswords (warband) on wide screens: iPad portrait and landscape, the Duo's inner screen. Nov 26, 2026.
   Contract: docs/ipad-duo/GAME-WORKER-GUIDE.md. The build links this file last in <head>, behind the gate's media query, only in
   --wide builds; shared/wide.js sets html.tc-wide plus one mode class. EVERY rule starts with html.tc-wide: a phone (and the Duo's
   outer screen) never applies a line of it. game.json "wide": level "column", root #app (column 820 tall, 1240 wide).

   tall  (portrait iPads)   the phone's stack in a wider column, slots sized from the column width and the screen height.
   wide  (landscape iPads)  two panes: hud, next foe, field and bench on one side; the shop, Reroll / Sell, the hint and Fight!
                            on the thumb side (right; html.tcw-left mirrors). Fight: the field between two side panels.
   fold  (Duo inner 890x626) the same two panes as two halves of the screen, with a gutter over the hinge that nothing crosses.

   Sizes: the page's slots read --sh (field), --bh (bench), --oh (shop picture) and the JS draws each Human at the biggest of
   3 / 2.5 / 2 / 1.5 / 1x that fits its slot (fitScale, measured with a probe: wideLen in index.html). Nothing is shrunk with
   transform:scale on wide screens (fitScreen is off there), so the pixel art stays crisp.

   Beating phone rules (guide section 5): the page's own @media (max-height: 900/830/780px) rules and the UI kit's generated
   ui.css (max-height: 780/765px, :not(#\9#\9) boosters) also match an iPad in landscape and the Duo's inner screen. Every size
   that matters is restated here with more weight (:not(#\9#\9#\9#\9) = 4 ids) or !important where the phone rule is !important.
   The variables below are set on html.tc-wide.tcw-*, which beats the page's :root { --sh } in every media query. */

/* ================================================================ every wide mode */
/* Skin art (fix, Nov 26): a wide.css never names a skin picture, not even through var(--ui-img-*): a url() taken from a
   variable is resolved against THIS file's folder, which on /outpost/ and /magic/ is the Pixel theme. To give a panel back its
   frame below the short-screen height, the short-screen rule of ui/ui.css keeps drawing its own border-image (so the url is
   resolved by ui.css, in this skin's folder) and only its well variables are pointed at the panel ones on that element. The
   children get the well back from these copies taken on <html>. */
html.tc-wide { --tcwk-well: var(--ui-img-well); --tcwk-well-slice: var(--ui-well-slice); --tcwk-well-bw: var(--ui-well-bw); }
/* the shared filler's fallback tile is a skin variable used from shared/wide.css, so it would load another skin's tile (or a 404):
   drop that fallback here; a skin's own wide backdrop (--tcw-img-backdrop, written by the build) still shows, else the theme's own
   page backdrop shows through */
html.tc-wide #tcWideBg .tcw-fill { --ui-img-bg-tile: none; background-color: transparent; }
html.tc-wide #rotate { display: none !important; }
html.tc-wide { --wb-fside: 200px; --wb-gap: 10px; }

/* the UI kit's short-screen look (max-height 780 / 765) is a phone squeeze: wide screens keep the normal kit frames */
@media (max-height: 780px) {
  html.tc-wide #hud:not(#\9#\9#\9#\9), html.tc-wide #ui-shopboard:not(#\9#\9#\9#\9) { border-width: var(--ui-panel-edge); }
}
@media (max-height: 765px) {
  html.tc-wide #hud:not(#\9#\9#\9#\9), html.tc-wide #ui-shopboard:not(#\9#\9#\9#\9) {
    border-width: var(--ui-panel-edge); box-shadow: var(--ui-panel-shadow);
    --ui-img-well: var(--ui-img-panel); --ui-well-slice: var(--ui-panel-slice); --ui-well-bw: var(--ui-panel-bw); }
  html.tc-wide #hud > *, html.tc-wide #ui-shopboard > * { --ui-img-well: var(--tcwk-well); --ui-well-slice: var(--tcwk-well-slice); --ui-well-bw: var(--tcwk-well-bw); }
  html.tc-wide #hud:not(#\9#\9#\9#\9) { gap: 6px; padding: 0 2px 2px; }
  html.tc-wide #ui-shopboard:not(#\9#\9#\9#\9) { gap: 7px; padding: 0 0 2px; }
  html.tc-wide #foe:not(#\9#\9#\9#\9) { padding: 2px 6px; }
}
@media (max-height: 780px) {
  html.tc-wide #s-title h1 { font-size: 50px; }
}

/* shop: the same parts as on a phone, a little roomier */
html.tc-wide #s-shop:not(#\9#\9) { padding: 12px 16px 14px !important; gap: 8px !important; }
html.tc-wide #board, html.tc-wide #bench, html.tc-wide #offers { gap: var(--wb-gap) !important; }
html.tc-wide #board .slot, html.tc-wide #bench .slot { min-height: 0; }
html.tc-wide #hearts img { width: 24px; height: 22px; }
html.tc-wide #hud .rnd b { font-size: 15px !important; }
html.tc-wide .offer:not(#\9#\9#\9#\9) { min-height: calc(var(--oh) + 62px) !important; }
html.tc-wide .offer .nm { font-size: 13px !important; height: 28px; }
html.tc-wide #sellzone { min-height: 52px !important; }
/* the shop card's "i" badge: a 44 pt button on wide screens (was 24 px; App Store / guide minimum, fix Nov 26). The box is 44 x 44 and
   the round badge is drawn inside it at 32 px from the skin's own colours, so it does not cover the card's picture */
html.tc-wide .offer .info:not(#\9) { width: 44px; height: 44px; top: -8px; right: -8px; border: 0; border-radius: 50%;
  background: radial-gradient(circle, var(--ui-bg, #1e140f) 0 15px, var(--ui-accent-deep, #4a3622) 15px 16.5px, transparent 17px);
  font-size: 17px; line-height: 44px; padding: 0; }
/* the shop's bottom bar (Reroll | Fight!, TCFrame.actions in #shopbar): 52 pt plates on wide screens, in the shop pane where Fight! was */
html.tc-wide #shopbar .tcf-actions > .tcf-plate { --bh: 52px; }
html.tc-wide #shopbar .tcf-actions { max-width: none; padding: 0; margin: 0; }
html.tc-wide #hint { min-height: 16px; font-size: 13px; }

/* shop sizes per mode. --wb-in: the shop's inner width; --wb-cw: one field cell's width. Height terms: the screen minus the
   top bar and everything in the stack that is not a slot (measured at 820 x 1180 and 1180 x 820; see the change note). */
html.tc-wide.tcw-tall {
  --wb-in: calc(var(--tcw-col) - 32px);
  --wb-cw: calc((var(--wb-in) - 4 * var(--wb-gap)) / 5);
  --sh: max(60px, min(var(--wb-cw), calc((var(--tcw-h) - 640px) / 3.7)));
  --bh: calc(var(--sh) * .88);
  --oh: calc(var(--sh) * .84);
}
html.tc-wide.tcw-wide {
  --wb-in: calc(var(--tcw-col) - 32px);
  --wb-pl: calc((var(--wb-in) - 32px) * .58);        /* the field pane */
  --wb-pr: calc((var(--wb-in) - 32px) * .42);        /* the shop pane */
  --wb-cw: calc((var(--wb-pl) - 4 * var(--wb-gap)) / 5);
  --sh: max(60px, min(var(--wb-cw), calc((var(--tcw-h) - 310px) / 2.9)));
  --bh: calc(var(--sh) * .88);
  --wb-ow: calc((var(--wb-pr) - 30px - 2 * var(--wb-gap)) / 3);   /* a shop card (3 + 2 cards, see below) */
  --oh: max(56px, min(calc(var(--wb-ow) * .8), calc((var(--tcw-h) - 440px) / 2)));
}
html.tc-wide.tcw-fold {
  --wb-gap: 8px;
  --wb-gut: calc(var(--tcw-hinge-w) + 32px);
  --wb-half: calc((var(--tcw-w) - 32px - var(--wb-gut)) / 2);
  --wb-cw: calc((var(--wb-half) - 4 * var(--wb-gap)) / 5);
  --sh: max(54px, min(calc(var(--wb-cw) * .9), calc((var(--tcw-h) - 330px) / 2.9)));
  --bh: calc(var(--sh) * .88);
  --wb-ow: calc((var(--wb-half) - 30px - 2 * var(--wb-gap)) / 3);
  --oh: max(54px, min(calc(var(--wb-ow) * .8), calc((var(--tcw-h) - 440px) / 2)));
}

/* ---------------------------------------------------------------- tall: one column, centred in the height */
html.tc-wide.tcw-tall #s-shop > #hud { margin-top: auto; }
html.tc-wide.tcw-tall #s-shop > #shopbar { margin-top: 0; margin-bottom: auto; }

/* ---------------------------------------------------------------- wide and fold: two panes
   L = the field pane (hud, next foe, field, bench), R = the shop pane (shop, Reroll / Sell, hint, Fight!).
   The rows are the field pane's; the shop board spans its first four rows; Fight! lines up with the bench. */
html.tc-wide.tcw-wide { --wb-L: 1; --wb-R: 2; }
html.tc-wide.tcw-wide.tcw-left { --wb-L: 2; --wb-R: 1; }
html.tc-wide.tcw-fold { --wb-L: 1; --wb-R: 3; }
html.tc-wide.tcw-fold.tcw-left { --wb-L: 3; --wb-R: 1; }
html.tc-wide.tcw-wide #s-shop.on, html.tc-wide.tcw-fold #s-shop.on {
  display: grid; grid-template-rows: repeat(6, auto); align-content: center; column-gap: 32px; row-gap: 8px; }
html.tc-wide.tcw-wide #s-shop.on { grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); }
html.tc-wide.tcw-wide.tcw-left #s-shop.on { grid-template-columns: minmax(0, 42fr) minmax(0, 58fr); }
html.tc-wide.tcw-fold #s-shop.on { grid-template-columns: minmax(0, 1fr) var(--wb-gut) minmax(0, 1fr); column-gap: 0; }
html.tc-wide.tcw-wide #s-shop > *, html.tc-wide.tcw-fold #s-shop > * { grid-column: var(--wb-L); min-width: 0; }
html.tc-wide.tcw-wide #s-shop > #hud, html.tc-wide.tcw-fold #s-shop > #hud { grid-row: 1; }
html.tc-wide.tcw-wide #s-shop > #foe, html.tc-wide.tcw-fold #s-shop > #foe { grid-row: 2; }
html.tc-wide.tcw-wide #s-shop > .sec:has(+ #board), html.tc-wide.tcw-fold #s-shop > .sec:has(+ #board) { grid-row: 3; }
html.tc-wide.tcw-wide #s-shop > #board, html.tc-wide.tcw-fold #s-shop > #board { grid-row: 4; }
html.tc-wide.tcw-wide #s-shop > .sec:has(+ #bench), html.tc-wide.tcw-fold #s-shop > .sec:has(+ #bench) { grid-row: 5; }
html.tc-wide.tcw-wide #s-shop > #bench, html.tc-wide.tcw-fold #s-shop > #bench { grid-row: 6; }
html.tc-wide.tcw-wide #s-shop > #ui-shopboard, html.tc-wide.tcw-fold #s-shop > #ui-shopboard { grid-column: var(--wb-R); grid-row: 1 / 5; align-self: start; }
html.tc-wide.tcw-wide #s-shop > #hint, html.tc-wide.tcw-fold #s-shop > #hint { grid-column: var(--wb-R); grid-row: 5; align-self: end; }
html.tc-wide.tcw-wide #s-shop > #shopbar, html.tc-wide.tcw-fold #s-shop > #shopbar { grid-column: var(--wb-R); grid-row: 6; align-self: end; }
/* without the UI kit's shop board (a skin with no ui.js): the shop label, cards and Reroll / Sell are the screen's own children */
html.tc-wide.tcw-wide #s-shop > .sec:has(+ #offers), html.tc-wide.tcw-fold #s-shop > .sec:has(+ #offers) { grid-column: var(--wb-R); grid-row: 1; }
html.tc-wide.tcw-wide #s-shop > #offers, html.tc-wide.tcw-fold #s-shop > #offers { grid-column: var(--wb-R); grid-row: 2 / 4; align-self: start; }
html.tc-wide.tcw-wide #s-shop > #acts, html.tc-wide.tcw-fold #s-shop > #acts { grid-column: var(--wb-R); grid-row: 4; align-self: start; }

/* the shop pane is narrow and tall: the five cards as 3 + 2, centred, each much bigger than a fifth of the pane.
   --wb-cols tells the page's gridCell() how many cards share a row (it sizes the Humans' pictures from that). */
html.tc-wide.tcw-wide #offers, html.tc-wide.tcw-fold #offers {
  --wb-cols: 3; display: flex !important; flex-wrap: wrap; justify-content: center; row-gap: var(--wb-gap); }
html.tc-wide.tcw-wide #offers > .offer, html.tc-wide.tcw-fold #offers > .offer { flex: none; width: calc((100% - 2 * var(--wb-gap)) / 3); }

/* ---------------------------------------------------------------- fight screen */
html.tc-wide #fwrap:not(#\9) { margin: 0; }
html.tc-wide #fctl:not(#\9) { margin: 0; }
html.tc-wide.tcw-tall #s-fight.on { justify-content: center; gap: 6px; }
html.tc-wide.tcw-tall #fhud { width: 100%; }

/* wide: the field in the middle at full height, the scoreboard on the left, Speed / Skip on the right (thumb side) */
html.tc-wide.tcw-wide #s-fight.on {
  display: grid; grid-template-columns: minmax(var(--wb-fside), 1fr) auto minmax(var(--wb-fside), 1fr); grid-template-rows: minmax(0, 1fr);
  column-gap: 24px; align-items: center; padding: 12px 16px; }
html.tc-wide.tcw-wide #s-fight.on > #fwrap { grid-column: 2; grid-row: 1; }
html.tc-wide.tcw-wide #s-fight.on > #fhud:not(#\9#\9#\9#\9) {
  grid-column: 1; grid-row: 1; justify-self: end; width: var(--wb-fside); min-height: 0; flex-direction: column; justify-content: center;
  gap: 18px; padding: 18px 8px; border-width: var(--ui-bar-edge); }
html.tc-wide.tcw-wide #s-fight.on > #fctl { grid-column: 3; grid-row: 1; justify-self: start; width: var(--wb-fside); flex-direction: column; gap: 14px; padding: 0; }
html.tc-wide.tcw-wide.tcw-left #s-fight.on > #fhud:not(#\9#\9#\9#\9) { grid-column: 3; justify-self: start; }
html.tc-wide.tcw-wide.tcw-left #s-fight.on > #fctl { grid-column: 1; justify-self: end; }

/* fold: the field on one half, scoreboard and buttons on the other */
html.tc-wide.tcw-fold #s-fight.on {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--wb-gut) minmax(0, 1fr); grid-template-rows: 1fr auto auto 1fr;
  column-gap: 0; row-gap: 16px; padding: 12px 16px; }
html.tc-wide.tcw-fold #s-fight.on > #fwrap { grid-column: 1; grid-row: 1 / -1; align-self: center; justify-self: center; }
html.tc-wide.tcw-fold #s-fight.on > #fhud:not(#\9#\9#\9#\9) { grid-column: 3; grid-row: 2; width: auto; border-width: var(--ui-bar-edge); padding: 10px 6px; }
html.tc-wide.tcw-fold #s-fight.on > #fctl { grid-column: 3; grid-row: 3; width: auto; padding: 0; }
html.tc-wide.tcw-fold.tcw-left #s-fight.on > #fwrap { grid-column: 3; }
html.tc-wide.tcw-fold.tcw-left #s-fight.on > #fhud:not(#\9#\9#\9#\9), html.tc-wide.tcw-fold.tcw-left #s-fight.on > #fctl { grid-column: 1; }

/* the scoreboard as a side card: Orcs on top, the round, Humans below (the field's own order) */
html.tc-wide.tcw-wide #fhud .side, html.tc-wide.tcw-wide #fhud .side.r { flex-direction: row; justify-content: center; font-size: 16px; }
html.tc-wide.tcw-wide #fhud .tk { width: 40px; height: 40px; }
html.tc-wide.tcw-wide #fhud .mid { font-size: 14px; } html.tc-wide.tcw-wide #fhud .mid b { font-size: 17px; }
html.tc-wide #fctl .btn:not(#\9) { min-height: 52px; }
html.tc-wide.tcw-wide #fctl .btn:not(#\9) { width: 100%; }

/* ---------------------------------------------------------------- pop-ups: in fold mode on the shop half, never over the hinge */
html.tc-wide.tcw-fold .modal { justify-content: flex-end; padding: 0 16px; }
html.tc-wide.tcw-fold.tcw-left .modal { justify-content: flex-start; }
html.tc-wide.tcw-fold .modal .card, html.tc-wide.tcw-fold .modal.mid .card { width: var(--wb-half); max-width: none; }
html.tc-wide.tcw-fold #toast { left: auto; right: 16px; transform: none; max-width: var(--wb-half); }
html.tc-wide.tcw-fold.tcw-left #toast { right: auto; left: 16px; }

/* ---------------------------------------------------------------- title and run-over screens in fold mode: two halves */
html.tc-wide.tcw-fold #s-title.on, html.tc-wide.tcw-fold #s-over.on {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--wb-gut) minmax(0, 1fr); grid-auto-flow: dense;
  align-content: center; justify-items: center; row-gap: 12px; column-gap: 0; padding: 12px 16px; }
html.tc-wide.tcw-fold #s-title.on > *, html.tc-wide.tcw-fold #s-over.on > * { grid-column: var(--wb-L); }
html.tc-wide.tcw-fold #s-title.on > p.how, html.tc-wide.tcw-fold #s-title.on > .btns, html.tc-wide.tcw-fold #s-title.on > .best,
html.tc-wide.tcw-fold #s-over.on > .sum, html.tc-wide.tcw-fold #s-over.on > .best, html.tc-wide.tcw-fold #s-over.on > .btns { grid-column: var(--wb-R); }
