/* The hanging mobile menu: a gallery's menu as a hanging mobile on a white wall. The mobile itself (threads, wire arms,
   painted shapes and their shadow on the wall) is drawn by the script on a canvas; over it the real links follow the
   shapes, each with its caption, and the button at the top is where the mobile hangs from. The whole drawing is sized
   by --u, the pixels of one unit (the script sets it). */
:root {
  --page: #ffffff;          /* the wall */
  --ink: #161514;           /* the captions and the button */
  --ink-soft: #6d6a66;      /* the captions of the other pages */
  --paper: #f7f4ee;         /* the words on the button */
  --red: #d2382b;           /* the painted shapes */
  --black: #1b1a19;
  --yellow: #efb320;
  --blue: #2a58a6;
  --white: #f4f1ea;
  --wire: #1d1c1b;          /* the steel wire of the arms */
  --thread: #8d8984;        /* the threads */
  --brass: #b8913f;         /* the eyelet under the button */
  --shadow: #2a231c;        /* the colour of the mobile's shadow on the wall (the script lays it on lightly) */
  --focus: #161514;         /* 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: var(--ink);
  font-family: 'Bricolage Grotesque Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.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: 40px 16px;
}

/* ---------------------------------------------------------------- the frame of the mobile */
.mobile {
  --u: 1px;                 /* set by the script */
  position: relative;
  width: calc(var(--u) * 480);
  height: calc(var(--u) * 470);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

/* ---------------------------------------------------------------- the shapes: real links that follow the drawing */
.mobile__nav {
  position: absolute;
  inset: 0;
}

.piece {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  border-radius: calc(var(--u) * 10);
  outline: none;
  cursor: grab;
  touch-action: none;
  opacity: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-drag: none;
  will-change: transform;
}

.piece.is-held {
  cursor: grabbing;
}

/* the caption under the shape, like the label beside a work on a gallery wall */
.piece__label {
  position: absolute;
  left: 50%;
  bottom: 0;
  translate: -50% 0;
  padding: calc(var(--u) * 2) calc(var(--u) * 5);
  border-radius: calc(var(--u) * 5);
  color: var(--ink-soft);
  font-size: max(11.5px, calc(var(--u) * 14));
  line-height: 1.15;
  font-weight: 500;
  font-stretch: 88%;
  letter-spacing: 0.005em;
  white-space: nowrap;
  transition: font-weight 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), font-stretch 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.25s ease;
}

.piece[aria-current='page'] .piece__label {
  color: var(--ink);
  font-weight: 720;
}

.piece.is-on .piece__label {
  color: var(--ink);
  font-weight: 650;
  font-stretch: 100%;
}

.piece:focus-visible .piece__label {
  box-shadow: 0 0 0 2px var(--page), 0 0 0 3.5px var(--focus);
}

/* ---------------------------------------------------------------- the button the mobile hangs from */
.hanger {
  position: absolute;
  left: 50%;
  top: calc(var(--u) * 4);
  translate: -50% 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 9);
  height: 56px;
  min-width: 132px;
  padding: 0 24px 0 20px;
  border: 0;
  background: none;
  color: var(--paper);
  font: inherit;
  font-size: 17px;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}

/* the pill is a child of its own, so the script can swell it with a spring while the words keep still */
.hanger__bg {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -2px 4px rgba(0, 0, 0, 0.35),
    0 1px 2px rgba(20, 16, 12, 0.25),
    0 8px 18px -8px rgba(20, 16, 12, 0.45);
}

.hanger:focus-visible .hanger__bg {
  box-shadow:
    0 0 0 2px var(--page),
    0 0 0 4px var(--focus),
    0 8px 18px -8px rgba(20, 16, 12, 0.45);
}

.hanger__icon {
  position: relative;
  width: 22px;
  height: 22px;
}

.hanger__icon svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.glyph__wire,
.hanger__cross path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.glyph__shape {
  fill: currentColor;
}

.glyph__shape--red {
  fill: var(--red);
}

.hanger__cross {
  opacity: 0;
}

/* the two words share a box, one above the other; the open state rolls them */
.hanger__words {
  position: relative;
  display: grid;
  height: 22px;
  overflow: hidden;
  line-height: 22px;
}

.hanger__word {
  grid-area: 1 / 1;
  font-weight: 600;
  font-stretch: 86%;
  letter-spacing: 0.005em;
  transition: font-stretch 0.45s cubic-bezier(0.2, 0.9, 0.25, 1.25);
}

.hanger__word[data-word='close'] {
  transform: translateY(100%);
}

@media (hover: hover) {
  .hanger:hover .hanger__word {
    font-stretch: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .piece__label,
  .hanger__word {
    transition: none;
  }
}
