/* The toolbox menu: the actions of a photo editor as the trays of a cantilever toolbox, on a white page. The metal,
   the arms and the tools are painted on the canvas by the script; the buttons laid over it are the real menu, and
   the script moves them with the trays. --u is the length of one unit of the drawing. */
:root {
  --page: #ffffff;          /* the page */
  --paint: #2449c2;         /* the enamel of the box and the trays */
  --primer: #ece6d6;        /* the inside of the lids, where the tools hang */
  --zinc: #c9ced4;          /* the arms, the rivets and the latch */
  --stamp: #f2f5ff;         /* the letters stamped in the trays */
  --handle: #ffc21a;        /* the yellow of the knife and the level */
  --tip: #ff5a36;           /* the wet paint on the brush */
  --focus: #ff7a1a;         /* the ring of the keyboard focus */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: #11151c;
  font-family: 'Archivo Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

p {
  margin: 0;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 48px 16px;
}

/* ---------------------------------------------------------------- the frame */
/* the room the box needs: closed, it sits in the middle; open, it settles lower and the trays fill the room above
   it from side to side */
.box {
  --u: 1px;                 /* set by the script */
  position: relative;
  width: calc(var(--u) * 384);
  height: calc(var(--u) * 232);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.box__paint {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the box: the menu button */
.lid-button {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  width: calc(var(--u) * 190);
  height: calc(var(--u) * 60);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: calc(var(--u) * 6);
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.lid-button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

/* the zinc plate riveted to the front of the box: it says what the box is, and what it has just done. The plate
   itself is painted on the canvas; the words are here, so they stay sharp */
.plate {
  position: absolute;
  left: calc(var(--u) * 61);
  bottom: calc(var(--u) * 4);
  display: grid;
  width: calc(var(--u) * 68);
  height: calc(var(--u) * 14);
  overflow: hidden;
  pointer-events: none;
}

.plate__face {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  color: #1d2531;
  font-size: calc(var(--u) * 9.6);
  font-weight: 760;
  font-stretch: 88%;
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: 0 calc(var(--u) * 0.7) 0 rgba(255, 255, 255, 0.7);
}

/* the tracking leaves room after the last letter: the word gives it back, so it sits in the middle */
.plate__word {
  margin-right: -0.16em;
}

/* ---------------------------------------------------------------- the trays: the menu */
.trays {
  position: absolute;
  inset: 0;
  z-index: 1;
  outline: none;
  pointer-events: none;
}

.tray {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--u) * 92);
  height: calc(var(--u) * 36);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: calc(var(--u) * 5);
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.tray--board {
  height: calc(var(--u) * 68);
}

.trays[inert] .tray {
  pointer-events: none;
}

.tray:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: calc(var(--u) * 3);
}

/* the name of the action, stamped into the front of the tray: the stamp is light on the enamel, with the shadow
   of the press on its upper edge */
.tray__label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--u) * 3.6);
  display: block;
  color: var(--stamp);
  font-size: calc(var(--u) * 10.4);
  font-weight: 740;
  font-stretch: 84%;
  line-height: calc(var(--u) * 11);
  letter-spacing: 0.14em;
  text-align: center;
  text-indent: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow:
    0 calc(var(--u) * -0.7) 0 rgba(0, 0, 0, 0.45),
    0 calc(var(--u) * 0.6) 0 rgba(255, 255, 255, 0.18);
  opacity: 0;
  pointer-events: none;
}

.tray--board .tray__label {
  bottom: calc(var(--u) * 2.8);
}

/* under the pointer, or reached by the keys, the stamp of the tray brightens */
@media (hover: hover) and (pointer: fine) {
  .trays:not([inert]) .tray:hover .tray__label {
    color: #ffffff;
  }
}

.tray:focus-visible .tray__label {
  color: #ffffff;
}
