/* ─────────────────────────────────────────────────────────────
   공용 상단 네비 — templates/partials/site_nav.html 의 짝

   랜딩과 문서 페이지(정책 4종·고객문의)가 같은 네비를 쓰므로
   이 파일이 .lp-nav / .lp-account 계열을 단독으로 소유합니다.
   네비를 쓰는 화면은 반드시 이 파일을 함께 읽어야 합니다.
   ───────────────────────────────────────────────────────────── */

/* ── 상단 네비 ───────────────────────────────────────────── */
/* 바는 풀폭 — 시안의 sticky 반투명 상단바 + blur. */
.lp-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: var(--surface-bar);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}

/* 내용은 1120 컨테이너에 담아 브랜드·CTA 여백을 푸터와 동일 기준으로 맞춥니다. */
.lp-nav-inner {
  position: relative;
  max-width: var(--container);
  margin: 0 auto;
  min-height: var(--nav-h);
  padding: 0 clamp(20px, 5vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* 브랜드는 홈으로 가는 링크입니다 — 퍼플 'T' 배지 + 워드마크(시안 v3). */
.lp-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--brand);
  text-decoration: none;
}

.lp-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
}

.lp-brand-word {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: var(--tracking-tight);
}

.lp-nav-menu {
  display: flex;
  align-items: center;
  gap: clamp(9px, 2vw, 16px);
}

/* 중앙 링크 그룹 — 데스크톱에서 컨테이너 정중앙에 절대배치(시안). */
.lp-nav-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 30px;
}

/* 우측 액션(로그인·계정·CTA) 그룹. */
.lp-nav-actions {
  display: flex;
  align-items: center;
  gap: clamp(9px, 2vw, 16px);
}

/* ── 모바일 햄버거 · 드로어 (데스크톱에서는 감춤) ──────────────
   토글과 백드롭은 여기서 모양만 정의하고, 실제로 드러나는 것은
   아래 @media (max-width: 768px) 블록입니다. */
.lp-nav-toggle {
  display: none;   /* 모바일 미디어쿼리에서만 보입니다. */
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--control-bg);
  cursor: pointer;
  transition: border-color .2s ease;
}

.lp-nav-toggle:hover { border-color: var(--accent); }

.lp-nav-toggle-bar {
  width: 18px;
  height: 2px;
  margin: 0 auto;
  border-radius: 2px;
  background: var(--text);
  transition: transform .25s ease, opacity .2s ease;
}

/* 열린 상태 — 세 줄이 X 로 접힙니다. */
.lp-nav.is-open .lp-nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.lp-nav.is-open .lp-nav-toggle-bar:nth-child(2) { opacity: 0; }
.lp-nav.is-open .lp-nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.lp-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, .45);
}

.lp-nav-backdrop[hidden] { display: none; }

.lp-nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: color .25s ease;
}

.lp-nav-link:hover { color: var(--text); }

.lp-nav-link.is-active { color: var(--text); font-weight: 600; }

.lp-nav-login {
  text-decoration: none;
  padding: 9px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all .2s ease;
}

.lp-nav-login:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.lp-nav-cta {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 18px;
  background: var(--accent);
  color: var(--accent-on-solid);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: opacity .15s ease, transform .15s ease, box-shadow .15s ease;
}

.lp-nav-cta:hover {
  opacity: .85;
  color: var(--accent-on-solid);
}

/* 모바일 바 전용 CTA — 데스크톱에서는 드로어 밖에 있을 이유가 없어 감춘다. */
.lp-nav-cta--bar { display: none; }

/* ── 인증 대기 배지 (로그인 후 · 미승인) ─────────────────── */
.lp-nav-pending {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
}

/* ── 계정 메뉴 ───────────────────────────────────────────── */
.lp-account { position: relative; }

/* 계정 버튼 — 데스크톱은 원 하나에 첫 글자만 보이고,
   닉네임·화살표는 모바일 드로어에서만 드러납니다. */
.lp-account-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

/* 원+한글자 대신 간결한 라인 아이콘 — 테두리만 두른 담백한 버튼. */
.lp-account-btn-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--control-bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, color .2s;
}

.lp-account-btn:hover .lp-account-btn-avatar {
  border-color: var(--accent);
  color: var(--accent);
}

.lp-account-btn-name,
.lp-account-btn-caret { display: none; }

.lp-account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lp-account-avatar--lg {
  width: 36px;
  height: 36px;
}

/* 바깥을 눌러 닫기 위한 투명 판. */
.lp-account-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.lp-account-menu {
  position: absolute;
  top: 50px;
  right: 0;
  z-index: 41;
  min-width: 230px;
  padding: 8px;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .2);
  animation: lp-pop .18s;
}

.lp-account-menu[hidden],
.lp-account-backdrop[hidden] { display: none; }

.lp-account-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.lp-account-fullname {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.lp-account-email {
  margin-top: 1px;
  font-size: 12px;
  color: var(--text-faint);
}

.lp-account-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}

.lp-account-item:hover { background: var(--bg-alt); }

/* 미승인 사용자에게만 보이는 강조 항목. */
.lp-account-item--accent {
  color: var(--accent);
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* 지금 보고 있는 화면 (원본은 옅은 배경으로 표시합니다). */
.lp-account-item--on { background: var(--surface-band); }

.lp-account-item--muted { color: var(--text-muted); }

.lp-account-divider {
  height: 1px;
  margin: 6px 8px;
  background: var(--border);
}

/* 계정 메뉴가 뜰 때의 팝 애니메이션. */
@keyframes lp-pop {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ── 테마 스위치 — ☀️/🌙 양끝에 두고 노브가 현재 모드 쪽으로 미끄러집니다 ──
   상태는 [aria-pressed] 하나로 표현합니다(base.html 토글 JS 가 갱신).
   바에서는 버튼 자신이 스위치이고, 계정 메뉴에서는 항목 안의 장식(span)입니다. */
.lp-nav-theme { flex-shrink: 0; }

.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 56px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--control-bg);
  cursor: pointer;
  transition: border-color .2s ease;
}

button.theme-switch:hover { border-color: var(--accent); }

.theme-switch-icon {
  font-size: 12px;
  line-height: 1;
}

.theme-switch-knob {
  position: absolute;
  top: 2px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  transition: transform .2s ease;
}

/* 다크가 켜지면 노브가 🌙 쪽(오른쪽)으로 갑니다. */
.theme-switch[aria-pressed="true"] .theme-switch-knob,
[aria-pressed="true"] > .theme-switch .theme-switch-knob { transform: translateX(26px); }

/* 계정 메뉴 항목 버전 — 라벨은 왼쪽, 스위치는 오른쪽 끝. */
.lp-account-item--theme { justify-content: space-between; }
.lp-account-item--theme .theme-switch { flex-shrink: 0; }

/* JS 가 없으면 스위치가 동작하지 않으므로 감춥니다(OS 설정은 그대로 적용됨). */
.no-js .theme-switch { display: none; }

/* ── 잔여 크레딧·구독 표시 — '지갑' 버튼 없이 값이 바로 보인다 ──
   데스크톱: 좌측 하단 상주 도크(.lp-wallet-dock).
   모바일: 드로어의 닉네임 바로 아래 인라인(.lp-wallet-inline). */
.lp-wallet-inline { display: none; }   /* 모바일 드로어에서만 켠다 */

.lp-wallet-dock {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 45;
  min-width: 190px;
  padding: 10px 12px;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
  cursor: pointer;
  transition: border-color .2s ease;
}

.lp-wallet-dock:hover { border-color: var(--accent); }

/* 접힌 상태 — 코인 하나만 남는다. 클릭하면 JS 가 이 클래스를 토글한다. */
.lp-wallet-dock-coin { display: none; }

.lp-wallet-dock--min {
  min-width: 0;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.lp-wallet-dock--min .lp-wallet-dock-coin { display: block; }
.lp-wallet-dock--min [data-wallet-body],
.lp-wallet-dock--min .lp-wallet-dock-link { display: none; }

.lp-wallet-dock-link {
  display: block;
  margin-top: 6px;
  padding: 0 2px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}

.lp-wallet-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 2px;
  font-size: 13px;
  color: var(--text-muted);
}

.lp-wallet-row strong { color: var(--text); font-weight: 700; }

.lp-wallet-row--credits strong { color: var(--accent); font-size: 15px; }

.lp-wallet-note {
  font-size: 12.5px;
  color: var(--text-faint);
}

/* ── 모바일: 우측 슬라이드 드로어 ─────────────────────────────
   JS 가 있을 때만 드로어로 바꿉니다. no-js 에서는 메뉴를 열 수단이
   없으므로 기존처럼 아래로 접힌 채(flex-wrap) 그대로 둡니다. */
@media (max-width: 768px) {
  /* ★ backdrop-filter 는 fixed 자식의 containing block 을 만듭니다.
     모바일 드로어(.lp-nav-menu)가 fixed 라서, 바에 blur 가 남아 있으면 드로어가
     뷰포트가 아니라 네비 박스 기준으로 잡혀 이상하게 펼쳐집니다. 모바일에선 blur 를
     끄고 불투명 배경으로 둡니다(드로어를 쓰는 폭이라 blur 이득도 없습니다). */
  .lp-nav {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg);
  }

  html:not(.no-js) .lp-nav-toggle {
    display: inline-flex;
    position: relative;
    z-index: 65;   /* 열렸을 때 드로어(60) 위에 남아 X 로 닫을 수 있게. */
  }

  /* 드로어 모드에서는 메뉴가 흐름에서 빠져 space-between 이 기댈 상대가 없다.
     로고가 왼쪽 자리를 통째로 차지하게 해서, 뒤에 오는 것들(내 스튜디오·햄버거)이
     전부 오른쪽에 붙게 한다 — auto 마진 조합보다 브라우저 의존이 없다. */
  html:not(.no-js) .lp-brand { margin-right: auto; }

  /* 바 CTA(내 스튜디오) — 햄버거 왼쪽에 앉는다. */
  html:not(.no-js) .lp-nav-cta--bar {
    display: inline-flex;
    height: 34px;
    padding: 0 13px;
    font-size: 13px;
  }

  /* 드로어 안 CTA 는 바로 나갔으니 접는다. */
  html:not(.no-js) .lp-nav-menu .lp-nav-cta { display: none; }

  html:not(.no-js) .lp-nav-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    width: min(82vw, 300px);
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 74px 22px 28px;
    background: var(--control-bg);
    border-left: 1px solid var(--border);
    box-shadow: -18px 0 46px rgba(0, 0, 0, .28);
    overflow-y: auto;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .28s ease, visibility .28s ease;
  }

  html:not(.no-js) .lp-nav.is-open .lp-nav-menu {
    transform: none;
    visibility: visible;
  }

  /* 리사이즈 중에는 드로어 슬라이드 애니메이션을 끕니다 — 브레이크포인트를 넘나들 때
     transform 이 튀며 '우측으로 닫히는' 모션이 잠깐 보이는 걸 막습니다. */
  html:not(.no-js) .lp-nav-resizing .lp-nav-menu { transition: none !important; }

  /* 드로어에서는 중앙 링크 그룹과 액션 그룹을 세로로 풀어 쌓습니다.
     데스크톱의 절대배치(center)·가로배치(actions)를 여기서 정적 세로로 되돌립니다. */
  html:not(.no-js) .lp-nav-center,
  html:not(.no-js) .lp-nav-actions {
    position: static;
    transform: none;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  /* 드로어 안 순서: 액션(내 계정 → 영상 만들기/로그인) → 링크(자주 묻는 질문·가격 정책). */
  html:not(.no-js) .lp-nav-actions { order: 1; }
  html:not(.no-js) .lp-nav-center  { order: 2; }

  /* 드로어 안에서는 항목을 세로로 쌓고 탭 영역을 넓힙니다. */
  html:not(.no-js) .lp-nav-menu .lp-nav-link {
    padding: 13px 4px;
    font-size: 15px;
    border-bottom: 1px solid var(--border);
  }

  html:not(.no-js) .lp-nav-login,
  html:not(.no-js) .lp-nav-cta {
    margin: 4px 0 12px;
    text-align: center;
  }

  html:not(.no-js) .lp-nav-pending {
    justify-content: center;
    margin: 4px 0 12px;
  }

  /* 계정 메뉴는 드로어 안에서 떠 있는 팝오버 대신 인라인으로 펼칩니다. */
  html:not(.no-js) .lp-account { position: static; margin-bottom: 10px; }

  /* 계정 버튼 — 드로어에서는 원 대신 닉네임 전체와 펼침 화살표를 보여줍니다. */
  html:not(.no-js) .lp-account-btn {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-alt);
  }

  html:not(.no-js) .lp-account-btn-avatar {
    width: 34px;
    height: 34px;
  }

  html:not(.no-js) .lp-account-btn:hover .lp-account-btn-avatar {
    transform: none;
    box-shadow: none;
  }

  html:not(.no-js) .lp-account-btn-name {
    display: block;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
  }

  html:not(.no-js) .lp-account-btn-caret {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    transition: transform .2s ease;
  }

  html:not(.no-js) .lp-account-btn[aria-expanded="true"] .lp-account-btn-caret {
    transform: rotate(180deg);
  }

  html:not(.no-js) .lp-account-menu {
    position: static;
    min-width: 0;
    margin-top: 4px;
    padding: 0;
    border: none;
    background: none;
    box-shadow: none;
    animation: none;
  }

  /* 버튼에 이미 닉네임이 있으므로 머리(아바타·이름·이메일)를 접고
     항목들이 버튼 바로 아래로 이어지게 합니다. */
  html:not(.no-js) .lp-account-head { display: none; }

  /* 드로어 자체가 바깥 클릭으로 닫히므로 계정 전용 백드롭은 접습니다. */
  html:not(.no-js) .lp-account-backdrop { display: none; }

  /* 도크는 데스크톱 전용 — 모바일에서는 드로어 인라인이 그 역할을 한다. */
  .lp-wallet-dock { display: none; }

  /* 닉네임(계정 버튼) 바로 아래 인라인 표시. */
  html:not(.no-js) .lp-wallet-inline {
    display: block;
    margin: 4px 0 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-alt);
  }
}

/* ── 모션 최소화 선호 ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .lp-account-menu { animation: none; }
  .theme-switch-knob { transition: none; }
  .lp-nav-cta:hover { transform: none; }
  .lp-nav-menu { transition: none; }
  .lp-nav-toggle-bar { transition: none; }
  .lp-account-btn-caret { transition: none; }
}
