/* The swatch fan menu: a deck of paint card strips on a white page, held at the bottom by a brass rivet. Every strip
   turns round the rivet; the script sets each one's angle and how far it slides out along itself, and the size of
   the whole deck (--u, the length of one unit of the drawing). */
:root {
  --page: #ffffff;          /* the page */
  --card: #fbf9f4;          /* the card the strips are printed on */
  --ink: #1f1c18;           /* the names of the sections */
  --cover: #24211d;         /* the cover of the deck */
  --cover-ink: #f3ece0;     /* the words on the cover */
  --cover-muted: #a39a8b;
  --brass: #d2a446;         /* the rivet */
  --focus: #1f1c18;         /* the ring of the keyboard focus */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

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

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

ul {
  margin: 0;
  padding: 0;
  list-style: 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: 48px 16px;
}

/* ---------------------------------------------------------------- the deck */
.fan {
  --u: 1px;                 /* set by the script */
  position: relative;
  width: calc(var(--u) * 424);
  height: calc(var(--u) * 392);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.fan.is-held {
  cursor: grabbing;
}

/* every strip stands on the rivet; its own transform (from the script) turns it round the rivet */
.strip {
  position: absolute;
  left: calc(50% - var(--u) * 38);
  bottom: calc(var(--u) * 32);
  display: block;
  width: calc(var(--u) * 76);
  height: calc(var(--u) * 300);
  padding: 0;
  border: 0;
  border-radius: calc(var(--u) * 7);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: left;
  transform-origin: 50% calc(100% - var(--u) * 16);
  box-shadow:
    0 0 0 0.5px rgba(40, 30, 20, 0.14),
    0 1px 1px rgba(40, 30, 20, 0.08),
    0 calc(var(--u) * 6) calc(var(--u) * 14) calc(var(--u) * -6) rgba(40, 30, 20, 0.28);
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-drag: none;
  will-change: transform;
}

/* the grain of the card, over the paper and the printed colours alike */
.strip::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .2 0 0 0 0 .15 0 0 0 0 .1 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* a strip lifted out of the fan casts a longer shadow */
.strip.is-up {
  box-shadow:
    0 0 0 0.5px rgba(40, 30, 20, 0.14),
    0 2px 3px rgba(40, 30, 20, 0.1),
    0 calc(var(--u) * 14) calc(var(--u) * 26) calc(var(--u) * -8) rgba(40, 30, 20, 0.34);
}

.strip:focus-visible {
  box-shadow:
    0 0 0 2px var(--page),
    0 0 0 4px var(--focus),
    0 calc(var(--u) * 14) calc(var(--u) * 26) calc(var(--u) * -8) rgba(40, 30, 20, 0.34);
}

/* the printed colours: a deep one with its name, then two lighter mixes of it towards the card */
.strip__chips {
  position: absolute;
  left: calc(var(--u) * 6);
  right: calc(var(--u) * 6);
  top: calc(var(--u) * 6);
  display: grid;
  grid-template-rows: calc(var(--u) * 64) calc(var(--u) * 33) calc(var(--u) * 33);
  gap: calc(var(--u) * 3);
}

.chip {
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: calc(var(--u) * 5) calc(var(--u) * 6);
  border-radius: calc(var(--u) * 3);
  background: var(--c);
}

/* the deep colour's name sits at its top, so it shows when the strip peeks out of the closed deck */
.chip--deep {
  align-items: flex-start;
  border-radius: calc(var(--u) * 4) calc(var(--u) * 4) calc(var(--u) * 3) calc(var(--u) * 3);
}

.chip--mid {
  background: color-mix(in oklab, var(--c) 58%, #ffffff);
}

.chip--pale {
  background: color-mix(in oklab, var(--c) 26%, var(--card));
}

.chip__name {
  font-family: 'Fraunces Variable', Georgia, serif;
  font-style: italic;
  font-size: calc(var(--u) * 11);
  font-weight: 420;
  line-height: 1.1;
  color: color-mix(in oklab, var(--c) 40%, #000000);
}

.chip--deep .chip__name {
  color: rgba(255, 255, 255, 0.93);
  font-size: calc(var(--u) * 12);
}

/* the name of the section, printed up the left edge of the strip, read from the rivet outwards: in the open fan each
   strip lies on the one to its left, so its left edge is the part that always shows */
.strip__label {
  position: absolute;
  left: calc(var(--u) * 7);
  bottom: calc(var(--u) * 62);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: calc(var(--u) * 12.5);
  line-height: 1;
  font-weight: 640;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* the section you are in is printed in its own colour */
.strip[aria-current='page'] .strip__label {
  color: color-mix(in oklab, var(--c) 85%, #000000);
}

/* ---------------------------------------------------------------- the cover: the menu button */
.strip--cover {
  background: var(--cover);
  color: var(--cover-ink);
}

.cover__word {
  position: absolute;
  left: calc(var(--u) * 10);
  top: calc(var(--u) * 14);
  font-size: calc(var(--u) * 17);
  font-weight: 640;
  letter-spacing: -0.01em;
}

.cover__now {
  position: absolute;
  left: calc(var(--u) * 10);
  top: calc(var(--u) * 38);
  max-width: calc(var(--u) * 58);
  overflow: hidden;
  color: var(--cover-muted);
  font-family: 'Fraunces Variable', Georgia, serif;
  font-style: italic;
  font-size: calc(var(--u) * 12);
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* the five colours of the deck, as thin printed bars */
.cover__bars {
  position: absolute;
  left: calc(var(--u) * 10);
  right: calc(var(--u) * 10);
  top: calc(var(--u) * 70);
  display: grid;
  gap: calc(var(--u) * 3);
}

.cover__bars span {
  display: block;
  height: calc(var(--u) * 5);
  border-radius: 1px;
  background: var(--c);
}

.cover__spine {
  position: absolute;
  left: 50%;
  bottom: calc(var(--u) * 34);
  writing-mode: vertical-rl;
  transform: translateX(-50%) rotate(180deg);
  color: var(--cover-muted);
  font-size: calc(var(--u) * 11);
  font-weight: 560;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the rivet */
.fan__rivet {
  position: absolute;
  left: calc(50% - var(--u) * 9);
  bottom: calc(var(--u) * 39);
  width: calc(var(--u) * 18);
  height: calc(var(--u) * 18);
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 30%, #fff6d8 0 8%, transparent 32%),
    radial-gradient(circle at 50% 50%, var(--brass) 0 52%, color-mix(in oklab, var(--brass) 55%, #000000) 74%, color-mix(in oklab, var(--brass) 70%, #ffffff) 86%, color-mix(in oklab, var(--brass) 45%, #000000) 100%);
  box-shadow:
    0 1px 1.5px rgba(40, 25, 5, 0.5),
    0 calc(var(--u) * 3) calc(var(--u) * 6) rgba(40, 25, 5, 0.25);
  pointer-events: none;
  z-index: 40;
}
