/* The napkin menu: the menu of a trattoria, alone on a white page. The napkin is a cloth simulated point by point
   and drawn on a canvas behind the links; the links are real links laid on the linen, and the script bends them
   with it. On a real site put .table in the corner of the header, with room below it for the napkin. */
:root {
  --page: #ffffff;          /* the page */
  --rail: #2b2420;          /* the button, and the rail it becomes */
  --rail-text: #f6f1e7;     /* the words on the button */
  --linen: #f7f2e8;         /* the linen where the light falls on it */
  --linen-shadow: #c9bca6;  /* the linen in the deepest fold */
  --linen-back: #e6dccb;    /* the back of the linen, seen when a fold turns over */
  --stripe: #b4472c;        /* the two red threads woven along the hem */
  --text: #2b2420;          /* the links */
  --chosen: #b4472c;        /* the page you are on, and the link under the pointer */
}

* {
  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(--text);
  font-family: 'Fraunces Variable', 'Fraunces', Georgia, 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: 24px 16px;
}

/* ---------------------------------------------------------------- the frame */
/* the room the napkin hangs in: the canvas covers it, and the button moves inside it */
.table {
  position: relative;
  width: min(340px, 100%);
  height: 480px;
}

.cloth {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the button */
/* the script moves it (in the middle while closed, at the top while open) and stretches it into the rail */
.rail {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 50px;
  margin: 0;
  padding: 0 20px 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--rail);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 45%, rgba(0, 0, 0, 0.28));
  color: var(--rail-text);
  font: inherit;
  font-size: 17px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14) inset, 0 -1px 0 rgba(0, 0, 0, 0.3) inset, 0 8px 16px -10px rgba(43, 36, 32, 0.7);
}

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

.rail__word {
  grid-area: 1 / 1;
  font-variation-settings: 'opsz' 24, 'wght' 460, 'SOFT' 50;
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.6, 0.5, 1);
}

.rail__pleat {
  width: 26px;
  height: 14px;
  flex: none;
  overflow: visible;
}

.rail__pleat polyline {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) and (pointer: fine) {
  .rail:hover .rail__word {
    font-variation-settings: 'opsz' 24, 'wght' 640, 'SOFT' 100;
  }
}

.rail:focus-visible {
  outline: 2px solid var(--chosen);
  outline-offset: 4px;
}

.rail:active .rail__words {
  transform: translateY(1px);
}

/* ---------------------------------------------------------------- the links on the linen */
/* the script lays every link on the cloth with a matrix: where it is, how it turns, how a fold squeezes it */
.napkin {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  visibility: hidden;
}

.napkin.is-open {
  visibility: visible;
}

.napkin__list {
  display: contents;
}

.dish {
  --tone: var(--text);
  --shade: 1;
  position: absolute;
  left: 0;
  top: 0;
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 29px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 72, 'wght' 380, 'SOFT' 30, 'WONK' 0;
  color: color-mix(in srgb, var(--tone) calc(var(--shade) * 100%), #000);
  transform-origin: 0 0;
  pointer-events: auto;
  cursor: pointer;
  transition: font-variation-settings 0.45s cubic-bezier(0.34, 1.6, 0.5, 1);
  will-change: transform;
}

.dish[aria-current='page'] {
  --tone: var(--chosen);
  font-style: italic;
  font-variation-settings: 'opsz' 72, 'wght' 420, 'SOFT' 100, 'WONK' 1;
}

.dish.is-here {
  --tone: var(--chosen);
  font-variation-settings: 'opsz' 72, 'wght' 600, 'SOFT' 100, 'WONK' 0;
}

.dish[aria-current='page'].is-here {
  font-variation-settings: 'opsz' 72, 'wght' 620, 'SOFT' 100, 'WONK' 1;
}

/* the focus from the keyboard: a running stitch around the link */
.dish:focus-visible {
  outline: 1.5px dashed var(--chosen);
  outline-offset: 2px;
}

@media (max-width: 420px) {
  .table {
    height: 460px;
  }

  .dish {
    font-size: 27px;
  }
}
