/* A vertical stack of films. The film in focus is a rounded card (poster on the left, details on the right); the film before
   and the film after it are low rounded bars with a camera icon and just the name. It changes by itself every few seconds;
   click a bar, use the arrows or the keys, or drag up / down to change it yourself. Behaviour: js/movie-wheel.js */
.movie-wheel {
  --pill-h: 46px;
  --card-h: 204px;
  --gap: 12px;
  position: relative;
  width: 460px;
  margin: 0 auto;
  color: var(--ink, #1c1b19);
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-x;
  outline: none;
  cursor: grab;
}

.movie-wheel.is-dragging {
  cursor: grabbing;
}

.movie-wheel__viewport {
  position: relative;
  height: calc(var(--pill-h) * 2 + var(--card-h) + var(--gap) * 2);
}

.movie-wheel__stage {
  position: absolute;
  inset: 0;
}

/* the soft colour wash behind the glass, the same as the one behind the music card */
.movie-wheel__viewport::before {
  content: "";
  position: absolute;
  inset: -10px -22px -12px -22px;
  border-radius: 40px;
  background: linear-gradient(120deg, rgba(255, 205, 180, 0.5) 0%, rgba(214, 200, 255, 0.5) 55%, rgba(185, 225, 245, 0.5) 100%);
  filter: blur(34px);
  opacity: 0.4;
  pointer-events: none;
}

.movie-wheel__ring {
  position: absolute;
  inset: 0;
}

/* every film is a box that changes shape with its place in the stack (data-pos: 0 = in focus, -1 above, 1 below) */
.movie-wheel__item {
  --top: 0px;
  --h: var(--pill-h);
  --side: 8%;
  --o: 0;
  --r: calc(var(--pill-h) / 2);
  position: absolute;
  top: var(--top);
  left: var(--side);
  right: var(--side);
  height: var(--h);
  margin: 0;
  overflow: hidden;
  border-radius: var(--r);
  /* glass, the same as the music card: a see-through white, the board and the glow blurred behind it, a soft shadow, no outline */
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.62) 0%, rgba(255, 255, 255, 0.28) 100%);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  backdrop-filter: blur(18px) saturate(170%);
  box-shadow: 0 8px 20px rgba(28, 27, 25, 0.07);
  opacity: var(--o);
  transition: top 0.6s cubic-bezier(0.3, 0.7, 0.2, 1), height 0.6s cubic-bezier(0.3, 0.7, 0.2, 1),
    left 0.6s cubic-bezier(0.3, 0.7, 0.2, 1), right 0.6s cubic-bezier(0.3, 0.7, 0.2, 1),
    border-radius 0.6s cubic-bezier(0.3, 0.7, 0.2, 1), opacity 0.45s ease, box-shadow 0.45s ease;
  cursor: inherit;
}

.movie-wheel__item.no-anim,
.movie-wheel__item.no-anim * {
  transition: none !important;
}

.movie-wheel__item[data-pos="0"] {
  --top: calc(var(--pill-h) + var(--gap));
  --h: var(--card-h);
  --side: 0%;
  --o: 1;
  --r: 20px;
  z-index: 3;
  box-shadow: 0 18px 40px rgba(28, 27, 25, 0.12), 0 2px 6px rgba(28, 27, 25, 0.05);
}

.movie-wheel__item[data-pos="-1"] {
  --top: 0px;
  --o: 1;
  z-index: 2;
}

.movie-wheel__item[data-pos="1"] {
  --top: calc(var(--pill-h) + var(--gap) + var(--card-h) + var(--gap));
  --o: 1;
  z-index: 2;
}

/* the ones further away wait just outside the stack, unseen */
.movie-wheel__item[data-pos="-2"],
.movie-wheel__item[data-pos="-3"] {
  --top: calc(var(--pill-h) * -1 - var(--gap));
  --o: 0;
  z-index: 1;
  pointer-events: none;
}

.movie-wheel__item[data-pos="2"],
.movie-wheel__item[data-pos="3"] {
  --top: calc(var(--pill-h) * 2 + var(--card-h) + var(--gap) * 2);
  --o: 0;
  z-index: 1;
  pointer-events: none;
}

/* ---- the low bar: camera icon + name ---- */
.movie-wheel__pill {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 8px;
  opacity: 1;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.movie-wheel__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(28, 27, 25, 0.07);
  color: #2c303a;
}

.movie-wheel__icon svg {
  width: 17px;
  height: 17px;
}

.movie-wheel__pill-title {
  flex: 1 1 auto;
  min-width: 0;
  padding-right: 38px; /* balances the icon so the name sits in the middle of the bar */
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  letter-spacing: -0.005em;
}

/* ---- the card in focus: poster + details ---- */
.movie-wheel__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.movie-wheel__item.is-active .movie-wheel__face {
  opacity: 1;
  transition-delay: 0.18s;
}

.movie-wheel__item.is-active .movie-wheel__pill {
  opacity: 0;
}

.movie-wheel__face img {
  display: block;
  flex: none;
  width: 128px;
  height: calc(100% - 24px);
  margin: 0 0 0 12px;
  border-radius: 14px;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

.movie-wheel__info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 0 20px 0 20px;
  text-align: left;
}

/* the spacing goes in steps: director/year and genre sit close together; the title is set apart; the quote closes the card */
.movie-wheel__meta-line {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.movie-wheel__genre {
  margin-top: 3px;
  font-style: normal;
  font-size: 0.86rem;
  line-height: 1.3;
  color: var(--muted, #6b6963);
}

.movie-wheel__name {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 9px;
  padding-bottom: 0.1em; /* room for the tails of g, y, p under the last line */
  font-size: 1.45rem;
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.movie-wheel__quote {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 8px;
  font-size: 0.86rem;
  font-style: italic;
  line-height: 1.4;
  color: var(--muted, #6b6963);
}

/* the details also live inside the card; this copy is only for screen readers */
.movie-wheel__caption {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  pointer-events: none;
}

.movie-wheel:focus-visible .movie-wheel__viewport {
  outline: 2px solid rgba(28, 27, 25, 0.35);
  outline-offset: 4px;
  border-radius: 12px;
}

/* placed on the home board, away from the first screen: found by dragging the board */
.movie-wheel--board {
  position: absolute;
  left: 2480px;
  top: 170px; /* scattered up in the top area, well above the first screen */
  z-index: 2;
}

.movie-wheel__heading {
  margin: 0 0 8px;
  text-align: center;
  font-family: var(--scribble, "Covered By Your Grace", "Segoe Script", "Bradley Hand", cursive);
  font-size: 2rem;
  line-height: 1;
  font-weight: 400;
  letter-spacing: 0;
  transform: rotate(-2deg);
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  /* the board hides the native cursor (it draws its own); over the stack a grab hand is used instead */
  body.home.has-figma-cursors .board-viewport .board .movie-wheel,
  body.home.has-figma-cursors .board-viewport .board .movie-wheel * {
    cursor: grab;
  }

  body.home.has-figma-cursors .board-viewport .board .movie-wheel.is-dragging,
  body.home.has-figma-cursors .board-viewport .board .movie-wheel.is-dragging * {
    cursor: grabbing;
  }
}

/* up / down arrows, at the right of the stack (the middle of the stack is 202px down: 40px heading + half of the stack) */
.movie-wheel__nav {
  position: absolute;
  right: -18px;
  z-index: 6;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(28, 27, 25, 0.12);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink, #1c1b19);
  box-shadow: 0 4px 12px rgba(28, 27, 25, 0.12);
  cursor: pointer;
  /* hidden until you are on the stack (pointer over it, or it has focus) */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.movie-wheel__nav--prev {
  top: 162px;
}

.movie-wheel__nav--next {
  top: 202px;
}

.movie-wheel__nav svg {
  width: 16px;
  height: 16px;
  transform: rotate(90deg); /* the arrows point up and down */
}

.movie-wheel:hover .movie-wheel__nav,
.movie-wheel:focus-visible .movie-wheel__nav,
.movie-wheel.is-dragging .movie-wheel__nav {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: none) {
  .movie-wheel:focus-within .movie-wheel__nav {
    opacity: 1;
    pointer-events: auto;
  }
}

.movie-wheel__nav:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(28, 27, 25, 0.18);
}

.movie-wheel__nav:active {
  transform: scale(0.95);
}

@media (hover: hover) and (pointer: fine) {
  body.home.has-figma-cursors .board-viewport .board .movie-wheel .movie-wheel__nav,
  body.home.has-figma-cursors .board-viewport .board .movie-wheel .movie-wheel__nav * {
    cursor: pointer;
  }
}

@media (prefers-reduced-motion: reduce) {
  .movie-wheel__item,
  .movie-wheel__pill,
  .movie-wheel__face,
  .movie-wheel__nav {
    transition: none;
  }
}
