/* Function Machine */
/* the bar: long words on a wide tool, short words on a phone */
.fm-short{display:none}
.fm-dirlab{display:inline-flex;align-items:center;gap:.4em}
.fm-ico{width:1.25em;height:1.25em;flex:none;fill:none;stroke:currentColor;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
.fm-dir .btn[data-value=fwd][aria-pressed=true]{background:var(--blue);color:#fff}
.fm-dir .btn[data-value=back][aria-pressed=true]{background:var(--orange);color:#fff}

/* the stage: the tray of cards, the picture, the plates under the machines */
.fm-stage{display:flex;flex-direction:column}
.fm-tray{flex:none;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.4em;padding:.6em .7em .2em;position:relative;z-index:1}
.fm-tcard{display:inline-grid;place-items:center;min-width:max(1.85em,42px);height:max(2.05em,46px);padding:0 .25em;border:2px solid var(--ink);border-radius:.4em;background:#fff;color:var(--ink);
  font:700 1.3em/1 var(--font-head);font-variant-numeric:tabular-nums;box-shadow:2px 3px 0 var(--ink);cursor:grab;-webkit-tap-highlight-color:transparent;transition:transform .12s}
.fm-tcard:hover{transform:translateY(-3px) rotate(-3deg)}
.fm-tcard:nth-child(even):hover{transform:translateY(-3px) rotate(3deg)}
.fm-tcard:active{transform:translateY(1px)}
.fm-type{display:inline-flex;align-items:center;gap:.4em;margin-left:.5em}
.fm-type .ctl-label{max-width:4.5em;white-space:normal;text-align:right;line-height:1.1}
.fm-type .stepper input{width:3.6ch}
.fm-picwrap{flex:1;min-height:0;position:relative;z-index:2;pointer-events:none}
.fm-picwrap>svg{position:absolute;inset:0;width:100%;height:100%;display:block;overflow:visible}
.fm-plates{flex:none;position:relative;margin-bottom:1.5em}
.fm-plates:empty{display:none}
.fm-plate{position:absolute;top:0;display:flex;flex-direction:column;align-items:center;gap:.15em;padding:.25em .5em .45em;background:#f4f7fb;border:2px solid var(--ink);border-radius:.7em;box-shadow:2px 3px 0 var(--ink)}
.fm-plate-name{font-size:.76em;font-weight:600;color:var(--soft);white-space:nowrap}
.fm-plate-row{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.4em .5em}
.fm-pick{display:inline-flex;align-items:center;gap:.3em}
.fm-plate .ctl-label{display:none}
.fm-ops .btn{min-width:max(2.1em,42px);padding:0 .35em;font-size:1.2em;min-height:max(2.08em,42px)}
.fm-then{font-weight:600;color:var(--soft);font-size:.9em}.fm-check{min-width:5.5em}
[data-solved="1"] .fm-check{background:#fff;color:var(--ink)}
/* a phone: the plates and the settings of the rule are a panel over the stage */
.fm-slot{display:contents}
.fm-popbtn,.fm-popopts,.fm-done{display:none}
.fm-plates.pop{position:absolute;left:.5em;right:.5em;top:.5em;z-index:8;height:auto!important;margin:0;display:none;flex-direction:column;align-items:center;gap:.5em;
  padding:.7em .5em .8em;background:#fff;border:2px solid var(--ink);border-radius:.8em;box-shadow:3px 4px 0 var(--ink)}
.fm-plates.pop.open{display:flex}
.fm-plates.pop .fm-popopts{display:flex;flex-wrap:wrap;justify-content:center;gap:.45em}
.fm-plates.pop .fm-plate{position:static;box-shadow:none;max-width:100%!important}
.fm-plates.pop .fm-done{display:inline-flex;min-width:6em}
.fm-ghost{position:absolute;left:0;top:0;z-index:6;pointer-events:none;will-change:transform}
.fm-ghost>svg{display:block;width:100%;height:100%;overflow:visible;filter:drop-shadow(3px 6px 4px rgba(20,26,34,.28))}

/* the drawing */
.fm-art text{font-family:Lexend,Arial,sans-serif;font-weight:700}
.fm-art .fm-ink{stroke:var(--ink);stroke-width:var(--sw,3px);stroke-linejoin:round;vector-effect:non-scaling-stroke}
.fm-art .fm-ink.thin{stroke-width:var(--sw2,1.8px)}
.fm-art .fm-shadow{fill:var(--ink);opacity:.12}
.fm-art .fm-label,.fm-art .fm-cover-q,.fm-art .fm-num text{fill:var(--ink)}
.fm-art .fm-bar{stroke:var(--ink);fill:none;stroke-linecap:round}
.fm-art .fm-arrow-shape{stroke:none}
.fm-art .on-dark .fm-arrow-shape{fill:#fff;stroke:var(--ink);stroke-width:var(--sw2,1.8px);vector-effect:non-scaling-stroke;stroke-linejoin:round}
.fm-art .fm-ray{stroke-width:var(--sw2,1.8px);stroke-linecap:round;vector-effect:non-scaling-stroke}
.fm-art .fm-puff circle{fill:#fff}
.fm-art .fm-puff .fm-puff-in{stroke:none}
.fm-art .fm-tick{stroke:var(--ink);stroke-width:var(--sw2,1.8px);vector-effect:non-scaling-stroke;stroke-linecap:round}
.fm-art .fm-needle{fill:var(--red)}
.fm-art .fm-card-face{stroke:var(--ink);stroke-width:var(--sw,3px);vector-effect:non-scaling-stroke}
.fm-art .fm-card-shadow{fill:var(--ink);opacity:.22}
.fm-art .fm-ask{fill:#5b6573}
.fm-art .fm-zone-box{fill:rgba(31,111,209,.06);stroke:var(--blue);stroke-width:3px;stroke-dasharray:9 7;vector-effect:non-scaling-stroke}
.fm-art .fm-zone-box.hot{fill:rgba(31,111,209,.16);stroke-dasharray:none}
[data-dir=back] .fm-art .fm-zone-box{fill:rgba(232,115,12,.07);stroke:var(--orange)}
[data-dir=back] .fm-art .fm-zone-box.hot{fill:rgba(232,115,12,.18)}
.fm-art .fm-sign-lab{fill:var(--soft)}
.fm-art .fm-sign-q,.fm-art .fm-sign-none{fill:#7b8694}
.fm-art .fm-tag-text{fill:var(--red)}
.fm-art .fm-tag .fm-ink{stroke:var(--red)}

/* the side panel: what the machine says, and the table */
#side{width:20em;gap:.6em;padding-bottom:1.6em}
.fm-saybox{position:relative;flex:none;min-height:4.4em;display:flex;align-items:center;padding:.4em .7em;background:#fff;border:2px solid var(--ink);border-radius:.8em;box-shadow:2px 3px 0 var(--ink)}
.fm-saybox::before{content:"";position:absolute;left:-.62em;top:50%;width:1em;height:1em;margin-top:-.5em;background:#fff;border-left:2px solid var(--ink);border-bottom:2px solid var(--ink);transform:rotate(45deg)}
.fm-say{margin:0;font:600 .95em/1.3 var(--font-head);color:#2b3440}
.fm-table{--cols:1fr 1.5em 1fr;flex:none;border:2px solid var(--ink);border-radius:.7em;background:#fff;overflow:hidden;font-variant-numeric:tabular-nums}
.fm-table.three{--cols:1fr 1.1em 1fr 1.1em 1fr}
.fm-tr,.fm-th2{display:grid;grid-template-columns:var(--cols);align-items:center;min-height:1.85em;border-top:1px solid var(--grid-strong)}
.fm-th,.fm-th2{border-top:0;min-height:1.9em;background:var(--desk);border-bottom:2px solid var(--ink);font-weight:700;font-size:.85em;color:#39424e;text-align:center}
.fm-table .fm-th2{display:none}
.fm-rows .fm-tr:first-child{border-top:0}
.fm-td{text-align:center;font-weight:700;font-size:1.25em;line-height:1;padding:.1em 0;white-space:nowrap}
.fm-ta{display:grid;place-items:center}
.fm-tarrow{width:1.1em;height:.7em;fill:none;stroke:var(--blue);stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round}
.fm-tr.back{background:var(--tint-orange)}
.fm-tr.back .fm-tarrow{stroke:var(--orange)}
.fm-tr.newest{box-shadow:inset .3em 0 0 var(--gold)}
.fm-tr.flash{animation:fm-flash 1.1s ease-out}
@keyframes fm-flash{0%{background:var(--sun)}}
.fm-tr.wrong{background:var(--red-tint)}
.fm-td.bad .fm-n{display:inline-block;padding:.08em .3em;border:2px solid var(--red);border-radius:999px;color:var(--red)}
.fm-n{display:inline-flex;align-items:center}
.fm-fr{display:inline-flex;flex-direction:column;align-items:center;font-size:.6em;line-height:1.05;margin-left:.12em}
.fm-fr span:first-child{border-bottom:2px solid currentColor;padding:0 .1em}
.fm-sidebtns{display:flex;flex-wrap:wrap;gap:.5em}
.fm-sidebtns .btn{padding:0 .6em}
/* the bar must stay one row on a laptop, also in Guess the rule with two machines */
#bar{gap:.55em .75em}
.fm-level .btn{padding:0 .65em}
@media (prefers-reduced-motion:reduce){.fm-tr.flash{animation:none}.fm-tcard{transition:none}}

/* a tall or narrow tool: the side panel goes under the stage, and the table is two halves of four rows */
@container (max-width:680px) or (orientation:portrait){
  .tool-body{flex-direction:column}
  #side{width:auto;flex:none;border-left:0;border-top:2px solid var(--ink);padding:.5em .6em 1.4em;overflow:visible;
    display:grid;grid-template-columns:minmax(0,1fr);gap:.45em}
  .fm-saybox{min-height:3.2em}
  .fm-saybox::before{left:50%;top:-.62em;margin:0 0 0 -.5em;border:0;border-left:2px solid var(--ink);border-top:2px solid var(--ink)}
  .fm-table{display:grid;grid-template-columns:1fr 1fr}
  .fm-table .fm-th2{display:grid;border-left:2px solid var(--ink)}
  .fm-rows{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr;grid-template-rows:repeat(4,auto);grid-auto-flow:column}
  .fm-rows .fm-tr:nth-child(5){border-top:0}
  .fm-rows .fm-tr:nth-child(n+5){border-left:2px solid var(--ink)}
  .fm-sidebtns{justify-content:center}
}
@container (min-width:600px) and (orientation:portrait){
  #side{grid-template-columns:minmax(12em,1fr) 2fr;grid-template-areas:"say table" "btns table";align-items:start}
  .fm-saybox{grid-area:say}
  .fm-table{grid-area:table}
  .fm-sidebtns{grid-area:btns;justify-content:flex-start}
  .fm-saybox::before{left:auto;right:-.62em;top:50%;margin:-.5em 0 0;border:0;border-right:2px solid var(--ink);border-top:2px solid var(--ink)}
}
/* a phone: short words in the bar, the rule under the table, and a smaller tray */
@container (max-width:680px){
  .fm-long{display:none}
  .fm-short{display:inline}
  #bar{gap:.4em .5em}
  .fm-tray{gap:.3em;padding:.45em .3em .15em}
  .fm-tcard{min-width:42px;height:44px;font-size:1.2em}
  /* on a phone the typed number is a card to write on: tap it, type, and press Go on the keyboard */
  .fm-type{margin-left:0}
  .fm-type .ctl-label,.fm-type .stepper button{display:none}
  .fm-type .stepper{border-style:dashed;border-radius:.4em;min-height:44px}
  .fm-type .stepper input{width:2.9em;border:0;font-size:1.15em}
  .fm-drop{display:none}
  /* the words of the machine are read aloud, but there is no room to show them */
  .fm-saybox{position:absolute;width:1px;height:1px;min-height:0;padding:0;border:0;overflow:hidden;clip-path:inset(50%)}
  #bar .spacer{display:none}
  .fm-popbtn{display:inline-flex}
  .fm-td{font-size:1.1em}
}
