/* 로드맵 모달 — 모바일 우선. 좁은 화면에서는 아래에서 올라오는 시트,
   넓은 화면에서는 가운데 놓이는 창으로 바뀐다. */

.rm {
  background: transparent;
  border: 0;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  padding: 0;
  width: 100%;
}

.rm::backdrop {
  background: rgba(33, 14, 22, 0.55);
  opacity: 0;
  transition: opacity 0.32s ease;
}

.rm[open]::backdrop { opacity: 1; }

@starting-style {
  .rm[open]::backdrop { opacity: 0; }
}

.rm__sheet {
  --rm-ink: var(--ink-900, #241b1b);
  --rm-muted: var(--ink-600, #67595a);
  --rm-accent: var(--key-700, #7b2d44);
  --rm-paper: var(--ivory-0, #fffcf8);
  --rm-panel: var(--ivory-50, #f6f0ea);
  --rm-line: rgba(36, 27, 27, 0.14);
  --rm-line-strong: rgba(36, 27, 27, 0.28);

  background: var(--rm-paper);
  border-radius: 18px 18px 0 0;
  bottom: 0;
  color: var(--rm-ink);
  display: flex;
  flex-direction: column;
  left: 0;
  max-height: 92dvh;
  position: absolute;
  right: 0;
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.rm[open] .rm__sheet { transform: translateY(0); }

@starting-style {
  .rm[open] .rm__sheet { transform: translateY(100%); }
}

/* 손잡이 — 눌러도 닫히고, 모바일에서는 아래로 끌어도 닫힌다 */
.rm__grip {
  align-self: center;
  background: none;
  border: 0;
  cursor: pointer;
  display: block;
  flex: none;
  padding: 12px 40px 6px;
  touch-action: none;
}

.rm__grip::before {
  background: var(--rm-line-strong);
  border-radius: 999px;
  content: "";
  display: block;
  height: 4px;
  width: 40px;
}

.rm__bar {
  align-items: center;
  border-bottom: 1px solid var(--rm-line);
  display: grid;
  flex: none;
  gap: 8px;
  grid-template-columns: 2.75rem 1fr 2.75rem;
  padding: 4px 10px 12px;
}

.rm__title {
  font-family: var(--font-body, inherit);
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 화면이 바뀔 때 제목으로 포커스를 옮긴다(tabindex="-1"). 스크린리더가 읽을
   자리를 잡으려는 것이지 사용자가 짚어 간 자리가 아니다. tabindex="-1" 이라
   탭 순서에도 없어 키보드로 짚어 올 수 없다. 테두리를 그리지 않는다. */
.rm__title:focus,
.rm__title:focus-visible { outline: none; }

.rm__back,
.rm__close {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 999px;
  color: var(--rm-ink);
  cursor: pointer;
  display: inline-flex;
  font-size: 1rem;
  height: 2.75rem;
  justify-content: center;
  width: 2.75rem;
}

.rm__back:hover,
.rm__close:hover { background: var(--rm-panel); }

.rm__back[hidden] { visibility: hidden; display: inline-flex; }

.rm__body {
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 20px 8px;
  position: relative;
}

/* 아래에 내용이 더 있으면 가장자리를 흐린다. 끝에 닿으면 사라진다. */
.rm__body[data-more="true"] {
  mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent);
}

.rm__foot {
  background: var(--rm-paper);
  border-top: 1px solid var(--rm-line);
  flex: none;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
}

.rm__foot[hidden] { display: none; }

/* ---- 화면 전환 ---- */

.rm-step {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.rm-step.is-entering {
  opacity: 0;
  transform: translateY(10px);
}

/* ---- 공통 조각 ---- */

.rm-eyebrow {
  color: var(--rm-accent);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  margin: 0 0 6px;
}

.rm-lead {
  color: var(--rm-muted);
  font-size: 0.9375rem;
  line-height: 1.75;
  margin: 0 0 24px;
}

.rm-block { margin-bottom: 24px; }

.rm-block__label {
  color: var(--rm-accent);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  margin: 0 0 10px;
}

/* ---- 화면 1: 고민 고르기 ---- */

.rm-hero {
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
  position: relative;
}

.rm-hero img {
  aspect-ratio: 4 / 3;
  display: block;
  /* width·height 속성이 표현 힌트로 들어와 aspect-ratio 를 이긴다. auto 로 풀어야 한다. */
  height: auto;
  object-fit: cover;
  /* 얼굴부터 벨벳 네크라인까지가 4:3 안에 들어오는 지점 */
  object-position: center 40%;
  width: 100%;
}

.rm-hero__copy {
  background: linear-gradient(to top, rgba(33, 14, 22, 0.72), rgba(33, 14, 22, 0));
  bottom: 0;
  left: 0;
  padding: 40px 18px 16px;
  position: absolute;
  right: 0;
}

.rm-hero__copy .rm-eyebrow { color: var(--key-200, #d7a6b5); }

.rm-hero__title {
  color: var(--ivory-0, #fffcf8);
  font-family: var(--font-display, inherit);
  font-size: 1.375rem;
  font-weight: 500;
  line-height: 1.45;
  margin: 0;
  white-space: pre-line;
}

.rm-group { margin-bottom: 22px; }

.rm-group__label {
  color: var(--rm-accent);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  margin: 0 0 10px;
}

.rm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rm-chip {
  animation: rm-pop 0.34s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--i, 0) * 40ms);
  background: var(--rm-panel);
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--rm-ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.9375rem;
  min-height: 2.75rem;
  padding: 0 1.1rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.rm-chip:hover,
.rm-chip:focus-visible {
  background: var(--rm-paper);
  border-color: var(--rm-accent);
}

@keyframes rm-pop {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- 화면 2: 고민 상세 ---- */

.rm-detail__head {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.rm-detail__head img {
  aspect-ratio: 1;
  border-radius: 10px;
  flex: none;
  height: auto;
  object-fit: cover;
  object-position: center 26%;
  width: 5.5rem;
}

.rm-detail__title {
  font-family: var(--font-display, inherit);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.3;
  margin: 0;
}

.rm-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.rm-items li {
  animation: rm-pop 0.32s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
  display: flex;
  flex-direction: column;
}

.rm-items li > span { font-size: 0.9375rem; }

.rm-items small {
  color: var(--rm-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.rm-rows {
  margin: 0;
  padding: 0;
}

.rm-rows > div {
  animation: rm-pop 0.32s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--i, 0) * 55ms);
  border-top: 1px solid var(--rm-line);
  display: grid;
  gap: 2px 14px;
  grid-template-columns: minmax(4.5rem, 6rem) minmax(0, 1fr);
  padding: 12px 0;
}

.rm-rows > div:last-child { border-bottom: 1px solid var(--rm-line); }

.rm-rows dt {
  color: var(--rm-accent);
  font-size: 0.9375rem;
}

.rm-rows dd {
  color: var(--rm-muted);
  font-size: 0.9375rem;
  line-height: 1.7;
  margin: 0;
}

.rm-stages {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rm-stages li {
  animation: rm-pop 0.32s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--i, 0) * 55ms);
  border-top: 1px solid var(--rm-line);
  display: grid;
  gap: 2px;
  padding: 12px 0;
}

.rm-stages li:last-child { border-bottom: 1px solid var(--rm-line); }

.rm-stages__name {
  color: var(--rm-accent);
  font-size: 0.9375rem;
}

.rm-stages__for,
.rm-stages__do {
  color: var(--rm-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ---- 화면 3: 기간 구조 ---- */

/* 기간 구조 화면의 이미지 띠 — 아래 도식을 밀어내지 않게 얕게 자른다 */
.rm-band {
  border-radius: 12px;
  margin: 0 0 22px;
  overflow: hidden;
}

.rm-band img {
  aspect-ratio: 2 / 1;
  display: block;
  height: auto;
  object-fit: cover;
  /* 인물이 오른쪽에 치우친 컷이라 가로 위치를 그쪽으로 민다. */
  object-position: 62% 32%;
  width: 100%;
}

.rm-figure {
  margin: 0 0 24px;
}

.rm-timeline {
  color: var(--rm-ink);
  display: block;
  height: auto;
  width: 100%;
}

.rm-timeline__axis {
  stroke: var(--rm-line-strong);
  stroke-width: 1;
}

.rm-timeline__tick {
  animation: rm-tick 0.4s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(220ms + var(--i, 0) * 55ms);
  stroke: var(--rm-accent);
  stroke-width: 2.5;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes rm-tick {
  from { opacity: 0; transform: scaleY(0.2); }
  to { opacity: 1; transform: scaleY(1); }
}

.rm-timeline__label {
  fill: var(--rm-accent);
  font-family: var(--font-body, inherit);
  font-size: 13px;
}

.rm-timeline__sub {
  fill: var(--rm-muted);
  font-family: var(--font-body, inherit);
  font-size: 10.5px;
}

/* ---- 버튼 ---- */

.rm-actions {
  display: flex;
  gap: 8px;
}

.rm-btn {
  align-items: center;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  flex: 1 1 auto;
  font: inherit;
  font-size: 0.9375rem;
  justify-content: center;
  min-height: 3rem;
  padding: 0 1.1rem;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.rm-btn--solid {
  background: var(--wine-700, #4b1428);
  border: 1px solid var(--wine-700, #4b1428);
  color: var(--ivory-0, #fffcf8);
}

.rm-btn--solid:hover { background: var(--wine-500, #7a2b4b); }

.rm-btn--ghost {
  background: transparent;
  border: 1px solid var(--rm-line-strong);
  color: var(--rm-ink);
}

.rm-btn--ghost:hover { background: var(--rm-panel); }

/* ---- 넓은 화면에서는 가운데 창으로 ---- */

@media (min-width: 40rem) {
  .rm__sheet {
    border-radius: 14px;
    bottom: auto;
    left: 50%;
    max-height: 86dvh;
    max-width: 36rem;
    right: auto;
    top: 50%;
    transform: translate(-50%, -46%) scale(0.98);
    width: calc(100% - 3rem);
  }

  .rm[open] .rm__sheet { transform: translate(-50%, -50%) scale(1); }

  @starting-style {
    .rm[open] .rm__sheet { transform: translate(-50%, -46%) scale(0.98); }
  }

  .rm__grip { display: none; }

  .rm__bar { padding-top: 12px; }

  .rm__body { padding: 24px 24px 8px; }

  .rm-hero img { aspect-ratio: 16 / 9; }

  .rm-detail__head img { width: 7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .rm::backdrop,
  .rm__sheet,
  .rm-step { transition: none; }

  .rm-chip,
  .rm-items li,
  .rm-rows > div,
  .rm-stages li,
  .rm-timeline__tick { animation: none; }
}

/* 화면이 낮을 때(가로로 든 휴대폰) 여백을 줄여 본문 자리를 넓힌다 */
@media (max-height: 30rem) {
  .rm__sheet { max-height: 96dvh; }
  .rm__grip { padding: 8px 40px 4px; }
  .rm__bar { padding-bottom: 8px; }
  .rm__body { padding: 14px 20px 6px; }
  /* 하단 safe-area를 남긴다. padding-block 한 줄로 밀면 가로로 든 노치
     기기에서 버튼이 홈 인디케이터에 닿는다. */
  .rm__foot { padding-block: 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .rm-hero { margin-bottom: 14px; }
  .rm-hero img { aspect-ratio: 21 / 9; }
  /* 도식이 본문의 내용이고 사진은 장식이다. 자리가 없으면 사진을 뺀다. */
  .rm-band { display: none; }
  .rm-lead { margin-bottom: 16px; }
  .rm-block { margin-bottom: 16px; }
}
