/*
  The fact tiles' drawings (the tiles and their layout: fact-tiles.css, which
  is loaded after this file, so its rules for other widths come last): each
  drawing, how they come in with the scroll, and how they answer a pointer.
  Sizes are in the grid's unit 'u', or in a drawing's own units.
*/
/* Text size: the same letters at the default and the largest size. */
.type-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.type-guide {
  stroke: rgb(243 235 220 / 0.2);
  stroke-width: 1;
}
.type-guide.is-dashed {
  stroke-dasharray: 2 5;
}
.type-glyph {
  font-family: 'Instrument Serif', Georgia, serif;
  fill: var(--ink);
}
.type-glyph.is-large {
  fill: rgb(243 235 220 / 0.05);
  stroke: var(--ink);
  stroke-width: 1.2;
}
/* The outlines behind the front one, which give the letters their depth. */
.type-glyph.is-large.is-depth {
  fill: none;
  stroke-width: 0.8;
  stroke-opacity: 0.22;
}
.type-dim {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
}
.type-size {
  font-size: 13px;
  font-weight: 500;
  fill: var(--accent);
}

/* Color vision: the dot plate, centered under the title. */
.fact-plate {
  position: absolute;
  left: 17.1%;
  top: 29.9%;
  width: 65.8%;
  height: auto;
  aspect-ratio: 1;
}

/*
  Contrast: a row of specimens over the tile's right, its baseline the
  number's and its ratios on the caption's line.
*/
.contrast-ladder {
  position: absolute;
  right: 0;
  top: calc(var(--u) * 112);
  width: calc(var(--u) * 319);
}
.contrast-ladder text {
  font-family: 'Inter Tight', Arial, sans-serif;
}
.contrast-ladder .ladder-glyph text {
  font-family: 'Instrument Serif', Georgia, serif;
}
.ladder-ratio {
  font-size: 13px;
  fill: var(--ink-2);
  text-anchor: middle;
}
.ladder-ratio .is-ours {
  font-weight: 500;
  fill: var(--accent);
}

/*
  Load time: a stopwatch drawn close in fine ink lines on the cream tile,
  with soft metal and a lit face under them, and a shadow on the tile.  The
  ring and the hand, which move, are in the accent.
*/
.fact-art.dial {
  fill: none;
  stroke: var(--color-black);
  /* Up and right a little, clear of the number and its caption. */
  transform: translate(calc(var(--u) * 5), calc(var(--u) * -9));
}
.dial-body {
  filter: drop-shadow(-5px 9px 9px rgb(60 44 20 / 0.28));
}
.dial-metal {
  fill: url(#fact-dial-metal);
  stroke-width: 0.9;
}
.dial-face {
  fill: url(#fact-dial-face);
  stroke-width: 0.9;
}
.dial-well {
  fill: rgb(15 13 10 / 0.05);
  stroke: none;
}
.dial-turned {
  stroke-width: 0.5;
  opacity: 0.16;
}
.dial-line {
  stroke-width: 0.8;
}
.dial-line.is-fine {
  stroke-width: 0.45;
  opacity: 0.7;
}
.dial-line.is-heavy {
  stroke-width: 1.3;
}
.dial-solid {
  fill: var(--color-black);
  stroke: none;
}
.dial-num {
  fill: var(--color-black);
  stroke: none;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: -0.02em;
  text-anchor: middle;
}
.dial-arc {
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-dasharray: 1;
}
.dial-hand {
  fill: var(--accent);
  fill-rule: evenodd;
  stroke: none;
  transform-origin: 250px 80px;
  transform: rotate(360deg);
}
.dial-hand-shade {
  fill: rgb(15 13 10 / 0.16);
}
.dial-pin {
  fill: var(--color-white);
  stroke: none;
}
.dial-pusher {
  transform-box: fill-box;
}
/* Figures of one width, so the count doesn't shift as it runs. */
.is-dial .fact-value {
  font-variant-numeric: tabular-nums;
}

/*
  Keyboard: keycaps with travel.  Each key is a well with its cap standing
  7 units proud on a side wall; a cap goes down under a fine pointer, or
  while its key is held ('is-down', sections/fact-play.js), and springs back.
  The cap is the keycap model (blender/accessibility-keys) seen from above
  and in front, its every edge projected into the tile's units: 3.822 units
  to the mm across and 2.938 front to back (the cap's 56 units over its
  19.06 mm), and 2.442 per mm of height, which lifts the top face toward the
  back.  Its colors are dropper readings off the model's photo-matched
  render, band by band.  The cap ('b') is the slab and its ledge; the block
  ('.key-block') is the flare's foot, which clips the top face's shadows, so
  the flare's shading follows its rounded corners; the top face ('.key-top')
  carries the legend, printed flat on it, so squashed as the view squashes
  the face.
*/
.keys {
  --travel: calc(var(--u) * 7);
  --wall: #030202;
  display: flex;
  gap: calc(var(--u) * 8);
  padding-top: var(--travel);
}
.keys i {
  position: relative;
  width: calc(var(--u) * 72);
  height: calc(var(--u) * 56);
  border-radius: calc(var(--u) * 3.8); /* The slab's 1 mm corner. */
  background: #0b0a09;
}
/*
  The ledge, rolling off at the slab's rounded edge (0.45 mm), as the render
  reads it: to near black at the front, half way 1.1 units in and clear by
  2; darker on the right than the left; and a faint line at the back.  The
  roll is drawn with inset shadows, which follow the cap's rounded corners
  (straight gradients, one per side, crossed in square corners).
*/
.keys b {
  --edge:
    inset 0 calc(var(--u) * -1.1) calc(var(--u) * 1.8) #030202,
    inset calc(var(--u) * 0.9) 0 calc(var(--u) * 1.4) #080610,
    inset calc(var(--u) * -0.9) 0 calc(var(--u) * 1.2) #030303,
    inset 0 calc(var(--u) * 0.5) var(--u) #1a1918;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #282624;
  box-shadow:
    var(--edge),
    0 var(--travel) 0 var(--wall),
    0 calc(var(--travel) + var(--u) * 3) calc(var(--u) * 6) rgb(0 0 0 / 0.5);
  transform: translateY(calc(var(--travel) * -1));
  transition:
    transform 0.34s var(--ease-spring),
    box-shadow 0.34s var(--ease-spring);
}
/*
  The block's foot, 1 mm in from the slab (3.82 units across, 2.94 front
  to back), its corners the top face's 3 mm offset by 2 mm: 5 mm, or 19.12
  by 14.68 units.
*/
.key-block {
  position: absolute;
  inset: calc(var(--u) * 2.94) calc(var(--u) * 3.82);
  overflow: hidden;
  border-radius: calc(var(--u) * 19.12) / calc(var(--u) * 14.68);
  background: #252321; /* The flare's foot, past the last ring. */
}
/*
  The top face, 3 mm in from the slab and 1.5 mm up: in the block, 7.65
  units in at the sides, 2.21 at the back and 9.53 at the front, its corners
  3 mm (11.47 by 8.81 units).  Its shadows, clipped by the block, draw the
  flare as rings, each a step further out and a step darker, as the render
  reads the left flare: the shoulder rolls off from the face's own tone with
  no line at the face's edge (a single blurred halo left one, at half its
  strength there), down to the crease, darkest 3.7 to 4.4 units out, then
  lighter toward the foot.  Each ring sits a fifth of its reach lower, so
  the front band runs 1.25 times the sides, as the render's does.  On top,
  a rim on the right, drawn in by 1.5 units all round so it shows only
  there, where the strip light catches it.
*/
.key-top {
  position: absolute;
  inset: calc(var(--u) * 2.21) calc(var(--u) * 7.65) calc(var(--u) * 9.53);
  border-radius: calc(var(--u) * 11.47) / calc(var(--u) * 8.81);
  background: #2a2826;
  box-shadow:
    calc(var(--u) * 3) 0 calc(var(--u) * 2.6) calc(var(--u) * -1.5) #3e3c39,
    0 calc(var(--u) * 0.06) calc(var(--u) * 0.9) calc(var(--u) * 0.3) #2a2826,
    0 calc(var(--u) * 0.14) calc(var(--u) * 0.9) calc(var(--u) * 0.7) #272524,
    0 calc(var(--u) * 0.22) calc(var(--u) * 0.9) calc(var(--u) * 1.1) #1f1e1c,
    0 calc(var(--u) * 0.32) calc(var(--u) * 0.9) calc(var(--u) * 1.6) #1b1a19,
    0 calc(var(--u) * 0.42) calc(var(--u) * 0.9) calc(var(--u) * 2.1) #151315,
    0 calc(var(--u) * 0.52) calc(var(--u) * 0.9) calc(var(--u) * 2.6) #0f0e10,
    0 calc(var(--u) * 0.62) calc(var(--u) * 0.9) calc(var(--u) * 3.1) #0a090d,
    0 calc(var(--u) * 0.72) calc(var(--u) * 0.9) calc(var(--u) * 3.6) #070609,
    0 calc(var(--u) * 0.88) calc(var(--u) * 0.9) calc(var(--u) * 4.4) #08070b,
    0 calc(var(--u) * 1) calc(var(--u) * 0.9) calc(var(--u) * 5) #0e0c10,
    0 calc(var(--u) * 1.1) calc(var(--u) * 0.9) calc(var(--u) * 5.5) #141214,
    0 calc(var(--u) * 1.2) calc(var(--u) * 0.9) calc(var(--u) * 6) #1a1919,
    0 calc(var(--u) * 1.32) calc(var(--u) * 0.9) calc(var(--u) * 6.6) #1f1d1c,
    0 calc(var(--u) * 1.46) calc(var(--u) * 0.9) calc(var(--u) * 7.3) #232120;
}
/*
  The legend: SF Pro (the system face) at the size whose ink matches the
  render's ('tab' 5.14 mm wide, 19.6 units, and 2.67 mm tall), a 14.45 unit
  em, its baseline 8.1 mm from the cap's back on the raised face (14.99
  units below the face's top edge), squashed to 0.769 of its height as the
  view squashes the face.  The return arrow is the model's outline, already
  projected.
*/
.key-legend {
  position: absolute;
  inset-inline: 0;
  top: calc(var(--u) * 6.01); /* Measured: puts the baseline 14.99 down. */
  color: #e4e4e4;
  font:
    500 calc(var(--u) * 14.45) / 1 -apple-system,
    BlinkMacSystemFont,
    'Inter Tight',
    sans-serif;
  text-align: center;
  transform: scaleY(0.769);
  transform-origin: 50% 0;
}
svg.key-legend {
  inset-inline: auto;
  left: 50%;
  top: calc(var(--u) * 5.02);
  width: calc(var(--u) * 24.77);
  height: calc(var(--u) * 8.6);
  margin-left: calc(var(--u) * -12.385);
  fill: #e4e4e4;
  transform: none;
}
.keys .is-space {
  flex: 1;
}
/* The lit key, in its own readings. */
.keys .is-on {
  --wall: #1d1a60;
}
.keys .is-on b {
  --edge:
    inset 0 calc(var(--u) * -1.1) calc(var(--u) * 1.8) #221e70,
    inset calc(var(--u) * 0.8) 0 calc(var(--u) * 1.4) #3f38a8,
    inset calc(var(--u) * -0.8) 0 calc(var(--u) * 1.2) #1e1b56,
    inset 0 calc(var(--u) * 0.6) calc(var(--u) * 0.5) #363374;
  background: #8a83dd;
}
.keys .is-on .key-block {
  background: #7e77d7;
}
.keys .is-on .key-top {
  background: #8d86de;
  box-shadow:
    calc(var(--u) * 3) 0 calc(var(--u) * 2.6) calc(var(--u) * -1.5) #a69fea,
    0 calc(var(--u) * 0.06) calc(var(--u) * 0.9) calc(var(--u) * 0.3) #8d86de,
    0 calc(var(--u) * 0.14) calc(var(--u) * 0.9) calc(var(--u) * 0.7) #8880db,
    0 calc(var(--u) * 0.22) calc(var(--u) * 0.9) calc(var(--u) * 1.1) #756dd1,
    0 calc(var(--u) * 0.32) calc(var(--u) * 0.9) calc(var(--u) * 1.6) #7169d0,
    0 calc(var(--u) * 0.42) calc(var(--u) * 0.9) calc(var(--u) * 2.1) #6a61cc,
    0 calc(var(--u) * 0.52) calc(var(--u) * 0.9) calc(var(--u) * 2.6) #5c54c3,
    0 calc(var(--u) * 0.62) calc(var(--u) * 0.9) calc(var(--u) * 3.1) #4a44b5,
    0 calc(var(--u) * 0.72) calc(var(--u) * 0.9) calc(var(--u) * 3.6) #3432a0,
    0 calc(var(--u) * 0.88) calc(var(--u) * 0.9) calc(var(--u) * 4.4) #3a37a7,
    0 calc(var(--u) * 1) calc(var(--u) * 0.9) calc(var(--u) * 5) #4f4abd,
    0 calc(var(--u) * 1.1) calc(var(--u) * 0.9) calc(var(--u) * 5.5) #5a53c4,
    0 calc(var(--u) * 1.2) calc(var(--u) * 0.9) calc(var(--u) * 6) #6860cd,
    0 calc(var(--u) * 1.32) calc(var(--u) * 0.9) calc(var(--u) * 6.6) #7069d1,
    0 calc(var(--u) * 1.46) calc(var(--u) * 0.9) calc(var(--u) * 7.3) #7a73d5;
}
.keys .is-down b {
  transform: translateY(calc(var(--u) * -1));
  box-shadow:
    var(--edge),
    0 calc(var(--u) * 1) 0 var(--wall),
    0 calc(var(--u) * 2) calc(var(--u) * 2) rgb(0 0 0 / 0.5);
  transition-duration: 0.06s;
  transition-timing-function: var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .keys i {
    cursor: pointer;
  }
  .keys i:hover b {
    transform: translateY(calc(var(--u) * -1));
    box-shadow:
      var(--edge),
      0 calc(var(--u) * 1) 0 var(--wall),
      0 calc(var(--u) * 2) calc(var(--u) * 2) rgb(0 0 0 / 0.5);
    transition-duration: 0.06s;
    transition-timing-function: var(--ease-out);
  }
}

/*
  The rendered caps ('is-rendered' on the row): each key's Cycles render
  (blender/accessibility-keys: render_keycaps.py, then encode_keycaps.mjs)
  in place of the CSS cap.  Each image is cut to its key's outline and a
  unit of margin round the cap's box, 63 units of top and wall, at 1, 2
  and 3 px a unit, for the screen's density ('-webkit-image-set', which
  every current browser reads), so the browser hardly scales it: four
  times its drawn size, it went jagged or soft while the key moved, as the
  browser scales the fast way then.  The cap presses as the CSS cap does,
  a transform with its spring, on a layer of its own for good, so the
  browser never switches how it draws the cap as the key starts and stops;
  at rest and pressed it sits on whole pixels, so it is sharp whenever it
  is still.  (Moving the picture inside the cap instead put it on whole
  pixels all the way, and the spring's half pixel of overshoot showed as a
  pixel's snap at the end of the return.)  The well clips only below
  itself, so a pressed cap's wall slides into it, as the drawn wall
  shrinks.
*/
.keys.is-rendered i {
  clip-path: inset(
    calc(var(--u) * -10) calc(var(--u) * -1) 0 round 0 0 calc(var(--u) * 3.8) calc(var(--u) * 3.8)
  );
}
.keys.is-rendered i:nth-child(1) {
  --cap: -webkit-image-set(
    url('../assets/accessibility/keys/key-tab-1x.webp?v=3') 1x,
    url('../assets/accessibility/keys/key-tab-2x.webp?v=3') 2x,
    url('../assets/accessibility/keys/key-tab-3x.webp?v=3') 3x
  );
}
.keys.is-rendered i:nth-child(2) {
  --cap: -webkit-image-set(
    url('../assets/accessibility/keys/key-esc-1x.webp?v=3') 1x,
    url('../assets/accessibility/keys/key-esc-2x.webp?v=3') 2x,
    url('../assets/accessibility/keys/key-esc-3x.webp?v=3') 3x
  );
}
.keys.is-rendered i:nth-child(3) {
  --cap: -webkit-image-set(
    url('../assets/accessibility/keys/key-enter-1x.webp?v=3') 1x,
    url('../assets/accessibility/keys/key-enter-2x.webp?v=3') 2x,
    url('../assets/accessibility/keys/key-enter-3x.webp?v=3') 3x
  );
}
.keys.is-rendered i:nth-child(4) {
  --cap: -webkit-image-set(
    url('../assets/accessibility/keys/key-space-1x.webp?v=3') 1x,
    url('../assets/accessibility/keys/key-space-2x.webp?v=3') 2x,
    url('../assets/accessibility/keys/key-space-3x.webp?v=3') 3x
  );
}
.keys.is-rendered i b,
.keys.is-rendered i:hover b,
.keys.is-rendered i.is-down b {
  background: none;
  box-shadow: none;
  will-change: transform;
}
.keys.is-rendered i b {
  transform: translateY(round(calc(var(--travel) * -1), 1px));
}
.keys.is-rendered i.is-down b {
  transform: translateY(round(calc(var(--u) * -1), 1px));
}
.keys.is-rendered .key-block {
  display: none;
}
.keys.is-rendered b::before {
  content: '';
  position: absolute;
  top: calc(var(--u) * -1);
  left: calc(var(--u) * -1);
  width: calc(100% + var(--u) * 2);
  height: calc(var(--u) * 65);
  background: var(--cap) 50% 0 / 100% 100% no-repeat;
}
@media (hover: hover) and (pointer: fine) {
  .keys.is-rendered i:hover b {
    transform: translateY(round(calc(var(--u) * -1), 1px));
  }
}

/*
  Staging (sections/sustainability.js sets 'is-staged' where the tiles come
  in with the scroll, and 'is-in' on a tile once it is well into view): the
  drawings play once as their tile arrives.  The dimension lines draw, the
  large letters grow from the small ones' size, the dial's hand sweeps to
  its second with the arc, the specimens and the keys come in left to
  right, the plate settles, and the phone rises.  Without
  'is-staged' (a touch screen, reduced motion, no script) everything is
  shown in place.
*/
.is-staged .type-dim {
  stroke-dasharray: 1;
  transition: stroke-dashoffset 0.9s var(--ease-glide) 0.25s;
}
.is-staged .type-size,
.is-staged .fact-plate,
.is-staged .ladder-glyph text,
.is-staged .ladder-ratio text,
.is-staged .keys i,
.is-staged .speak {
  transition:
    opacity 0.6s var(--ease-glide) calc(0.2s + var(--i, 0) * 70ms),
    transform 0.9s var(--ease-glide) 0.1s;
}
.is-staged .type-glyph.is-large {
  /* Its baseline's start, in the drawing's units. */
  transform-origin: 172px 360px;
  transition:
    transform 1s var(--ease-glide) 0.15s,
    opacity 0.4s linear 0.15s;
}
.is-staged .dial-arc {
  stroke-dasharray: 1;
}
.is-staged .dial-arc,
.is-staged .dial-hand {
  transition: 1.1s var(--ease-glide) 0.3s;
  transition-property: stroke-dashoffset, transform;
}
.is-staged .fact-tile:not(.is-in) .type-dim,
.is-staged .fact-tile:not(.is-in) .dial-arc {
  stroke-dashoffset: 1;
}
.is-staged .fact-tile:not(.is-in) .dial-hand {
  transform: rotate(0deg);
}
.is-staged .fact-tile:not(.is-in) .type-size,
.is-staged .fact-tile:not(.is-in) .ladder-glyph text,
.is-staged .fact-tile:not(.is-in) .ladder-ratio text,
.is-staged .fact-tile:not(.is-in) .keys i {
  opacity: 0;
}
.is-staged .fact-tile:not(.is-in) .type-glyph.is-large {
  opacity: 0;
  transform: scale(0.32);
}
.is-staged .fact-tile:not(.is-in) .fact-plate {
  opacity: 0;
  transform: scale(0.94);
}
.is-staged .fact-tile:not(.is-in) .speak {
  opacity: 0;
  transform: translateY(calc(var(--u) * 28));
}

/*
  Pointer play (sections/fact-play.js, under 'is-playable').  The text
  tile's layers stand in depth and their stack turns to face the pointer;
  the script runs the stopwatch's hand and ring itself, so their staging
  transitions stand down.
*/
.is-playable .fact-tile.is-lead {
  perspective: calc(var(--u) * 900);
}
.is-playable .type-stack {
  transform-style: preserve-3d;
  will-change: transform;
}
.is-playable .type-layer {
  transform: translateZ(calc(var(--z) * var(--u)));
}
.is-playable .dial-arc,
.is-playable .dial-hand {
  transition: none;
}
.is-playable .contrast-ladder {
  cursor: ew-resize;
}
