/* The wallpaper picker to fling with inertia. A frosted sheet on a near black page; the two lights behind it take the
   colours of the wallpaper in the middle (--tint-a, --tint-b, written by the script). Each preview (.wp) is moved only
   by the script, one transform per frame; its card (.wp__card) is styled and lifted only by the CSS, and the picture
   inside it (.wp__pic) slides on its own transform. The rim of the sheet catches a light that follows the pointer. */
:root {
  --page: #07070a;            /* the page */
  --sheet: rgba(20, 20, 25, 0.82); /* the frosted sheet */
  --edge: rgba(255, 255, 255, 0.085); /* the edge at rest */
  --ink: #f3f2f6;             /* the words */
  --muted: #8a8996;           /* the small words */
  --button: #f4f3f7;          /* the Set wallpaper button */
  --button-ink: #0b0b0e;      /* the words on the button */
  --done: #b9f1d6;            /* applied */
  --tint-a: 126, 92, 255;     /* first light behind the sheet (from the wallpaper) */
  --tint-b: 40, 196, 214;     /* second light behind the sheet (from the wallpaper) */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

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

/* the two lights that take the colours of the wallpaper in the middle */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(55vmax 38vmax at 22% 18%, rgba(var(--tint-a), 0.2), transparent 70%),
    radial-gradient(50vmax 36vmax at 82% 88%, rgba(var(--tint-b), 0.16), transparent 70%);
}

/* a little grain over everything */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

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

.stage {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.sheet {
  --mx: 30%;
  --my: 0%;
  position: relative;
  width: min(92vw, 392px);
  padding: clamp(12px, 3.2vh, 18px) clamp(12px, 4vw, 16px) clamp(12px, 3vh, 16px);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0) 38%),
    var(--sheet);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 12px 30px -10px rgba(0, 0, 0, 0.6),
    0 50px 90px -40px rgba(0, 0, 0, 0.9);
  opacity: 0;
}

/* the rim catches a light where the pointer is: a radial gradient masked down to the 1px border */
.sheet__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: radial-gradient(180px 140px at var(--mx) var(--my), rgba(var(--tint-a), 1), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0.8;
}

.sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.sheet__title {
  margin: 0;
  font-size: 16px;
  font-weight: 620;
  font-variation-settings: 'wdth' 106;
  letter-spacing: 0.005em;
}

.sheet__sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.sheet__count {
  margin: 1px 0 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 560;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.count__now {
  display: inline-block;
  min-width: 0.65em;
  text-align: right;
}

.sheet__of {
  color: var(--muted);
  font-weight: 450;
}

/* the row of previews */
.track {
  position: relative;
  height: clamp(150px, 44vh, 300px);
  margin: clamp(10px, 2.6vh, 16px) calc(-1 * clamp(12px, 4vw, 16px)) 0;
  touch-action: none;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  -webkit-mask: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  mask: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}

.track.is-grabbing {
  cursor: grabbing;
}

.track:focus-visible {
  outline: none;
}

/* a soft pool of light the middle preview stands on */
.track__floor {
  position: absolute;
  left: 50%;
  bottom: 2%;
  width: 52%;
  height: 22%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(var(--tint-a), 0.28), transparent);
  filter: blur(8px);
  pointer-events: none;
}

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

.wp {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--cw, 140px);
  height: var(--ch, 250px);
  margin: calc(var(--ch, 250px) / -2) 0 0 calc(var(--cw, 140px) / -2);
  will-change: transform;
}

/* the soft shadow under each preview: stretched by the script with the speed */
.wp__shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -7%;
  height: 12%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.75), transparent);
  filter: blur(6px);
  pointer-events: none;
}

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

.wp__card {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--cw, 140px) * 0.15);
  overflow: hidden;
  background: #111;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 1px 1px rgba(0, 0, 0, 0.4),
    0 10px 24px -10px rgba(0, 0, 0, 0.8),
    0 30px 50px -28px rgba(0, 0, 0, 0.9);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
  transform: translateZ(0);
}

@media (hover: hover) {
  .wp:not(.is-focus):hover .wp__card {
    transform: translateY(-4px);
  }
}

.wp.is-press .wp__card {
  transform: scale(0.97);
  transition-duration: 0.18s;
}

/* the picture is wider than its frame: the script slides it like a view through a window */
.wp__pic {
  position: absolute;
  top: 0;
  left: -18%;
  width: 136%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* the previews away from the middle sink into the dark */
.wp__dim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: #050507;
  opacity: calc(0.55 - 0.55 * var(--f, 0));
}

/* the glass: a top sheen, and a light streak the script moves with the lean (--g) */
.wp__gloss {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(105deg, transparent calc(var(--g, 50%) - 22%), rgba(255, 255, 255, 0.16) var(--g, 50%), transparent calc(var(--g, 50%) + 18%)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 22%, transparent 70%, rgba(0, 0, 0, 0.28));
  mix-blend-mode: soft-light;
}

/* the inner bezel that catches the light on the top edge */
.wp__card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

/* the lock screen drawn on top of the wallpaper */
.wp__lock {
  position: absolute;
  left: 0;
  right: 0;
  top: 9%;
  display: grid;
  justify-items: center;
  gap: 0.1em;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

.wp__date {
  font-size: calc(var(--cw, 140px) * 0.068);
  font-weight: 560;
  letter-spacing: 0.02em;
  opacity: 0.85;
  white-space: nowrap;
}

.wp__time {
  font-size: calc(var(--cw, 140px) * 0.3);
  line-height: 1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'wdth' calc(78 + 34 * var(--f, 0)), 'wght' calc(320 + 260 * var(--f, 0));
  white-space: nowrap;
}

/* the home bar of the preview */
.wp__bar {
  position: absolute;
  left: 34%;
  right: 34%;
  bottom: 4.5%;
  height: max(2px, calc(var(--cw, 140px) * 0.018));
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.75);
  pointer-events: none;
}

/* the chip on the wallpaper that is in use */
.wp__badge {
  position: absolute;
  left: 50%;
  bottom: 12%;
  display: flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.42em 0.8em 0.42em 0.62em;
  border-radius: 999px;
  font-size: max(9px, calc(var(--cw, 140px) * 0.07));
  font-weight: 600;
  white-space: nowrap;
  color: #0c0c0f;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
}

.wp__badge svg {
  width: 1.05em;
  height: 1.05em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the flash that runs over the wallpaper when it is applied */
.wp__flash {
  position: absolute;
  inset: -10% -60%;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 38%, rgba(255, 255, 255, 0.55) 50%, transparent 62%);
  opacity: 0;
}

/* the dial under the row: thin ticks that slide with it, taller near the caret */
.dial {
  position: relative;
  height: 18px;
  margin: clamp(4px, 1.2vh, 8px) 0 0;
  -webkit-mask: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
  mask: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
}

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

.tick {
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: 12px;
  margin-left: -0.5px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.5);
  transform-origin: 50% 0;
}

.tick.is-major {
  background: rgba(255, 255, 255, 0.85);
}

.dial__caret {
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 8px;
  height: 5px;
  margin-left: -4px;
  fill: var(--ink);
}

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: clamp(8px, 2vh, 12px);
  padding: 0 2px 0 4px;
}

.foot__words {
  min-width: 0;
}

.foot__name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.foot__meta {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apply {
  position: relative;
  flex: none;
  height: 44px;
  min-width: 132px;
  padding: 0 16px 0 14px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--button);
  color: var(--button-ink);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.1), 0 8px 20px -10px rgba(var(--tint-a), 0.9);
  transition: background-color 0.35s ease, color 0.35s ease, box-shadow 0.35s ease;
}

.apply.is-done {
  background: rgba(185, 241, 214, 0.12);
  color: var(--done);
  box-shadow: inset 0 0 0 1px rgba(185, 241, 214, 0.38);
}

.apply:focus-visible {
  outline: 2px solid rgba(var(--tint-a), 1);
  outline-offset: 3px;
}

/* the light that crosses the button on hover */
.apply__shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.7) 50%, transparent 70%);
  transform: translateX(-120%);
  pointer-events: none;
}

.apply__face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 100%;
}

.apply__words {
  font-size: 13.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 100;
  white-space: nowrap;
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (hover: hover) {
  .apply:hover .apply__words {
    font-variation-settings: 'wdth' 112;
  }
  .apply:not(.is-done):hover .apply__shine {
    transform: translateX(120%);
    transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

.apply__icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.apply__spin {
  stroke-dasharray: 0.3 0.7;
  opacity: 0;
  transform-origin: 8px 8px;
}

.apply__check {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

@media (max-width: 400px) {
  .apply {
    min-width: 128px;
    padding: 0 14px 0 12px;
  }
  .apply__words {
    font-size: 13px;
  }
  .foot__name {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wp__card,
  .apply__words {
    transition: none;
  }
}
