/* Menu on the guide: the menu of a small studio, Datum, on warm paper. Five entries in Archivo (a variable sans,
   weight 100 to 900 and width 62 to 125), each resting on its own faint guide; one thin vermilion guide follows the
   pointer. The script moves the entries, the guide and the weights. */
:root {
  --paper: #f3f0e8;               /* the page */
  --ink: #141414;                 /* the entries */
  --grey: #8d887e;                /* the small texts */
  --rule: rgba(20, 20, 20, 0.16); /* the entries' own guides, at rest */
  --accent: #e2432a;              /* the guide that follows the pointer */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow: hidden;
}

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

.stage {
  --pad: clamp(16px, 6vw, 96px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100svh;
  padding: clamp(18px, 3.4vw, 40px) var(--pad) clamp(18px, 3vw, 36px);
  touch-action: none;
}

/* ---------------------------------------------------------------- the top line and the hint */
.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 14px;
  letter-spacing: 0.01em;
  overflow: hidden;
}

.top__name,
.top__note {
  display: inline-block;
}

.top__name {
  font-variation-settings: 'wght' 620, 'wdth' 100;
}

.top__note {
  color: var(--grey);
  font-variation-settings: 'wght' 420, 'wdth' 100;
}

.hint {
  margin: 0;
  font-size: 13px;
  color: var(--grey);
  text-align: center;
}

/* ---------------------------------------------------------------- the menu */
.menu {
  --fs: clamp(30px, min(7vw, 7.6vh), 88px);
  position: relative;
  align-self: center;
  justify-self: center;
  width: min(100%, 1040px);
}

.row {
  position: relative;
  height: calc(var(--fs) * 1.14);
}

/* each entry's own guide: a faint hairline where it rests */
.row__rest {
  position: absolute;
  top: -5px;
  bottom: -5px;
  left: 0;
  width: 1px;
  background: var(--rule);
  pointer-events: none;
}

.item {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  font-size: var(--fs);
  line-height: 1.14;
  color: inherit;
  text-decoration: none;
  z-index: 1;
  outline: none;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* the mask lets the entry rise into place when the page opens */
.item__mask {
  display: block;
  overflow: hidden;
}

.item__text {
  display: inline-block;
  white-space: nowrap;
  letter-spacing: -0.012em;
  font-variation-settings: 'wght' 280, 'wdth' 100;
}

.item:focus-visible .item__text {
  outline: 1px solid var(--ink);
  outline-offset: 6px;
}

/* ---------------------------------------------------------------- the guide that follows the pointer */
.guide {
  position: absolute;
  top: -30px;
  bottom: -30px;
  left: -5px;
  width: 11px;
  z-index: 0;
  pointer-events: none;
  will-change: transform;
}

/* a hairline with a small tick at each end, shown by a clip that opens from the pointer */
.guide__line {
  position: absolute;
  inset: 0;
  background: linear-gradient(var(--accent), var(--accent)) center / 1px 100% no-repeat;
  clip-path: inset(50% 0 50% 0);
}

.guide__line::before,
.guide__line::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accent);
}

.guide__line::before {
  top: 0;
}

.guide__line::after {
  bottom: 0;
}

/* where the guide stands, in pixels from the left of the menu */
.guide__readout {
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'wght' 420, 'wdth' 100;
  color: var(--grey);
  white-space: nowrap;
  transform: translateX(-50%);
  opacity: 0;
}

@media (max-width: 640px) {
  .menu {
    --fs: clamp(30px, 9.4vw, 44px);
  }

  .top {
    font-size: 13px;
  }
}
