/**
 * ============================================================
 * WePlaNet – Shell Overlays (메뉴 / 채팅 / 멤버십 공통 UI)
 * ------------------------------------------------------------
 * 와이어프레임:
 *  - P11~13,18~19: 햄버거 → 좌측 메뉴 드로어
 *  - P13: DM 목록 (종이비행기 FAB)
 *  - P18: DM 1:1 채팅방
 *  - P19: DM 구독(멤버십) 만료 배너
 *  - P27: Membership 가입 모달
 *  - P33: Membership 상세보기 모달
 * ============================================================
 */

/* ---------- Backdrop (메뉴/채팅 공통 딤) ---------- */
.shell-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 31, 0.4);
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--wp-med) var(--wp-ease), visibility var(--wp-med);
}

.shell-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* =========================================================
 * 1. 좌측 메뉴 드로어 (햄버거)
 * ========================================================= */
.drawer-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 310;
  width: min(320px, 88vw);
  height: 100vh;
  background: var(--wp-surface);
  border-right: 1px solid var(--wp-hairline);
  display: flex;
  flex-direction: column;
  padding: 20px 18px 24px;
  transform: translateX(-105%);
  transition: transform var(--wp-med) var(--wp-ease);
  box-shadow: var(--wp-shadow-modal);
}

.drawer-menu.is-open {
  transform: translateX(0);
}

.drawer-menu__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.drawer-menu__greet {
  font-size: var(--wp-fs-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.35;
  margin-bottom: 22px;
}

.drawer-menu__greet em {
  font-style: normal;
  color: var(--wp-brand);
}

.drawer-menu__section-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--wp-muted);
  margin-bottom: 10px;
}

/* 커뮤니티 목록 영역이 남은 공간을 차지해서, 아래 메뉴(컬렉션·공지사항·Shop·설정)가
   목록 길이와 상관없이 항상 드로어 맨 아래에 붙게 한다. */
#drawerCommunities {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.drawer-menu__communities {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 24px;
  flex: 1;
  overflow: auto;
  /* 목록이 길면 스크롤은 되되 스크롤바는 보이지 않게 */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.drawer-menu__communities::-webkit-scrollbar {
  display: none;
}

.drawer-menu__communities a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--wp-radius-sm);
  font-size: var(--wp-fs-sm);
  font-weight: 600;
}

.drawer-menu__communities a:hover {
  background: var(--wp-brand-soft);
  color: var(--wp-brand-dark);
}

.drawer-menu__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid var(--wp-hairline);
  padding-top: 12px;
}

.drawer-menu__nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  border-radius: var(--wp-radius-sm);
  font-size: var(--wp-fs-sm);
  font-weight: 600;
  color: var(--wp-ink-soft);
}

.drawer-menu__badge {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--wp-live, #e11d48);
  flex-shrink: 0;
}

.drawer-menu__badge[hidden] {
  display: none;
}

.drawer-menu__nav a:hover {
  background: var(--wp-paper);
  color: var(--wp-ink);
}

.drawer-menu__nav .nav-ico {
  width: 28px;
  text-align: center;
  font-size: 16px;
}

/* =========================================================
 * 2. FAB (종이비행기 = 채팅, 캘린더 = 커뮤니티 일정)
 * ========================================================= */
.fab-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--wp-brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  box-shadow: 0 8px 24px rgba(15, 107, 107, 0.35);
  transition: transform var(--wp-fast), background var(--wp-fast);
}

.fab:hover {
  transform: scale(1.06);
  background: var(--wp-brand-dark);
}

/* 안 읽은 DM 개수 (dm-realtime.js 가 #fabChat 안에 붙임) */
#fabChat {
  position: relative;
}

.fab__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  border: 2px solid var(--wp-paper);
  background: var(--wp-live);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
  pointer-events: none;
}

.dm-list-item__unread {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--wp-live);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.fab--secondary {
  background: var(--wp-surface);
  color: var(--wp-ink-soft);
  border: 1px solid var(--wp-line);
  box-shadow: var(--wp-shadow);
}

.fab--secondary:hover {
  background: var(--wp-paper);
  color: var(--wp-brand);
}

/* =========================================================
 * 3. DM 패널 (모바일 폭 오버레이)
 * ========================================================= */
.dm-panel {
  position: fixed;
  right: 18px;
  bottom: 90px;
  z-index: 320;
  width: min(380px, calc(100vw - 24px));
  height: min(640px, calc(100vh - 120px));
  background: var(--wp-surface);
  border: 1px solid var(--wp-hairline);
  border-radius: 18px;
  box-shadow: var(--wp-shadow-modal);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.dm-panel.is-open {
  display: flex;
}

/* --- DM 공통 헤더 --- */
.dm-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--wp-hairline);
  flex-shrink: 0;
}

.dm-header__title {
  flex: 1;
  font-weight: 800;
  font-size: var(--wp-fs-md);
  letter-spacing: -0.02em;
  min-width: 0;
}

.dm-header__title small {
  display: block;
  font-weight: 500;
  font-size: 11px;
  color: var(--wp-muted);
}

.dm-body {
  flex: 1;
  overflow: auto;
  background: #f3f1ed;
}

/* --- DM 목록 (P13) --- */
.dm-promo {
  margin: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--wp-brand-soft), var(--wp-accent-soft));
  border: 1px solid #d5e4e3;
}

.dm-promo strong {
  display: block;
  font-size: var(--wp-fs-sm);
  margin-bottom: 4px;
}

.dm-promo a {
  font-size: var(--wp-fs-xs);
  font-weight: 700;
  color: var(--wp-brand);
}

.dm-section-label {
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--wp-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dm-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--wp-surface);
  border-bottom: 1px solid var(--wp-hairline);
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.dm-list-item:hover {
  background: #faf9f7;
}

.dm-list-item__avatar {
  position: relative;
}

.dm-list-item__avatar .online-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
}

.dm-list-item__meta {
  flex: 1;
  min-width: 0;
}

.dm-list-item__name {
  font-weight: 700;
  font-size: var(--wp-fs-sm);
}

.dm-list-item__group {
  font-size: 11px;
  color: var(--wp-muted);
}

.dm-list-item__preview {
  font-size: var(--wp-fs-xs);
  color: var(--wp-ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.dm-list-item__time {
  font-size: 11px;
  color: var(--wp-faint);
  flex-shrink: 0;
}

/* --- DM 채팅방 (P18 / P19) --- */
.dm-room {
  display: none;
  flex-direction: column;
  height: 100%;
}

.dm-room.is-active {
  display: flex;
}

.dm-list-view {
  display: none;
  flex-direction: column;
  height: 100%;
}

.dm-list-view.is-active {
  display: flex;
}

/* 멤버십/DM 구독 만료 배너 (P19) */
.dm-expired {
  margin: 10px 12px;
  padding: 14px;
  border-radius: 12px;
  background: #1a2423;
  color: #f1eee8;
  display: flex;
  align-items: center;
  gap: 12px;
}

.dm-expired__icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #2563eb;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}

.dm-expired__text {
  flex: 1;
  min-width: 0;
}

/* 한 번도 가입 안 한 팬: "구독 만료" 대신 가입 안내 문구 */
.dm-expired__text--join,
.dm-expired.is-never-subscribed .dm-expired__text--expired {
  display: none;
}

.dm-expired.is-never-subscribed .dm-expired__text--join {
  display: block;
}

.dm-expired__text strong {
  display: block;
  font-size: var(--wp-fs-sm);
  margin-bottom: 2px;
}

.dm-expired__text span {
  font-size: 11px;
  opacity: 0.75;
}

.dm-expired__cta {
  font-size: var(--wp-fs-xs);
  font-weight: 800;
  color: #93c5fd;
  white-space: nowrap;
}

.dm-expired__cta:hover {
  color: #fff;
}

/* 메시지 버블 */
.dm-messages {
  flex: 1;
  overflow: auto;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dm-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 92%;
}

.dm-msg--me {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.dm-msg__bubble {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--wp-surface);
  border: 1px solid var(--wp-hairline);
  font-size: var(--wp-fs-sm);
  line-height: 1.45;
  color: var(--wp-ink);
}

.dm-msg--me .dm-msg__bubble {
  background: var(--wp-brand);
  border-color: var(--wp-brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.dm-msg:not(.dm-msg--me) .dm-msg__bubble {
  border-bottom-left-radius: 4px;
}

/* 아바타 옆 메타(ARTIST 태그/닉네임) + 말풍선을 감싸는 컨테이너.
   기본 div(block)로 두면 메타 줄 너비에 맞춰 말풍선까지 늘어나서, 짧은 메시지 뒤에 빈 공간이 남는 문제가 있었음.
   flex-column + align-items:flex-start로 각 줄이 자기 내용물 너비만큼만 차지하도록 함 */
.dm-msg__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.dm-msg__meta {
  font-size: 10px;
  color: var(--wp-muted);
}

.dm-msg__meta .artist-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #7c3aed;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  margin-right: 4px;
  letter-spacing: 0.04em;
}

.dm-msg__time {
  font-size: 10px;
  color: var(--wp-faint);
  align-self: flex-end;
  margin-bottom: 2px;
}

.dm-sticker {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  background: linear-gradient(145deg, #ffe8d6, #d6ebea);
  display: grid;
  place-items: center;
  font-size: 40px;
}

/* 입력창 */
.dm-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--wp-hairline);
  background: var(--wp-surface);
  flex-shrink: 0;
}

.dm-composer input {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--wp-line);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--wp-paper);
}

.dm-composer input:focus {
  outline: none;
  border-color: var(--wp-brand);
}

.dm-composer .send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--wp-brand);
  color: #fff;
  display: grid;
  place-items: center;
}

/* 금칙어/전송 한도 초과 경고 배너 (브라우저 alert 대신 화면 안에서 알려줌) */
.dm-warning {
  flex-shrink: 0;
  margin: 0 12px 8px;
  padding: 10px 12px;
  border-radius: var(--wp-radius-sm, 8px);
  background: #fdecea;
  color: #b3261e;
  border: 1px solid #f5c6c2;
  font-size: var(--wp-fs-xs, 12px);
  font-weight: 600;
  line-height: 1.4;
}

/* 오늘 남은 전송 횟수 */
.dm-quota {
  flex-shrink: 0;
  margin: 0;
  padding: 0 14px 10px;
  font-size: var(--wp-fs-xs, 12px);
  color: var(--wp-ink-soft, #6b7280);
  text-align: right;
}

.dm-quota.is-empty {
  color: #b3261e;
  font-weight: 700;
}

/* =========================================================
 * 4. 멤버십 전용 페이지 / 카드 보강
 * ========================================================= */
.membership-hero {
  text-align: center;
  padding: 40px 20px 24px;
}

.membership-hero__badge {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--wp-brand), var(--wp-accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 28px;
}

.membership-hero h1 {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.3;
  margin-bottom: 10px;
}

.membership-card-detail {
  background: var(--wp-paper);
  border-radius: var(--wp-radius);
  padding: 16px;
  margin-bottom: 16px;
}

.membership-card-detail__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--wp-fs-sm);
  padding: 6px 0;
}

.membership-card-detail__row span:first-child {
  color: var(--wp-muted);
}

/* 햄버거 버튼 */
.menu-toggle {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--wp-ink);
  font-size: 20px;
  line-height: 1;
}

.menu-toggle:hover {
  background: var(--wp-brand-soft);
  color: var(--wp-brand);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* 멤버십 혜택 리스트 (shell 모달에서도 community.css 없이 동작) */
.membership-benefits {
  margin: 16px 0 20px;
  padding: 0;
}

.membership-benefits li {
  position: relative;
  padding: 8px 0 8px 18px;
  font-size: var(--wp-fs-sm);
  color: var(--wp-ink-soft);
  border-bottom: 1px solid var(--wp-hairline);
}

.membership-benefits li::before {
  content: "·";
  position: absolute;
  left: 4px;
  font-weight: 800;
  color: var(--wp-brand);
}

.membership-price {
  text-align: center;
  font-size: var(--wp-fs-xl);
  font-weight: 800;
  margin: 16px 0;
  letter-spacing: -0.02em;
}

.membership-price small {
  display: block;
  font-size: var(--wp-fs-xs);
  font-weight: 500;
  color: var(--wp-muted);
  margin-top: 4px;
}

/* =========================================================
 * 모바일(560px 이하) 헤더
 * 아이콘 버튼·간격이 PC 크기 그대로면 로고/커뮤니티 이름 자리가 모자라 서로 겹친다.
 * ========================================================= */
@media (max-width: 560px) {
  .site-header,
  .community-top {
    gap: 8px;
    padding: 0 12px;
  }

  .header-left {
    flex: 0 1 auto;
    gap: 6px;
  }

  .brand {
    gap: 8px;
    font-size: 17px;
    min-width: 0;
  }

  .brand__mark {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }

  .brand__text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions,
  .community-top__right {
    gap: 2px;
    flex-shrink: 0;
  }

  .site-header .icon-btn,
  .community-top > .menu-toggle {
    width: 34px;
    height: 34px;
  }

  /* 커뮤니티 헤더는 아이콘이 6개까지 늘어나므로(검색·언어·테마·알림·샵·프로필) 더 촘촘하게 */
  .community-top__right {
    gap: 0;
  }

  .community-top__right .icon-btn {
    width: 32px;
    height: 32px;
  }

  .header-actions .btn--sm,
  .community-top__right .btn--sm {
    padding: 0 10px;
    white-space: nowrap;
  }

  .community-top__left {
    gap: 6px;
  }

  .community-top__left a.home-link {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
  }
}
