/* Nine Keeps on wide screens (iPad, the Duo's inner screen). Nov 26, 2026. Contract: docs/ipad-duo/GAME-WORKER-GUIDE.md.
   Only in --wide builds, linked last with the gate's media query; every rule starts with html.tc-wide, so a phone never
   applies a line. Level "column" (game.json): #game is the root, #app the wrap; this file lays out the two boards itself.
   The square sizes come from the TCWide script at the end of index.html (--tcw9-big, --tcw9-mini, --tcw9-cf, --tcw9-cm).
     tall (iPad portrait):   the phone stack, bigger: top bar, players, status, big board, realm map, legend.
     wide (iPad landscape):  the two boards side by side: realm map with the players above it on one side, the big board
                             with the top bar and the status above it on the thumb side (tc_wide_hand, default right).
     fold (Duo inner):       the same two columns, one per half; nothing crosses the hinge.
   Captured keeps keep their tokens in sight (Scott's rule): nothing here lays an owner token over a keep.
   Unified frame (Nov 29, 2026): the frame's top bar (#tcfBar, Back | name | Help, Menu) sits above both screens in #app; the old
   in-play top bar, the setup page's Games link and its How to play fold are gone, so their grid places went too. */

/* ------------------------------------------------------------------ square sizes (fall back to the phone formulas) */
html.tc-wide {
  --big: var(--tcw9-big, max(var(--bigMin, 44px), min(calc((var(--W) - 84px) / 3), calc(var(--Hb) * .42 / 3), 104px)));
  --mini: var(--tcw9-mini, max(var(--miniMin, 20px), min(calc((var(--W) - 118px) / 9), calc(var(--Hb) * .58 / 9), 40px)));
}

/* ------------------------------------------------------------------ home */
html.tc-wide #app > #home { width: 100%; max-width: 560px; margin: 0 auto; }
html.tc-wide.tcw-tall #app > #home { max-width: 660px; gap: 22px; }
html.tc-wide.tcw-tall #home h1:not(#\9#\9#\9) { font-size: 48px; }
html.tc-wide.tcw-tall #home .sub { font-size: 15px; }
html.tc-wide.tcw-tall #home .pick:not(#\9#\9#\9) { width: 200px; }
/* 140 px coins: 5 device px per art px on a 2x iPad (the picture is 96% of the coin) */
html.tc-wide.tcw-tall #home .pick svg:not(#\9#\9#\9) { width: 140px; height: 140px; }
html.tc-wide.tcw-tall #home .pick b { font-size: 20px; }
html.tc-wide.tcw-tall #home .crest .vs:not(#\9#\9#\9) { margin-top: 72px; font-size: 28px; }
html.tc-wide.tcw-tall #home .card { padding: 18px; gap: 14px; }
/* landscape and the Duo: two columns, title and coins | play buttons and how to play */
html.tc-wide.tcw-wide #app > #home,
html.tc-wide.tcw-fold #app > #home {
  max-width: 1040px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 48px; row-gap: 14px;
  align-content: center; }
html.tc-wide.tcw-wide #home > div:not(.card):nth-of-type(1),
html.tc-wide.tcw-fold #home > div:not(.card):nth-of-type(1) { grid-column: 1; grid-row: 1; }
html.tc-wide.tcw-wide #home > div:not(.card):nth-of-type(2),
html.tc-wide.tcw-fold #home > div:not(.card):nth-of-type(2) { grid-column: 1; grid-row: 2; }
html.tc-wide.tcw-wide #home > .card,
html.tc-wide.tcw-fold #home > .card { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
html.tc-wide.tcw-wide #home .pick:not(#\9#\9#\9) { width: 180px; }
html.tc-wide.tcw-wide #home .pick svg:not(#\9#\9#\9) { width: 112px; height: 112px; }
html.tc-wide.tcw-wide #home .crest .vs:not(#\9#\9#\9) { margin-top: 58px; }
html.tc-wide.tcw-wide #home h1:not(#\9#\9#\9) { font-size: 46px; }
/* fold: the two home columns are the two halves of the screen */
html.tc-wide.tcw-fold #home .pick:not(#\9#\9#\9) { width: 164px; }
html.tc-wide.tcw-fold #app { padding-left: 0; padding-right: 0; }
html.tc-wide.tcw-fold #app > #home { max-width: none; width: var(--tcw-w); padding: 0 16px; column-gap: calc(var(--tcw-hinge-w) + 32px); }

/* ------------------------------------------------------------------ play screen: HUD a touch bigger than the phone (not in fold) */
html.tc-wide:not(.tcw-fold) #game .pcard svg:not(#\9#\9#\9) { width: 44px; height: 44px; }
html.tc-wide:not(.tcw-fold) #game .pcard .nm { font-size: 16px; }
html.tc-wide:not(.tcw-fold) #game .pcard .meta:not(#\9#\9#\9) { font-size: 13px; }
html.tc-wide:not(.tcw-fold) #game .score { font-size: 23px; }
html.tc-wide:not(.tcw-fold) #game #status.status:not(#\9#\9#\9) { font-size: 17px; }
html.tc-wide #game .flag { font-size: 12px; }

/* ------------------------------------------------------------------ tall: the phone stack, as wide as the column */
html.tc-wide.tcw-tall #game > .players,
html.tc-wide.tcw-tall #game > #resultBar { width: 100%; max-width: max(520px, calc(9 * var(--mini) + 100px)); align-self: center; }

/* ------------------------------------------------------------------ wide and fold: two columns */
html.tc-wide.tcw-wide #game:not(.hidden),
html.tc-wide.tcw-fold #game:not(.hidden) {
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; row-gap: 8px; column-gap: 32px;
  grid-template-columns: var(--tcw9-cm, 1fr) var(--tcw9-cf, 1fr); justify-content: space-evenly;
  grid-template-areas: "pl st" "mp st" "mp fc" "lg fc"; }
html.tc-wide.tcw-wide.tcw-left #game:not(.hidden) {
  grid-template-columns: var(--tcw9-cf, 1fr) var(--tcw9-cm, 1fr); grid-template-areas: "st pl" "st mp" "fc mp" "fc lg"; }
html.tc-wide.tcw-fold #game:not(.hidden) {
  width: var(--tcw-w); max-width: none !important; margin: 0; padding: 0 16px; column-gap: 0;
  grid-template-columns: minmax(0, 1fr) calc(var(--tcw-hinge-w) + 32px) minmax(0, 1fr); justify-content: stretch;
  grid-template-areas: "pl . st" "mp . st" "mp . fc" "lg . fc"; }
html.tc-wide.tcw-fold.tcw-left #game:not(.hidden) { grid-template-areas: "st . pl" "st . mp" "fc . mp" "fc . lg"; }
html.tc-wide.tcw-wide #game > .players, html.tc-wide.tcw-fold #game > .players { grid-area: pl; align-self: center; min-width: 0; }
html.tc-wide.tcw-wide #game > #status, html.tc-wide.tcw-fold #game > #status { grid-area: st; justify-self: center; align-self: start; }
html.tc-wide.tcw-wide #game > #resultBar, html.tc-wide.tcw-fold #game > #resultBar { grid-area: st; align-self: start; width: 100%; max-width: 520px; justify-self: center; min-width: 0; }
html.tc-wide.tcw-wide #game > #focus, html.tc-wide.tcw-fold #game > #focus { grid-area: fc; align-self: center; justify-self: center; }
html.tc-wide.tcw-wide #game > #map, html.tc-wide.tcw-fold #game > #map { grid-area: mp; align-self: center; justify-self: center; margin-top: 0; }
html.tc-wide.tcw-wide #game > #legend, html.tc-wide.tcw-fold #game > #legend { grid-area: lg; align-self: end; margin-top: 0; }
/* the Duo's half is phone-sized: the result bar's title and button on one line each */
html.tc-wide.tcw-fold #game > #resultBar h2 { font-size: 20px; }

/* ------------------------------------------------------------------ the map played directly (squares 44 px or more) */
/* empty squares of the keeps the move may go in: a faint dot (the phone's beckon dot, still) */
html.tc-wide.tcw9-direct #map .mc.tcw9-can { position: relative; }
html.tc-wide.tcw9-direct #map .mc.tcw9-can::before { content: ""; position: absolute; inset: 40%; border-radius: 50%; background: rgba(224,180,76,.38); }
/* the square picked (tap twice to place): a gold ring on the map as on the big board */
html.tc-wide.tcw9-direct #map .mc.tcw9-sel { box-shadow: 0 0 0 3px var(--gold), 0 0 12px rgba(255,200,80,.85); }
html.tc-wide.tcw9-direct #map .mc.tcw9-sel::before { inset: 30%; background: rgba(255,226,140,.75); }
html.tc-wide.tcw9-direct #legend::after { content: " Or tap a square on the map."; }

/* ------------------------------------------------------------------ sheets: wider than a phone sheet */
html.tc-wide #tokenOverlay > .sheet:not(#\9#\9#\9) { max-width: 680px; }
html.tc-wide:not(.tcw-fold) #tokenOverlay .tgrid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
/* 84 px coins: 3 device px per art px on a 2x iPad */
html.tc-wide:not(.tcw-fold) #tokenOverlay .tok svg { width: 84px; height: 84px; }
html.tc-wide #levelOverlay > .sheet:not(#\9#\9#\9) { max-width: 560px; }
html.tc-wide.tcw-wide .overlay { align-items: center; }
/* fold: a sheet sits on the thumb half */
html.tc-wide.tcw-fold .overlay { align-items: center; justify-content: flex-end; padding: 12px 16px; }
html.tc-wide.tcw-fold.tcw-left .overlay { justify-content: flex-start; }
html.tc-wide.tcw-fold .overlay > .sheet:not(#\9#\9#\9) { max-width: calc((var(--tcw-w) - var(--tcw-hinge-w)) / 2 - 32px); }

/* ------------------------------------------------------------------ the frame's top bar (unified frame, Nov 29, 2026) */
/* fold: #app has no side padding here, so the bar does not reach out past it (its own 16 pt margins stay) */
html.tc-wide.tcw-fold #app > #tcfBar { margin-left: 0; margin-right: 0; }
