/* web/hud/gambits.css
   The Gambits panel (web/hud/gambits.js), worded as Final Fantasy XII's: a small toggle
   reading On or Off in its title bar (web/hud/gambit_switch.js), then five rows of a grip, a lamp,
   a target cell, an arrow, an action cell and the peace sign, and under them Up, Down
   and Clear for the selected row. A cell's list opens beside the panel
   (web/hud/panel_actions.css). A row being dragged by its grip is faded and dashed,
   with a line in the panel's colour where it will land. A row is tinted by whether it
   helps or harms, and the row that fired is lit in the panel's colour over its tint for
   a moment. Every size is in em, so it follows the panel's text size. */

.gb { --gb-peace: #b9b4ff; }
/* The toggle's track and knob are drawn in the middle of its button, so with touch
   controls the button grows to a finger's size and they do not. */
.gb-switch {
  display: inline-flex; align-items: center; gap: .45em; margin: 0;
  font-weight: 700; color: var(--pn-text);
}
.gb-switch .gb-toggle { position: relative; width: 2.3em; height: 1.4em; padding: 0; border: 0; background: none; cursor: pointer; }
.gb-toggle::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 2.1em; height: 1.15em; box-sizing: border-box;
  border-radius: 1em; border: 1px solid #3a3f4b; background: #2a2e3a; transition: background .15s, border-color .15s;
}
.gb-toggle::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: .8em; height: .8em; margin: -.4em 0 0 -.95em;
  border-radius: 50%; background: #8a90a2; transition: margin-left .15s;
}
.gb-toggle[aria-checked="true"]::before { background: color-mix(in srgb, var(--tc) 55%, #2a2e3a); border-color: var(--tc); }
.gb-toggle[aria-checked="true"]::after { margin-left: .15em; background: #ffe2a6; }
.gb-switch .gb-toggle:disabled { opacity: .5; cursor: default; }
@media (prefers-reduced-motion: reduce) { .gb-toggle::before, .gb-toggle::after { transition: none; } }
/* The rows share one grid, so the arrows line up down the board. The target and the
   action share what the grip, lamp, arrow and peace sign leave, evenly until one has
   all it needs; the action takes what is over. Neither is ever wider than its share,
   so a long word breaks rather than widening the board. */
.gb-rows {
  list-style: none; margin: 0; padding: 0; display: grid; gap: .3em .3em;
  grid-template-columns: max-content 1.2em minmax(0, max-content) 1em minmax(0, auto) 1.45em;
}
.gb-row {
  grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; position: relative;
  align-items: center; padding: .3em .4em; border-radius: 5px;
  border: 1px solid #262a36; background: #14161d; transition: border-color .4s, box-shadow .4s;
}
/* A row that helps or harms is tinted in its meaning's colour, which gambits.js sets as
   --gb-tint, faint enough that the cells stay readable. */
.gb-row.tinted {
  background: color-mix(in srgb, var(--gb-tint) 11%, #14161d);
  border-color: color-mix(in srgb, var(--gb-tint) 30%, #262a36);
}
.gb-row.off, .gb-all-off .gb-row { opacity: .5; }
.gb-row.sel { border-color: #454c63; background: #181b24; }
.gb-row.sel:where(.tinted) {
  background: color-mix(in srgb, var(--gb-tint) 15%, #181b24);
  border-color: color-mix(in srgb, var(--gb-tint) 55%, #454c63);
}
.gb-row.lit {
  border-color: var(--tc); transition: none;
  box-shadow: 0 0 0 1px var(--tc) inset, 0 0 .8em color-mix(in srgb, var(--tc) 30%, transparent);
}

/* The line sits in the gap between two rows, past the row's 1px border. */
.gb-row.drag { opacity: .55; border-style: dashed; }
.gb-row.drop-before::before, .gb-row.drop-after::after {
  content: ""; position: absolute; left: .3em; right: .3em; height: 2px; border-radius: 2px;
  background: var(--tc); pointer-events: none;
}
.gb-row.drop-before::before { top: calc(-.15em - 2px); }
.gb-row.drop-after::after { bottom: calc(-.15em - 2px); }
.gb-rows.dragging, .gb-rows.dragging * { cursor: grabbing; user-select: none; }

/* The grip is as tall as its row, and its dots' width is the font's, never squeezed. */
.gb-grip {
  align-self: stretch; padding: 0 .1em; border: 0; border-radius: 3px; background: none;
  font: inherit; line-height: 1; color: var(--pn-quiet); cursor: grab; touch-action: none;
}
.gb-grip:hover, .gb-grip:focus-visible { color: var(--pn-soft); }
/* The lamp is a dot drawn in the middle of its button, so with touch controls
   (web/hud/touch.css) the button grows to a finger's size and the dot does not. */
.gb-lamp {
  position: relative; width: 1.15em; height: 1.15em; padding: 0; border: 0; border-radius: 50%;
  background: none; cursor: pointer;
}
.gb-lamp::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 1.15em; height: 1.15em;
  box-sizing: border-box; border-radius: 50%; border: 1px solid #3a3f4b; background: #1d2029;
}
.gb-lamp.on::before {
  border-color: var(--tc);
  background: radial-gradient(circle at 40% 35%, color-mix(in srgb, var(--tc) 35%, #fff), var(--tc) 60%,
    color-mix(in srgb, var(--tc) 50%, #000));
}
/* With touch controls every button is about 44px square, so the grip and lamp columns
   take their buttons' width rather than overlapping. */
:where(:root[data-controls="touch"]) .gb-rows {
  grid-template-columns: max-content max-content minmax(0, max-content) 1em minmax(0, auto) max-content;
}
/* A cell too long for the column wraps between words rather than hiding what it says,
   and a word too long for it breaks. Its words carry the Tap indicator (web/hud/tap.css). */
.gb-cell {
  min-width: 0; overflow-wrap: anywhere; padding: .1em .3em; border: 1px solid transparent; border-radius: 4px;
  background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.gb-cell:hover { border-color: transparent; }
.gb-cell:focus-visible, .gb-lamp:focus-visible, .gb-grip:focus-visible,
.gb-peace:focus-visible, .gb-toggle:focus-visible { outline: 1px solid #7fb2ff; outline-offset: 1px; }
.gb-cell.empty { color: var(--pn-quiet); }
.gb-cell.unusable { color: var(--pn-faint); text-decoration: line-through; }
.gb-side { font-weight: 700; }
.gb-arrow { color: var(--pn-faint); text-align: center; }
.gb-refusal { grid-column: 1 / -1; margin: .1em 0 0; font-size: .85em; color: var(--warn); }
/* The peace sign, lit when the row also works outside a fight. */
.gb-peace {
  display: inline-flex; align-items: center; justify-content: center; width: 1.45em; height: 1.45em;
  padding: 0; border: 1px solid transparent; border-radius: 4px; background: none; color: var(--pn-quiet); cursor: pointer;
}
.gb-peace svg { width: 1em; height: 1em; }
.gb-peace:hover { border-color: var(--cell-edge); color: var(--pn-soft); }
.gb-peace.on { color: var(--gb-peace); border-color: color-mix(in srgb, var(--gb-peace) 45%, transparent); }

.gb-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .35em; margin-top: .55em; }
.gb-picked { margin-left: auto; font-size: .85em; color: var(--pn-soft); }
.gb-note { margin: .3em 0 0; font-size: .85em; color: var(--warn); }
.gb-note:empty { display: none; }

/* A row stays on one line while the target and the action each have room for a word of
   twelve letters. Narrower, the action goes under the target, the arrow under the lamp
   and the peace sign after the action; the grip runs down both lines. With touch
   controls the grip and lamp take more room, so a row goes to two lines sooner, and on
   the narrowest board they share the first line with the peace sign, the target has
   the second and the action the third. */
.gb { container-type: inline-size; }
@container (width < 21.5em) {
  .gb-rows { grid-template-columns: max-content 1.2em minmax(0, 1fr) 1.45em; }
  .gb-row > .gb-grip { grid-area: 1 / 1 / span 2; }
  .gb-row > .gb-lamp { grid-area: 1 / 2; }
  .gb-row > [data-cell="target"] { grid-area: 1 / 3 / auto / span 2; }
  .gb-row > .gb-arrow { grid-area: 2 / 2; }
  .gb-row > [data-cell="action"] { grid-area: 2 / 3; }
  .gb-row > :is(.gb-peace, .gb-peace-gap) { grid-area: 2 / 4; }
}
@container (width < 28em) {
  :where(:root[data-controls="touch"]) .gb-rows {
    grid-template-columns: max-content max-content minmax(0, 1fr) max-content;
  }
  :where(:root[data-controls="touch"]) .gb-row > .gb-grip { grid-area: 1 / 1 / span 2; }
  :where(:root[data-controls="touch"]) .gb-row > .gb-lamp { grid-area: 1 / 2; }
  :where(:root[data-controls="touch"]) .gb-row > [data-cell="target"] { grid-area: 1 / 3 / auto / span 2; }
  :where(:root[data-controls="touch"]) .gb-row > .gb-arrow { grid-area: 2 / 2; }
  :where(:root[data-controls="touch"]) .gb-row > [data-cell="action"] { grid-area: 2 / 3; }
  :where(:root[data-controls="touch"]) .gb-row > :is(.gb-peace, .gb-peace-gap) { grid-area: 2 / 4; }
}
@container (width < 19em) {
  :where(:root[data-controls="touch"]) .gb-row > .gb-grip { grid-area: 1 / 1; }
  :where(:root[data-controls="touch"]) .gb-row > [data-cell="target"] { grid-area: 2 / 1 / auto / -1; }
  :where(:root[data-controls="touch"]) .gb-row > :is(.gb-peace, .gb-peace-gap) { grid-area: 1 / 4; }
  :where(:root[data-controls="touch"]) .gb-row > .gb-arrow { grid-area: 3 / 1; }
  :where(:root[data-controls="touch"]) .gb-row > [data-cell="action"] { grid-area: 3 / 2 / auto / -1; }
}
