:root {
  --bg: #ffffff;            /* the page */
  --ink: #141414;           /* the letters, the words and the button outline */
  --muted: #8a867e;         /* the notes on the right */
  --rule: #e4e0d8;          /* the hairline under every row */
  --accent: #e5432a;        /* the vermilion initial of the page you are on */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}

body {
  font-family: 'Mona Sans Variable', 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

/* the frame: the script sets its size from the window (--w, --step, --word, --frame-h), so the open menu always fits */
.frame {
  position: relative;
  width: var(--w, 360px);
  height: var(--frame-h, 360px);
}

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

/* ---------------------------------------------------------------- the button */
.toggle {
  position: absolute;
  top: 0;
  left: 0;
  height: 54px;
  padding: 0 18px 0 22px;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}

.toggle:focus-visible {
  outline: 1.5px solid var(--ink);
  outline-offset: 4px;
}

.toggle__word {
  position: relative;
  display: inline-flex;
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0.16em;
  font-variation-settings: 'wght' var(--bw, 520), 'wdth' var(--bwd, 100);
}

/* one letter per span: each one is measured to know where its initial takes off from */
.toggle__l {
  display: inline-block;
  line-height: 1;
}

.toggle__close {
  position: absolute;
  left: 22px;
  top: 50%;
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0.04em;
  translate: 0 -50%;
  opacity: 0;
  font-variation-settings: 'wght' 480, 'wdth' var(--cwd, 75);
  pointer-events: none;
}

.toggle__icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
}

.toggle__bar {
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-linecap: round;
}

/* ---------------------------------------------------------------- the rows */
.menu {
  position: absolute;
  top: 72px;
  left: 0;
  right: 0;
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  position: relative;
  height: var(--step, 60px);
}

.row__link {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 2px;
  color: var(--ink);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.row__link:focus-visible {
  outline: 1.5px solid var(--ink);
  outline-offset: 2px;
  border-radius: 4px;
}

/* the initial: GSAP flies it (x, y, scale) from its letter in the button; its glyph is a child, for the squash */
.row__initial {
  display: inline-block;
  line-height: 1;
  font-size: var(--word, 32px);
  transform-origin: 0 0;
  opacity: 0;
  font-variation-settings: 'wght' var(--wght, 420), 'wdth' 100;
  will-change: transform;
}

.row__glyph {
  display: inline-block;
  transform-origin: 50% 100%;
  transition: color 0.35s ease;
}

.row__link[aria-current='page'] .row__glyph {
  color: var(--accent);
}

/* the rest of the word opens out of the initial: a clip from the left and the width axis from narrow to wide */
.row__rest {
  display: inline-block;
  line-height: 1;
  font-size: var(--word, 32px);
  letter-spacing: -0.012em;
  padding-right: 0.08em;
  clip-path: inset(-20% 100% -20% 0);
  font-variation-settings: 'wght' var(--wght, 420), 'wdth' var(--wdth, 75);
}

.row__note {
  margin-left: auto;
  padding-left: 12px;
  font-size: 12px;
  line-height: 1.2;
  color: var(--muted);
  text-align: right;
  opacity: 0;
  font-variation-settings: 'wght' 400, 'wdth' 92;
}

.row__arrow {
  flex: none;
  margin-left: 12px;
  overflow: visible;
}

.row__arrow path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 34;
  stroke-dashoffset: 34;
}

.row__rule {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--rule);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

@media (max-width: 360px) {
  .row__note { display: none; }
  .row__arrow { margin-left: auto; }
}
