/* ---------- a table's cells: their fills and errors, cells chosen and named, the bar's cell tools (16d, 16e) ---------- */

/* A cell's fill is a block of its colour, as its swatch is (style.css), its words in the ink that reads on it; typed
   in, it keeps its colour, ringed in that ink. */
.obj.table .tc[data-k], .obj.table .tc.th[data-k] { background: var(--k-f); color: var(--k-on); --ink-2: var(--k-on); }
.obj.table .tc[data-k]:focus { background: var(--k-f); box-shadow: inset 0 0 0 1.5px var(--k-on); }
/* A formula that can't be worked out shows its error (#DIV/0!...) in red, why on its tip. */
.obj.table .tc[data-err]:not(:focus):not([data-k]) { color: var(--k-red-a); }

/* Cells chosen together and the cells a formula names, in the table's colour, over the canvas under the bar (16e). */
#tcov { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#tcov > * { position: absolute; left: 0; top: 0; box-sizing: border-box; }
.tcv-r { border: 1.5px solid var(--c-table); border-radius: 2px; background: color-mix(in srgb, var(--c-table) 8%, transparent); }
.tcv-r.pt { border-style: dashed; }
.tcv-b { border: 2px solid var(--c-table); border-radius: 2px; background: color-mix(in srgb, var(--c-table) 10%, transparent); }
.tcv-f { border: 1.5px dashed var(--c-table); border-radius: 2px; }
/* The fill handle: a square at their corner, which a drag carries them on with. */
.tcv-h {
  width: 8px; height: 8px; margin: -5px 0 0 -5px; border-radius: 2px; background: var(--c-table); box-shadow: 0 0 0 1.5px var(--surface);
  pointer-events: auto; cursor: crosshair; touch-action: none;
}
.tcv-h::before { content: ""; position: absolute; inset: -7px; }
body.moving #tcov, body.drawing #tcov, body.sizing #tcov, body.marking #tcov, body.panning #tcov, body.dv #tcov { opacity: 0; }
body.tc-filling, body.tc-filling * { cursor: crosshair !important; }
/* Words chosen in the cell typed in don't show while cells are chosen: the cells are what is chosen. */
body.tc-blk .tgrid > .tc:focus { caret-color: transparent; }
body.tc-blk .tgrid > .tc::selection, body.tc-choosing .tgrid > .tc::selection { background: transparent; }

/* The bar's cell tools (tables.css has the bar): the cell's name, then ƒx, Σ and its ▾, the fill; its columns and
   rows after them, unless the window is narrow. */
.tgb-a { min-width: 3ch; padding: 0 2px 0 1px; font: 500 11px/1 var(--f-mono); letter-spacing: .03em; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
#tgbar.cell { padding-left: 8px; }
.tgb-o.tgb-v { width: 14px; margin-left: -3px; }
.tgb-o.tgb-v svg { width: 10px; height: 10px; }
.tgb-o[aria-expanded="true"] { color: var(--ink); background: var(--press-bg); box-shadow: var(--press); }
.tgb-sw {
  width: 12px; height: 12px; border-radius: 3px; box-sizing: border-box; background: var(--k-f);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 18%, transparent);
}
.tgb-sw:not([data-k]) { background: linear-gradient(to top right, transparent calc(50% - .6px), var(--ink-3) calc(50% - .6px), var(--ink-3) calc(50% + .6px), transparent calc(50% + .6px)); }
.tgb-sw.mixed { background: conic-gradient(var(--k-red-a) 0 25%, var(--k-yellow-a) 0 50%, var(--k-teal-a) 0 75%, var(--k-blue-a) 0); }
/* At its end, what cells chosen add up to (Excel's status bar's words). */
.tgb-s > span { padding-right: 3px; white-space: nowrap; font: 500 9px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-q); }
.tgb-s b { font: 500 11px/1 var(--f-mono); letter-spacing: .02em; text-transform: none; font-variant-numeric: tabular-nums; color: var(--ink); }
@media (max-width: 520px) { #tgbar.cell .tgb-n, .tgb-av { display: none; } }
@media (pointer: coarse) { .tgb-o.tgb-v { width: 22px; } .tgb-a { font-size: 12px; } }

/* The bar's lists: the Functions, the sums, the fills (the rail's card's look, rail.css). */
#tgpop {
  position: fixed; left: 0; top: 0; z-index: 30; width: 304px; max-width: calc(100vw - 16px); max-height: calc(100vh - 24px); overflow-y: auto;
  overscroll-behavior: contain; padding: 13px 10px 10px; box-sizing: border-box; border-radius: 9px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule), var(--pop); user-select: none; -webkit-user-select: none;
}
#tgpop.tgp-sums { width: 212px; padding: 5px; }
#tgpop.tgp-fill { width: 244px; padding: 13px 12px 12px; }
#tgpop[hidden] { display: none; }
#tgpop .ip-h { margin: 0 4px 10px; }
/* The kinds, on as many lines as they need: every one in sight, none past an edge to scroll to. */
.fx-k { display: flex; flex-wrap: wrap; gap: 2px; margin: 0 0 8px; padding: 2px; border-radius: 7px; background: var(--press-bg); box-shadow: var(--press); }
.fx-kb {
  flex: none; height: 24px; padding: 0 8px; border: 0; border-radius: 5px; cursor: pointer; background: transparent; color: var(--ink-q);
  font: 500 8.5px/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
}
.fx-kb[aria-selected="true"] { color: var(--ink); background: var(--surface); box-shadow: var(--raise-sm), var(--edge); }
@media (hover: hover) { .fx-kb:not([aria-selected="true"]):hover { color: var(--ink-2); } }
.fx-l { max-height: 216px; margin: 0 -2px; overflow-y: auto; overscroll-behavior: contain; }
.fx-i, .tgp-i {
  display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: baseline; gap: 8px; width: 100%; padding: 6px 8px; box-sizing: border-box;
  border: 0; border-radius: 6px; cursor: pointer; background: transparent; text-align: left; color: var(--ink-2); font: 12.5px/17px var(--f-ui);
}
.fx-i b, .tgp-i b { font: 500 10.5px/17px var(--f-mono); letter-spacing: .02em; color: var(--ink); }
.fx-i span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) { .fx-i:hover, .tgp-i:hover { color: var(--ink); background: var(--press-bg); } }
.fx-i:active, .tgp-i:active { background: var(--press-bg); box-shadow: var(--press); }
.tgp-i { grid-template-columns: 64px minmax(0, 1fr); }
.tgp-more { margin-top: 4px; position: relative; }
.tgp-more::before { content: ""; position: absolute; left: 8px; right: 8px; top: -3px; height: 1px; background: var(--rule); }
.fx-d { margin: 8px 0 0; padding: 10px 6px 2px; border-top: 1px solid var(--rule); }
.fxs { font: 500 11px/16px var(--f-mono); letter-spacing: .01em; color: var(--ink-2); overflow-wrap: anywhere; }
.fxs b { font-weight: 500; color: var(--ink); }
.fxs em { font-style: normal; color: var(--c-table); text-decoration: underline 1.5px; text-underline-offset: 3px; }
.fxd { margin-top: 4px; font: 12.5px/17px var(--f-ui); color: var(--ink-2); }
.fxe { margin-top: 5px; font: 500 10.5px/15px var(--f-mono); color: var(--c-table); overflow-wrap: anywhere; }

/* The formula's tip, under the cell typed in: the functions a name begins (one of them marked, as the arrow keys go),
   or how the function the caret is in is written. */
#fxtip {
  position: fixed; left: 0; top: 0; z-index: 12; width: max-content; max-width: min(340px, calc(100vw - 16px)); padding: 4px; box-sizing: border-box;
  border-radius: 8px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--rule), var(--pop); user-select: none; -webkit-user-select: none;
}
#fxtip[hidden] { display: none; }
#fxtip.sig { padding: 7px 10px 8px; max-width: min(380px, calc(100vw - 16px)); }
#fxtip .fxd { font-size: 12px; line-height: 16px; color: var(--ink-q); }
.fxo { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: baseline; gap: 8px; padding: 5px 8px; border-radius: 5px; cursor: pointer; font: 12px/16px var(--f-ui); color: var(--ink-q); }
.fxo b { font: 500 10.5px/16px var(--f-mono); letter-spacing: .02em; color: var(--ink); }
.fxo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fxo[aria-selected="true"] { color: var(--ink-2); background: var(--press-bg); box-shadow: var(--press); }
@media (hover: hover) { .fxo:hover { color: var(--ink-2); } }
@media (pointer: coarse) { .fxo { padding: 9px 10px; } .fx-i, .tgp-i { padding: 9px 8px; } .fx-kb { height: 30px; } }
@media (prefers-reduced-motion: reduce) { #tgpop, #fxtip { transition: none; } }
