/*
 * 앱 소개 스크롤 이야기(홈·/for-shops 공용, 2026-11-15).
 * 넓은 화면: 왼쪽 글이 한 장씩 올라오고, 오른쪽 고정 무대의 기기 화면이 그 장으로 바뀌며 확대 카드·강조 테두리가 붙는다.
 * 좁은 화면: 장마다 글 → 기기 → 확대 카드를 차례로 보여 준다. 움직임은 transform·opacity만, 이동 거리는 24px 이하.
 * 스크립트가 없으면(.story-ready 없음) 모든 장이 그대로 보인다. 색은 tokens.css 변수만 쓴다.
 */
.story {
  --story-header: var(--header, 88px);
  --phone-h: min(calc(100svh - var(--story-header) - 140px), 640px);
  --phone-w: calc(var(--phone-h) * 0.4605 + 18px);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
  background: var(--paper);
}
.story-layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.story-intro {
  padding: 56px 0 24px;
}
.story-intro h1 {
  font-size: clamp(32px, 3.3vw, 46px);
  line-height: 1.32;
  letter-spacing: -0.045em;
  font-weight: 900;
  margin: 12px 0 20px;
  word-break: keep-all;
}
.story-intro > p,
.story-intro .story-lead {
  font-size: 18px;
  line-height: 1.8;
  color: var(--muted);
  margin: 0 0 28px;
  text-wrap: balance;
}
.story-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-brand-strong);
  font-size: 14px;
  font-weight: 700;
}
.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 28px;
}
.story-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: var(--radius-button-large);
  border: 1px solid var(--stroke-neutral-muted);
  background: var(--bg-layer-default);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  transition: background-color 0.2s, border-color 0.2s;
}
.story-action:hover {
  border-color: var(--stroke-brand);
  background: var(--bg-brand-weak);
}
.story-action.is-primary {
  border-color: var(--bg-brand-solid);
  background: var(--bg-brand-solid);
  color: var(--fg-neutral-inverted);
}
.story-action.is-primary:hover {
  background: var(--bg-brand-solid-pressed);
}
.story-action:focus-visible,
.story-dots button:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}
.story-steps {
  list-style: none;
  margin: 0;
  padding: 0;
}
.story-step {
  padding: 48px 0;
}
.story-title {
  font-size: clamp(28px, 2.7vw, 40px);
  line-height: 1.36;
  letter-spacing: -0.045em;
  font-weight: 900;
  margin: 0 0 18px;
  word-break: keep-all;
}
/* 「…」·[…] 묶음(뒤 조사 포함)은 가운데서 줄이 바뀌지 않는다. */
.story-keep {
  white-space: nowrap;
}
.story-note {
  margin: 18px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius-input);
  background: var(--bg-brand-weak);
  color: var(--fg-brand-strong);
  font-size: 14px;
  line-height: 1.7;
  text-wrap: balance;
}
.story-word {
  display: inline-block;
}

/* 기기 */
.story-visual {
  position: relative;
  margin: 32px auto 0;
}
.story-device {
  position: relative;
  background: var(--bg-neutral-inverted);
  box-shadow: 0 24px 48px var(--overlay-dim10), 0 6px 14px var(--overlay-dim10);
}
.story-phone {
  width: var(--phone-w);
  padding: 9px;
  border-radius: 46px;
  margin: 0 auto;
}
.story-phone .story-screen {
  border-radius: 37px;
}
.story-screen {
  position: relative;
  overflow: hidden;
  background: var(--bg-layer-default);
}
.story-screen img,
.story-zoom img {
  display: block;
  width: 100%;
  height: auto;
}
.story-desktop {
  width: 100%;
  border-radius: 14px;
  padding: 0 0 8px;
  background: var(--bg-layer-basement);
  border: 1px solid var(--stroke-neutral-weak);
}
.story-desktop .story-screen {
  margin: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--stroke-neutral-weak);
}
.story-browser-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
}
.story-browser-bar i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--stroke-neutral-muted);
}
.story-browser-bar span {
  margin-left: 12px;
  padding: 3px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-layer-default);
  color: var(--muted);
  font-size: 11px;
}
/* 화면 속 강조 테두리 */
.story-ring {
  position: absolute;
  left: var(--rl);
  top: var(--rt);
  width: var(--rw);
  height: var(--rh);
  border: 3px solid var(--stroke-brand);
  border-radius: 14px;
  box-shadow: 0 0 0 6px var(--bg-brand-weak-pressed);
  pointer-events: none;
}
/* 확대 카드: 같은 캡처를 그대로 잘라 키운 부분 */
.story-zoom {
  position: absolute;
  z-index: 2;
  padding: 10px;
  border-radius: 18px;
  background: var(--bg-layer-default);
  border: 1px solid var(--stroke-neutral-weak);
  box-shadow: var(--elevation-floating), 0 18px 40px var(--overlay-dim10);
}
.story-zoom img {
  border-radius: 10px;
}
.story-visual[data-device="phone"] .story-zoom {
  width: min(calc(var(--phone-w) * 1.06), calc(var(--phone-h) * 0.62 / var(--zr)));
  right: calc(50% + var(--phone-w) * 0.12);
  top: var(--zy);
  translate: 0 -50%;
}
.story-visual[data-device="desktop"] .story-zoom {
  width: min(44%, calc(var(--phone-h) * 0.5 / var(--zr)));
  left: -6%;
  top: var(--zy);
  translate: 0 -50%;
}

/* 무대(넓은 화면에서만) */
.story-stage {
  display: none;
}
.story-dots ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.story-dots button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}
.story-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stroke-neutral-muted);
  transition: transform 0.3s var(--ease-out), background-color 0.3s;
}
.story-dots [aria-current="step"] span {
  background: var(--bg-brand-solid);
  transform: scale(1.5);
}
.story-progress {
  position: absolute;
  right: 15px;
  width: 2px;
  border-radius: 2px;
  background: var(--stroke-neutral-weak);
  overflow: hidden;
}
.story-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg-brand-solid);
  transform-origin: top;
  transform: scaleY(var(--story-progress, 0));
}

@media (min-width: 960px) {
  .story-ready .story-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 40px;
  }
  /* 넓은 화면: 제목은 정한 줄에서만 바뀐다. */
  .story-ready .story-title,
  .story-ready .story-intro h1 {
    white-space: nowrap;
  }
  .story-ready .story-note {
    justify-self: start;
    align-self: flex-start;
  }
  .story-ready .story-intro,
  .story-ready .story-step {
    min-height: calc(100svh - var(--story-header));
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 0;
  }
  .story-ready .story-step {
    min-height: calc(92svh - var(--story-header));
  }
  .story-ready .story-step:last-child {
    min-height: calc(100svh - var(--story-header));
  }
  .story-ready .story-stage {
    display: block;
    position: sticky;
    top: var(--story-header);
    height: calc(100svh - var(--story-header));
  }
  .story-stage-inner {
    position: absolute;
    inset: 0 48px 0 0;
  }
  .story-ready .story-stage .story-visual {
    position: absolute;
    left: 60%;
    top: 50%;
    translate: -50% -52%;
    margin: 0;
    width: var(--phone-w);
  }
  .story-ready .story-stage .story-visual[data-device="phone"] .story-zoom {
    width: min(calc(var(--phone-w) * 0.86), calc(var(--phone-h) * 0.62 / var(--zr)));
  }
  .story-ready .story-stage .story-visual[data-device="desktop"] {
    left: 50%;
    width: min(calc(100% - 24px), calc(var(--phone-h) * 1.45));
    translate: -50% -52%;
  }
  .story-stage .story-dots {
    position: absolute;
    right: 0;
    top: 50%;
    translate: 0 -50%;
  }
  .story-stage .story-progress {
    top: calc(50% - 150px);
    height: 300px;
    z-index: -1;
  }
  .story-ready .story-copy {
    transition: opacity 0.45s var(--ease-out);
  }
  .story-ready .story-step:not(.is-active) .story-copy {
    opacity: 0.28;
  }
  /* 무대 층 전환 */
  .story-ready .story-stage .story-visual {
    opacity: 0;
    visibility: hidden;
    transform: translate3d(0, 24px, 0) scale(0.97);
    transition: opacity 0.5s var(--ease-out), transform 0.7s var(--ease-out), visibility 0s linear 0.7s;
  }
  .story-ready .story-stage .story-visual.is-before {
    transform: translate3d(0, -24px, 0) scale(0.97);
  }
  .story-ready .story-stage .story-visual.is-active {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.5s var(--ease-out), transform 0.7s var(--ease-out), visibility 0s;
  }
}

/* 공통 등장 움직임(넓은 화면 무대·좁은 화면 장 모두) */
.story-ready .story-visual .story-zoom {
  opacity: 0;
  transform: translate3d(-16px, 12px, 0) scale(0.94);
  transition: opacity 0.45s var(--ease-out), transform 0.6s var(--ease-out);
}
.story-ready .story-visual .story-ring {
  opacity: 0;
  transform: scale(1.06);
  transition: opacity 0.4s var(--ease-out), transform 0.5s var(--ease-out);
}
.story-ready .story-visual .story-screen img {
  transform: scale(1.03);
  transition: transform 0.9s var(--ease-out);
}
.story-ready .story-visual.is-active .story-zoom {
  opacity: 1;
  transform: none;
  transition-delay: 0.22s;
}
.story-ready .story-visual.is-active .story-ring {
  opacity: 1;
  transform: none;
  transition-delay: 0.42s;
}
.story-ready .story-visual.is-active .story-screen img {
  transform: none;
}
.story-ready .story-word {
  opacity: 0;
  transform: translate3d(0, 0.45em, 0);
  transition: opacity 0.5s var(--ease-out), transform 0.6s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 45ms);
}
.story-ready .is-seen .story-word {
  opacity: 1;
  transform: none;
}
.story-ready .story-note {
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  transition: opacity 0.5s var(--ease-out) 0.18s, transform 0.6s var(--ease-out) 0.18s;
}
.story-ready .is-seen .story-note {
  opacity: 1;
  transform: none;
}

/* 좁은 화면: 장마다 세로로 */
@media (max-width: 959px) {
  .story {
    --phone-w: min(68vw, 290px);
    --phone-h: calc((var(--phone-w) - 18px) * 2.1714);
  }
  .story-layout {
    padding: 0 16px;
  }
  .story-intro {
    padding: 36px 0 8px;
  }
  .story-intro h1 {
    font-size: clamp(30px, 8.4vw, 40px);
  }
  .story-intro > p,
  .story-intro .story-lead {
    font-size: 16px;
  }
  .story-step {
    padding: 40px 0 56px;
    border-top: 1px solid var(--stroke-neutral-weak);
  }
  .story-title {
    font-size: clamp(26px, 7.2vw, 34px);
  }
  .story-visual {
    width: 100%;
    max-width: 420px;
    margin-top: 28px;
  }
  .story-visual[data-device="phone"] {
    padding-left: 12%;
  }
  .story-visual[data-device="phone"] .story-zoom {
    width: min(78%, calc(var(--phone-h) * 0.55 / var(--zr)));
    right: auto;
    left: 0;
  }
  .story-visual[data-device="desktop"] .story-zoom {
    position: relative;
    left: auto;
    top: auto;
    translate: none;
    margin: -16% 0 0 auto;
    width: min(64%, 270px);
  }
  .story-ready .story-step:not(.is-seen) .story-device {
    opacity: 0;
    transform: translate3d(0, 24px, 0);
  }
  .story-ready .story-step .story-device {
    transition: opacity 0.6s var(--ease-out), transform 0.7s var(--ease-out);
  }
}
@media (max-width: 380px) {
  .story-browser-bar span {
    display: none;
  }
}
