/* 넷플 순위 — 단일 스타일시트. 전처리기·유틸리티 프레임워크 없음.
   모바일 360px 기준. 가로 스크롤이 생기지 않아야 한다. */

:root {
  --bg: #141414;
  --surface: #1f1f1f;
  --surface-2: #2a2a2a;
  --text: #f2f2f2;
  --text-dim: #a3a3a3;
  --accent: #e50914;
  --warn: #f5c518;
  --line: #333;
  --radius: 10px;
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR",
               "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

.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;
}

/* ── 헤더 ─────────────────────────────────────────────── */

.hdr {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-top));
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(20, 20, 20, 0.96);
  border-bottom: 1px solid var(--line);
}

.hdr__title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.hdr__meta {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ── 데이터 신선도 경고 ──────────────────────────────────
   수집이 며칠째 실패해도 앱은 지난 데이터를 정상처럼 보여준다.
   Actions 시절엔 GitHub 이 실패 메일을 보냈지만 로컬 러너에는 그게 없다.
   그래서 앱 자신이 감시자가 된다 — 헤더가 노랗게 변하는 것이 알림이다. */

.hdr--stale {
  background: rgba(60, 45, 0, 0.96);
  border-bottom-color: var(--warn);
}

/* 경고 문구는 제목·갱신일 아래 한 줄을 통째로 차지한다.
   헤더가 flex 라 기본폭 100%를 줘야 줄바꿈이 된다. */
.hdr__stale {
  flex: 0 0 100%;
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--warn);
}

.hdr--stale .hdr__meta {
  color: var(--warn);
}

/* ── 토스트 ───────────────────────────────────────────────
   카드를 누르면 제목이 복사된다. 그 사실을 알리는 유일한 신호다.
   화면을 가리지 않도록 아래쪽에 잠깐 떴다 사라진다. */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.94);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  /* 넘칠 때 말줄임. 제목이 길어도 한 줄을 유지한다 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  /* 탭을 가로채지 않는다 */
  pointer-events: none;
}

.toast--on {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 0.01s, visibility 0.01s; transform: translate(-50%, 0); }
}

/* ── 탭 ───────────────────────────────────────────────── */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.tab {
  flex: 1;
  min-height: var(--tap);
  padding: 10px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ── 컨트롤 ───────────────────────────────────────────── */

.controls {
  padding: 10px 14px 6px;
  display: grid;
  gap: 8px;
}

.controls__row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.controls__row--seg { justify-content: space-between; }

.select {
  min-height: var(--tap);
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.select--period { flex: 0 1 130px; }

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.seg__btn {
  min-height: var(--tap);
  min-width: 64px;
  padding: 8px 14px;
  border: 0;
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.seg__btn[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
}

.range {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ── 리스트 ───────────────────────────────────────────── */

.list {
  display: grid;
  gap: 10px;
  padding: 8px 14px 28px;
}

.card {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  position: relative;
}

.card--seen { opacity: 0.4; }

.card__main {
  display: flex;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* ── 포스터 ───────────────────────────────────────────── */

.poster {
  position: relative;
  flex: 0 0 80px;
  width: 80px;
  height: 120px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
}

.poster__img {
  width: 80px;
  height: 120px;
  object-fit: cover;
  display: block;
}

.poster__fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 800;
  color: #6b6b6b;
}

.poster__rank {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 24px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  border-bottom-right-radius: 6px;
}

/* ── 카드 본문 ────────────────────────────────────────── */

.body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.body__title {
  font-weight: 700;
  font-size: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.body__badges {
  font-size: 12px;
  color: var(--text-dim);
}

.body__overview {
  font-size: 13px;
  color: #c9c9c9;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.body__overview--empty { color: #6b6b6b; font-style: italic; }

/* ── 봤음 토글 ────────────────────────────────────────── */

.check {
  flex: 0 0 var(--tap);
  align-self: flex-end;
  width: var(--tap);
  height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: #5a5a5a;
  cursor: pointer;
}

.check[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── 상태 ─────────────────────────────────────────────── */

.status {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-dim);
  display: grid;
  gap: 14px;
  justify-items: center;
}

.status__retry {
  min-height: var(--tap);
  padding: 10px 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* ── 스켈레톤 ─────────────────────────────────────────── */

.card--skeleton .poster,
.card--skeleton .skel-line {
  background: linear-gradient(90deg, #232323 25%, #2e2e2e 37%, #232323 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}

.card--skeleton .body { justify-content: center; gap: 8px; width: 100%; }

.skel-line { height: 12px; border-radius: 4px; }
.card--skeleton .skel-line:nth-child(1) { width: 65%; }
.card--skeleton .skel-line:nth-child(2) { width: 40%; }
.card--skeleton .skel-line:nth-child(3) { width: 90%; }

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .card--skeleton .poster,
  .card--skeleton .skel-line { animation: none; }
}
