:root {
  --bg: #0a0a09;               /* the night of the page */
  --ink: #f4f1ea;              /* the words, warm white */
  --mute: #6e6c66;             /* the next reference, in grey */
  --paper: #f3eee4;            /* the polaroid frame, a warm paper */
  --paper-edge: #dcd5c7;       /* the paper where it turns */
  --note: #9b9488;             /* the small pencil note on the frame */
  --glow: rgba(255, 214, 160, .09); /* the lamp behind the active card */
  --ring: rgba(244, 241, 234, .08); /* the thin dial of the wheel */
  --grain: .07;
  --shadow: .55;
  --pad: clamp(14px, 2.6vw, 36px);
  --big: clamp(19px, min(4.3vw, 6.2vh), 60px);
  --small: clamp(10px, min(1.05vw, 1.7vh), 13px);
  --card-w: 200px;
  --card-h: 256px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.defs { position: absolute; width: 0; height: 0; }

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  max-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 70% at 50% 46%, #141311 0%, rgba(10, 10, 9, 0) 62%),
    var(--bg);
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.stage.is-dragging { cursor: grabbing; }

/* the lamp behind the card on top */
.glow {
  position: absolute;
  left: 50%;
  top: var(--top-y, 42%);
  width: calc(var(--card-w) * 3.4);
  height: calc(var(--card-h) * 2.2);
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, var(--glow), rgba(0, 0, 0, 0));
  pointer-events: none;
}

/* the thin dial the cards ride on, with a tick for every slot */
.dial {
  position: absolute;
  left: 50%;
  top: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform;
}
.dial::before,
.dial::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
.dial::before { border: 1px solid var(--ring); }
.dial::after {
  inset: -9px;
  background: repeating-conic-gradient(from -.06deg, rgba(244, 241, 234, .2) 0 .12deg, rgba(0, 0, 0, 0) .12deg 18deg);
  -webkit-mask: radial-gradient(closest-side, rgba(0, 0, 0, 0) calc(100% - 7px), #000 calc(100% - 6px));
  mask: radial-gradient(closest-side, rgba(0, 0, 0, 0) calc(100% - 7px), #000 calc(100% - 6px));
}

.cards { position: absolute; inset: 0; z-index: 1; }

/* a card: the outer box is moved by the wheel, .lift answers the pointer, .body takes the one-pixel landing */
.card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--card-w);
  height: var(--card-h);
  opacity: 0;
  will-change: transform;
  backface-visibility: hidden;
}
.card__lift {
  position: absolute;
  inset: 0;
  transition: transform .5s cubic-bezier(.34, 1.56, .64, 1);
}
.card__shadow {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 10%;
  bottom: -6%;
  border-radius: 6px;
  background: rgba(0, 0, 0, var(--shadow));
  filter: blur(calc(var(--card-h) * .06));
  transform-origin: 50% 0;
  will-change: transform, opacity;
}
.card__body {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 18%),
    linear-gradient(0deg, rgba(120, 100, 70, .07), rgba(120, 100, 70, 0) 30%),
    var(--paper);
  box-shadow:
    0 0 0 .5px var(--paper-edge),
    0 1px 1px rgba(0, 0, 0, .25),
    0 4px 8px rgba(0, 0, 0, .22),
    0 14px 28px rgba(0, 0, 0, .28),
    0 30px 60px rgba(0, 0, 0, .3);
}
/* a faint tooth on the paper */
.card__body::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .4  0 0 0 0 .34  0 0 0 0 .25  0 0 0 .5 0'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
  opacity: .32;
  mix-blend-mode: multiply;
  pointer-events: none;
}
.card__photo {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 6.5%;
  bottom: 19%;
  overflow: hidden;
  background: #1a1916;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18);
}
.card__photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}
.card__img { filter: saturate(.9) contrast(1.04); }
.card__ghost {
  opacity: 0;
  mix-blend-mode: screen;
  will-change: transform, opacity;
}
/* the inner shade of a print, and a gloss that slides as the card turns */
.card__photo::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 calc(var(--card-h) * .08) rgba(0, 0, 0, .35), inset 0 1px 0 rgba(0, 0, 0, .3);
  pointer-events: none;
}
.card__gloss {
  position: absolute;
  top: -10%;
  bottom: -10%;
  left: -60%;
  width: 220%;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, .16) 47%, rgba(255, 255, 255, .05) 52%, rgba(255, 255, 255, 0) 60%);
  mix-blend-mode: screen;
  pointer-events: none;
  will-change: transform;
}
.card__note {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 6.5%;
  display: flex;
  justify-content: space-between;
  font-size: clamp(7px, calc(var(--card-h) * .036), 11px);
  letter-spacing: .02em;
  color: var(--note);
  white-space: nowrap;
}

@media (hover: hover) {
  .card:hover .card__lift { transform: translateY(-5px); }
  .stage.is-dragging .card:hover .card__lift { transform: none; }
}
.card:active .card__lift { transform: translateY(-1px) scale(.985); transition-duration: .15s; }

/* the words: white over black, black over the paper */
.top,
.words,
.foot {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  mix-blend-mode: difference;
  pointer-events: none;
  z-index: 2;
}

.top {
  top: var(--pad);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: var(--small);
  line-height: 1.25;
}
.brand { display: flex; flex-direction: column; }
.brand__name { font-weight: 640; letter-spacing: -.01em; font-size: 1.18em; }
.brand__line,
.count__n { color: #8e8b84; }
.count { display: flex; gap: 1.2em; }
.count__on { font-weight: 560; }

.words { top: 0; bottom: 0; }

.block {
  position: absolute;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 21% 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 2vw;
  font-size: var(--fit, var(--big));
  font-weight: 560;
  letter-spacing: -.035em;
  line-height: 1.08;
}
.block--now { top: var(--now-y, 17%); }
.block--next { top: var(--next-y, 70%); color: var(--mute); }

.line {
  position: relative;
  display: block;
  height: 1.3em;
  margin-bottom: -.2em;
  overflow: hidden;
  overflow: clip;
}
.line > span {
  position: absolute;
  left: 0;
  top: 0;
  line-height: 1.3;
  white-space: nowrap;
  will-change: transform;
}
.line--format { grid-column: 1; grid-row: 1; }
.line--author { grid-column: 2; grid-row: 1; }
.line--title { grid-column: 2; grid-row: 2; }
.line--year { grid-column: 3; grid-row: 1; min-width: 2.6em; }
.line--year > span { left: auto; right: 0; }

.foot {
  bottom: var(--pad);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--small);
}
.hint { color: #8e8b84; }

.arrows { display: flex; gap: 8px; pointer-events: auto; }
.arrow {
  position: relative;
  width: clamp(32px, min(3vw, 5vh), 42px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(244, 241, 234, .28);
  background: none;
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  transition: transform .45s cubic-bezier(.34, 1.56, .64, 1), border-color .3s;
}
.arrow::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ink);
  transform: scale(0);
  transition: transform .45s cubic-bezier(.34, 1.56, .64, 1);
}
.arrow svg {
  position: relative;
  width: 44%;
  height: 44%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .4s cubic-bezier(.34, 1.56, .64, 1), color .2s;
}
@media (hover: hover) {
  .arrow:hover { border-color: rgba(244, 241, 234, .7); }
  .arrow:hover::before { transform: scale(1); }
  .arrow:hover svg { color: var(--bg); }
  [data-prev]:hover svg { transform: translateX(-2px); }
  [data-next]:hover svg { transform: translateX(2px); }
}
.arrow:active { transform: scale(.92); transition-duration: .12s; }
.arrow:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }

.measure {
  position: absolute;
  left: -9999px;
  top: 0;
  white-space: nowrap;
  font-weight: 560;
  letter-spacing: -.035em;
  visibility: hidden;
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='160' height='160' filter='url(%23g)'/></svg>");
  mix-blend-mode: overlay;
  z-index: 5;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* narrow screens: the format and the year go small on the line above, the author and the title stay big */
@media (max-width: 640px) {
  .block {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
  }
  .line--format,
  .line--year { font-size: var(--small); letter-spacing: .01em; font-weight: 500; height: 1.6em; margin-bottom: .1em; }
  .line--format > span,
  .line--year > span { line-height: 1.6; }
  .line--format { grid-column: 1; grid-row: 1; }
  .line--year { grid-column: 2; grid-row: 1; min-width: 3em; }
  .line--author { grid-column: 1 / -1; grid-row: 2; }
  .line--title { grid-column: 1 / -1; grid-row: 3; }
  .count__on { display: none; }
}
