/* Area Model */
/* the multiplication: large steppers with arrows, and a large times sign between them */
.am-calc{display:inline-flex;align-items:center;gap:.4em}
.am-calc .stepper{font-size:1.1em}
.am-calc .stepper input{width:3ch}
.am-times{font:700 1.6em/1 var(--font-head);padding:0 .05em}
.am-ex{display:inline-flex;flex-wrap:wrap;align-items:center;gap:.35em}
.am-opts{display:inline-flex;align-items:center;gap:.45em}
.am-row-b:empty{display:none}
.am-chip{padding:0 .6em;font-variant-numeric:tabular-nums}
.am-ico{width:1.15em;height:1.15em;flex:none;display:block}
.am-ico-box{display:inline-flex}

/* the controls and the working, at the side */
#side{width:22em;gap:.6em;padding:.65em;overflow:hidden}
.am-ctl{flex:none;display:flex;flex-direction:column;gap:.45em}
.am-row{display:flex;flex-wrap:wrap;gap:.45em}
.am-row>.btn{flex:1 1 auto;padding:0 .6em}
.am-row-a .am-split{flex:1 1 100%;font-size:1.15em;min-height:max(2.7em,46px)}
.am-split .am-ico{width:1.25em;height:1.25em}
.am-row-b .toggle{justify-content:center}

/* the written working: a page of an exercise book with a red margin line */
.am-work{flex:1;min-height:0;overflow:auto;position:relative;background:#fff;border:2px solid var(--ink);border-radius:.8em;box-shadow:3px 3px 0 var(--ink);
  padding:.3em .55em .55em 1.35em;font-weight:700;font-size:1.2em;line-height:1.3;font-variant-numeric:tabular-nums}
.am-work::before{content:"";position:absolute;left:.6em;top:0;bottom:0;width:2px;background:#f2a493}
.am-line{display:flex;flex-wrap:wrap;column-gap:.3em;row-gap:.12em;padding:.28em .1em .28em 1.1em;border-bottom:1.5px solid var(--grid-strong)}
.am-seg{display:inline-flex;align-items:center;gap:.3em;white-space:nowrap}
.am-seg:first-child{margin-left:-1.1em}
.am-op{color:var(--ink)}
.am-pill,.am-pv>.am-pill{background:var(--c);border:1.5px solid var(--ink);border-radius:.32em;padding:0 .26em}
.am-ans{background:var(--gold);border:2px solid var(--ink);border-radius:.32em;padding:0 .3em}
.am-q{position:relative;font:inherit;line-height:1.2;color:var(--blue);background:#fff;border:2px dashed var(--blue);border-radius:.32em;padding:0 .55em;cursor:pointer}
.am-q.ans{border-color:var(--ink);color:var(--ink);background:var(--gold-tint)}
.am-q::after{content:"";position:absolute;inset:-9px -5px}
.am-q:hover{background:var(--blue-tint)}
.p0{--c:#dcebff}.p1{--c:#ffe1d9}.p2{--c:#dbf3e2}.p3{--c:#fff1c2}.p4{--c:#e9e1fc}.p5{--c:#ffe6cc}
/* the partial products: one row for each part, the products in a column, then the column sum */
.am-prods{display:grid;grid-template-columns:repeat(7,auto);justify-content:start;align-items:center;column-gap:.3em;padding:.3em .1em .1em 0}
.am-prow{display:contents}
.am-prow>*{padding:.12em 0}
.am-sw{width:.85em;height:.85em;padding:0;border:2px solid var(--ink);border-radius:.2em;background:var(--c);margin-right:.15em}
.am-pv,.am-f1{justify-self:end;text-align:right}
/* the "+" of the column sum stands with the numbers and their rule, well apart from the "=" of the last row */
.am-prow>.am-plus{justify-self:end;padding-left:.65em}
.am-rule{grid-column:6/8;height:0;border-top:2.5px solid var(--ink);margin:.16em 0 .1em .65em}
.am-total>.am-pv{grid-column:7}
.am-remark{margin:.45em .1em 0;font-size:max(14px,.72em);font-weight:600;line-height:1.35;color:var(--soft)}
.am-remark.warn{color:#7a4a00;background:var(--gold-tint);border:1.5px solid var(--gold);border-radius:.45em;padding:.3em .5em}

/* the picture */
#pic text{font-family:Lexend,Arial,sans-serif;font-weight:700;text-anchor:middle;fill:var(--ink)}
#pic .am-shadow{fill:var(--ink);fill-opacity:.12}
#pic .am-grid{fill:none;stroke:var(--ink);stroke-opacity:.15}
#pic .am-grid-sq{fill:none;stroke:var(--ink);stroke-opacity:.42}
#pic .am-grid-ten{fill:none;stroke:var(--ink);stroke-opacity:.38;stroke-width:1.5}
#pic .am-edge{fill:none;stroke:var(--ink);stroke-width:3;stroke-linejoin:round}
#pic .am-cutline{fill:none;stroke:var(--ink);stroke-width:2.6;stroke-dasharray:9 7;stroke-linecap:round}
#pic .am-cutdone{fill:none;stroke:var(--ink);stroke-width:3;stroke-linecap:round}
#pic .am-dimline{fill:none;stroke:var(--ink);stroke-width:2;stroke-linecap:round}
#pic .am-dimtext,#pic .am-label text,#pic .am-bubble text{paint-order:stroke;stroke:#fff;stroke-width:.26em;stroke-linejoin:round}
#pic .am-label .am-sum{fill:#39424e}
#pic .am-label.hidden{cursor:pointer}
#pic .am-qmark{fill:var(--blue)}
#pic .am-leader{fill:none;stroke:var(--ink);stroke-width:1.8;stroke-linecap:round}
#pic .am-leader-halo{fill:none;stroke:#fff;stroke-width:5;stroke-linecap:round}
#pic .am-dot{fill:var(--ink)}
#pic .am-handle{cursor:grab;outline:none}
#pic .am-handle.am-grab{cursor:grabbing}
#pic .am-disc{fill:var(--sun);stroke:var(--ink);stroke-width:2.5}
#pic .am-shade{fill:var(--ink);fill-opacity:.16}
#pic .am-ring{fill:none;stroke:none}
#pic .am-handle:focus-visible .am-ring{stroke:var(--blue);stroke-width:3.5}
#pic .am-grab .am-disc{stroke-width:3.2}
#pic .am-off .am-disc{fill:#fff;stroke:var(--red);stroke-dasharray:5 4}
#pic .am-bubble rect{fill:#fff;stroke:var(--ink);stroke-width:2.5}
#pic .am-tag rect{fill:#fff;stroke:var(--soft);stroke-width:1.5;stroke-dasharray:4 3}
#pic .am-tag text{fill:var(--soft);font-weight:600}
#pic .am-snip{pointer-events:none}
/* spare scissors snip now and then: "pick me up" (not with reduced motion) */
#pic .am-half{transform-origin:12px 14.5px}
#pic .am-park .am-half-a{animation:am-snip-a 4.2s ease-in-out 1.2s infinite}
#pic .am-park .am-half-b{animation:am-snip-b 4.2s ease-in-out 1.2s infinite}
@keyframes am-snip-a{0%,76%,88%,100%{transform:none}82%,94%{transform:rotate(-13deg)}}
@keyframes am-snip-b{0%,76%,88%,100%{transform:none}82%,94%{transform:rotate(13deg)}}
@media (prefers-reduced-motion:reduce){#pic .am-park .am-half-a,#pic .am-park .am-half-b{animation:none}}

/* tall frames (tablet, phone): the side panel goes under the picture, with a fixed height */
@container (orientation:portrait){
  .tool-body{flex-direction:column}
  #side{width:auto;height:19em;flex:none;flex-direction:row;align-items:stretch;border-left:0;border-top:2px solid var(--ink)}
  .am-ctl{width:17em;justify-content:flex-start}
}
/* a phone: the controls in two rows, the working under them */
@container (max-width:560px){
  .tool-bar{gap:.45em .5em;padding:.45em .5em}
  .tool-bar>.spacer,.am-ex>.ctl-label{display:none}
  .am-ex{gap:.3em}
  .am-chip{padding:0 .45em}
  .am-calc .stepper input{width:2.8ch;min-width:0;padding:0}
  #side{flex-direction:column;height:calc(2 * max(2.5em,42px) + 17.15em);padding:.5em .5em 1.4em;gap:.45em}
  .am-ctl{width:auto;gap:.4em}
  .am-row{flex-wrap:nowrap;gap:.35em}
  .am-row>.btn{padding:0 .5em}
  .am-row-a .am-split{flex:1 1 auto;font-size:1em;min-height:max(2.5em,42px)}
  .am-snd-t{display:none}
  .am-row-b .toggle{flex:1 1 auto}
  .am-row-b .am-snd{flex:0 0 auto}
  .am-work{font-size:1.05em;line-height:1.22;padding-bottom:.4em}
  .am-line{padding-top:.12em;padding-bottom:.12em}
  .am-prods{padding-top:.2em}
  .am-prow>*{padding-top:0;padding-bottom:0}
  .am-remark{margin-top:.3em;line-height:1.25}
  .am-remark.warn{padding:.2em .45em}
}
