/* =========================================================
   common.css — 모든 페이지에서 공유하는 리셋 / 변수 / 공통 컴포넌트
   새 페이지를 추가할 때는 이 파일을 그대로 <link>하고,
   페이지 전용 스타일만 별도 css(예: studio.css)로 분리할 것.
   ========================================================= */

:root {
  /* 브랜드 컬러 — 초록 계열 없이 완전한 흑백. 흰 배경 + 검은 포인트. */
  --accent: #171717;
  --accent-hover: #3a3a3a;
  --accent-soft: rgba(23, 23, 23, 0.08);
  --text-on-accent: #ffffff;

  /* 텍스트 */
  --text-primary: #171717;
  --text-secondary: #5c5c5c;
  --text-muted: #8f8f8f;

  /* 배경 / 보더 — 페이지 바탕은 흰색, 카드/드롭다운은 그보다 살짝 어두운 표면 */
  --bg: #ffffff;
  --bg-soft: #f4f4f4;
  --surface: #ffffff;
  --surface-hover: #ececec;
  --border: #dcdcdc;
  --border-soft: #e6e6e6;
  --shadow-color: rgba(0, 0, 0, 0.12);

  /* 레이아웃 */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-pill: 999px;
  --page-padding: 40px;
  --font-sans: 'Manrope', system-ui, -apple-system, 'Apple SD Gothic Neo', sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

html {
  color-scheme: light;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  /* 페이지를 완전히 그릴 준비가 되기 전까지 통째로 숨겨둔다 — js/common.js의
     페이지 전환 로딩바가 리소스를 다 불러오면 inline style로 다시 보여준다. */
  visibility: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- 페이지 전환 로딩바 (유튜브 스타일) ----------
   body가 visibility: hidden이어도 이 바는 보여야 해서 visibility: visible로
   되돌려둔다(visibility는 자손에서 다시 켤 수 있다). js/common.js가
   loader-start → loader-done → loader-hide 순서로 클래스를 바꿔가며
   움직이고, 다 끝나면 스스로 지운다. */
#pageLoader {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: var(--accent);
  z-index: 9999;
  visibility: visible;
  transition: width 0.2s ease;
}

#pageLoader.loader-start {
  width: 85%;
  transition: width 1.2s cubic-bezier(0.1, 0.7, 1, 0.1);
}

#pageLoader.loader-done {
  width: 100%;
  transition: width 0.2s ease;
}

#pageLoader.loader-hide {
  opacity: 0;
  transition: opacity 0.3s ease;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

img {
  max-width: 100%;
  display: block;
}

/* HTML의 hidden 속성은 항상 최우선으로 숨겨지게 함.
   개별 요소 CSS에서 display:flex/inline-block 등을 지정해도
   hidden이 붙어있으면 무조건 안 보이도록 보장. */
[hidden] {
  display: none !important;
}

/* ---------- 버튼 ---------- */
.btn {
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  padding: 10px 6px;
}

.btn-ghost:hover {
  color: var(--text-primary);
}

.btn-secondary {
  background: var(--bg-soft);
  color: var(--text-primary);
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--border);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- 칩 / 태그 ---------- */
.chip {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-soft);
  border-radius: var(--radius-pill);
  padding: 6px 13px;
}

/* ---------- 헤더 (모든 페이지 공통) ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px var(--page-padding);
  border-bottom: 1px solid var(--border-soft);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 1;
  min-width: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  margin-left: 25px;
  flex-shrink: 0;
}

.logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  max-width: 640px;
  width: 100%;
  color: var(--text-muted);
}

.search-bar input {
  border: none;
  background: none;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
  width: 100%;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px var(--shadow-color);
  padding: 8px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 40;
  color: var(--text-primary);
}

.search-results-group-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  padding: 6px 10px 4px;
}

.search-result-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
}

.search-result-item:hover {
  background: var(--bg-soft);
}

.search-result-item span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

.search-empty {
  padding: 12px 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

/* 커뮤니티/상세/읽기 등 index.html 외 페이지는 헤더에 로그인 관련 UI를
   아예 안 넣는다(js/common.js — authArea.innerHTML = ''). 그래서
   .header-right는 이 페이지들에서는 사실상 빈 채로 남는다. */

/* 삼선 버튼 — 모든 페이지 헤더(.header-left)에 로고 옆으로 들어가는
   일반 버튼이다. 모바일/태블릿(1024px 이하)에서 누르면 #accountDropdown이
   펼쳐지고, 데스크톱(1025px 이상)에서는 좌측 사이드바로 항상 펼쳐져
   있어서 이 버튼 자체를 숨긴다(아래 데스크톱 미디어쿼리). 로고/검색창/
   스위치와 높이를 맞추기 위해 크기를 이 셋과 같은 42px로 잡는다. */
.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-secondary);
  font-size: 17px;
}

.mobile-menu-btn:hover {
  background: var(--border);
}

/* 계정 드롭다운 — 모든 페이지의 #accountDropdown/#accountPanel에 공통으로
   적용된다. 모바일/태블릿(1024px 이하)은 삼선 버튼을 누르기 전까지 항상
   숨겨진 채 화면 우측 상단에 떠 있는 플로팅 패널이고, 데스크톱(1025px
   이상)은 아래 미디어쿼리가 화면 왼쪽에 항상 펼쳐진 사이드바로 바꿔준다
   (유튜브 좌측 메뉴 느낌 — 본문은 그만큼 오른쪽으로 밀려나고, 사이드바가
   position:fixed라서 스크롤해도 같이 움직이지 않아 본문만 스크롤되는
   것처럼 보인다). */
.account-dropdown {
  display: flex;
  position: absolute;
  top: 86px;
  right: var(--page-padding);
  width: 230px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px var(--shadow-color);
  z-index: 60;
  padding: 6px;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

.account-dropdown.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* 사이드바 전용 로고 — 1024px 이하(모바일/태블릿)에서는 숨기고, 헤더 쪽
   원래 로고만 보여준다. 데스크톱에서는 아래 미디어쿼리가 뒤집는다. */
.sidebar-logo {
  display: none;
  margin-left: 0;
}

/* ---------- 데스크톱(1025px 이상): 좌측 고정 사이드바 ---------- */
@media (min-width: 1025px) {
  /* 로고는 사이드바에 따로 있고, 삼선 버튼은 데스크톱에선 쓸 일이 없어서
     완전히 지운다(display:none) — 그래야 검색창이 헤더 맨 왼쪽부터 시작해서
     필터바/작품 목록과 같은 x축(왼쪽 기준선)에서 정렬된다. */
  .mobile-menu-btn {
    display: none;
  }

  .site-header .logo {
    display: none;
  }

  .sidebar-logo {
    display: flex;
    padding: 0 10px;
    margin-left: 25px;
  }

  .account-dropdown {
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    width: 220px;
    height: 100vh;
    max-height: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    box-shadow: none;
    border-right: 1px solid var(--border-soft);
    border-radius: 0;
    padding: 20px 12px;
    gap: 20px;
    z-index: 50;
  }

  body {
    margin-left: 220px;
  }
}

.account-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: var(--radius-md);
  padding: 7px;
}

/* 로그인 상태 확인이 끝나기 전까지 보여주는 스켈레톤 — js/common.js의
   renderAuthArea가 실제 메뉴로 accountPanel을 통째로 바꿔치기하면
   사라진다. 사이드바가 비어 있다가 메뉴가 갑자기 팝업하는 느낌을 줄인다. */
.panel-skeleton {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.skeleton-row {
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--border-soft) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.skeleton-row-user {
  height: 48px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.panel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 13px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: left;
  position: relative;
}

.panel-link:hover {
  background: var(--bg-soft);
  color: var(--text-primary);
}

.panel-row-user {
  color: var(--text-primary);
  font-weight: 800;
}

.panel-row-user:hover {
  background: var(--bg-soft);
}

.panel-row-auth {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 4px 10px 10px;
}

.panel-auth-btn {
  text-align: center;
}

.panel-subtext {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.panel-subtext:hover {
  color: var(--text-secondary);
}

.notif-bell-wrap.panel-row {
  padding: 0;
}

.panel-notif-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 13px 10px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.account-panel .notif-dropdown {
  top: calc(100% + 4px);
  left: 0;
  right: auto;
  width: 100%;
}

/* ---------- 반응형 (모바일) ---------- */
@media (max-width: 720px) {
  :root {
    --page-padding: 16px;
  }

  /* index.html에서는 로고 옆에 검색창·소설/웹툰 스위치·삼선 버튼까지 있어서
     한 줄에 안 들어가면 줄바꿈되게 한다(다른 페이지는 로고 하나뿐이라
     영향 없음). */
  .header-left {
    gap: 14px;
    flex-wrap: wrap;
    row-gap: 10px;
  }

  .logo {
    margin-left: 3px;
  }
}

@media (max-width: 480px) {
  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
}

/* index.html 계정 패널의 .panel-row-user 안에서 쓰는데, 특정 부모에
   묶어둘 필요가 없어서 그냥 범용 클래스로 둔다. */
.user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--accent);
}

/* 프로필 아이콘을 안 올린 사람의 댓글/글 목록에 표시되는 빈 원 — 아이콘이
   있으면 img.comment-avatar가 그 자리에 대신 렌더링된다(js/common.js의
   avatarHTML). 댓글(community.js/notice.js/read.js) · 커뮤니티 글 목록/상세에서 공용으로 쓴다. */
.comment-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-placeholder {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
}

/* ---------- 신고 패널 (detail.js/read.js/community.js 공용) ---------- */
.report-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 260px;
  max-width: 90vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px var(--shadow-color);
  padding: 14px;
  z-index: 50;
}

.report-panel-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
}

.report-reason-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.report-reason-btn {
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.report-reason-btn:hover {
  background: var(--bg-soft);
  color: var(--text-primary);
}

.report-cancel-btn {
  font-size: 12px;
  color: var(--text-muted);
}

.report-panel-result {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---------- 알림(승격추천 승인요청) 종 아이콘 ---------- */
.notif-bell-wrap {
  position: relative;
}

.notif-bell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.notif-bell:hover {
  background: var(--border);
  color: var(--text-primary);
}

.notif-dot {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e0393e;
  border: 1.5px solid var(--bg-soft);
}

.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  max-width: 92vw;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px var(--shadow-color);
  z-index: 20;
}

.notif-dropdown.open {
  display: block;
}

.notif-dropdown-title {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-soft);
}

.notif-empty {
  padding: 24px 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.notif-item {
  position: relative;
  padding: 12px 30px 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item strong {
  color: var(--text-primary);
}

.notif-remove {
  position: absolute;
  top: 10px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.notif-remove:hover {
  background: var(--bg-soft);
  color: var(--text-secondary);
}

.notif-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.notif-actions .btn {
  padding: 6px 12px;
  font-size: 12px;
}