/* wide.css — the wide-screen engine's shared rules (iPad, Duo inner screen, desktop). Nov 26, 2026 (docs/ipad-duo/ENGINE.md).
   shared/wide.css. Only built in with "wide": true / --wide. The build links it with media="(min-width:500px) and (min-height:500px)"
   (the number comes from WIDE_MIN in shared/wide.js), and EVERY rule
   below starts with html.tc-wide (set only by wide.js behind the same gate). Two locks: a phone never applies one line.
   Build check (ENGINE.md 5): a wide.css rule whose selector does not start with html.tc-wide stops the build.
   Specificity: html.tc-wide + an attribute beats the page's own ids in most places; UI v2's generated :not(#\9#\9) selectors
   are beaten with !important on the few properties that need it (never edit ui.css or theme.css by hand). */

/* ---------------------------------------------------------------- 0. skin art slots
   The build appends one line per file it finds in packs/themes/<skin>/files/wide/ (ENGINE.md 6), e.g.
   html.tc-wide{--tcw-img-wing-top:url(theme/wide/wing-top.png)}   (relative to this file, at the edition's root).
   A slot with no file keeps the fallback below, so a skin with no wide art still works (plain backdrop, dark edge). */
html.tc-wide { --tcw-wing-w: 192px; --tcw-backdrop-size: 128px; }

/* ---------------------------------------------------------------- 1. the filler layer (every page, level "frame") */
html.tc-wide #tcWideBg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; image-rendering: pixelated; }
html:not(.tc-wide) #tcWideBg { display: none; }
html.tc-wide #tcWideBg > i { position: absolute; display: block; background-repeat: no-repeat; image-rendering: pixelated; }
/* the backdrop beyond the wings: the skin's own tile (theme files/wide/backdrop.png, written into wide-art.css as --tcw-img-backdrop,
   which sits next to this file at the edition's root, so its relative url points into the right skin). Without that file the layer
   is transparent and the page's and theme's own backdrop shows through.
   NEVER use a skin url variable (--ui-img-*, from theme.css or a generated ui/ui.css) in a wide.css: a url() that comes through
   var() resolves against the stylesheet that USES it, so from <edition>/wide.css or <edition>/<game>/wide.css it points at the
   wrong folder (Pixel's /theme/ui/... on Outpost and Magic, or a 404). VERIFY-REPORT B1 / S3; fixed Nov 26, 2026 (fix worker B).
   A page's own wide.css may still set --ui-img-bg-tile: none on the filler (8 games do): this rule no longer reads it. */
html.tc-wide #tcWideBg .tcw-fill { inset: 0;
  background: var(--tcw-img-backdrop, none) 50% 0 / var(--tcw-backdrop-size, 128px) repeat; }
/* wings: one picture per side, hugging the column, drawn at whole device pixels (2x art at DPR 2 = 1 CSS px per art px) */
html.tc-wide #tcWideBg .tcw-wing { top: 0; bottom: 0; width: var(--tcw-wing-w, 192px); }
html.tc-wide #tcWideBg .tcw-wing.l { left: calc(var(--tcw-colL, 0px) - var(--tcw-wing-w, 192px));
  background: var(--tcw-img-wing-top, none) 100% 0 / var(--tcw-wing-w, 192px) auto no-repeat,
              var(--tcw-img-wing-bottom, none) 100% 100% / var(--tcw-wing-w, 192px) auto no-repeat,
              var(--tcw-img-wing-mid, none) 100% 0 / var(--tcw-wing-w, 192px) auto repeat-y; }
html.tc-wide #tcWideBg .tcw-wing.r { right: calc(var(--tcw-colR, 0px) - var(--tcw-wing-w, 192px)); transform: scaleX(-1);
  background: var(--tcw-img-wing-top, none) 100% 0 / var(--tcw-wing-w, 192px) auto no-repeat,
              var(--tcw-img-wing-bottom, none) 100% 100% / var(--tcw-wing-w, 192px) auto no-repeat,
              var(--tcw-img-wing-mid, none) 100% 0 / var(--tcw-wing-w, 192px) auto repeat-y; }
/* a thin frame on each side of the column (theme files/wide/edge.png, 16 px wide, repeats down) */
html.tc-wide #tcWideBg .tcw-edge { top: 0; bottom: 0; width: 8px; background: var(--tcw-img-edge, linear-gradient(90deg, rgba(0,0,0,.55), rgba(0,0,0,0))) 0 0 / 8px auto repeat-y; }
html.tc-wide #tcWideBg .tcw-edge.l { left: calc(var(--tcw-colL, 0px) - 8px); transform: scaleX(-1); }
html.tc-wide #tcWideBg .tcw-edge.r { right: calc(var(--tcw-colR, 0px) - 8px); }
html.tc-wide:not(.tcw-fold) #tcWideBg .tcw-spine,
html.tc-wide.tcw-fold:not(.tcw-split) #tcWideBg .tcw-spine { display: none; }
/* fold: a spine down the hinge (theme files/wide/spine.png, 24 px wide, repeats down); sits UNDER the page */
html.tc-wide.tcw-fold #tcWideBg .tcw-spine { top: 0; bottom: 0; width: 24px; left: calc(var(--tcw-hinge-x) + var(--tcw-hinge-w) / 2 - 12px);
  background: var(--tcw-img-spine, linear-gradient(90deg, transparent, rgba(0,0,0,.5), transparent)) 0 0 / 24px auto repeat-y; }
/* no wings while the column fills the screen (Split View half, narrow windows) */
html.tc-wide #tcWideBg .tcw-wing { display: var(--tcw-wings, block); }

/* the page's own background still paints the column; the theme's body backdrop stays as it is (it shows only if no art) */

/* ---------------------------------------------------------------- 2. shared fixed controls follow the column (every page) */
/* music.js's ♪ button and the home page's music-player button sit at the column's top right, not the iPad's far corner */
html.tc-wide body > button[aria-label="Music on/off"] { right: calc(var(--tcw-colR, 0px) + 16px) !important; }
html.tc-wide body > #mpBtn { right: calc(var(--tcw-colR, 0px) + 16px + 44px + 8px) !important; }
html.tc-wide #toast { max-width: min(90vw, 520px); }

/* ---------------------------------------------------------------- 3. level "column": a wider play column */
html.tc-wide.tcw-column [data-tcw="wrap"] { max-width: none !important; width: 100%; }
html.tc-wide.tcw-column [data-tcw="root"] { max-width: var(--tcw-col) !important; margin-left: auto; margin-right: auto; }

/* ---------------------------------------------------------------- 4. level "split": board + panel */
html.tc-wide.tcw-split [data-tcw="pass"] { display: contents !important; }
html.tc-wide.tcw-split [data-tcw-btn] { min-height: var(--tcw-btn) !important; min-width: var(--tcw-btn); }

/* tall (portrait iPad, w/h < 0.85): the page's own stack, just wider; board grows to --tcw-board-w x --tcw-board-h */
html.tc-wide.tcw-split.tcw-tall [data-tcw="root"] { width: var(--tcw-col); max-width: var(--tcw-col) !important; margin: 0 auto; }

/* wide (landscape iPad, square windows): top bar across, board, side panel on the thumb side */
html.tc-wide.tcw-split.tcw-wide [data-tcw="root"]:not(.hidden) {
  display: grid !important; width: var(--tcw-col); max-width: none !important; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr) var(--tcw-panel);
  grid-template-rows: auto repeat(var(--tcw-np), min-content) 1fr;
  column-gap: 16px; row-gap: 10px; align-content: stretch; }
html.tc-wide.tcw-split.tcw-wide.tcw-left [data-tcw="root"]:not(.hidden) { grid-template-columns: var(--tcw-panel) minmax(0, 1fr); }
html.tc-wide.tcw-split.tcw-wide [data-tcw="top"]   { grid-row: 1; grid-column: 1 / -1; }
html.tc-wide.tcw-split.tcw-wide [data-tcw="board"] { grid-row: 2 / -1; grid-column: 1; align-self: center; justify-self: center; }
html.tc-wide.tcw-split.tcw-wide [data-tcw="panel"] { grid-column: 2; align-self: start; min-width: 0; }
html.tc-wide.tcw-split.tcw-wide.tcw-left [data-tcw="board"] { grid-column: 2; }
html.tc-wide.tcw-split.tcw-wide.tcw-left [data-tcw="panel"] { grid-column: 1; }

/* fold (Duo opened, compact landscape): board on one half, top bar and panel on the other; nothing crosses the hinge */
html.tc-wide.tcw-split.tcw-fold [data-tcw="root"]:not(.hidden) {
  display: grid !important; width: var(--tcw-w); max-width: none !important; margin: 0;
  grid-template-columns: minmax(0, 1fr) calc(var(--tcw-hinge-w) + 32px) minmax(0, 1fr);
  grid-template-rows: auto repeat(var(--tcw-np), min-content) 1fr; row-gap: 10px; }
html.tc-wide.tcw-split.tcw-fold [data-tcw="board"] { grid-row: 1 / -1; grid-column: 1; align-self: center; justify-self: center; }
html.tc-wide.tcw-split.tcw-fold [data-tcw="top"],
html.tc-wide.tcw-split.tcw-fold [data-tcw="panel"] { grid-column: 3; min-width: 0; }
html.tc-wide.tcw-split.tcw-fold.tcw-left [data-tcw="board"] { grid-column: 3; }
html.tc-wide.tcw-split.tcw-fold.tcw-left [data-tcw="top"],
html.tc-wide.tcw-split.tcw-fold.tcw-left [data-tcw="panel"] { grid-column: 1; }

/* ---------------------------------------------------------------- 5. pop-ups and sheets */
/* bottom sheets stay centred but not wider than a phone sheet; on wide screens they rise from the panel side instead */
html.tc-wide.tcw-wide .overlay > .sheet,
html.tc-wide.tcw-fold .overlay > .sheet { max-width: 420px; }

/* ---------------------------------------------------------------- 6. reduce motion: the filler never moves anyway */

/* ---------------------------------------------------------------- 7. fold mode: pop-ups keep to one half (Nov 26, 2026, shared-fix worker)
   In fold mode nothing may sit across the hinge. These go to the PANEL half (the thumb side: right, or left with tcw-left), where the
   top bar and controls are, so the board on the other half stays clear. --tcw-hinge-x / -w come from wide.js (no hinge reported: the
   middle, width 0). Only in fold mode; tall and wide keep the centred pop-ups. */
/* the Kingdom / Stronghold reward toasts (+Gold, trophies, bounties, rank up: shared/meta.js .tcm-toasts, top centre) */
html.tc-wide.tcw-fold .tcm-toasts {
  left: calc(var(--tcw-hinge-x) + var(--tcw-hinge-w) + (100vw - var(--tcw-hinge-x) - var(--tcw-hinge-w)) / 2) !important;
  width: min(360px, calc(100vw - var(--tcw-hinge-x) - var(--tcw-hinge-w) - 24px)) !important; }
html.tc-wide.tcw-fold.tcw-left .tcm-toasts {
  left: calc(var(--tcw-hinge-x) / 2) !important; width: min(360px, calc(var(--tcw-hinge-x) - 24px)) !important; }
/* a page's own fixed #toast (centred with left:50% + translateX(-50%); wide.js marks it data-tcw-toast only when it is position:fixed,
   so the few pages whose #toast sits inside their own box are left alone) */
html.tc-wide.tcw-fold [data-tcw-toast]:not(#\9#\9) {
  left: calc(var(--tcw-hinge-x) + var(--tcw-hinge-w) + (100vw - var(--tcw-hinge-x) - var(--tcw-hinge-w)) / 2) !important;
  max-width: calc(100vw - var(--tcw-hinge-x) - var(--tcw-hinge-w) - 24px) !important; }
html.tc-wide.tcw-fold.tcw-left [data-tcw-toast]:not(#\9#\9) {
  left: calc(var(--tcw-hinge-x) / 2) !important; max-width: calc(var(--tcw-hinge-x) - 24px) !important; }
/* the tutorial's end card (shared/tutorial.js .tt-end: a centred card over a dark screen) on the panel half; its card in the steps
   is placed by TCWide.tutCard (wide.js) */
html.tc-wide.tcw-fold #tcTut .tt-end {
  display: grid; grid-template-columns: minmax(0, 1fr) calc(var(--tcw-hinge-w) + 24px) minmax(0, 1fr); align-items: center; justify-items: center; }
html.tc-wide.tcw-fold #tcTut .tt-end > .tt-card { grid-column: 3; grid-row: 1; width: min(330px, calc(100% - 24px)); }
html.tc-wide.tcw-fold.tcw-left #tcTut .tt-end > .tt-card { grid-column: 1; }
