@charset "UTF-8";
html, body {
  margin: 0;
  overflow: hidden;
}

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

@property --x {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
@property --y {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
@property --s {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}
.lp {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.lp__grid {
  position: relative;
  width: 216px;
  height: 128px;
  border-radius: 16px;
  background: rgba(23, 20, 26, 0.22);
  transition: background-color 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* 펼친 동안 판이 한 단계 짙어진다 — 열렸다는 사실이 판 전체로 보인다 */
.lp.open .lp__grid {
  background: rgba(23, 20, 26, 0.46);
}

.lp__btn {
  --x: 0px;
  --y: 0px;
  --s: 1;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff7e6;
  cursor: pointer;
  translate: calc(-50% + var(--x)) calc(-50% + var(--y));
  scale: var(--s);
  transition: translate 300ms cubic-bezier(0.2, 0.8, 0.2, 1), scale 300ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.lp__btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

.lp__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* 접힌 상태 — 앞 세 개만 한 줄로 */
.lp__btn:nth-child(1) {
  --x: -52px;
}

.lp__btn:nth-child(2) {
  --x: 0px;
}

.lp__btn:nth-child(3) {
  --x: 52px;
}

/* 숨은 넷은 제 빈 칸에서 배율 0 으로 기다린다 — 가운데서 날아오면 앞 세 개와 겹친다 */
.lp__btn:nth-child(4) {
  --x: -52px;
  --y: 0px;
}

.lp__btn:nth-child(5) {
  --x: 0px;
  --y: 0px;
}

.lp__btn:nth-child(6) {
  --x: 52px;
  --y: 0px;
}

.lp__btn:nth-child(7) {
  --x: 0px;
  --y: 44px;
}

.lp__btn--more {
  --s: 0;
  opacity: 0;
  pointer-events: none;
}

/* 펼친 상태 — 앞 세 개가 윗줄로 흩어지고 숨은 넷이 제자리에서 커진다 */
.lp.open .lp__btn--more {
  --s: 1;
  opacity: 1;
  pointer-events: auto;
}

.lp.open .lp__btn:nth-child(1) {
  --y: -44px;
}

.lp.open .lp__btn:nth-child(2) {
  --y: -44px;
}

.lp.open .lp__btn:nth-child(3) {
  --y: -44px;
}

.lp__toggle {
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(23, 20, 26, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
}

.lp__toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* 자동 재생 — 한 줄에서 격자로 흩어졌다 84% 에 한 줄로 되돌아온다 */
.is-demo .lp__btn {
  animation-duration: 2s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  animation-iteration-count: infinite;
}

.is-demo .lp__btn:nth-child(1) {
  animation-name: lp-c1;
}

.is-demo .lp__btn:nth-child(2) {
  animation-name: lp-c2;
}

.is-demo .lp__btn:nth-child(3) {
  animation-name: lp-c3;
}

.is-demo .lp__grid {
  animation-name: lp-pad;
  animation-duration: 2s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.is-demo .lp__btn--more {
  animation-name: lp-grow;
}

@keyframes lp-c1 {
  0%, 12% {
    --y: 0px;
  }
  36%, 72% {
    --y: -44px;
  }
  84%, 100% {
    --y: 0px;
  }
}
@keyframes lp-c2 {
  0%, 12% {
    --y: 0px;
  }
  36%, 72% {
    --y: -44px;
  }
  84%, 100% {
    --y: 0px;
  }
}
@keyframes lp-c3 {
  0%, 12% {
    --y: 0px;
  }
  36%, 72% {
    --y: -44px;
  }
  84%, 100% {
    --y: 0px;
  }
}
/* 앞 세 개가 윗줄로 다 올라간 뒤(36%)에야 커지고, 내려오기 전(72%)에 줄어든다 — 겹칠 틈이 없다 */
@keyframes lp-grow {
  0%, 36% {
    --s: 0;
    opacity: 0;
  }
  36.01% {
    opacity: 1;
  }
  44%, 60% {
    --s: 1;
    opacity: 1;
  }
  71.99% {
    opacity: 1;
  }
  72%, 100% {
    --s: 0;
    opacity: 0;
  }
}
@keyframes lp-pad {
  0%, 43.99% {
    background-color: rgba(23, 20, 26, 0.22);
  }
  44%, 60% {
    background-color: rgba(23, 20, 26, 0.46);
  }
  72%, 100% {
    background-color: rgba(23, 20, 26, 0.22);
  }
}
@media (max-width: 340px) {
  .lp__grid {
    width: 200px;
    height: 124px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .is-demo .lp__btn,
  .is-demo .lp__grid {
    animation-name: none;
  }
  .lp__btn {
    transition: none;
  }
}
