/* The venetian blind menu: a plain blind of ivory slats over the menu. Opening the menu, the slats turn in 3D one
   after the other and the menu shows through behind them; the words sit exactly between the slats. */
:root {
  --page: #000000;          /* the page */
  --wall: #f7f2e9;          /* the button's word, and the ring round its focus */
  --ink: #2b1b17;           /* the button */
  --room: #0f4643;          /* the menu behind the blind */
  --room-ink: #f8dccd;      /* the menu's words */
  --accent: #ff9b63;        /* a word pointed at */
  --slat: #efe5d6;          /* the slats */
  --slat-shade: #2d5652;    /* the shadow on a slat turned away from the light */
  --pitch: 68px;            /* set by the script: the height of a slat */
}

* {
  box-sizing: border-box;
}

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

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

a {
  color: inherit;
  text-decoration: none;
}

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

.page {
  position: relative;
  height: 100svh;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the top: the button, over everything */
.top {
  position: absolute;
  inset: 0 0 auto;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: calc(var(--pitch) * 1.5);
  padding: 0 clamp(16px, 4vw, 56px);
  pointer-events: none;
}

.top > * {
  pointer-events: auto;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 16px 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--wall);
  font: 600 15px/1 'Hanken Grotesk Variable', system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 8px 22px -10px rgba(43, 27, 23, 0.6);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.5s ease, color 0.5s ease, transform 0.2s ease;
}

.page.is-dark .toggle {
  background: var(--room-ink);
  color: var(--room);
}

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

.toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--wall);
}

.toggle__words {
  position: relative;
  display: grid;
  overflow: hidden;
  height: 1.2em;
  line-height: 1.2;
}

.toggle__word {
  grid-area: 1 / 1;
}

/* the icon: a little blind of three slats, which turn with the big one */
.toggle__icon {
  display: grid;
  gap: 3px;
  width: 18px;
  perspective: 60px;
}

.toggle__icon i {
  display: block;
  height: 2.5px;
  border-radius: 2px;
  background: currentColor;
}

/* ---------------------------------------------------------------- the menu, behind the blind */
/* every link sits in one gap between two slats: the script spreads them over the whole height of the blind and gives
   each its gap in --row (the gap below slat --row minus one) */
.menu {
  position: absolute;
  inset: 0;
  z-index: 1;
  --edge: clamp(28px, 9vw, 140px);
  background: var(--room);
  color: var(--room-ink);
}

.menu__links {
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu__link {
  position: absolute;
  left: var(--edge);
  top: calc(var(--row, 3) * var(--pitch) - var(--pitch) / 2);
  display: flex;
  align-items: baseline;
  gap: 22px;
  height: var(--pitch);
  padding-top: calc(var(--pitch) * 0.08);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.menu__word {
  font-family: 'Bodoni Moda Variable', Georgia, serif;
  font-size: calc(var(--pitch) * 0.7);
  font-weight: 460;
  line-height: 1;
  letter-spacing: -0.015em;
  white-space: nowrap;
  transition: color 0.3s ease, transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.menu__note {
  color: color-mix(in srgb, var(--room-ink) 62%, transparent);
  font-size: 14px;
  white-space: nowrap;
  transition: color 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
  .menu__link:hover .menu__word {
    color: var(--accent);
    transform: translateX(10px);
  }

  .menu__link:hover .menu__note {
    color: var(--room-ink);
  }
}

.menu__link:active .menu__word {
  color: var(--accent);
}

.menu__link:focus-visible .menu__word {
  color: var(--accent);
  transform: translateX(10px);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 8px;
}

/* ---------------------------------------------------------------- the blind */
.blind {
  position: absolute;
  inset: 0;
  z-index: 2;
  /* a far viewpoint in the middle: near it the slats turn without leaning over the gaps, so no word gets cut */
  perspective: 2800px;
  perspective-origin: 50% 50%;
  touch-action: none;
}

.page.is-open .blind {
  pointer-events: none;
}

.slat {
  position: absolute;
  left: 0;
  right: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.slat__face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* a thin dark line and a soft light make each slat round */
.slat__face--front::after,
.slat__face--back::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0, rgba(255, 255, 255, 0) 30%, rgba(0, 0, 0, 0) 70%, rgba(60, 30, 20, 0.16) 96%, rgba(60, 30, 20, 0.36) 100%);
  pointer-events: none;
}

/* both faces are the bare slat: a band of ivory, lighter at the top, with its line of light */
.slat__face--front,
.slat__face--back {
  background: linear-gradient(180deg, color-mix(in srgb, var(--slat) 70%, #fff) 0%, var(--slat) 38%, color-mix(in srgb, var(--slat) 84%, #6b5446) 100%);
}

.slat__face--back {
  transform: rotateX(180deg);
}

/* the light on each face, set by the script from the slat's angle */
.slat__shade {
  position: absolute;
  inset: 0;
  background: var(--slat-shade);
  opacity: 0;
  pointer-events: none;
}

/* the line of light along the top edge of the slat */
.slat__face--front::before,
.slat__face--back::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: 1.5px;
  background: rgba(255, 252, 245, 0.7);
  pointer-events: none;
}

/* the ladder cords: a twisted string in front of the slats, with its soft shadow on them */
.blind__cord {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--at);
  z-index: 3;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background:
    repeating-linear-gradient(160deg, rgba(120, 96, 78, 0.35) 0 2px, transparent 2px 5px),
    linear-gradient(90deg, #d9cfc0, #fbf6ee 45%, #cfc4b4);
  box-shadow: 2px 1px 3px rgba(43, 27, 23, 0.28);
  pointer-events: none;
}

/* ---------------------------------------------------------------- phone */
@media (max-width: 720px) {
  .menu {
    --edge: 28px;
  }

  .menu__note {
    display: none;
  }

  .menu__word {
    font-size: min(var(--pitch) * 0.7, 13vw);
  }
}
