/* The oscilloscope nav: the top bar of a small maker of synthesizers, alone on a black page. The links sit on the
   glass of an oscilloscope, with a trace of green phosphor drawn under them by the script, which reads the colours
   of the trace from here. */
:root {
  --page: #000000;          /* the page */
  --panel: #121413;         /* the bar, the front panel of the instrument */
  --panel-edge: rgba(255, 255, 255, 0.075);  /* the bar's edge */
  --silk: #d9ddd6;          /* the name, printed on the panel */
  --glass: #050b07;         /* the glass of the tube */
  --grid: rgba(120, 255, 170, 0.075);  /* the lines etched on the glass */
  --phosphor: #5dff98;      /* the trace */
  --hot: #e6fff0;           /* the trace where the beam is strongest */
  --dim: #3f8a5b;           /* the other links */
  --lit: #b9ffd2;           /* the current link and the one pointed at */
  --cta: #55e88f;           /* the button */
  --on-cta: #03140a;        /* the words on the button */
  --ring: #a6ffc8;          /* the outline of the keyboard focus */
}

* {
  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(--silk);
  font-family: 'Martian Mono Variable', ui-monospace, monospace;
  -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 glass 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(940px, 100%);
  height: 62px;
  padding: 0 7px 0 18px;
  border-radius: 17px;
  background: var(--panel);
  box-shadow:
    inset 0 0 0 1px var(--panel-edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 24px 48px -30px rgba(93, 255, 152, 0.16);
}

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

a:focus {
  outline: none;
}

/* ---------------------------------------------------------------- the name */
.brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 6px 0 2px;
  border-radius: 10px;
}

.brand__mark {
  width: 26px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: var(--silk);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.brand__name {
  font-size: 14px;
  font-stretch: 112.5%;
  font-weight: 640;
  letter-spacing: -0.02em;
}

/* ---------------------------------------------------------------- the glass */
/* the tube's window: deep green black, a little lighter in the middle, set into the panel. The lines etched on the
   glass: a division every 40 pixels, and the axis the trace runs on, with its fine ticks */
.screen {
  --axis: 36px;             /* the height of the trace in the glass, read by the script */
  position: relative;
  flex: 1;
  min-width: 0;
  align-self: stretch;
  margin: 6px 0;
  border-radius: 11px;
  overflow: hidden;
  background:
    linear-gradient(transparent calc(var(--axis) - 0.5px), var(--grid) calc(var(--axis) - 0.5px), var(--grid) calc(var(--axis) + 0.5px), transparent calc(var(--axis) + 0.5px)),
    repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 40px) 19.5px 0 / auto,
    radial-gradient(120% 160% at 50% 55%, #0a1a10 0%, var(--glass) 62%, #020403 100%);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.9),
    inset 0 2px 5px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* the fine ticks along the axis */
.screen::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--axis) - 2.5px);
  height: 5px;
  background: repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 8px) 3.5px 0 / auto;
  pointer-events: none;
}

/* the curved glass: a soft sheen across its top and a darker rim round its edge */
.screen__glass {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  background:
    radial-gradient(90% 70% at 50% -30%, rgba(220, 255, 235, 0.075), transparent 70%),
    radial-gradient(140% 220% at 50% 50%, transparent 58%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}

/* the links scroll sideways inside the glass when they do not fit */
.screen__scroll {
  position: relative;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

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

/* when the links do not all fit, the glass darkens towards the side where more of them wait */
.screen__fade {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 30px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.screen__fade--l {
  left: 0;
  background: linear-gradient(90deg, #020403 15%, rgba(2, 4, 3, 0));
}

.screen__fade--r {
  right: 0;
  background: linear-gradient(270deg, #020403 15%, rgba(2, 4, 3, 0));
}

.screen.is-after .screen__fade--l,
.screen.is-before .screen__fade--r {
  opacity: 1;
}

.track {
  position: relative;
  width: max-content;
  min-width: 100%;
  height: 100%;
}

/* the trace lies on the glass, under the words; its halo is a blurred copy, added to the light of the glass */
.trace {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  mix-blend-mode: screen;
  pointer-events: none;
}

.trace--glow {
  opacity: 0.9;
}

/* ---------------------------------------------------------------- the links */
.list {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-evenly;
  height: 100%;
  margin: 0;
  padding: 0 10px;
  list-style: none;
}

/* each link is as tall as the glass, so a touch on the trace under a word chooses it too; the word sits in the top row */
.link {
  display: block;
  height: 100%;
  padding: 10px 12px 0;
  color: var(--dim);
  font-size: 11px;
  font-stretch: 87.5%;
  font-weight: 560;
  letter-spacing: 0.06em;
  line-height: 13px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

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

/* the keys: a ring drawn close round the capitals, well above the trace */
.link__word::after {
  content: '';
  position: absolute;
  inset: -4px -7px -3px calc(-7px + 0.06em);
  border: 1.5px solid var(--ring);
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
}

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

.link[aria-current='page'],
.link:focus-visible {
  color: var(--lit);
  text-shadow: 0 0 7px rgba(93, 255, 152, 0.45);
}

@media (hover: hover) {
  .link:hover {
    color: var(--lit);
    text-shadow: 0 0 7px rgba(93, 255, 152, 0.35);
  }
}

.link:active .link__word {
  transform: translateY(0.5px) scale(0.96);
}

/* ---------------------------------------------------------------- the button */
/* the pill of a panel button: the words widen on the variable width axis, the pill swells with a bounce */
.cta {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 138px;
  height: 44px;
  padding: 0;
  color: var(--on-cta);
  font-size: 12px;
  font-stretch: 100%;
  font-weight: 680;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  isolation: isolate;
  transition: font-stretch 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.16s ease-out;
}

.cta__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 13px;
  background: var(--cta);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -2px 0 rgba(0, 40, 16, 0.25), 0 0 18px -4px rgba(93, 255, 152, 0.4);
}

@media (hover: hover) {
  .cta:hover {
    font-stretch: 112.5%;
  }
}

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

.brand:focus-visible,
.cta:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

.cta:focus-visible {
  border-radius: 13px;
}

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 760px) {
  .bar {
    gap: 9px;
    height: 58px;
    padding: 0 6px 0 13px;
    border-radius: 16px;
  }

  .screen {
    --axis: 34px;
    margin: 5px 0;
    border-radius: 10px;
  }

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

  .list {
    padding: 0 22px;
  }

  .cta {
    width: 90px;
    height: 42px;
    font-size: 11px;
  }

  .cta__bg {
    border-radius: 11px;
  }
}

/* on a phone the name goes and the mark stays, so the glass has more room */
@media (max-width: 480px) {
  .brand__name {
    display: none;
  }

  .brand {
    padding: 0 2px;
  }
}

/* with less motion: no presses that shrink, and the button keeps its width */
@media (prefers-reduced-motion: reduce) {
  .cta {
    font-stretch: 100%;
  }
  @media (hover: hover) {
    .cta:hover {
      font-stretch: 100%;
    }
  }

  .cta:active,
  .link:active .link__word {
    transform: none;
  }
}
