/* The reading line menu: the full-screen menu of a design studio, alone on a white page. The links are set in
   Roboto Flex (a variable sans: width 25 to 151, weight 100 to 1000, optical size 8 to 144), small and light; a
   reading line closed by two hairlines shows a copy of them set big, heavy and wide. The script moves the line, the
   copy and the button.
   On a real site the menu covers the screen: give .reader `position: fixed; inset: 0; width: auto; padding: 24px` and
   the button stays in its corner, top right; here it sits in the middle of the page, alone. */
:root {
  --page: #ffffff;          /* the page, and the band of the reading line */
  --ink: #141414;           /* the button, the hairlines and the links in the line */
  --grey: #8f8b83;          /* the small links */
  --note: #8f8b83;          /* the note beside the link in the line */
  --accent: #e2432a;        /* the page you are on */
}

* {
  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: 'Roboto Flex Variable', 'Roboto Flex', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

a:focus,
button:focus {
  outline: none;
}

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

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 40px 16px;
}

/* ---------------------------------------------------------------- the frame */
/* --row: the height of a small row; --lens: the height of the reading line (and of a big row);
   --small and --big: the two sizes of the type */
.reader {
  --row: 42px;
  --lens: 104px;
  --small: 16px;
  --big: 66px;
  --gap: 34px;
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
}

/* ---------------------------------------------------------------- the button */
/* the script moves the button (to the middle of the frame while the menu is closed); its children move for the CSS */
.toggle {
  position: relative;
  z-index: 3;
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  margin: 0;
  padding: 0 4px 0 12px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* Menu and Close share one place; the word that is not shown waits below it, out of the mask */
.toggle__words {
  position: relative;
  display: grid;
  overflow: clip;
  height: 1.4em;
  line-height: 1.4em;
}

.toggle__word {
  grid-area: 1 / 1;
  display: block;
  text-align: right;
  font-variation-settings: 'wdth' 100, 'wght' 480;
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.5, 0.5, 1);
}

/* two hairlines, the reading line in small: they cross when the menu is open */
.toggle__icon {
  position: relative;
  width: 20px;
  height: 20px;
}

.toggle__line {
  position: absolute;
  left: 1px;
  right: 1px;
  top: 50%;
  height: 1.5px;
  margin-top: -0.75px;
}

.toggle__line b {
  position: absolute;
  inset: 0;
  border-radius: 1px;
  background: var(--ink);
  transition: transform 0.5s cubic-bezier(0.34, 1.6, 0.5, 1);
}

.toggle__line:first-child {
  transform: translateY(-3.5px);
}

.toggle__line:last-child {
  transform: translateY(3.5px);
}

/* under the pointer the word widens and the two lines open, like the reading line */
@media (hover: hover) {
  .toggle:hover .toggle__word {
    font-variation-settings: 'wdth' 122, 'wght' 620;
  }

  .toggle[aria-expanded='false']:hover .toggle__line:first-child b {
    transform: translateY(-1.5px);
  }

  .toggle[aria-expanded='false']:hover .toggle__line:last-child b {
    transform: translateY(1.5px);
  }
}

.toggle:active .toggle__word {
  font-variation-settings: 'wdth' 92, 'wght' 700;
  transition-duration: 0.12s;
}

.toggle:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------------------------------------------------------------- the menu */
.menu {
  position: relative;
  margin-top: var(--gap);
  padding: calc((var(--lens) - var(--row)) / 2) 0;
  visibility: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* the small links, the real ones: light and grey */
.row {
  display: flex;
  align-items: center;
  height: var(--row);
  color: var(--grey);
  font-size: var(--small);
  line-height: 1;
  white-space: nowrap;
  transition: color 0.35s ease;
  -webkit-touch-callout: none;
}

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

/* the mask lets the word rise into its row */
.row__mask {
  display: block;
  overflow: clip;
  padding: 0.2em 0;
}

.row__word {
  display: block;
  font-variation-settings: 'wdth' 100, 'wght' 340;
  letter-spacing: 0.005em;
}

/* ---------------------------------------------------------------- the reading line */
.strip,
.lens {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* the band hides the small rows behind the big ones; the script sets its top and height */
.strip__fill {
  position: absolute;
  top: 0;
  left: -2px;
  right: -2px;
  height: 1px;
  background: var(--page);
  transform-origin: 0 0;
}

/* the hairlines: the script moves the outer element, GSAP draws the inner one */
.strip__rule {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
}

.strip__rule i {
  position: absolute;
  inset: 0;
  background: var(--ink);
  transform-origin: 0 50%;
}

/* ---------------------------------------------------------------- the lens: the big copy */
.lens {
  z-index: 1;
}

.lens__row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: var(--lens);
  color: var(--ink);
  white-space: nowrap;
}

.lens__row.is-current {
  color: var(--accent);
}

.lens__word {
  display: block;
  font-size: var(--big);
  line-height: 1;
  letter-spacing: -0.02em;
  /* the capitals sit in the middle of the line, not the whole box */
  padding-top: 0.04em;
  transition: color 0.35s ease;
}

.lens__note {
  display: block;
  flex: none;
  color: var(--note);
  font-size: 13px;
  letter-spacing: 0.01em;
  font-variation-settings: 'wdth' 100, 'wght' 430;
}

/* the keys: a thin frame round the big word reached */
.lens__row.is-focus .lens__word {
  outline: 1px solid currentColor;
  outline-offset: 5px;
  border-radius: 3px;
}

/* ---------------------------------------------------------------- a phone */
@media (max-width: 560px) {
  .reader {
    --row: 40px;
    --lens: 84px;
    --small: 15px;
    --big: 47px;
    --gap: 26px;
  }

  .lens__note {
    font-size: 11px;
  }
}

@media (max-width: 400px) {
  .lens__note {
    display: none;
  }
}

/* moving less: the button and the words fade, nothing slides */
@media (prefers-reduced-motion: reduce) {
  .toggle__word,
  .toggle__line b {
    transition: none;
  }

  .toggle .toggle__line b {
    transform: none !important;
  }
}
