/* Stage Badge — PLAN_P0a v3 (2026-04-20)
 * 헤더 내부 회원 전환 사다리 배지 + 드롭다운
 * 전체 사이트 공통 (head.php에 include)
 */

/* ===== 배지 ===== */
.stage-badge-wrap {
  position: relative;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}

.stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  background: #f5f3ef;
  border: 1px solid #e4e4e8;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  line-height: 1;
  min-height: 32px;
}

.stage-badge:hover {
  background: #ede9e0;
  border-color: #d4d0c8;
}

.stage-badge:focus-visible {
  outline: 2px solid #0d7680;
  outline-offset: 2px;
}

.stage-badge .sb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c4c4c8;
  display: inline-block;
  transition: all 0.15s;
}

.stage-badge .sb-dot-done    { background: #0d7680; }
.stage-badge .sb-dot-current { background: #0d7680; }
.stage-badge .sb-dot-active  {
  background: #0d7680;
  box-shadow: 0 0 0 2px rgba(13, 118, 128, 0.3);
}
.stage-badge .sb-dot-inactive { background: #c4c4c8; }

/* ===== 드롭다운 ===== */
.stage-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  /* 배지는 헤더 우측 부근 → 드롭다운은 배지 우측 끝 기준 왼쪽 펼침 (오른쪽 짤림 방지) */
  right: 0;
  left: auto;
  width: 340px;
  max-width: calc(100vw - 24px);
  background: #fff;
  border: 1px solid #e4e4e8;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  padding: 16px 16px 16px 16px;
  z-index: 1002;
  opacity: 0;
  transition: opacity 0.15s ease;
}

/* ===== X 닫기 버튼 ===== */
.sd-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #888;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.sd-close:hover {
  background: #f5f3ef;
  color: #1a1a1f;
}
.sd-close:focus-visible {
  outline: 2px solid #0d7680;
  outline-offset: 2px;
}

.stage-dropdown[hidden] {
  display: none;
}

.stage-dropdown.is-open {
  opacity: 1;
}

/* 드롭다운 내 4단계 사다리 */
.sd-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sd-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 58px;
  flex-shrink: 0;
  font-size: 0.72rem;
  color: #78716c;
}

.sd-step .sd-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e4e4e8;
  border: 2px solid #c4c4c8;
}

.sd-step-done    { color: #444; }
.sd-step-done    .sd-dot { background: #0d7680; border-color: #0d7680; }
.sd-step-current { color: #1a1a1f; font-weight: 700; }
.sd-step-current .sd-dot { background: #0d7680; border-color: #0a5c64; }
.sd-step-active  { color: #1a1a1f; font-weight: 700; }
.sd-step-active  .sd-dot {
  background: #0d7680;
  border-color: #0a5c64;
  box-shadow: 0 0 0 3px rgba(13, 118, 128, 0.2);
}

.sd-connector {
  width: 14px;
  height: 2px;
  background: #e4e4e8;
  margin-top: -12px;
  flex-shrink: 0;
}
.sd-connector-done { background: #0d7680; }

/* 드롭다운 메시지 + CTA */
.sd-msg {
  font-size: 0.82rem;
  color: #444;
  line-height: 1.4;
  margin: 0 0 12px;
  padding-right: 28px; /* X 버튼 공간 */
}

.sd-cta {
  display: block;
  text-align: center;
  padding: 10px 16px;
  background: #0d7680;
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.88rem;
  transition: background 0.15s;
}

.sd-cta:hover,
.sd-cta:focus-visible {
  background: #0a5c64;
  color: #fff;
}

/* 모바일 390px — 배지 축소, 드롭다운 width 조정 */
@media (max-width: 640px) {
  .stage-badge-wrap { margin-right: 4px; }
  .stage-badge {
    padding: 5px 7px;
    gap: 3px;
    min-height: 26px;
  }
  .stage-badge .sb-dot {
    width: 6px;
    height: 6px;
  }
  /* 모바일 드롭다운 — viewport 기준 fixed 배치 (짤림 방지) */
  .stage-dropdown {
    position: fixed;
    top: auto;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    /* 헤더 높이(60px) + 여유 6px 아래에 위치 */
    margin-top: 6px;
    padding: 12px;
  }
  /* 고정 위치 보정을 위한 JS 계산 필요시를 위한 기본값 */
  .stage-badge-wrap.is-open .stage-dropdown {
    /* JS가 open 시 top 값 동적 설정 */
  }
  .sd-step {
    min-width: 52px;
    font-size: 0.68rem;
  }
  .sd-close {
    width: 32px;
    height: 32px; /* 모바일 터치 타깃 확대 */
    font-size: 22px;
  }
}
