/* /<game>/calculator Check a trade (pages/calculator.js, markup pages/calculator-markup.js): the header, You give and You
   get side by side, the answer under them. One frame per thing (spec/nav/UX.md rule 15): an item's only box is its
   tier tile (the Shop tile, spec/cards/PICK.md, ui.css .u-item); "+ Add" is a dashed square the size of a tile; the
   answer is words and buttons on the page, no panel. Spaces kept for what changes (a side's row of tiles, the answer),
   so adding or taking out an item never moves the page. Prefix ck-. Colours: tokens only. */

.ck .u-val { gap: 3px; }   /* the coin glued to its number (rule 16) */
/* two quick taps on a tile add two, never zoom the page */
.ck :is(.ck-q, .ck-opt, .ck-x, .ck-add, .ck-minebtn, .ck-step__btn) { touch-action: manipulation; }
.ck-head { margin-bottom: 24px; }
.ck-title { margin: 0 0 4px; }
.ck-sub { margin: 0; color: var(--color-wolf); font: 400 17px/24px var(--font); }
.ck-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: start; }
/* a side measures its own width (the tiles size from it) and keeps its layers to itself; the side with an open search
   list sits above the other (its list covers the other side's take-out buttons) */
.ck-side { min-width: 0; container-type: inline-size; isolation: isolate; }
.ck-side:focus-within { z-index: 2; }

/* the side's head: "YOU GIVE 🔥500" (the trade card's side label, the total right next to it), Use my items on the right */
.ck-side__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-height: 32px; margin-bottom: 12px; }
/* one line of text whose strut is the total's size, so the label sits on the same baseline with or without a total */
.ck-side__title { min-width: 0; margin: 0; color: var(--color-eel); font: 700 22px/28px var(--font); }
.ck-side__total { margin-left: 8px; color: var(--color-eel); font-variant-numeric: tabular-nums; }
.ck-side__total:empty { display: none; }
.ck-side__total .u-val { color: inherit; }
.ck-side__total .u-coin { width: 18px; height: 22px; }
.ck-none { color: var(--color-label); font-size: 15px; }
/* Use my items (signed in): a small text link, the button itself a 44px target round its words (the margins keep the
   head's line as it was) */
.ck-minebtn { flex: none; display: inline-flex; align-items: center; min-height: 44px; margin: -12px -8px; padding: 0 8px; border: 0; border-radius: 12px; background: none; color: var(--color-link); font: 700 15px/20px var(--font); cursor: pointer; }
@media (hover: hover) { .ck-minebtn:hover { text-decoration: underline; } }
.ck-minebtn:focus-visible { outline: 2px solid var(--color-macaw); outline-offset: -2px; }

/* ================================================================ a side's row: the picked tiles, then "+ Add"
   Four columns at most (4 items a side), each up to 112px; the row keeps room for a two-line name, so a long one
   ("Chroma Constellation") doesn't push the page down */
.ck-picks {
  --t: min(112px, (100cqw - 36px) / 4); --nl: 18px; --vl: 18px;
  position: relative; display: grid; grid-template-columns: repeat(4, var(--t)); gap: 12px; align-items: start;
  min-height: calc(var(--t) + 8px + 2 * var(--nl) + 2px + var(--vl)); margin: 0; padding: 0; list-style: none;
}
.ck-pick { position: relative; display: flex; min-width: 0; }
/* take one out: a small dot in the tile's top corner (inside it, like the tile's own marks), a 44px target round it */
.ck-x {
  position: absolute; top: 0; right: 0; z-index: 3; display: flex; align-items: flex-start; justify-content: flex-end;
  width: 44px; height: 44px; padding: 6px; border: 0; border-radius: 0 16px 0 0; background: none; color: var(--color-snow); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ck-x__dot {
  display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--color-wolf); box-shadow: 0 0 0 2px var(--color-snow); transition: background-color var(--m-fast) var(--m-ease-out);
}
.ck-x__dot > svg { width: 12px; height: 12px; }
@media (hover: hover) { .ck-x:hover .ck-x__dot { background: var(--color-eel); } }
.ck-x:active .ck-x__dot { transform: scale(.92); }
.ck-x:focus-visible { outline: none; }
.ck-x:focus-visible .ck-x__dot { outline: 2px solid var(--color-macaw); outline-offset: 2px; }
/* "+ Add": the dashed square, a "+" and the word in the link colour; it goes to the side's search */
.ck-add { cursor: pointer; }
.ck-add .u-item__slot { color: var(--color-link); transition: border-color var(--m-fast) var(--m-ease-out), transform var(--m-fast) var(--m-ease-out); }
.ck-add .u-item__slot > svg { width: 28px; height: 28px; }
.ck-add .u-item__name { color: var(--color-link); }
@media (hover: hover) { .ck-add:hover .u-item__slot { border-color: var(--color-link); } }
.ck-add:active .u-item__slot { transform: translateY(2px); }
.ck-add:focus-visible { outline: none; }
.ck-add:focus-visible .u-item__slot { outline: 2px solid var(--color-macaw); outline-offset: 3px; }
/* how many of a stack (a game whose slot holds one, MM2: "x42 Harvester" is one of its 4): − n + on the picture's foot,
   the pickers' stepper (app/components/itempick.css .ip-step: the same look and size; this page's own, as the server's
   first HTML draws it with calculator.css only). The number a field as wide as its digits (--d) */
.ck-step {
  position: absolute; top: 0; left: 50%; z-index: 3; display: flex; align-items: center; height: 32px;
  /* the picture is as wide as the tile and square: its foot is 100% of the tile's width down */
  margin-top: calc(100% - 38px); transform: translateX(-50%);
  border-radius: 10px; background: var(--color-snow); box-shadow: 0 0 0 2px var(--color-swan), 0 2px 0 2px var(--color-swan);
}
.ck-step__btn {
  position: relative; display: flex; align-items: center; justify-content: center; width: 30px; height: 32px; padding: 0;
  border: 0; border-radius: 10px; background: none; color: var(--color-macaw); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--m-fast) var(--m-ease-out);
}
.ck-step__btn::after { content: ""; position: absolute; inset: -6px -2px; }   /* a bigger target, inside the tile */
@media (hover: hover) { .ck-step__btn:not(:disabled):hover { background: var(--color-polar); } }
.ck-step__btn:active:not(:disabled) { transform: translateY(1px); }
.ck-step__btn:disabled { color: var(--color-hare); cursor: default; }
.ck-step__btn:focus-visible { outline: 2px solid var(--color-macaw); outline-offset: -2px; }
.ck-step__n {
  box-sizing: content-box; width: calc(var(--d, 1) * 1ch); min-width: 14px; height: 32px; margin: 0; padding: 0 4px;
  border: 0; border-radius: 6px; background: none; color: var(--color-eel); font: 700 15px/32px var(--font);
  font-variant-numeric: tabular-nums; text-align: center; caret-color: var(--color-macaw); outline: 0; appearance: none;
  -webkit-tap-highlight-color: transparent; cursor: text;
}
.ck-step__n:focus { background: var(--color-polar); box-shadow: inset 0 0 0 2px var(--color-macaw); }

/* ================================================================ the search under each side, with its list of matches */
.ck-find { position: relative; margin-top: 12px; }
.ck-search input:disabled { cursor: not-allowed; }
.ck-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; max-height: 360px; overflow-y: auto; background: var(--color-snow); }
.ck-results[hidden] { display: none; }
.ck-results__label { margin: 0; padding: 12px 14px 4px; color: var(--color-label); font: 700 13px/16px var(--font); letter-spacing: .06em; text-transform: uppercase; }
.ck-opt { grid-template-columns: 40px minmax(0, 1fr) auto; column-gap: 14px; padding: 8px 14px; min-height: 60px; }
.ck-opt__name { display: flex; flex-direction: column; min-width: 0; color: var(--color-eel); font-weight: 700; line-height: 20px; overflow-wrap: break-word; }
.ck-opt__name small { color: var(--color-wolf); font-weight: 400; font-size: 15px; }
.ck-opt__n { display: contents; }
.ck-opt.is-in .u-pic { box-shadow: inset 0 0 0 2px var(--color-macaw); }
.ck-opt.is-active .ck-opt__name, .ck-opt.is-active .ck-opt__name small { color: var(--color-whale); }
.ck-opt__val { color: var(--color-wolf); font-size: 15px; white-space: nowrap; }
/* a touch screen has no arrow keys: the first match lit in blue read as already picked (Go on the keyboard still
   takes it) */
@media (hover: none) {
  .ck-opt.is-active { background: var(--color-snow); color: var(--color-eel); }
  .ck-opt.is-active .ck-opt__name { color: var(--color-eel); }
  .ck-opt.is-active .ck-opt__name small { color: var(--color-wolf); }
}
.ck-noresult { margin: 0; padding: 16px; color: var(--color-label); font: 700 15px/20px var(--font); }

/* ================================================================ "Popular": four items to tap in
   The 40px tile with the name and value beside it, no frame (a soft hover). One in the trade: the picked edge, blue
   words and its count; a full side greys the rest */
.ck-quick { margin-top: 24px; }
.ck-quick:empty { display: none; }
.ck-quick__label { margin: 0 0 8px; color: var(--color-label); font: 700 13px/16px var(--font); letter-spacing: .06em; text-transform: uppercase; }
.ck-quick__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }
.ck-q { display: flex; align-items: center; gap: 12px; min-width: 0; min-height: 56px; padding: 6px 8px; margin: 0 -8px; border: 0; border-radius: 12px; background: none; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
@media (hover: hover) { .ck-q:not(:disabled):hover { background: var(--color-polar); } }
.ck-q:not(:disabled):active .u-pic { transform: translateY(2px); }
.ck-q:focus-visible { outline: 2px solid var(--color-macaw); outline-offset: -2px; }
.ck-q .u-pic { flex: none; transition: box-shadow var(--m-fast) var(--m-ease-out), transform var(--m-fast) var(--m-ease-out); }
.ck-q__text { display: flex; flex-direction: column; min-width: 0; }
.ck-q__name { color: var(--color-eel); font: 700 15px/20px var(--font); overflow-wrap: break-word; }
.ck-q .u-val { color: var(--color-label); font: 700 15px/20px var(--font); }
.ck-q.is-picked .u-pic { box-shadow: inset 0 0 0 2px var(--color-macaw); }
.ck-q.is-picked :is(.ck-q__name, .u-val) { color: var(--color-whale); }
.ck-q:disabled { cursor: default; }
.ck-q:disabled:not(.is-picked) .u-pic { background: var(--item-off-face); }
.ck-q:disabled:not(.is-picked) .u-pic > img { opacity: var(--item-off-img); filter: var(--item-off-filter); }
.ck-q:disabled:not(.is-picked) .ck-q__name { color: var(--color-label); }

/* "Use my items": your items as picture cards in a window */
.ck-minemodal { width: min(680px, calc(100vw / var(--zoom, 1) - 32px)); max-width: none; }
.ck-mine__hint { margin: 0 0 12px; color: var(--color-wolf); font: 700 15px/20px var(--font); text-align: center; }
.ck-mine__grid { max-height: min(calc(52vh / var(--zoom, 1)), 480px); overflow-y: auto; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); padding: 4px 6px 8px 4px; text-align: left; }

/* ================================================================ the answer: one big line, one muted line, the buttons
   Left-aligned under the sides; its room is kept while it waits, so it fills in without moving anything */
.ck-out { min-height: 140px; margin-top: 32px; }
.ck-hint { margin: 0; padding: 5px 0; color: var(--color-wolf); font: 400 17px/24px var(--font); }
.ck-hint.is-bad { color: var(--color-fire-ant); font-weight: 700; }
.ck-answer__title { width: fit-content; max-width: 100%; margin: 0; color: var(--color-eel); font: 700 28px/34px var(--font); font-variant-numeric: tabular-nums; transform-origin: left center; }
.ck-answer__title .u-val { color: inherit; }
.ck-answer__title .u-coin { width: 22px; height: 28px; }
.ck-answer__sub { margin: 4px 0 0; color: var(--color-wolf); font: 400 17px/24px var(--font); }
.ck-link { color: var(--color-link); font-weight: 700; text-decoration: none; border-radius: 4px; }
@media (hover: hover) { .ck-link:hover { text-decoration: underline; } }
.ck-link:focus-visible { outline: 2px solid var(--color-macaw); outline-offset: 2px; }
.ck-answer__btns { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

/* a narrow side (two columns on a small laptop): tiles under 100px, so the names one step down (Deathspeaker fits) */
@container (max-width: 439px) {
  .ck-picks { --nl: 17px; --vl: 17px; }
  .ck-picks .u-item__name, .ck-picks :is(.u-item__val, .u-item__why) { font-size: 14px; line-height: 17px; }
}
/* one column: the sides one over the other, Popular folded into the search (an empty field lists it), so the answer
   stays near the first screen */
@media (max-width: 899px) {
  .ck-cols { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .ck-quick { display: none; }
}
/* phones: a side is its name, the search, then the tiles picked, four a row. The search is the one way to add here (no
   "+ Add" tile beside it doing the same, UX.md rule 12) and an empty side has no row, so both sides fit the first
   screen. Tapping a search lifts its side under the top bar (calculator.js): the keyboard covers the lower half, the
   list drops into the room between, and a pick lands right under the field, in view, with the answer under the sides. */
@media (max-width: 699px) {
  .ck-head { margin-bottom: 16px; }
  .ck-cols { gap: 24px; }
  /* lifted under the top bar by the page's own scroll padding (frame.css: the bar + 16px); a scroll margin on top of it
     left the previous side's last 68px in sight and the list under the keyboard */
  .ck-side { display: flex; flex-direction: column; }
  .ck-side__head { order: -2; min-height: 28px; margin-bottom: 8px; }
  .ck-find { order: -1; margin-top: 0; }
  /* the list under the search: 48px pictures */
  .ck-opt { grid-template-columns: 48px minmax(0, 1fr) auto; min-height: 64px; }
  .ck-opt .u-pic { --s: 48px !important; }   /* UI.pic writes its 40px on the element */
  .ck-pick--add { display: none; }
  .ck-picks:not(:has(.ck-pick:not(.ck-pick--add))) { display: none; }
  html.kb .ck-results { max-height: max(176px, calc(var(--vv-h, calc(100dvh / var(--zoom, 1))) - var(--f-top-h) - 128px)); }
  /* the items picked: tiles four a row (a side holds four), the name under each */
  .ck-picks { --t: calc((100cqw - 24px) / 4); --nl: 17px; --vl: 17px; margin-top: 16px; gap: 8px; }
  .ck-picks .u-pic--fill[data-tier] { padding: 6%; }   /* the item fills its tile */
  .ck-out { min-height: 196px; margin-top: 24px; }
  .ck-answer__btns { flex-direction: column; align-items: stretch; margin-top: 16px; }
  .ck-link { padding: 11px 0; }   /* a 44px tap round the words; inline, so the line doesn't grow */
  /* "Use my items": tiles three a row, two where three would leave a picked one's − n + wider than its tile (the
     narrowest phones; ui.css's phone grid is .u-tiles:not(.u-tiles--sm), so this says .u-tiles too) */
  .u-tiles.ck-mine__grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 16px 8px; }
}
/* a phone where four tiles a row would be under 92px (− 999 + is 92px wide): where a slot is a stack, three a row */
@media (max-width: 699px) {
  @container (max-width: 391px) {
    .ck-picks--stacks { --t: calc((100cqw - 16px) / 3); grid-template-columns: repeat(3, var(--t)); }
  }
}
/* the narrowest phones (320-359px): three tiles a row, so a name like Harvester stays whole (four left 58px tiles) */
@media (max-width: 359px) {
  .ck-picks { --t: calc((100cqw - 16px) / 3); grid-template-columns: repeat(3, var(--t)); }
}
