/* ThumbPop — vanilla CSS, 빌드툴 없음.
   색은 전부 변수로 → M3에서 라이트/다크 토글 붙이기 쉽게.
   기본값 = 라이트 (유튜브 라이트 테마 기준). */

:root {
  /* 앱 셸(좌측 입력/헤더) 색 — 유튜브와 무관, ThumbPop UI */
  --app-bg: #f4f5f7;
  --app-panel: #ffffff;
  --app-border: #e3e5e8;
  --app-text: #0f1115;
  --app-muted: #5c6370;
  --app-accent: #ff2d55;

  /* 유튜브 미리보기 영역 색 (라이트 테마) */
  --yt-bg: #ffffff;
  --yt-title: #0f0f0f;
  --yt-meta: #606060;
  --yt-skeleton: #e5e5e5;
  --yt-badge-bg: rgba(0, 0, 0, 0.8);
  --yt-badge-text: #ffffff;

  /* 데스크톱 추천 그리드 — 실제 픽셀 기준 (16:9) */
  --thumb-w: 360px;
  --thumb-h: 202px; /* 360 * 9/16 = 202.5 */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Roboto", "Noto Sans KR", -apple-system, BlinkMacSystemFont,
    "Segoe UI", system-ui, sans-serif;
  background: var(--app-bg);
  color: var(--app-text);
  -webkit-font-smoothing: antialiased;
}

/* ── 헤더 ──────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 16px 24px;
  background: var(--app-panel);
  border-bottom: 1px solid var(--app-border);
  flex-wrap: wrap;
}
.brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand span { color: var(--app-accent); }
.tagline {
  margin: 0;
  font-size: 13px;
  color: var(--app-muted);
}

/* 언어 셀렉터 (헤더 오른쪽 끝으로) */
.lang-picker { margin-left: auto; }
#lang-select {
  font-family: inherit;
  font-size: 13px;
  color: var(--app-text);
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  cursor: pointer;
}
#lang-select:focus { outline: none; border-color: var(--app-accent); }

/* 스크린리더 전용 (시각적으로 숨김) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── 2단 레이아웃 ──────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  padding: 20px 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 18px;
}
.panel-title {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--app-muted);
}

/* ── 입력 패널 ─────────────────────────────────────────────────── */
.dropzone {
  position: relative;
  border: 2px dashed var(--app-border);
  border-radius: 10px;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  background: #fafbfc;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--app-accent);
  outline: none;
}
.dropzone.dragover {
  border-color: var(--app-accent);
  background: #fff5f7;
}
.dropzone.has-image { border-style: solid; }
.dropzone-empty { padding: 16px; pointer-events: none; }
.dropzone-icon {
  font-size: 28px;
  color: var(--app-accent);
  line-height: 1;
  margin-bottom: 8px;
}
.dropzone-text {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--app-text);
}
.dropzone-hint {
  margin: 0;
  font-size: 11px;
  color: var(--app-muted);
}
.dropzone-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.field {
  display: block;
  margin-top: 14px;
}
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--app-muted);
  margin-bottom: 5px;
}
.field-label em {
  font-style: normal;
  font-weight: 400;
  opacity: 0.7;
}
.field input,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--app-text);
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--app-accent);
}
.field textarea {
  resize: vertical;
  min-height: 56px;
  line-height: 1.4;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* 입력 패널 보조 텍스트 */
.field-hint {
  margin: 6px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--app-muted);
}
.field-error {
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--app-accent);
}

/* ── 경쟁자 추가: URL 인풋 + 추가 버튼 ─────────────────────────── */
.competitor-add {
  display: flex;
  gap: 8px;
}
.competitor-add input {
  flex: 1;
  min-width: 0;
}
#competitor-add-btn {
  flex: 0 0 auto;
  padding: 0 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--app-accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s;
}
#competitor-add-btn:hover { filter: brightness(0.94); }
#competitor-add-btn:active { filter: brightness(0.88); }

/* ── 추가된 경쟁자 칩(작은 썸네일 + 제거 버튼) ─────────────────── */
.competitor-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.competitor-chip {
  position: relative;
  width: 76px;
}
.competitor-chip-thumb {
  width: 76px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: var(--yt-skeleton);
}
.competitor-chip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.competitor-remove,
.variant-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  color: #fff;
  background: #1a1d23;
  border: 2px solid var(--app-panel);
  border-radius: 50%;
  cursor: pointer;
}
.competitor-remove:hover,
.variant-remove:hover { background: var(--app-accent); }

/* ── A/B 변형 스트립 (내 썸네일 A/B/C 관리) ────────────────────── */
.variant-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.variant-chip { position: relative; width: 76px; }
.variant-chip-thumb {
  position: relative;
  width: 76px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: var(--yt-skeleton);
  outline: 2px solid var(--app-accent);
  outline-offset: 1px;
}
.variant-chip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.variant-chip-badge {
  position: absolute;
  top: 3px;
  left: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--app-accent);
  border-radius: 4px;
}
.variant-add-tile { width: 76px; }
.variant-add-btn {
  width: 76px;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  color: var(--app-muted);
  background: #fafbfc;
  border: 2px dashed var(--app-border);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.variant-add-btn:hover {
  color: var(--app-accent);
  border-color: var(--app-accent);
}

/* 미리보기 카드 썸네일 위 A/B/C 뱃지 (변형 2개 이상일 때) */
.yt-variant-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: var(--app-accent);
  border-radius: 6px;
}

/* ── 미리보기 컨트롤 (컨텍스트 탭 / 테마 토글) ─────────────────── */
.preview-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.context-tabs,
.theme-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 9px;
}
.context-tab,
.theme-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--app-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
}
.context-tab:hover:not(.is-active),
.theme-btn:hover:not(.is-active) { color: var(--app-text); }
.context-tab.is-active,
.theme-btn.is-active {
  background: var(--app-panel);
  color: var(--app-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ── 미리보기 무대 ─────────────────────────────────────────────── */
.preview-stage {
  background: var(--yt-bg);
  border-radius: 10px;
  padding: 16px;
  overflow-x: auto;
  transition: background 0.15s;
}

/* 다크 테마 — 무대에 --yt-* 변수만 다시 깔면 자식 색이 전부 따라온다. */
.preview-stage.is-dark {
  --yt-bg: #0f0f0f;
  --yt-title: #f1f1f1;
  --yt-meta: #aaaaaa;
  --yt-skeleton: #272727;
  --yt-badge-bg: rgba(0, 0, 0, 0.8);
  --yt-badge-text: #ffffff;
}

/* ── 유튜브 데스크톱 추천 그리드 (실제 픽셀) ───────────────────── */
.yt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--thumb-w));
  gap: 16px 16px;
  justify-content: start;
}

.yt-card { width: var(--thumb-w); }

.yt-thumb {
  position: relative;
  width: var(--thumb-w);
  height: var(--thumb-h);
  border-radius: 12px;
  overflow: hidden;
  background: var(--yt-skeleton);
}
.yt-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.yt-duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 1px 4px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--yt-badge-text);
  background: var(--yt-badge-bg);
  border-radius: 4px;
}

.yt-info {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}
.yt-avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--yt-skeleton);
  overflow: hidden;
}
.yt-avatar.is-mine {
  background: var(--app-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
}
.yt-text { min-width: 0; flex: 1; }
.yt-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--yt-title);
  /* 유튜브처럼 2줄 클램프 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.yt-title.placeholder { color: var(--yt-meta); font-weight: 400; }
.yt-channel {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 18px;
  color: var(--yt-meta);
}
.yt-meta {
  margin: 0;
  font-size: 12px;
  line-height: 18px;
  color: var(--yt-meta);
}

/* 내 카드 강조 (미리보기에서 어느 게 내 건지 알아보게 — 출시 전엔 끌 수도) */
.yt-card.is-mine .yt-thumb {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

/* 자리표시용 빈 카드 (경쟁자 없을 때) + 경쟁자 카드의 중립 텍스트 라인 공용 */
.yt-card.skeleton .yt-thumb { background: var(--yt-skeleton); }
.sk-line {
  height: 12px;
  border-radius: 4px;
  background: var(--yt-skeleton);
  margin-top: 8px;
}
.sk-line.short { width: 60%; }

/* 경쟁자 카드 — 실제 썸네일, 텍스트는 중립 회색(시선은 썸네일에). */
.yt-card.is-competitor .yt-thumb { background: var(--yt-skeleton); }

/* ── 컨텍스트: 데스크톱 검색 결과 (썸네일 좌 + 텍스트 우) ───────── */
.yt-search {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.yt-row {
  display: flex;
  gap: 16px;
  max-width: 720px;
}
.yt-row .yt-thumb { flex: 0 0 var(--thumb-w); }
.yt-row-info {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
}
.yt-row-title {
  margin: 0;
  font-size: 18px;
  line-height: 26px;
  font-weight: 500;
  color: var(--yt-title);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.yt-row-title.placeholder { color: var(--yt-meta); font-weight: 400; }
.yt-row-meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--yt-meta);
}
.yt-row-channel {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--yt-meta);
}
.yt-row-channel .yt-avatar {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  font-size: 11px;
}
/* 검색 행 스켈레톤 라인 — 실제 폭감 흉내 */
.yt-row-info .sk-line.title { height: 18px; width: 70%; margin-top: 2px; }
.yt-row-info > .sk-line.short { width: 45%; }
.yt-row-channel .sk-line.tiny {
  width: 96px;
  height: 10px;
  margin-top: 0;
}

/* ── 컨텍스트: 모바일 피드 (단일 컬럼, 풀폭 썸네일) ──────────────── */
.yt-mobile {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 400px;
  margin: 0 auto;
}
.yt-mobile .yt-card { width: 100%; }
.yt-mobile .yt-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}
