@property --grad-angle {
  syntax: "<integer>";
  inherits: true;
  initial-value: 45;
}
@property --grad-stop-a {
  syntax: "<integer>";
  inherits: true;
  initial-value: 30;
}
@property --grad-stop-b {
  syntax: "<integer>";
  inherits: true;
  initial-value: 75;
}
html, body {
  margin: 0;
  overflow: hidden;
}

.stage {
  box-sizing: border-box;
  min-height: 100vh;
  display: grid;
  place-items: center;
  margin: 0;
  background: #17141a;
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
  padding: clamp(8px, 4vw, 24px);
}

.gen {
  min-width: 0;
  --grad-angle: 45;
  --grad-stop-a: 30;
  --grad-stop-b: 75;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
  width: min(100%, 400px);
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.gen__top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gen__preview {
  position: relative;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 132px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(calc(var(--grad-angle) * 1deg), #2f6df6 calc(var(--grad-stop-a) * 1%), #ff9ebb calc(var(--grad-stop-b) * 1%));
}

.gen__angle-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 4px;
  margin: -2px 0 0 -18px;
  border-radius: 999px;
  background: #fff7e6;
  transform-origin: 18px 2px;
  transform: rotate(calc(var(--grad-angle) * 1deg));
  opacity: 0.9;
}

.gen__grid {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.gen__row {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.gen__lab {
  flex: 0 0 auto;
  width: 40px;
  color: #fff7e6;
  font-weight: 700;
  font-size: 10px;
  line-height: 1.4;
}

.gen__slot {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  align-items: center;
  height: 16px;
}

.gen__slot::before {
  content: "";
  grid-area: 1/1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.gen__rng {
  grid-area: 1/1;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.gen__rng::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.gen__rng::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.gen__rng:focus-visible {
  outline: 2px solid #5b8cf8;
  outline-offset: 2px;
  border-radius: 999px;
}

.gen__thumb {
  position: absolute;
  top: 50%;
  left: calc(var(--pct) * 1%);
  width: 12px;
  height: 12px;
  margin-top: -6px;
  margin-left: -6px;
  border-radius: 50%;
  background: #5b8cf8;
  pointer-events: none;
}

.gen__row:nth-child(1) .gen__thumb {
  --pct: calc(var(--grad-angle) / 360 * 100);
}

.gen__row:nth-child(2) .gen__thumb {
  --pct: var(--grad-stop-a);
}

.gen__row:nth-child(3) .gen__thumb {
  --pct: var(--grad-stop-b);
}

.gen__out {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.gen__code {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  background: #17141a;
  color: #fff7e6;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
  font-weight: 500;
  font-size: 10px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
}

.gen__prop {
  color: #5b8cf8;
}

.gen__v {
  font-weight: 700;
}

.gen__v--angle::after {
  counter-reset: v var(--grad-angle);
  content: counter(v);
}

.gen__v--a::after {
  counter-reset: v var(--grad-stop-a);
  content: counter(v);
}

.gen__v--b::after {
  counter-reset: v var(--grad-stop-b);
  content: counter(v);
}

.gen__copy {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: #0a4fe8;
  color: #fff7e6;
  font-family: inherit;
  font-weight: 700;
  font-size: 11px;
  line-height: 1.4;
  cursor: pointer;
}

.gen__copy:focus-visible {
  outline: 2px solid #5b8cf8;
  outline-offset: 2px;
}

@keyframes gradAngle {
  0%, 100% {
    --grad-angle: 45;
  }
  35% {
    --grad-angle: 210;
  }
  70% {
    --grad-angle: 315;
  }
}
@keyframes gradStopA {
  0%, 100% {
    --grad-stop-a: 30;
  }
  40% {
    --grad-stop-a: 45;
  }
  80% {
    --grad-stop-a: 10;
  }
}
@keyframes gradStopB {
  0%, 100% {
    --grad-stop-b: 75;
  }
  50% {
    --grad-stop-b: 55;
  }
  85% {
    --grad-stop-b: 90;
  }
}
.gen.is-demo {
  animation-name: gradAngle, gradStopA, gradStopB;
  animation-duration: 2s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  animation-iteration-count: infinite;
}

@media (prefers-reduced-motion: reduce) {
  .gen.is-demo {
    animation: none !important;
  }
}
@media (max-width: 340px) {
  .gen {
    gap: 8px;
    padding: 8px;
  }
  .gen__top {
    gap: 8px;
  }
  .gen__preview {
    width: 104px;
    height: 56px;
  }
  .gen__code {
    font-size: 9px;
  }
}
