.rest-transition {
  --rest-scene-image: none;
  background: #090c13;
}

.rest-transition::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(circle at 50% 48%, transparent 0 22%, rgba(4, 7, 12, .18) 62%, rgba(3, 5, 10, .72) 100%),
    linear-gradient(180deg, rgba(5, 8, 15, .08), rgba(5, 8, 15, .38));
  content: '';
  pointer-events: none;
}

.rest-transition::after {
  position: absolute;
  inset: -20%;
  z-index: 2;
  content: '';
  opacity: 0;
  pointer-events: none;
}

.rest-transition-sky,
.rest-transition.is-short .rest-transition-sky,
.rest-transition.is-long .rest-transition-sky {
  inset: -5%;
  z-index: 0;
  background: var(--rest-scene-image) center / cover no-repeat;
  filter: brightness(.78) saturate(1.06);
  animation: rest-scene-camera var(--rest-duration) cubic-bezier(.2, .65, .25, 1) both;
}

.rest-transition.is-short .rest-transition-sky { filter: brightness(.82) saturate(1.08); }
.rest-transition.is-long .rest-transition-sky { filter: brightness(.68) saturate(1.03); }

.rest-transition.rest-effect-embers::after,
.rest-transition.rest-effect-firelight::after,
.rest-transition.rest-effect-torchlight::after {
  background:
    radial-gradient(circle at 24% 76%, rgba(255, 205, 104, .8) 0 1px, transparent 2px),
    radial-gradient(circle at 31% 68%, rgba(255, 148, 61, .72) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 72% 78%, rgba(255, 221, 142, .6) 0 1px, transparent 2px),
    radial-gradient(circle at 78% 64%, rgba(255, 126, 49, .58) 0 1px, transparent 2px);
  background-size: 128px 146px, 174px 188px, 214px 176px, 156px 202px;
  opacity: .62;
  animation: rest-scene-embers var(--rest-duration) ease-out both;
}

.rest-transition.rest-effect-firelight::before,
.rest-transition.rest-effect-torchlight::before {
  background:
    radial-gradient(circle at 76% 62%, rgba(255, 151, 49, .21), transparent 34%),
    radial-gradient(circle at 50% 48%, transparent 0 22%, rgba(4, 7, 12, .2) 65%, rgba(3, 5, 10, .7) 100%);
  animation: rest-scene-firelight 900ms ease-in-out infinite alternate;
}

.rest-transition.rest-effect-stars::after {
  background-image:
    radial-gradient(circle, rgba(255,255,255,.92) 0 1px, transparent 1.8px),
    radial-gradient(circle, rgba(190,216,255,.84) 0 1px, transparent 1.6px);
  background-position: 0 0, 41px 53px;
  background-size: 92px 86px, 137px 121px;
  opacity: .3;
  animation: rest-scene-stars var(--rest-duration) ease-in-out both;
}

.rest-transition.rest-effect-rain::after {
  background-image: repeating-linear-gradient(105deg, transparent 0 16px, rgba(190, 220, 255, .24) 17px 18px, transparent 19px 34px);
  opacity: .25;
  transform: translate3d(-8%, -12%, 0);
  animation: rest-scene-rain 780ms linear infinite;
}

.rest-transition.rest-effect-snow::after {
  background-image:
    radial-gradient(circle, rgba(255,255,255,.78) 0 1.5px, transparent 2px),
    radial-gradient(circle, rgba(225,238,255,.62) 0 2px, transparent 2.6px);
  background-position: 0 0, 52px 39px;
  background-size: 96px 92px, 143px 132px;
  opacity: .42;
  animation: rest-scene-snow 1500ms linear infinite;
}

.rest-transition-card {
  position: relative;
  z-index: 3;
  background: linear-gradient(145deg, rgba(13, 17, 27, .74), rgba(19, 23, 34, .52));
  box-shadow: 0 24px 76px rgba(0, 0, 0, .52), inset 0 1px rgba(255, 255, 255, .1);
}

@keyframes rest-scene-camera {
  0% { opacity: 0; transform: translate3d(-1.3%, .7%, 0) scale(1.03); }
  14% { opacity: 1; }
  78% { opacity: 1; }
  100% { opacity: .35; transform: translate3d(1.3%, -.9%, 0) scale(1.09); }
}

@keyframes rest-scene-embers {
  0% { opacity: 0; transform: translate3d(0, 10%, 0) scale(.96); }
  18%, 70% { opacity: .62; }
  100% { opacity: 0; transform: translate3d(1.5%, -12%, 0) scale(1.05); }
}

@keyframes rest-scene-firelight {
  from { opacity: .76; filter: brightness(.94); }
  to { opacity: 1; filter: brightness(1.08); }
}

@keyframes rest-scene-stars {
  0%, 100% { opacity: .08; transform: scale(1); }
  45%, 72% { opacity: .34; transform: scale(1.025); }
}

@keyframes rest-scene-rain {
  from { transform: translate3d(-8%, -12%, 0); }
  to { transform: translate3d(2%, 10%, 0); }
}

@keyframes rest-scene-snow {
  from { transform: translate3d(-2%, -10%, 0); }
  to { transform: translate3d(3%, 11%, 0); }
}

@media (max-width: 700px) {
  .rest-transition-sky,
  .rest-transition.is-short .rest-transition-sky,
  .rest-transition.is-long .rest-transition-sky { inset: -8%; }
  .rest-transition-card { min-width: min(290px, calc(100vw - 34px)); padding: 21px 24px 19px; }
}

@media (prefers-reduced-motion: reduce) {
  .rest-transition::before,
  .rest-transition::after,
  .rest-transition-sky { animation: none !important; }
  .rest-transition-sky { opacity: 1; transform: none; }
}
