/* 02 · One word changes the answer, in motion (Wave A; rebuilt in Wave J). mid-word.js marks the
   block .mw when it runs. The rules under #word (not .mw) also hold without JavaScript: they lay the
   sheet out on its grid (Wave J, owner's item 5), and the block reads in its final state. Tokens: motion.css.

   ---- (Wave J, owner's item 5) The squared paper is the layout's ruler. ----
   --c is the cell: 28 px on a wide screen, 20 px on a phone (mid-word.js makes it a whole number of
   device pixels under the booklet's zoom: 44 device px at 2540 by 1400). The sheet's width, padding and
   every vertical distance on it are whole cells; the grid starts at the sheet's corner, so no cell is cut
   at an edge (the lines are the device row just above and the column just left of each multiple of --c;
   none is drawn on the right or bottom edge).
   Every line of text stands on a grid line: its line height is 1 or 2 cells and the line is moved by
   the font's own metrics (k = (ascent - descent) / 2 of the em box, from the font files) so that its
   baseline falls on the line, as handwriting sits on a notebook's line:
     Uslovie Book (serif) .3765, Uslovie Sans .3325, Uslovie Mono .375, Uslovie Display .388, Uslovie Pen .338.
   In a line of height L, the baseline is at L / 2 + k em; `top` moves it to the grid line wanted.
   mid-word.js then measures each kind of line and trims the rest (--fq, --fp, ... : the fonts' rounding). */
#word .squared {--c:28px;--hair:1px;--ax-w:1.25px;--pad:calc(2 * var(--c));
  box-sizing:border-box;width:round(nearest,calc(100% + 2 * var(--pad)),var(--c));
  margin-left:calc(-1 * var(--pad));margin-right:0;padding:calc(2 * var(--c)) var(--pad) var(--c);
  /* replaces sections.css .squared's background (28 px tiles from -1 px, cut at the edges) */
  background:repeating-linear-gradient(#0000 0 calc(var(--c) - var(--hair)),#dbe1ec 0 var(--c)) 0 0/100% calc(100% - var(--hair)) no-repeat,
    repeating-linear-gradient(90deg,#0000 0 calc(var(--c) - var(--hair)),#dbe1ec 0 var(--c)) 0 0/calc(100% - var(--hair)) 100% no-repeat,#fbfbf9}
/* A zero-size probe mid-word.js puts at a line's start to read its baseline. */
mw-probe {display:inline-block;width:0;height:0;vertical-align:baseline}

/* The sentence: lines of two cells, the baseline on the middle line of each (the letters fill the
   upper cell, the descenders dip into the lower). Replaces sections.css .word-q's 1.36 and Wave D's 1.5. */
#word .word-q {--L:calc(2 * var(--c));line-height:var(--L);position:relative;top:calc(-.3765em + var(--fq,0px))}
/* The marker in the sentence covers the letters' full height: from just above the ascenders and umlauts
   (.92 em over the baseline) to just under the descenders (.26 em below); a chisel tip, its leading edge
   slanted. At rest the slant lies past the word's slot, so the word is marked edge to edge.
   (Replaces sections.css .word-q .swap's 62 % / 58 %.) The slot is cut a little wider than the word, so no
   letter's overhang is cut (sections.css: inset(0 -1px)). */
#word .word-q .swap {--mk-h:1.18em;background:linear-gradient(var(--marker),var(--marker)) 0 calc(var(--L) / 2 - .5435em)/100% var(--mk-h) no-repeat;
  clip-path:inset(calc(var(--L) / 2 - .5735em) -.08em calc(var(--L) / 2 - .6665em))}
/* A slot's window is its letters' height (from .95 em over the baseline to .29 em under it), not its line's two
   cells: a word leaving or arriving is out of sight once it has moved off its own line, so it never shows over or
   under its neighbours. The same for the one-cell slots of the gloss line and the caption (sans: .95 / .27 em). */
#word .word-ru .swap[lang] {clip-path:inset(calc(var(--c) / 2 - .5735em) -.08em calc(var(--c) / 2 - .6665em))}
#word .word-ru .swap:not([lang]),#word .word-ans>.swap {clip-path:inset(calc(var(--c) / 2 - .6175em) -.08em calc(var(--c) / 2 - .6025em))}
.mw .word-q .swap {background-image:linear-gradient(100deg,var(--marker) calc(100% - 10px),#0000 calc(100% - 3px));background-size:calc(100% + 10px) var(--mk-h)}

/* ---- (Wave J, owner's item 4) The five alternatives, written on the paper (mid-word.js builds them):
   each a box pencilled into one grid cell and the word in the exam's italic, standing on the box's line;
   each takes a whole number of cells, so every one starts on a grid line. No pill, no shadow. The chosen
   one: the pen's cross in its box and the marker over the word. Pointed at or reached by Tab: a pencil
   line under the word. Replaces sections.css .word-picks and its buttons. */
#word .word-picks {display:flex;flex-wrap:wrap;gap:0;margin-top:var(--c)}
#word .word-picks button {position:relative;isolation:isolate;flex:none;display:block;height:calc(2 * var(--c));min-height:0;margin:0;padding:0 0 0 var(--c);
  border:0;border-radius:0;background:none;box-shadow:none;color:var(--ink);font:italic 22px/calc(2 * var(--c)) var(--serif);text-align:left;white-space:nowrap;
  cursor:pointer;-webkit-tap-highlight-color:transparent;transition:none}
#word .word-picks button>* {pointer-events:none}
#word .word-picks .wp-w {position:relative;top:calc(-.3765em + var(--fp,0px))}
/* The box: one cell, its bottom on the word's line. */
#word .wp-box {position:absolute;left:0;top:calc(var(--fp,0px));width:var(--c);height:var(--c);overflow:visible;fill:none;stroke-linecap:round;stroke-linejoin:round}
#word .wp-sq {stroke:#14171c6b;stroke-width:1.25;transition:stroke var(--dur-micro) var(--ease-ink)}
#word .wp-x {stroke:var(--blue);stroke-width:2.1;stroke-dasharray:1 2;stroke-dashoffset:1}
#word [aria-pressed="true"] .wp-x {stroke-dashoffset:0}
#word [aria-pressed="true"] .wp-sq {stroke:#14171cb3}
/* The marker over the chosen word: the full height of its letters (from .92 em above the baseline to .26 em below). */
#word .wp-w::before {content:"";position:absolute;z-index:-1;left:-.1em;right:-.2em;top:.119em;height:1.18em;
  background:linear-gradient(100deg,var(--marker) calc(100% - 8px),#0000 calc(100% - 2px));clip-path:inset(0 100% 0 0)}
#word [aria-pressed="true"] .wp-w::before {clip-path:inset(0 0 0 0)}
/* The pencil line under a word that can be chosen. */
#word .wp-ul {position:absolute;left:-.04em;width:calc(100% + .08em);top:calc(1.039em + .17em);height:.28em;overflow:visible;fill:none}
#word .wp-ul path {stroke:#14171c99;stroke-width:1.3;stroke-linecap:round;vector-effect:non-scaling-stroke;stroke-dasharray:1 2;stroke-dashoffset:1;transition:stroke-dashoffset var(--dur-ink) var(--ease-ink)}
@media (hover:hover) {
  #word .word-picks button:not([aria-pressed="true"]):hover .wp-ul path {stroke-dashoffset:0}
  #word .word-picks button:hover .wp-sq {stroke:#14171cb3}
}
#word .word-picks button:not([aria-pressed="true"]):focus-visible .wp-ul path {stroke-dashoffset:0}
#word .word-picks button:focus:not(:focus-visible) {outline:none}
@media (prefers-reduced-motion:reduce) {#word .wp-ul path,#word .wp-sq {transition:none}}

/* Without JavaScript: the other words' answers, one line to a cell. */
#word .word-alt {margin-top:var(--c);line-height:var(--c);position:relative;top:calc(var(--c) / 2 - .3325em)}

/* The working: the word and its meaning on one line of one cell, the baseline on its bottom line.
   (Replaces sections.css .word-ru's flex row: two fonts on one baseline, not two.) */
#word .word-work {--lw:round(down,calc(100% - var(--c)),calc(4 * var(--c)));margin-top:var(--c)}
#word .word-ru {display:block;height:var(--c);line-height:var(--c);white-space:nowrap;position:relative;top:calc(var(--c) / 2 - .3325em + var(--fr,0px))}
#word .word-ru .swap {vertical-align:baseline}
#word .word-ru .swap+.swap {margin-left:14px}
#word .word-stage {margin-top:0;align-items:end}

/* The inequality, as a student writes it on squared paper: two characters to a cell (the mono's advance is
   .6 em, so a size of a cell over 1.2), the sign in a cell of its own, each line two cells tall with its
   baseline on the lower line: the cell above each sign is free for the pen's correction. The second line
   is set in five cells, so its x and its sign stand under the first line's. (Replaces sections.css
   .word-eq's clamp size, 2.3 line height and the .sign's 1.2 em.) */
#word .word-eq {font:400 calc(var(--c) / 1.2)/calc(2 * var(--c)) var(--mono);letter-spacing:0;padding:0;white-space:nowrap;position:relative;top:calc(var(--c) - .375em + var(--fe,0px))}
#word .word-eq .eq-2 {padding-left:calc(5 * var(--c))}
#word .word-eq .sign {width:var(--c);min-width:0;text-align:center;vertical-align:baseline}
/* The strike, across the printed sign in its cell. */
#word .word-eq .sign .pen {inset:auto;left:-6%;width:112%;top:calc(.375em + var(--c) - .74em - var(--fe,0px));height:.8em}
/* The pen's sign, written in the cell above the printed one (replaces Wave A's .5 em-high position and M 4's phone one). */
.mw .word-eq .sign .hand {position:absolute;left:0;bottom:auto;top:calc(.375em - var(--c) - var(--fe,0px));width:var(--c);height:var(--c);margin:0;overflow:visible;
  fill:none;stroke:var(--blue);stroke-width:1.85;stroke-linecap:round;stroke-linejoin:round;transform:rotate(-6deg)}
.mw .sign .pen path,.mw .struck .sign .pen path {transition:none}
.mw .sign i {clip-path:inset(50%)}
.mw .sign .hand path {stroke-dasharray:1 2}

/* The answer: its label on one cell, a free cell, and the number four cells tall standing on the line of
   the inequality's last baseline. It stands centred on the 200 tick (the answers are 199 to 201: it no
   longer slides the 2.7 px to them), and its three digits are set at a pitch (--dp, mid-word.js) that puts
   its left edge on a grid line. Its size: four cells over the digits' height (.724 em). */
#word .word-mark {margin-left:calc(.5 * var(--lw))}
#word .word-ans>.swap {line-height:var(--c);height:var(--c);margin-bottom:var(--c);position:relative;top:calc(var(--c) / 2 - .3325em + var(--fl,0px))}
#word .word-ans strong {--n:4;font-size:calc(var(--n) * var(--c) / .724);line-height:calc(var(--n) * var(--c));height:calc(var(--n) * var(--c));
  position:relative;top:calc(var(--n) * var(--c) / 2 - .388em)}
/* Without JavaScript the number is plain text in the line (an inline flex box would set its own baseline). */
#word:not(.mw) .word-ans .roll {display:inline}
/* With the odometer the digits' drums are placed from the box's top: the digit's baseline in a drum is
   .948 em down (half its 1.12 em line plus .388 em). */
.mw .word-ans strong {top:0}
.mw .word-ans .roll {position:relative;vertical-align:top;top:calc(var(--n) * var(--c) - .948em + var(--fn,0px))}
/* The odometer above the point: one drum per digit (mid-word.js). */
/* The drum's window is the digits' own height (measured on the numeral: ink from .225em to .17em
   short of the 1.12em cell), so a digit turning away leaves at the top of the row, not above it. */
.odo-d {display:block;height:1.12em;line-height:1.12;overflow:hidden;clip-path:inset(.2em -.1em .145em)}
.mw .odo-d {width:var(--dp,auto);text-align:center}
.odo-d i {display:block;font-style:normal}
.odo-d b {display:block;height:1.12em;font-weight:inherit}

/* ---- The number line. The axis lies on a grid line one cell below the line's top (the device rows just
   above it, as the grid's own line), the ticks on vertical grid lines (the line is a multiple of four
   cells long: 0, 100, 200, 300, 400 a whole number of cells apart), the labels' baselines one cell
   below the axis. --ax is the axis' centre: the band, the point and the ticks are centred on it.
   (Replaces sections.css .word-line's 50 px, the axis at 20 px and the band at 8–19 px.) */
#word .word-ray {margin-top:var(--c)}
#word .word-line {--ax-x:var(--c);--ax:calc(var(--c) - var(--ax-w) / 2);width:var(--lw);height:calc(2 * var(--c));margin-right:0}
#word .word-line::before {top:calc(var(--c) - var(--ax-w));right:calc(-1 * var(--ax-x));border-top-width:var(--ax-w)}
#word .word-line::after {top:var(--ax);right:calc(-1 * var(--ax-x));margin-top:0}
#word .word-line span,#word .word-line span:first-of-type,#word .word-line span:last-of-type {--ty:calc(1.5 * var(--c) - .375em + var(--ft,0px));top:var(--ty);padding:0;line-height:var(--c);transform:translateX(-50%)}
#word .word-line span::before,#word .word-line span:first-of-type::before,#word .word-line span:last-of-type::before {left:50%;top:calc(var(--ax) - 6px - var(--ty));height:12px;border-left-width:var(--ax-w);margin-left:calc(-1 * var(--ax-w))}
#word .word-fill {top:calc(var(--ax) - 5.5px);height:11px;transform:none}
#word .word-dot {top:var(--ax)}
/* The arrow from the note's first letter up to the point. */
#word .word-arrow {left:calc(var(--at) * 100% + 6px);top:calc(var(--ax) + 6px);width:calc(2 * var(--c));height:calc(2 * var(--c))}
/* The note: a line of two cells under the line, its baseline on the lower one, starting two cells right of
   the 200 tick. Written straight along the line (it was turned 2°). */
#word .word-why {line-height:calc(2 * var(--c));min-height:calc(2 * var(--c));max-width:calc(100% - .5 * var(--lw) - 2 * var(--c));margin:0 0 0 calc(.5 * var(--lw) + 2 * var(--c));
  position:relative;top:calc(var(--c) - .338em + var(--fw,0px));transform:none}

/* ---- The band and the point, as a drop (Wave J, owner's items 2 and 3). The band is placed by
   mid-word.js's springs (--from, --to; --halo gathers it round the point for "genau"; --thin, below 1
   while it runs fast). Its centre is always the axis' centre: the same y in every state and while it
   moves. Its ends are cut at the chisel's slant, as the marker in the sentence, and round again as it
   gathers into the halo. The point is a disc that opens into a ring (--hole, a spring of its own). */
.mw .word-line {cursor:grab;touch-action:pan-y;-webkit-user-select:none;user-select:none}
.mw .word-line.dragging {cursor:grabbing}
.mw .word-line::before {transform-origin:0 50%}
/* --halo 1: a disc of marker 22 px across, centred on the point (genau); 0: the band 10 px thick. */
.mw .word-fill {--h:var(--halo,0);--bh:calc((10px + var(--h) * 12px) * var(--thin,1));transition:none;
  left:calc(var(--from) * 100% - var(--h) * 11px);right:calc((1 - var(--to)) * 100% - var(--h) * 11px);
  top:calc(var(--ax) - var(--bh) / 2);height:var(--bh);transform:none;
  border-radius:calc(3px + var(--h) * 8px) calc(9px + var(--h) * 2px) calc(4px + var(--h) * 7px) calc(8px + var(--h) * 3px) / calc(5px + var(--h) * 6px) calc(6px + var(--h) * 5px) calc(4px + var(--h) * 7px) calc(6px + var(--h) * 5px);
  --sl:calc(7px * (1 - var(--h)));clip-path:polygon(var(--sl) 0,100% 0,calc(100% - var(--sl)) 100%,0 100%)}
.mw .word-dot,.mw .word-line.open .word-dot {background:var(--blue);transition:transform var(--dur-micro) var(--ease-ink),box-shadow var(--dur-micro) var(--ease-ink)}
/* A 44 px pad to take the point by; held, it lifts a little with a soft ring of the pen's blue. */
.mw .word-dot::before {content:"";position:absolute;inset:-15px;border-radius:50%}
.mw .word-line.dragging .word-dot {transform:scale(1.18);box-shadow:0 0 0 6px #1f43a622}
/* The ring's hole: mid-word.js's spring (it opens a little past full and settles; it was a CSS transition). */
.mw .word-dot::after {content:"";position:absolute;inset:0;border-radius:50%;background:#fbfbf9;transform:scale(var(--hole,0));transition:none}
.mw .word-arrow path {stroke-dasharray:1 2}
/* Two hairline chevrons beside the point: shown on hover and once on arrival, gone after the first use. */
.word-nudge {left:calc(var(--at) * 100%);top:var(--ax,20px);display:flex;gap:24px;transform:translate(-50%,-55%);font:400 14px/1 var(--mono);color:var(--blue);opacity:0;pointer-events:none;transition:opacity var(--dur-sweep) var(--ease-paper)}
.word-nudge b {font-weight:400}
/* (Wave F, fix 5) Until the point has been moved once, the chevrons stay beside it, faint: on a phone the
   line is often still below the window when the arrival shows them. */
.mw .word-line:not(.used) .word-nudge {opacity:.45}
.mw.mw-draft .word-line .word-nudge {opacity:0}
@media (hover:hover) {.mw .word-line:hover .word-nudge {opacity:.7}}
.mw .word-line.hinting .word-nudge {opacity:.7}
.mw .word-line.used .word-nudge,.mw .word-line.dragging .word-nudge {opacity:0}

/* The note, written behind the nib. The ink's box reaches past its letters on every side (Bad Script's
   capitals, long descenders and slant), so the writing's mask never cuts a letter. */
/* (Follow-up) Both inline-blocks hang from the top of their line, not from its baseline: on the baseline, WebKit
   rounded the line box 0.31 px taller than its two cells and the whole sheet came out 25.011 cells high (itest JW.1).
   Their own lines have the same font and line height as the note's, so the baseline stays where it was. */
.mw .word-why .pen-line {position:relative;display:inline-block;max-width:100%;vertical-align:top}
.mw .word-why .ink {display:inline-block;padding:.15em .3em;margin:-.15em -.3em;vertical-align:top}
.mw .word-why .ink.writing {-webkit-mask:linear-gradient(90deg,#000 calc(100% - 16px),#0000) 0 0/calc(100% + 18px) 100% no-repeat;mask:linear-gradient(90deg,#000 calc(100% - 16px),#0000) 0 0/calc(100% + 18px) 100% no-repeat}
.mw .word-why .nib {position:absolute;left:0;top:calc(var(--c) + .338em - .24em);width:3.5px;height:3.5px;margin:-1.75px 0 0 -1.75px;border-radius:50%;background:var(--blue);opacity:0}

/* Arrival (armed only while the block is below the window): the sheet waits a
   little low and turned, the line unruled, until they come into view. */
.mw.mw-lay .squared {transform:translateY(32px) rotate(-.5deg)}
.mw.mw-draft .word-line::before {transform:scaleX(0)}
.mw.mw-draft .word-line::after,.mw.mw-draft .word-line span,.mw.mw-draft .word-fill,.mw.mw-draft .word-arrow,.mw.mw-draft .word-why {opacity:0}
.mw.mw-draft .word-dot {transform:scale(0)}

@media (prefers-reduced-motion:reduce) {
  .mw .word-dot::after,.word-nudge {transition:none}
}

/* The sheet's shadow turns a little as the page goes down, as if the sun moved round (Wave D,
   item 16): mid-light.js sets --sun-c / --sun-s (its turn and length). Without them it is
   sections.css's shadow exactly. */
.mw .squared {box-shadow:0 0 0 1px #14171c0f,calc(-14px * var(--sun-s,0)) calc(14px * var(--sun-c,1)) 30px -14px #14171c26}

/* Glosses (Wave D, item 13): an ordinary German word of the sentence, pointed at, tapped or reached
   with Tab, gets its Russian meaning written above it in the student's blue hand (mid-word.js; the
   nib and the mask are motion.css's .m-dot and .m-writing). Not the swapped word, and never on the task.
   (Wave J) Written straight, its baseline on the grid line between the word's line and the one above
   (the word's baseline less a cell: .286 em of the sentence's descent is .4767 of the gloss's em at .6);
   its box reaches past its letters on every side, so the writing's mask never cuts one. */
.mw .word-q .wg {position:relative;border-radius:1px;outline-offset:3px;-webkit-tap-highlight-color:transparent}
.mw .word-q .wg-ru {position:absolute;left:.04em;bottom:calc(var(--c) + .3147em);white-space:nowrap;font:400 .6em/1 var(--pen);font-style:normal;letter-spacing:0;color:var(--blue);
  padding:.45em .25em .35em;margin:0 0 -.35em -.25em;visibility:hidden;pointer-events:none}
.mw .word-q .wg.on .wg-ru {visibility:visible}
/* The pen's dotted underline under the words that can be glossed. (Wave E, fix 6) At rest it is there,
   faint, so that the words are found (Wave D had none); the word being glossed has it full. */
/* (Wave I, item 3) Three such words now, and fainter at rest (was #1f43a64d). */
.mw .word-q .wg {text-decoration:underline dotted #1f43a638;text-decoration-thickness:1.5px;text-underline-offset:.2em;transition:text-decoration-color var(--dur-micro) var(--ease-ink)}
.mw .word-q .wg.on {text-decoration-color:#1f43a6b3}
@media (hover:hover) and (pointer:fine) {.mw .word-q .wg {cursor:help}}
.mw .word-q .wg i.m-dot {left:.04em;top:auto;bottom:calc(var(--c) + .4em)}
.mw .word-q .wg:focus {outline:none}
.mw .word-q .wg:focus-visible {outline:1.5px solid var(--blue)}

/* ---- The phone: a cell of 20 px, the sheet one cell's padding, as wide as a whole number of cells
   allows (it may reach 10 px into the page's margins), centred. The block fits one 390 by 844 screen
   under the masthead, heading to note. */
@media (max-width:820px) {
  #word .squared {--c:20px;--pad:var(--c);width:round(down,calc(100% + 20px),var(--c));margin-left:calc((100% - round(down,calc(100% + 20px),var(--c))) / 2);margin-right:0}
  #word .word-picks button {font-size:17px}
  /* At least 44 px to tap, though a row is 40: nothing is drawn round it. */
  #word .word-picks button::after {content:"";position:absolute;inset:-2px 0}
  /* The line runs to the column's edge; its arrow reaches half a cell into the padding. */
  #word .word-work {--lw:round(down,calc(100% + var(--c) / 2),calc(4 * var(--c)))}
  #word .word-line {--ax-x:calc(var(--c) * .5)}
  /* The inequality on the left, the answer in the last six cells: its label (two lines of a cell), a free
     cell, the number two cells tall, left on the column's grid line. */
  #word .word-stage {grid-template-columns:minmax(0,1fr) calc(6 * var(--c));column-gap:0}
  #word .word-mark {margin:0}
  #word .word-ans {align-items:flex-start;text-align:left}
  #word .word-ans>.swap {height:auto;max-width:none}
  #word .word-ans strong {--n:2}
  #word .word-ray {margin-top:0}
  /* Clear of the 200 under the point: from the note's top up past the label's right end. */
  #word .word-arrow {left:calc(var(--at) * 100% + 8px);top:calc(var(--ax) + 1px);width:28px;height:28px;transform:none}
  #word .word-why {max-width:none;margin:0;text-align:center}
  .mw .word-q .wg-ru {font-size:16px;bottom:calc(var(--c) + .2145em)}
  .mw .word-why {font-size:19px}
  .mw.mw-lay .squared {transform:translateY(18px)}
}
