/* Loading placeholders ("skeletons"): a grey block with a soft shine sliding across,
   shown while an image is still loading on a slow connection. Used with
   showWhenLoaded() in js/lib/images.js. */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--color-skeleton);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, var(--color-skeleton-shine) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: skeleton-shine 1.4s ease-in-out infinite;
}

@keyframes skeleton-shine {
  to {
    transform: translateX(100%);
  }
}

/* The image stays invisible until it has loaded, then fades in over the skeleton
   (and over a .screen-sketch, if there is one). */
.skeleton > img,
.skeleton > picture > img {
  position: relative;
  z-index: 1;
  opacity: 0;
  transition: opacity 500ms var(--ease-in-out);
}

.skeleton.is-loaded > img,
.skeleton.is-loaded > picture > img {
  opacity: 1;
}

.skeleton.is-loaded::after {
  content: none;
}

/* ---------- Screen sketch ---------- */

/* Grey shapes that hint at a screen while it loads: a menu bar, a picture area and a dock
   (js/lib/screen-sketch.js). Sizes are percentages, so it fits any placeholder size. */
.screen-sketch {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 7%;
  padding: 8%;
}

.screen-sketch-bar {
  display: flex;
  align-items: center;
  gap: 5%;
}

.screen-sketch-dot {
  width: 9%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--color-skeleton-shape);
}

.screen-sketch-line {
  width: 38%;
  height: 0.5em;
  min-height: 3px;
  border-radius: var(--radius-pill);
  background: var(--color-skeleton-shape);
}

.screen-sketch-line.is-short {
  width: 16%;
  margin-left: auto;
}

.screen-sketch-picture {
  display: grid;
  place-items: center;
  border-radius: 8%;
  background: var(--color-skeleton-shape);
}

.screen-sketch-picture svg {
  width: 26%;
  fill: var(--color-skeleton);
}

.screen-sketch-dock {
  display: flex;
  justify-content: center;
  gap: 5%;
  justify-self: center;
  width: 60%;
  padding: 3.5% 0;
  border-radius: var(--radius-pill);
  background: var(--color-skeleton-shape);
}

.screen-sketch-dock .screen-sketch-dot {
  width: 14%;
  background: var(--color-skeleton);
}

/* Once the wallpaper is in, the sketch is no longer needed. */
.skeleton.is-loaded .screen-sketch {
  display: none;
}
