@property --reveal {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 50%;
}
@property --reveal-num {
  syntax: "<number>";
  inherits: true;
  initial-value: 0.5;
}
html, body {
  margin: 0;
  overflow: hidden;
}

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

.ba {
  position: relative;
  width: 200px;
  max-width: 100%;
  aspect-ratio: 4/3;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
  touch-action: none;
  cursor: ew-resize;
  font: 700 12px/1 system-ui, sans-serif;
  --reveal: 50%;
  --reveal-num: 0.5;
}

.ba__after,
.ba__before {
  position: absolute;
  inset: 0;
}

.ba__after {
  background: linear-gradient(155deg, #fff7e6 0%, #17141a 100%);
}

.ba__before {
  background: linear-gradient(155deg, #17141a 0%, #fff7e6 65%);
  clip-path: inset(0 calc(100% - var(--reveal)) 0 0);
}

.ba__badge {
  position: absolute;
  top: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #ffd23f;
  color: #17141a;
  letter-spacing: 0.04em;
}

.ba__badge--before {
  left: 12px;
  opacity: calc(0.72 + 0.28 * var(--reveal-num));
}

.ba__badge--after {
  right: 12px;
  opacity: calc(1 - 0.28 * var(--reveal-num));
}

.ba__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--reveal);
  width: 4px;
  transform: translateX(-50%);
  background: #ffd23f;
}

.ba__grip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #ffd23f;
  transform: translate(-50%, -50%);
  box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
}

.ba.is-demo {
  animation: reveal-loop 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}

@keyframes reveal-loop {
  0%, 8% {
    --reveal: 20%;
    --reveal-num: 0.2;
  }
  50% {
    --reveal: 80%;
    --reveal-num: 0.8;
  }
  92%, 100% {
    --reveal: 20%;
    --reveal-num: 0.2;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ba.is-demo {
    animation: none;
    --reveal: 50%;
    --reveal-num: 0.5;
  }
}
