/* ===== Deck Browser (Phase 4) ===== */

/* --- Deck Browser Container --- */
.deck-browser {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* --- 4-4. Layer 1: 탭 바 --- */
.deck-tabs {
  position: relative;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  background: var(--bg-primary);
}

.deck-tabs-scroll {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.deck-tabs-scroll::-webkit-scrollbar {
  display: none;
}

.deck-tab {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
  user-select: none;
}

.deck-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border);
}

.deck-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(var(--accent-rgb, 0,0,0), 0.25);
}

.deck-tab-discover {
  color: var(--accent-pink);
  border-color: transparent;
}

.deck-tab-discover.active {
  background: var(--accent-pink);
  color: #fff;
  border-color: var(--accent-pink);
}

/* --- 4-1. 카드 기본 스타일 --- */
.deck-card {
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
  padding: 24px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.deck-card:hover {
  box-shadow: 0 12px 40px rgba(0,0,0,0.14), 0 2px 6px rgba(0,0,0,0.08);
}

.deck-card:active {
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.deck-card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.deck-coverage-badge {
  display: inline-block;
  background: var(--accent-primary, #e67e22);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.4;
}

.deck-card-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.deck-card-path {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 12px;
  opacity: 0.7;
}

.deck-card-preview {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.deck-card-preview::-webkit-scrollbar {
  width: 4px;
}

.deck-card-preview::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* 카드 프리뷰 내 리스트 넘버링 겹침 방지 */
.deck-card-preview ol,
.deck-card-preview ul {
  padding-left: 1.6em;
  margin: 4px 0;
  list-style-position: outside;
}

.deck-card-preview li {
  padding-left: 0.2em;
}

/* --- MOC 카드 내 노트 목록 --- */
.deck-card-notelist {
  flex: 1;
  overflow-y: auto;
  margin-top: 8px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.deck-card-notelist::-webkit-scrollbar {
  width: 4px;
}

.deck-card-notelist::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.deck-notelist-section {
  margin-bottom: 10px;
}

.deck-notelist-heading {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
  padding: 2px 0;
  border-bottom: 1px solid var(--border-light);
}

.deck-notelist-items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.deck-notelist-item {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck-notelist-item:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.deck-card-sections {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 12px;
}

.deck-card-section {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* --- 캐러셀 공통 --- */
.deck-carousel {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.deck-carousel-track {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.deck-carousel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  flex-shrink: 0;
}

.deck-back {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  transition: all 0.2s;
}

.deck-back:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.deck-moc-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- 4-7. 정렬 옵션 --- */
.deck-sort-options {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.deck-sort-btn {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.deck-sort-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.deck-sort-btn.active {
  background: var(--accent);
  color: var(--text-on-card);
  border-color: var(--accent);
}

.deck-sort-select {
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* --- 인디케이터 --- */
.deck-indicators {
  display: none;
  justify-content: center;
  gap: 6px;
  padding: 12px 0;
  flex-shrink: 0;
}

.deck-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.3;
  transition: opacity 0.2s, transform 0.2s;
}

.deck-dot.active {
  opacity: 1;
  background: var(--accent);
  transform: scale(1.2);
}

/* --- 4-5. 집중 모드 --- */
.deck-focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  animation: deckFocusIn 0.3s ease;
}

/* --- 레이어 전환 슬라이드 애니메이션 --- */
@keyframes deckSlideInRight {
  from { opacity: 0; transform: translateX(60px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes deckSlideOutLeft {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-60px); }
}

@keyframes deckSlideInLeft {
  from { opacity: 0; transform: translateX(-60px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes deckSlideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(60px); }
}

.deck-slide-in-right { animation: deckSlideInRight 0.3s ease forwards; }
.deck-slide-out-left { animation: deckSlideOutLeft 0.25s ease forwards; }
.deck-slide-in-left { animation: deckSlideInLeft 0.3s ease forwards; }
.deck-slide-out-right { animation: deckSlideOutRight 0.25s ease forwards; }

@keyframes deckFocusIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.deck-focus-overlay.closing {
  animation: deckFocusOut 0.2s ease forwards;
}

@keyframes deckFocusOut {
  to { opacity: 0; transform: scale(0.96); }
}

.deck-focus-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.deck-focus-header button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  transition: background 0.2s;
}

.deck-focus-header button:hover {
  background: var(--bg-hover);
}

.deck-focus-pdf {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.deck-focus-pdf:hover {
  background: var(--accent) !important;
  color: #fff;
}

.deck-focus-pdf:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.deck-focus-content {
  padding: 24px 16px;
  max-width: 720px;
  margin: 0 auto;
  flex: 1;
  overflow-y: auto;
  min-height: 200px;
}

.deck-focus-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.deck-focus-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.deck-focus-body {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.deck-focus-body.md-rendered {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.deck-focus-error {
  color: var(--accent-pink);
  text-align: center;
  padding: 40px 0;
}

.deck-focus-editor {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px;
  background: var(--bg-primary);
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  resize: none;
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
}

.deck-focus-save-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.deck-focus-nav {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.deck-focus-nav button {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--accent);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  transition: all 0.2s;
  font-weight: 500;
}

.deck-focus-nav button:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.deck-focus-nav button:disabled {
  color: var(--text-muted);
  cursor: default;
  border-color: var(--border-light);
  background: transparent;
}

.deck-focus-nav button:disabled:hover {
  background: transparent;
  border-color: var(--border-light);
}

/* --- 4-2. 데스크탑 커버플로우 (≥ 768px) --- */
@media (min-width: 768px) {
  .deck-carousel {
    perspective: 1000px;
    overflow: visible;
  }

  .deck-carousel-track {
    position: relative;
    flex: 1;
    min-height: 520px;
  }

  /* 황금비 세로 카드 (1:1.618) — 2단계/3단계 동일 크기 */
  .deck-card {
    position: absolute;
    width: 320px;
    height: 518px;
    left: 50%;
    top: 50%;
    margin-left: -160px;
    margin-top: -259px;
  }

  .deck-indicators {
    display: none !important;
  }

  /* 탭 바 fade 불필요 */
  .deck-tabs-fade {
    display: none;
  }

  /* 정렬: 모바일 셀렉트 숨김 */
  .deck-sort-select {
    display: none;
  }

  /* 집중 모드: 배경 블러 + dim, 카드 크기에 맞춤 */
  .deck-focus-overlay {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }

  .deck-focus-header {
    background: var(--bg-primary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-width: 480px;
    width: 100%;
  }

  .deck-focus-content {
    background: var(--bg-primary);
    max-width: 480px;
    width: 100%;
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
    flex: none;
  }

  .deck-focus-editor {
    background: var(--bg-primary);
    max-width: 480px;
    width: 100%;
    padding: 24px;
    max-height: 60vh;
    flex: none;
  }

  .deck-focus-nav {
    background: var(--bg-primary);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    max-width: 480px;
    width: 100%;
  }
}

/* --- 4-3. 모바일 flat 스와이프 (< 768px) --- */
@media (max-width: 767px) {
  .deck-carousel {
    overflow: hidden;
  }

  .deck-carousel-track {
    position: relative;
    padding: 16px 0;
  }

  .deck-card {
    position: absolute;
    width: min(calc(100vw - 80px), 320px);
    height: calc(100% - 32px);
    max-height: 420px;
    left: 50%;
    top: 50%;
    /* JS carousel sets transform including centering offsets */
  }

  .deck-indicators {
    display: flex;
  }

  /* 탭 바: 가로 스크롤 + fade 힌트 */
  .deck-tabs-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .deck-tabs-scroll::-webkit-scrollbar {
    display: none;
  }

  .deck-tabs-fade {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to right, transparent, var(--bg-primary));
    pointer-events: none;
  }

  /* 정렬: 데스크탑 버튼 숨기고 모바일 셀렉트만 */
  .deck-sort-btn {
    display: none;
  }

  /* 집중 모드: 풀스크린 + 블러 */
  .deck-focus-overlay {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .deck-focus-content {
    padding: 16px;
  }

  .deck-focus-title {
    font-size: 1.3rem;
  }
}
