/* The Ferris wheel carousel: a steel wheel on a black page, its cabins painted each in its own colour with a little
   landscape in the window, the chosen one at the bottom, open over the boarding deck. */
:root {
  --page: #000000;          /* the page */
  --ink: #f6f0e6;           /* the words */
  --muted: #9b9488;         /* the smaller words */
  --steel: #d9d2c5;         /* the wheel, the legs and the hangers */
  --steel-deep: #6f695f;    /* the steel in the shade */
  --ring: #3a3731;          /* the arrows' ring */
  --wheel: 128px;           /* the wheel's radius, at most (less on a narrow screen) */
  --cab-w: 80px;            /* a cabin */
  --cab-h: 98px;
  --open-w: 128px;          /* the cabin chosen, open */
  --open-h: 158px;
  --hang: 16px;             /* from the pin to the cabin's roof */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

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

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 32px 16px;
  overflow: hidden;
}

.ride {
  width: min(720px, 100%);
  min-width: 0;
}

.ride__title {
  margin: 0;
  text-align: center;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 28px;
  font-weight: 600;
  font-variation-settings: 'opsz' 72, 'SOFT' 50;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------- the wheel */
.ride__view {
  position: relative;
  height: 456px;            /* worked out by the script from the wheel and the cabins */
  margin-top: 14px;
  border-radius: 22px;
  outline: none;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

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


.ride__wheel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ride__cabins {
  position: absolute;
  inset: 0;
}

/* ---------------------------------------------------------------- a cabin
   The element sits on its pin and turns round it: the script moves it and swings it. Inside, the hanger and the
   cabin, which opens with --f (0 closed, 1 open). */
.cab {
  --f: 0;
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
  cursor: pointer;
}

.cab__pin {
  position: absolute;
  left: -5px;
  top: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--page);
  box-shadow: inset 0 0 0 2.5px var(--steel);
}

.cab__rod {
  position: absolute;
  left: -1px;
  top: 3px;
  width: 2px;
  height: calc(var(--hang) - 6px);
  border-radius: 1px;
  background: linear-gradient(90deg, var(--steel), var(--steel-deep));
}

.card {
  --w: calc(var(--cab-w) + (var(--open-w) - var(--cab-w)) * var(--f));
  --h: calc(var(--cab-h) + (var(--open-h) - var(--cab-h)) * var(--f));
  --pad: calc(6px + 2px * var(--f));
  position: absolute;
  left: calc(var(--w) / -2);
  top: var(--hang);
  display: flex;
  flex-direction: column;
  width: var(--w);
  height: var(--h);
  padding: var(--pad);
  border-radius: calc(12px + 4px * var(--f));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg, var(--tone) 0%, var(--tone) 55%, var(--tone-deep) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    inset 0 -10px 18px -12px rgba(0, 0, 0, 0.5);
  transition: filter 0.25s;
}

/* the canopy over the cabin, where the hanger holds it */
.card::before {
  content: '';
  position: absolute;
  left: 22%;
  right: 22%;
  top: -6px;
  height: 9px;
  border-radius: 9px 9px 2px 2px;
  background: linear-gradient(180deg, var(--steel), var(--steel-deep));
}

.card__win {
  position: relative;
  flex: none;
  height: calc(var(--h) * (0.52 - 0.05 * var(--f)));
  overflow: hidden;
  border-radius: calc(7px + 3px * var(--f));
  background: #111;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14);
}

.card__win svg {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* the glass: a dark rim inside and a streak of light across it */
.card__win::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(118deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0.2) 44%, rgba(255, 255, 255, 0) 52%, rgba(255, 255, 255, 0) 60%, rgba(255, 255, 255, 0.1) 63%, rgba(255, 255, 255, 0) 68%);
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.28), inset 0 6px 10px -6px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.card__name {
  margin: calc(6px + 2px * var(--f)) 0 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: calc(11.5px + 3.5px * var(--f));
  font-weight: 600;
  font-variation-settings: 'opsz' 24, 'SOFT' 50;
  line-height: 1.12;
  letter-spacing: -0.005em;
  hyphens: none;
}

/* the dates and the price, under the name, as the cabin opens */
.card__more {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  bottom: calc(var(--pad) + 1px);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  opacity: calc(var(--f) * 2.6 - 1.6);
  transform: translateY(calc((1 - var(--f)) * 8px));
}

.card__date {
  color: rgba(246, 240, 230, 0.78);
  font-weight: 500;
}

.card__price {
  font-variant-numeric: tabular-nums;
}

/* the cabin under the mouse: the cabin brightens and the view in its window comes closer */
@media (hover: hover) {
  .ride__view:not(.is-held) .cab:hover .card {
    filter: brightness(1.12) saturate(1.05);
  }

  .ride__view:not(.is-held) .cab:hover .card__win svg {
    transform: scale(1.08);
  }
}

/* the cabin chosen, with the keys on the wheel: a ring round it */
.ride__view:focus-visible .cab.is-at .card {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

html[data-using='pointer'] .ride__view:focus-visible .cab.is-at .card {
  outline: none;
}

/* ---------------------------------------------------------------- the arrows, on the deck beside the legs */
.turn {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--page);
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ring);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
  -webkit-tap-highlight-color: transparent;
}

.turn svg {
  width: 22px;
  height: 22px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.45s cubic-bezier(0.34, 1.7, 0.5, 1);
}

@media (hover: hover) {
  .turn:hover {
    background: var(--ink);
    color: var(--page);
    box-shadow: inset 0 0 0 1.5px var(--ink);
  }

  .turn--next:hover svg {
    transform: rotate(22deg);
  }

  .turn--prev:hover svg {
    transform: rotate(-22deg);
  }
}

.turn:active {
  transform: scale(0.9);
}

.turn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

html[data-using='pointer'] .turn:focus-visible {
  outline: none;
}

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

@media (max-width: 560px) {
  :root {
    --cab-w: 64px;
    --cab-h: 84px;
    --open-w: 106px;
    --open-h: 140px;
    --hang: 14px;
  }

  .stage {
    padding: 24px 16px;
  }

  .ride__title {
    font-size: 24px;
  }

  .ride__view {
    height: 420px;
    margin-top: 10px;
  }

  .card__name {
    font-size: calc(10.5px + 2.5px * var(--f));
  }

  .card__more {
    font-size: 10.5px;
  }

  .turn {
    width: 42px;
    height: 42px;
    margin: -21px 0 0 -21px;
  }
}
