/* The variable weight menu: a full-screen menu on bone paper. The words are set in a variable typeface (Anybody,
   weight 100 to 900 and width 50 to 150): every letter takes its weight and its width from how far the pointer is,
   so a wave of heavy, wide letters follows it through the menu. Under the menu, the black page. */
:root {
  --page: #000000;          /* the page under the menu */
  --paper: #ebe6da;         /* the menu */
  --ink: #161412;           /* the words of the menu */
  --faint: #9a9488;         /* the words far from the pointer mix towards this */
  --accent: #ff4b22;        /* the note beside the word pointed at, and the focus ring */
  --rule: rgba(22, 20, 18, 0.14);
  --night: #151412;         /* the button's word while the menu is closed */
  --bone: #efe9dc;          /* the button while the menu is closed */
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--bone);
  font-family: 'Anybody Variable', system-ui, sans-serif;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
}

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

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

/* ---------------------------------------------------------------- the button */
/* a pill with Menu or Close, and two lines that cross into an X while the menu is open; it stays above the menu */
.toggle {
  position: fixed;
  top: 22px;
  right: clamp(16px, 3.4vw, 44px);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 8px 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--bone);
  color: var(--night);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.45s ease, color 0.45s ease;
}

body.is-open .toggle {
  background: var(--ink);
  color: var(--paper);
}

.toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 999px;
}

.toggle__words {
  position: relative;
  display: grid;
  height: 1.2em;
  overflow: hidden;
  line-height: 1.2em;
}

.toggle__word {
  grid-area: 1 / 1;
  text-align: right;
}

.toggle__icon {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: color-mix(in srgb, currentColor 14%, transparent);
}

.toggle__icon i {
  position: absolute;
  left: 9px;
  right: 9px;
  top: 50%;
  height: 1.6px;
  margin-top: -0.8px;
  border-radius: 2px;
  background: currentColor;
}

/* ---------------------------------------------------------------- the menu */
.menu {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  grid-template-rows: 1fr;
  padding: 96px clamp(16px, 3.4vw, 44px) clamp(22px, 4vh, 40px);
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

.menu__list {
  position: relative;
  align-self: center;
  margin: 0;
  padding: 0;
  list-style: none;
  touch-action: none;
}

.menu__row {
  border-top: 1px solid var(--rule);
}

.menu__row:last-child {
  border-bottom: 1px solid var(--rule);
}

.menu__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0.02em 0;
  font-size: clamp(44px, min(13vw, 14.2vh), 176px);
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.menu__item:focus-visible {
  outline: none;
}

/* the word, in a window that lets it rise into place; it leans from its foot */
.menu__mask {
  display: block;
  flex: none;
  overflow: clip;
  padding: 0.06em 0.3em 0.04em 0;
  margin-right: -0.3em;
}

.menu__word {
  position: relative;
  display: block;
  white-space: nowrap;
}

/* the letters lean together from the word's foot */
.menu__lean {
  display: inline-block;
  transform-origin: 0 82%;
}

/* every letter: the script sets its weight, its width and --v, how close the wave is (0 far, 1 under it) */
.menu__char {
  --v: 0;
  display: inline-block;
  color: color-mix(in srgb, var(--ink) calc(58% + var(--v) * 42%), var(--faint));
  font-weight: 260;
  font-stretch: 82%;
  letter-spacing: -0.01em;
}

/* the note beside the word pointed at (or reached with the keys) */
.menu__note {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 560;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateX(-14px);
  transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.menu__note::after {
  content: '';
  width: 26px;
  height: 12px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 12'%3E%3Cpath d='M0 6h23M18 1l5 5-5 5' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 12'%3E%3Cpath d='M0 6h23M18 1l5 5-5 5' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") center / contain no-repeat;
}

.menu__row.is-on .menu__note {
  opacity: 1;
  transform: none;
}

/* the keys: a ring round the word reached */
.menu__item:focus-visible .menu__mask {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (max-width: 720px) {
  .menu__item {
    font-size: clamp(46px, 14.6vw, 66px);
  }

  .menu__note {
    display: none;
  }
}

/* with reduced motion the note fades in place, without sliding */
@media (prefers-reduced-motion: reduce) {
  .menu__note {
    transform: none;
    transition: opacity 0.3s ease;
  }
}
