/* The interlocking keys tab bar: a brushed aluminium plate alone on a white page, with five long cream keys in a
   dark well and, under them, a slot where the steel latch bar can be seen. The keys are tilted by the script on
   every frame; the colours are here. */
:root {
  --page: #ffffff;          /* the page */
  --plate: #d9d6cf;         /* the brushed aluminium plate */
  --plate-dark: #a9a59c;    /* its lower edge, in the shade */
  --well: #1f1c19;          /* the dark well the keys sit in, and the slot */
  --key: #efe7d4;           /* the cream plastic of a key */
  --key-dark: #cfc4ab;      /* the same plastic towards the front, where the light falls less */
  --front: #e4e2dc;         /* the aluminium front of a key */
  --icon: #7d7365;          /* an icon at rest */
  --icon-hover: #5a5145;    /* an icon under the pointer */
  --lit: #e2472b;           /* the icon of the key held down */
  --name: #3b3833;          /* the name engraved on the front */
  --steel: #9aa0a4;         /* the latch bar */
  --steel-light: #e6eaec;   /* its lit edge */
  --steel-dark: #50565a;    /* its shaded edge and the spring's anchor */
  --brass: #c7a25e;         /* the lugs under the keys */
  --brass-light: #f1dfae;   /* their lit side */
  --brass-dark: #7d5e28;    /* their shaded side */
  --ring: #1f1c19;          /* the focus ring */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--name);
  font-family: 'Archivo Variable', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

/* ---------------------------------------------------------------- the plate */
/* as wide as a phone's tab bar, never wider than 420 pixels nor than the screen */
.deck {
  position: relative;
  width: min(420px, 100%);
  height: 72px;
  border-radius: 20px;
  /* brushed aluminium: fine horizontal grain over a soft fall of light from the top */
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0 1px, rgba(0, 0, 0, 0.025) 1px 2px, rgba(255, 255, 255, 0.05) 2px 3px),
    linear-gradient(180deg, color-mix(in srgb, var(--plate) 55%, #ffffff) 0%, var(--plate) 46%, color-mix(in srgb, var(--plate) 80%, var(--plate-dark)) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1.5px 0 color-mix(in srgb, var(--plate-dark) 70%, transparent),
    0 0 0 1px rgba(60, 56, 48, 0.16),
    0 18px 30px -18px rgba(40, 36, 30, 0.5),
    0 4px 10px -5px rgba(40, 36, 30, 0.2);
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

/* the opening the keys stand in: dark inside, with a lit lip along its lower edge */
.deck__well {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 5px;
  height: 46px;
  border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--well) 70%, #000000) 0%, var(--well) 60%, color-mix(in srgb, var(--well) 88%, #ffffff) 100%);
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.6),
    0 1px 0 rgba(255, 255, 255, 0.75),
    0 -1px 0 rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

/* the edge of the plate over the back of the keys: they go on under it, to their pivot */
.deck__lip {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 5px;
  height: 7px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, rgba(14, 10, 6, 0.5) 0%, rgba(14, 10, 6, 0.16) 55%, rgba(14, 10, 6, 0) 100%);
  pointer-events: none;
}

/* the slot under the keys, where the latch bar shows */
.deck__slot {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 55px;
  height: 13px;
  overflow: hidden;
  border-radius: 3px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--well) 70%, #000000) 0%, var(--well) 50%, color-mix(in srgb, var(--well) 85%, #ffffff) 100%);
  box-shadow:
    inset 0 1.5px 2px rgba(0, 0, 0, 0.7),
    0 1px 0 rgba(255, 255, 255, 0.7),
    0 -1px 0 rgba(0, 0, 0, 0.1);
  pointer-events: none;
}

.deck__works {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.works__bar {
  fill: url(#kb-steel);
}

.works__edge {
  fill: none;
  stroke: var(--steel-light);
  stroke-width: 0.6;
  opacity: 0.85;
}

.works__lug {
  fill: url(#kb-lug);
}

.works__spring {
  fill: none;
  stroke: var(--steel-light);
  stroke-width: 0.9;
  stroke-linejoin: round;
}

.works__anchor {
  fill: var(--steel-dark);
}

/* ---------------------------------------------------------------- the keys */
.deck__keys {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.key {
  position: relative;
  display: block;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--icon);
  font: inherit;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

/* a key: a lever turned about a pivot behind the plate (the script), seen a little from above. Its top is the cream
   plastic with the icon, its front a sloping strip of aluminium with the name */
.key__body {
  position: absolute;
  left: 4.5px;
  right: 4.5px;
  top: 6px;
  height: 31px;
  transform-origin: 50% 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.key__top {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-top: 2px;
  overflow: hidden;
  border-radius: 3px 3px 1px 1px;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--key) 70%, #ffffff) 0%, var(--key) 40%, var(--key-dark) 100%);
  box-shadow:
    inset 1px 0 0 rgba(255, 255, 255, 0.6),
    inset -1px 0 0 rgba(120, 100, 70, 0.22),
    inset 0 -1px 0 rgba(120, 100, 70, 0.3);
}

/* how the light falls on the top as the key tilts, and the shadow the keys beside throw into it (the script) */
.key__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(20, 12, 4, 0.55) 0%, rgba(20, 12, 4, 0) 22%, rgba(20, 12, 4, 0) 78%, rgba(20, 12, 4, 0.55) 100%), rgba(30, 20, 8, 0.4);
  opacity: 0;
  pointer-events: none;
}

.key__icon {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.key__fill {
  fill: currentColor;
  stroke: none;
  opacity: 0;
}

.key__front {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 13px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 0 0 2.5px 2.5px;
  transform-origin: 50% 0;
  transform: rotateX(-50deg);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 1px, rgba(0, 0, 0, 0.03) 1px 2px),
    linear-gradient(180deg, color-mix(in srgb, var(--front) 60%, #ffffff) 0%, var(--front) 50%, color-mix(in srgb, var(--front) 82%, #6d6a62) 100%);
  box-shadow:
    inset 0 0.8px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(60, 56, 48, 0.35);
}

.key__name {
  position: relative;
  color: var(--name);
  font-size: 8.4px;
  font-weight: 640;
  font-stretch: 78%;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  padding-left: 0.12em;
  /* engraved: a lit lip under the cut */
  text-shadow: 0 0.6px 0 rgba(255, 255, 255, 0.85);
}

/* the glint on the aluminium: it runs as the key tilts (the script) */
.key__gloss {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0) 70%);
  mix-blend-mode: soft-light;
  will-change: transform;
}

/* the focus, from the keyboard only: a ring round the key and its well */
.key::after {
  content: '';
  position: absolute;
  left: 1px;
  right: 1px;
  top: 3px;
  height: 52px;
  border-radius: 9px;
  box-shadow: 0 0 0 2px var(--ring), 0 0 0 3.5px rgba(255, 255, 255, 0.9);
  opacity: 0;
  pointer-events: none;
}

.key:focus-visible::after {
  opacity: 1;
}

html[data-using='pointer'] .key:focus-visible::after {
  opacity: 0;
}
