/* ── 변수 ───────────────────────────────────── */
:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --border: rgba(255,255,255,.08);
  --border-hover: rgba(255,255,255,.15);
  --text: #e8e8f0;
  --text-muted: rgba(232,232,240,.5);
  --text-dim: rgba(232,232,240,.72);
  --accent: #c8a96e;
  --accent2: #e8c98a;
  --green: #4ade80;
  --yellow: #fbbf24;
  --red: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --font-serif: 'Nanum Myeongjo', Georgia, serif;
  --font-sans: 'Pretendard', -apple-system, system-ui, sans-serif;
}

/* ── 리셋 & 베이스 ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* 그레인 텍스처 */
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
}

/* ── 헤더 ───────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,10,15,.88);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 0;
  padding-top: max(14px, env(safe-area-inset-top));
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
}

.header-left { display: flex; flex-direction: column; gap: 2px; }

h1 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.clapperboard { font-size: 18px; }

.date-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.2px;
}

.refresh-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  flex-shrink: 0;
}

.refresh-btn:hover { border-color: var(--border-hover); color: var(--text); background: #22222e; }
.refresh-btn:active { transform: scale(.92) rotate(30deg); }

/* 업데이트 뱃지 */
.update-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 6px 0 8px;
  color: var(--text-muted);
  min-height: 28px;
}

.update-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.update-badge.fresh .update-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.update-badge.stale .update-dot { background: var(--yellow); }
.update-badge.fresh { color: rgba(74,222,128,.8); }
.update-next { color: var(--text-muted); }

/* ── 메인 ───────────────────────────────────── */
main {
  flex: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}

.summary-bar {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  padding: 2px 0;
}

/* 로딩 */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 20px;
}

.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { font-size: 13px; color: var(--text-muted); }

/* ── 카드 ───────────────────────────────────── */
.card-list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color .2s, transform .15s;
  animation: fadeUp .35s ease both;
}

.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 시간·채널 행 */
.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.time {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.3px;
}

.channel-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(200,169,110,.12);
  border: 1px solid rgba(200,169,110,.25);
  color: var(--accent2);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* 제목 행 */
.title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.3px;
}

/* 연령 배지 (제목 옆) */
.age-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  flex-shrink: 0;
  align-self: center;
}

.age-badge.all {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.5);
  border: 1px solid rgba(255,255,255,.1);
}

.age-badge.age12, .age-badge.age15 {
  background: rgba(251,191,36,.12);
  color: var(--yellow);
  border: 1px solid rgba(251,191,36,.25);
}

.age-badge.age19 {
  background: rgba(248,113,113,.12);
  color: var(--red);
  border: 1px solid rgba(248,113,113,.25);
}

/* 태그 */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tag {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

/* 줄거리 */
.plot {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 런타임 */
.runtime {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── 빈 상태 / 에러 ─────────────────────────── */
.empty-panel, .error-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 56px 20px;
  text-align: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.empty-icon, .error-icon { font-size: 36px; }
.empty-title, .error-title { font-size: 15px; font-weight: 700; }
.empty-desc, .error-desc { font-size: 13px; color: var(--text-muted); }

.retry-btn {
  margin-top: 6px;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1px solid var(--border-hover);
  background: var(--bg3);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.retry-btn:hover { background: #22222e; }

/* ── 푸터 ───────────────────────────────────── */
footer {
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.channel-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.footer-copy {
  font-size: 11px;
  color: rgba(232,232,240,.3);
}

/* ── 모바일 반응형 ───────────────────────────── */
@media (max-width: 480px) {
  main { padding: 12px 12px; }
  h1 { font-size: 18px; }
  .title { font-size: 16px; }
  .card { padding: 14px; }
  .time-row { margin-bottom: 6px; }
}

/* ── 포스터 레이아웃 ────────────────────────── */
.card-inner {
  display: flex;
  gap: 14px;
}

.poster-wrap {
  flex-shrink: 0;
  width: 80px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  background: #1e1e2a;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.poster-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .3s;
}

.poster-placeholder {
  font-size: 28px;
  opacity: .35;
}

.card-body {
  flex: 1;
  min-width: 0;
}

/* 모바일에서 포스터 크기 조정 */
@media (max-width: 380px) {
  .poster-wrap { width: 66px; height: 100px; }
}

/* ── 탭바 ──────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  padding: 10px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}

.tab-btn.active {
  background: var(--accent);
  color: #0a0a0f;
  border-color: var(--accent);
}

/* ── 평점/감독/출연진 ────────────────────────── */
.movie-rating {
  font-size: 12px;
  color: #fbbf24;
  margin-left: 6px;
  font-weight: 600;
}

.movie-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 4px 0;
}

.movie-director,
.movie-cast {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── 장르/키워드 태그 구분 ───────────────────── */
.tag-genre {
  background: var(--accent);
  color: #0a0a0f;
  font-weight: 700;
  border-color: var(--accent);
}

.tag-keyword {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-weight: 400;
}
