/* The rack and pinion nav: the top bar of a watchmaker on a white page, with a steel rack under the links and a brass
   pinion that rolls on it. The metals are drawn by the script in SVG with the colours below. */
:root {
  --page: #ffffff;          /* the page */
  --bar: #ffffff;           /* the bar */
  --edge: rgba(24, 22, 18, 0.09);  /* the bar's edge */
  --ink: #18171a;           /* the brand, the current link and the one pointed at */
  --muted: #85817a;         /* the other links */
  --ring: #2d5d95;          /* the outline of the keyboard focus */
  --brass-hi: #fff6dc;      /* the pinion: where the light catches it */
  --brass-light: #f1d89b;
  --brass: #cfa75c;
  --brass-dark: #94702f;
  --brass-deep: #5f4417;    /* its edges turned away from the light */
  --steel-hi: #ffffff;      /* the rack and the small gear in the hub */
  --steel-light: #dde1e7;
  --steel: #aeb5bf;
  --steel-dark: #727a86;
  --steel-deep: #4f555e;
  --cavity: #2a241c;        /* the dark inside the hub */
  --cavity-light: #54473a;
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

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

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

.stage {
  min-height: 100svh;
  display: grid;
  /* one column as wide as the window: the links that do not fit scroll inside the bar instead of widening it */
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 48px 16px;
}

/* ---------------------------------------------------------------- the bar */
.bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(900px, 100%);
  height: 64px;
  padding: 0 12px 0 22px;
  border-radius: 18px;
  background: var(--bar);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    0 1px 2px rgba(30, 26, 18, 0.05),
    0 20px 44px -28px rgba(40, 32, 18, 0.42);
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

a:focus {
  outline: none;
}

/* ---------------------------------------------------------------- the brand: just the name, engraved wide */
.brand {
  flex: none;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 13px;
  font-stretch: 125%;
  font-weight: 640;
  letter-spacing: 0.3em;
  line-height: 1;
  text-transform: uppercase;
  /* the last letter's spacing would push the name off centre */
  margin-right: -0.3em;
}

/* ---------------------------------------------------------------- the links, with the rack under them */
/* the links scroll sideways inside the bar when they do not fit; auto margins centre them without cutting the first */
.strip {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  --fade-l: 0px;
  --fade-r: 0px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
}

.strip::-webkit-scrollbar {
  display: none;
}

.strip.is-after {
  --fade-l: 30px;
}

.strip.is-before {
  --fade-r: 30px;
}

.track {
  position: relative;
  flex: none;
  height: 100%;
  margin: 0 auto;
}

/* the rack and the pinion lie on the bar, under the links */
.mech {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.list {
  position: relative;
  display: flex;
  height: 100%;
  margin: 0;
  padding: 0 8px;
  list-style: none;
}

/* each link is as tall as the bar, so a touch on the pinion's row chooses it too; the word sits in the top row */
.link {
  display: block;
  height: 100%;
  padding: 9px 15px 0;
  /* a link lights up as the pinion comes under it: --lit, from 0 to 1, is written by the script at every frame */
  color: var(--muted);
  color: color-mix(in srgb, var(--ink) calc(var(--lit, 0) * 100%), var(--muted));
  font-size: 12px;
  font-stretch: 112%;
  font-weight: 560;
  letter-spacing: 0.14em;
  line-height: 14px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.25s ease;
}

.link__word {
  position: relative;
  display: block;
  margin-right: -0.14em;
  transition: transform 0.16s ease-out;
}

/* the keys: a ring drawn close round the capitals, so it never touches the pinion below */
.link__word::after {
  content: '';
  position: absolute;
  inset: -2.5px -7px -1px calc(-7px + 0.14em);
  border: 2px solid var(--ring);
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
}

.link:focus-visible .link__word::after {
  opacity: 1;
}

.link[aria-current='page'] {
  --lit: 1;
}

.link:focus-visible {
  color: var(--ink);
}

/* where color-mix is missing, the current link is simply dark */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .link[aria-current='page'] {
    color: var(--ink);
  }
}

@media (hover: hover) {
  .link:hover {
    color: var(--ink);
  }
}

.link:active .link__word {
  transform: scale(0.95);
}

/* ---------------------------------------------------------------- the button */
.cta {
  display: flex;
  flex: none;
  align-items: center;
  height: 38px;
  padding: 0 17px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(24, 23, 26, 0.85);
  font-size: 12px;
  font-stretch: 112%;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color 0.22s ease, color 0.22s ease, transform 0.16s ease-out;
}

@media (hover: hover) {
  .cta:hover {
    background: var(--ink);
    color: var(--bar);
  }
}

.cta:active {
  transform: scale(0.97);
}

/* ---------------------------------------------------------------- the keys */
.brand:focus-visible,
.cta:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 4px;
}

.cta:focus-visible {
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- the metals */
.rack__shadow {
  fill: rgba(40, 34, 24, 0.11);
}

.rack__body {
  stroke: rgba(46, 52, 62, 0.42);
  stroke-width: 0.5;
  stroke-linejoin: round;
}

/* the flat face of the bar under the teeth, catching the light along its top */
.rack__face {
  fill: none;
  stroke: var(--steel-hi);
  stroke-width: 0.7;
  opacity: 0.75;
}

.rack__lit {
  fill: none;
  stroke: var(--steel-hi);
  stroke-width: 0.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rack__shade {
  fill: none;
  stroke: var(--steel-dark);
  stroke-width: 0.7;
  stroke-linecap: round;
  opacity: 0.8;
}

.pinion__shadow {
  fill: rgba(46, 34, 14, 0.3);
}

/* a fine dark line round the teeth, so the lit ones still stand out from the white bar */
.pinion__line {
  fill: none;
  stroke: rgba(84, 58, 16, 0.5);
  stroke-width: 0.5;
  stroke-linejoin: round;
}

.pinion__edge {
  fill: none;
  stroke-width: 0.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pinion__edge--hi {
  stroke: var(--brass-hi);
}

.pinion__edge--lit {
  stroke: var(--brass-light);
  opacity: 0.8;
}

.pinion__edge--shade {
  stroke: var(--brass-dark);
  opacity: 0.75;
}

.pinion__edge--dark {
  stroke: var(--brass-deep);
  opacity: 0.85;
}

/* a fine line turned in the face of the wheel, near its rim */
.pinion__groove {
  fill: none;
  stroke: var(--brass-dark);
  stroke-width: 0.5;
  opacity: 0.45;
}

.pinion__chamfer {
  fill: none;
  stroke-width: 0.9;
}

.pinion__inner-shadow {
  fill: rgba(0, 0, 0, 0.5);
}

.pinion__inner-edge {
  fill: none;
  stroke: var(--steel-hi);
  stroke-width: 0.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}

.pinion__pivot {
  fill: var(--steel-deep);
}

/* ---------------------------------------------------------------- narrow screens */
/* the button goes, and the links get a little less air, so they still fit beside the name */
@media (max-width: 960px) {
  .bar {
    gap: 10px;
    padding: 0 10px 0 18px;
  }

  .cta {
    display: none;
  }

  .link {
    padding-left: 11px;
    padding-right: 11px;
  }
}

@media (max-width: 720px) {
  .bar {
    gap: 6px;
    padding: 0 6px 0 16px;
  }

  .brand {
    font-size: 12px;
    letter-spacing: 0.24em;
    margin-right: -0.24em;
  }

  .list {
    padding: 0 6px;
  }

  .link {
    padding: 9px 13px 0;
  }
}

/* on the narrowest phones the name gives its room to the links */
@media (max-width: 359px) {
  .brand {
    display: none;
  }

  .bar {
    padding-left: 6px;
  }
}

/* with less motion, the presses do not shrink */
@media (prefers-reduced-motion: reduce) {
  .link:active .link__word,
  .cta:active {
    transform: none;
  }
}
