/* -------------------------------------------------------------
 * 해외 자막 음매드 모음 (Subtitled Otomad Archive) - Style
 * Cool Neutral 60-30-10 System + Single Accent (#4169E1)
 * ------------------------------------------------------------- */

/* 1. 라이트 모드 (Cool Neutral: #FAFAFA / #FFFFFF / #18181B) */
:root, [data-theme="light"] {
  --bg-canvas: #fafafa;                       /* 60% 무채색 기본 캔버스 */
  --bg-canvas-backdrop: rgba(250, 250, 250, 0.90);
  --bg-surface: #ffffff;                      /* 30% 카드·모달·드로어 표면 */
  --bg-subtle: #f4f4f5;                       /* 컨트롤 바, 칩, 서브 컨테이너 (Zinc-100) */
  --bg-hover: #e4e4e7;                        /* 호버 명도 단계 (Zinc-200) */
  --bg-input: #ffffff;                        /* 입력창 배경 */
  --bg-modal-backdrop: rgba(15, 17, 21, 0.48);

  --text-primary: #18181b;                    /* 핵심 텍스트 (Zinc-900, 순수 흑백 회피) */
  --text-secondary: #52525b;                  /* 보조 텍스트 (Zinc-600) */
  --text-muted: #71717a;                      /* 메타데이터·날짜 (Zinc-500, >= 4.5:1) */
  --text-link: #3558c7;                       /* 강조 링크 (명도 대비 >= 4.5:1) */

  --border-subtle: rgba(24, 24, 27, 0.08);    /* 기본 헤어라인 구분선 */
  --border-medium: rgba(24, 24, 27, 0.16);    /* 입력창·컨트롤 테두리 */
  --border-hairline: rgba(0, 0, 0, 0.08);     /* 썸네일 외곽 1px 헤어라인 */
  --border-focus: #4169e1;                    /* 단일 강조색 포커스 링 */

  /* 10% 단일 강조색 (Royal Blue) */
  --primary: #4169e1;
  --primary-hover: #3558c7;
  --primary-text: #ffffff;
  --primary-soft-bg: rgba(65, 105, 225, 0.09);
  --primary-soft-text: #2e52c4;
  --primary-soft-border: rgba(65, 105, 225, 0.28);

  /* 저채도 파스텔 Pill 배지 (Light) */
  --badge-yt-bg: #fbf1f2;
  --badge-yt-text: #883740;
  --badge-yt-border: rgba(136, 55, 64, 0.16);

  --badge-naver-bg: #eff7f2;
  --badge-naver-text: #276342;
  --badge-naver-border: rgba(39, 99, 66, 0.16);

  --badge-neutral-bg: #f4f4f5;
  --badge-neutral-text: #52525b;
  --badge-neutral-border: rgba(24, 24, 27, 0.10);

  /* 편집/경고 시맨틱 토큰 (편집 모드 및 모달 전용) */
  --accent-warn: #b45309;
  --accent-warn-bg: rgba(217, 119, 6, 0.10);
  --accent-warn-text: #92400e;
  --accent-warn-border: rgba(217, 119, 6, 0.30);

  --accent-danger: #dc2626;
  --accent-danger-bg: rgba(220, 38, 38, 0.08);
  --accent-danger-text: #b91c1c;
  --accent-danger-border: rgba(220, 38, 38, 0.24);

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.06);
  --scrollbar-thumb: #d4d4d8;
  --skeleton-base: #e4e4e7;
  --skeleton-highlight: #f4f4f5;
}

/* 2. 다크 모드 (Cool Neutral: #0F1115 / #181B20 / #F4F4F5) */
[data-theme="dark"] {
  --bg-canvas: #0f1115;                       /* 60% 다크 베이스 캔버스 */
  --bg-canvas-backdrop: rgba(15, 17, 21, 0.90);
  --bg-surface: #181b20;                      /* 30% 카드·모달·드로어 표면 */
  --bg-subtle: #20242b;                       /* 컨트롤 바, 칩, 서브 컨테이너 */
  --bg-hover: #2a2f38;                        /* 호버 명도 단계 */
  --bg-input: #14171c;                        /* 입력창 배경 */
  --bg-modal-backdrop: rgba(9, 11, 14, 0.72);

  --text-primary: #f4f4f5;                    /* 핵심 텍스트 (Zinc-100, 순수 흰색 회피) */
  --text-secondary: #a1a1aa;                  /* 보조 텍스트 (Zinc-400) */
  --text-muted: #8e95a2;                      /* 메타데이터·날짜 (>= 4.5:1) */
  --text-link: #8ca9ff;                       /* 다크 배경용 명도 보정 강조 링크 */

  --border-subtle: rgba(255, 255, 255, 0.10); /* 기본 헤어라인 구분선 */
  --border-medium: rgba(255, 255, 255, 0.16); /* 입력창·컨트롤 테두리 */
  --border-hairline: rgba(255, 255, 255, 0.10); /* 썸네일 외곽 1px 헤어라인 */
  --border-focus: #5b82f0;                    /* 다크 배경용 포커스 링 */

  /* 10% 단일 강조색 (Royal Blue, 다크 환경 명도 조정) */
  --primary: #4169e1;
  --primary-hover: #5278ea;
  --primary-text: #ffffff;
  --primary-soft-bg: rgba(91, 130, 240, 0.14);
  --primary-soft-text: #8ca9ff;
  --primary-soft-border: rgba(91, 130, 240, 0.30);

  /* 저채도 반투명 Pill 배지 (Dark) */
  --badge-yt-bg: rgba(190, 90, 100, 0.16);
  --badge-yt-text: #dfb0b5;
  --badge-yt-border: rgba(223, 176, 181, 0.18);

  --badge-naver-bg: rgba(74, 155, 110, 0.16);
  --badge-naver-text: #a4d4b8;
  --badge-naver-border: rgba(164, 212, 184, 0.18);

  --badge-neutral-bg: rgba(255, 255, 255, 0.06);
  --badge-neutral-text: #a1a1aa;
  --badge-neutral-border: rgba(255, 255, 255, 0.10);

  /* 편집/경고 시맨틱 토큰 (Dark) */
  --accent-warn: #eab308;
  --accent-warn-bg: rgba(234, 179, 8, 0.12);
  --accent-warn-text: #fde047;
  --accent-warn-border: rgba(234, 179, 8, 0.30);

  --accent-danger: #f87171;
  --accent-danger-bg: rgba(248, 113, 113, 0.12);
  --accent-danger-text: #fca5a5;
  --accent-danger-border: rgba(248, 113, 113, 0.28);

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-card-hover: 0 4px 14px rgba(0, 0, 0, 0.35);
  --scrollbar-thumb: #2a2f38;
  --skeleton-base: #1e2229;
  --skeleton-highlight: #282d36;
}

/* 테마 전환 시 즉각 일괄 반영 (순차 깜빡임 방지) */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  -webkit-transition: none !important;
  -moz-transition: none !important;
  -o-transition: none !important;
  -ms-transition: none !important;
  transition: none !important;
}

body {
  font-family: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  letter-spacing: -0.01em;
  overflow-x: hidden;
  text-align: left;
}

::selection {
  background-color: rgba(65, 105, 225, 0.28);
  color: var(--text-primary);
}

/* -------------------------------------------------------------
 * 공통 시맨틱 헬퍼 클래스
 * ------------------------------------------------------------- */
.theme-bg-canvas { background-color: var(--bg-canvas) !important; }
.theme-bg-surface { background-color: var(--bg-surface) !important; }
.theme-bg-subtle { background-color: var(--bg-subtle) !important; }
.theme-bg-input { background-color: var(--bg-input) !important; }
.theme-bg-hover:hover,
.theme-hover-bg:hover { background-color: var(--bg-hover) !important; }

.theme-text-main { color: var(--text-primary) !important; }
.theme-text-sub { color: var(--text-secondary) !important; }
.theme-text-muted { color: var(--text-muted) !important; }
.theme-text-link { color: var(--text-link) !important; }
.theme-hover-text:hover { color: var(--text-primary) !important; }

.theme-border-subtle { border-color: var(--border-subtle) !important; }
.theme-border-medium { border-color: var(--border-medium) !important; }
.theme-border-hairline { border-color: var(--border-hairline) !important; }

.theme-accent-btn {
  background-color: var(--primary);
  color: var(--primary-text);
  transition: background-color 0.16s ease;
}
.theme-accent-btn:hover {
  background-color: var(--primary-hover);
}

.theme-accent-text { color: var(--primary-soft-text); }
.theme-accent-soft {
  background-color: var(--primary-soft-bg);
  color: var(--primary-soft-text);
  border-color: var(--primary-soft-border);
}

.theme-focus-ring:focus {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 2px var(--primary-soft-bg);
}

/* 저채도 상태/플랫폼 Pill 배지 */
.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill-badge-yt {
  background-color: var(--badge-yt-bg);
  color: var(--badge-yt-text);
  border-color: var(--badge-yt-border);
}
.pill-badge-naver {
  background-color: var(--badge-naver-bg);
  color: var(--badge-naver-text);
  border-color: var(--badge-naver-border);
}
.pill-badge-neutral {
  background-color: var(--badge-neutral-bg);
  color: var(--badge-neutral-text);
  border-color: var(--badge-neutral-border);
}
.pill-badge-accent {
  background-color: var(--primary-soft-bg);
  color: var(--primary-soft-text);
  border-color: var(--primary-soft-border);
}

/* 가로 스크롤바 숨김 유틸리티 */
.no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* 기본 스크롤바 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-canvas);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* -------------------------------------------------------------
 * 카드 아이템 & 호버 인터랙션 (Layout Shift 금지, 200ms 이내 투명도/테두리 전환)
 * ------------------------------------------------------------- */
.card-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.card-item:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-card-hover);
}

/* 썸네일 컨테이너 (1px 헤어라인 보정) */
.thumb-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-hairline);
}
.thumb-frame-box {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  border-radius: 0.5rem;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
}
.thumb-frame img,
.thumb-frame-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

/* 썸네일 하단 반투명 스크림 */
.thumb-scrim {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.56) 0%, rgba(0, 0, 0, 0.14) 55%, transparent 100%);
}

/* 썸네일 퀵 재생 버튼 (호버/포커스 시 은은히 강조) */
.thumb-play-btn {
  opacity: 0.88;
  transition: opacity 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}
.group:hover .thumb-play-btn {
  opacity: 1;
}

/* 카드 내 아바타 아이콘 크기 */
.card-avatar-img {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  max-width: 20px !important;
  max-height: 20px !important;
  object-fit: cover;
  border-radius: 9999px;
  flex-shrink: 0;
  border: 1px solid var(--border-hairline);
}

/* 스켈레톤 로더 */
.skeleton {
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-highlight) 50%, var(--skeleton-base) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 텍스트 2줄 제한 */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 모달 페이드 & 슬라이드 드로어 */
.modal-fade {
  animation: modalIn 0.16s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes modalIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.drawer-slide-in {
  animation: drawerIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes drawerIn {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}

/* -------------------------------------------------------------
 * 컬렉션(재생목록) 카드 상단 덱 스택 효과 (Layout Shift 없는 정갈한 테두리 전환)
 * ------------------------------------------------------------- */
.playlist-card {
  position: relative;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.playlist-deck-stack {
  position: relative;
  width: 100%;
  padding-top: 8px;
}

.playlist-deck-layer-1 {
  position: absolute;
  top: 0;
  left: 6%;
  right: 6%;
  height: 10px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  background-color: var(--bg-subtle);
  border-top: 1px solid var(--border-medium);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  transition: border-color 0.18s ease, background-color 0.18s ease;
  z-index: 1;
}

.playlist-deck-layer-2 {
  position: absolute;
  top: 4px;
  left: 3%;
  right: 3%;
  height: 10px;
  border-top-left-radius: 9px;
  border-top-right-radius: 9px;
  background-color: var(--bg-hover);
  border-top: 1px solid var(--border-medium);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  transition: border-color 0.18s ease, background-color 0.18s ease;
  z-index: 2;
}

.playlist-thumb-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  box-shadow: var(--shadow-card);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  z-index: 3;
}

.group:hover .playlist-thumb-box {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-card-hover);
}
.group:hover .playlist-deck-layer-1,
.group:hover .playlist-deck-layer-2 {
  border-color: var(--border-medium);
}

/* -------------------------------------------------------------
 * 비주얼 웹 빌더 (WYSIWYG) 스타일
 * ------------------------------------------------------------- */
.builder-dragging {
  opacity: 0.4 !important;
  border: 1.5px dashed var(--accent-warn) !important;
  cursor: grabbing !important;
}

.builder-drag-target {
  border: 1.5px solid var(--primary) !important;
  box-shadow: 0 0 0 2px var(--primary-soft-bg) !important;
}

.builder-highlight-pulse {
  animation: builder-pulse 1.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes builder-pulse {
  0% {
    outline: 2px solid var(--primary);
    box-shadow: 0 0 18px var(--primary-soft-bg);
  }
  100% {
    outline: 2px solid transparent;
    box-shadow: none;
  }
}

.builder-inline-editable {
  border-radius: 4px;
  padding: 1px 4px;
  margin: -1px -4px;
  transition: background-color 0.15s ease, outline-color 0.15s ease;
  cursor: text;
}
.builder-inline-editable:hover {
  background: var(--primary-soft-bg);
  outline: 1px dashed var(--border-focus);
}
.builder-inline-editable:focus {
  background: var(--bg-subtle);
  outline: 1.5px solid var(--border-focus);
  color: var(--text-primary);
}

@keyframes slideUp {
  from {
    transform: translate(-50%, 16px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

.animate-slide-up {
  animation: slideUp 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 컴팩트 카드 밀도 스타일 */
.card-compact .card-body {
  padding: 0.625rem 0.75rem !important;
}
.card-compact h3 {
  font-size: 0.78rem !important;
  line-height: 1.3 !important;
}
