/* Place Value Chart */
#stage{display:flex;flex-direction:column}

/* control bar */
.pv-form{flex-wrap:nowrap}
.pv-input{width:7.5em;min-height:max(2.5em,42px);padding:0 .5em;border:2px solid var(--ink);border-radius:.6em;background:#fff;color:var(--ink);font:700 1.1em/1 var(--font-head);font-variant-numeric:tabular-nums}
.pv-input[aria-invalid=true]{border-color:var(--red);box-shadow:0 0 0 2px var(--red-tint)}
.pv-shift .btn{min-width:3.6em}

/* side panel */
#side{gap:.9em}
.pv-short{display:none}
.pv-group{display:flex;flex-direction:column;align-items:flex-start;gap:.4em}
.pv-side-h{margin:0;font-weight:700;font-size:.95em}
.pv-group .ctl{flex-direction:column;align-items:flex-start;gap:.25em}
.pv-info{margin:-.15em 0 .2em;font-size:.85em;font-weight:600;color:var(--soft)}

/* number display */
.pv-display{flex:none;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.1em 1.4em;padding:.3em .8em .35em;min-height:4.4em}
.pv-num{font-size:min(5em,8.5cqw,12.5cqh);font-weight:700;line-height:1.1;white-space:nowrap;font-variant-numeric:tabular-nums}
.pv-num .sep{color:var(--ink)}
.pv-q{display:inline-block;min-width:2.6em;padding:0 .3em;text-align:center;border:.06em dashed var(--ink);border-radius:.2em;background:#fff;color:var(--ink)}
.pv-facts{flex:0 1 auto;min-width:0;max-width:44em;font-size:1.05em;line-height:1.3}
.pv-facts p{margin:.1em 0}
.pv-words{font-weight:600}
.pv-exp{font-weight:700;font-variant-numeric:tabular-nums}
.pv-note{display:inline-block;padding:.12em .55em;border:2px solid var(--gold);border-radius:.5em;background:var(--gold-tint);font-weight:600;font-size:.9em}
.pv-note.err{border-color:var(--red);background:var(--red-tint);color:#9c2410}

/* chart */
.pv-scroll{flex:1;min-height:0;overflow-x:auto;overflow-y:hidden;padding:0 .7em .7em;overscroll-behavior-x:contain}
.pv-chart{display:flex;width:100%;height:100%;min-width:calc(var(--n)*5.8em);border:2px solid var(--ink);border-radius:.8em;overflow:hidden;background:#fff;box-shadow:.15em .22em 0 rgba(20,26,34,.12)}
.pv-col{flex:1 1 0;min-width:0;display:flex;flex-direction:column;border-left:2px solid var(--ink);position:relative;container-type:inline-size}
.pv-col:first-child{border-left:0}
.pv-col.dec{background:#fbfcfe}
.pv-head{flex:none;height:3.4em;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.1em;padding:0 .2em;background:var(--c);color:#fff;border-bottom:2px solid var(--ink);text-align:center}
.pv-col.dec .pv-head{background:var(--ct);color:var(--c)}
.pv-name{font-size:.8em;font-weight:600;line-height:1.1}
.pv-val{font-size:1.05em;font-weight:700;line-height:1;font-variant-numeric:tabular-nums}
.pv-digit{flex:none;height:2.3em;display:grid;place-items:center;position:relative;border-bottom:2px solid var(--line)}
.pv-digit b{font-size:1.75em;line-height:1;color:var(--c)}
.pv-col.over .pv-head{box-shadow:inset 0 0 0 .22em var(--gold)}
.pv-col.over .pv-digit{background:var(--gold-tint)}
.pv-col.over .pv-digit b{color:var(--ink)}
.pv-col.over .pv-digit::before{content:"!";position:absolute;left:.3em;top:50%;transform:translateY(-50%);display:grid;place-items:center;width:1.3em;height:1.3em;border-radius:50%;background:var(--gold);border:2px solid var(--ink);font-weight:700;font-size:.85em}
.pv-chart.hide .pv-digit b{visibility:hidden}
/* the decimal point sits on the line between the ones and the tenths */
.pv-col.pt .pv-digit::after{content:"";position:absolute;z-index:3;right:-.42em;bottom:.35em;width:.7em;height:.7em;border-radius:50%;background:var(--ink)}
.pv-col.pt + .pv-col{border-left-width:4px}

/* counters in ten-frames: 1 to 10 in the first frame, 11 to 19 in the second */
.pv-area{flex:1;min-height:0;display:grid;place-items:center;container-type:size;cursor:pointer;outline-offset:-4px}
.pv-frames{--cell:min(calc((100cqw - 1.4em) / 4.15), calc((100cqh - .8em) / 5.1), 7em);display:flex;gap:.5em}
.pv-frame{display:grid;grid-template-columns:repeat(2,var(--cell));grid-template-rows:repeat(5,var(--cell));grid-auto-flow:column;gap:1.5px;background:#d3deea;border:2px solid #aebdcd;border-radius:.3em;overflow:hidden}
.pv-frame.f2{border-style:dashed}
.pv-col:not(.more) .f2{display:none}
/* while only the first frame is in use, its counters can be larger */
.pv-col:not(.more) .pv-frames{--cell:min(calc((100cqw - .8em) / 2.15), calc((100cqh - .8em) / 5.15), 7em)}
.pv-cell{display:grid;place-items:center;background:#fff}
.pv-counter{width:82%;height:82%;border-radius:50%;background:var(--cl);border:max(2px,calc(var(--cell) * .07)) solid var(--ink);box-shadow:0 calc(var(--cell) * .06) 0 rgba(20,26,34,.22);touch-action:none;cursor:grab;transition:transform .18s}
.pv-counter.pop{animation:pv-pop .24s ease-out}
.pv-counter.lifted{position:relative;z-index:6;pointer-events:none;transition:none;cursor:grabbing;box-shadow:0 calc(var(--cell) * .18) calc(var(--cell) * .12) rgba(20,26,34,.3)}
.pv-chart.flying .pv-counter,.pv-chart.flying-digits .pv-digit b{visibility:hidden}
/* a wide column turns the ten-frames on their side: 5 across and 2 down, one frame above the other */
@container (min-aspect-ratio:6/5){
  .pv-frames{--cell:min(calc((100cqw - .8em) / 5.1), calc((100cqh - 1.4em) / 4.15), 7em);flex-direction:column}
  .pv-col:not(.more) .pv-frames{--cell:min(calc((100cqw - .8em) / 5.1), calc((100cqh - .8em) / 2.15), 7em)}
  .pv-frame{grid-template-columns:repeat(5,var(--cell));grid-template-rows:repeat(2,var(--cell));grid-auto-flow:row}
}
/* a tall, thin column (phone): one frame above the other, and larger counters while only one frame is in use */
@container (max-aspect-ratio:1/2){
  .pv-frames{--cell:min(calc((100cqw - .8em) / 2.15), calc((100cqh - 1.6em) / 10.2), 7em);flex-direction:column;gap:.3em}
  .pv-col:not(.more) .pv-frames{--cell:min(calc((100cqw - .8em) / 2.15), calc((100cqh - .8em) / 5.15), 7em)}
}
@keyframes pv-pop{from{transform:scale(.3)}}
@media (prefers-reduced-motion:reduce){.pv-counter.pop{animation:none}.pv-counter{transition:none}}

/* buttons at the top of each column (not along the bottom edge, next to the ad): narrow columns put the Regroup or Rename button on a second row */
.pv-foot{flex:none;display:grid;grid-template-columns:1fr 1fr;gap:.25em;padding:.3em;border-bottom:2px solid var(--line)}
.pv-pm{grid-row:1;padding:0;min-width:40px}
.pv-pm span{font-size:1.4em;line-height:1}
.pv-act{grid-row:2;grid-column:1/-1;font-size:.85em;padding:0 .4em;gap:.3em}
.pv-act .arr{display:none}
.pv-act.rg{background:var(--gold)}
.pv-act.rg:hover{background:#ffd25c}
@container (min-width:15em){
  .pv-foot{grid-template-columns:max(2.5em,42px) 1fr max(2.5em,42px)}
  .pv-act{grid-row:1;grid-column:2;font-size:.95em}
  .pv-act .arr{display:inline}
  .pv-name{font-size:.9em}
}

/* ghosts that fly during an animation */
.pv-fly{position:absolute;inset:0;pointer-events:none;z-index:20;overflow:hidden}
.pv-ghost{position:absolute;border-radius:50%;border:2px solid var(--ink);transition-property:background-color;box-shadow:0 .12em 0 rgba(20,26,34,.22)}
.pv-gdigit{position:absolute;transform:translate(-50%,-50%);line-height:1;font-weight:700}

/* narrow tool (phone): the side panel goes under the chart */
@container (max-width:680px){
  .tool-body{flex-direction:column}
  #side{width:auto;flex-direction:row;flex-wrap:wrap;gap:.4em 1em;border-left:0;border-top:2px solid var(--ink);padding:.45em .6em;overflow:visible}
  .pv-group{flex-direction:row;flex-wrap:wrap;align-items:center;gap:.4em .6em}
  .pv-group .ctl{gap:.15em}
  .pv-side-h,.pv-info,.pv-long{display:none}
  .pv-short{display:inline}
  .pv-input{width:5.6em}
  .pv-scroll{padding:0 .4em .4em}
  .pv-display{min-height:3.6em;padding:.25em .5em}
  .pv-facts{font-size:.95em;text-align:center}
}
