:root {
  --bg: #0e0e10;
  --surface: #18181b;
  --surface-2: #1f1f23;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --line: #2a2a30;
  --ember: #ff5c38;     /* 운영일수 = 점수 색 */
  --live: #3ddc84;      /* still-live dot */
  --accent: #ff5c38;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* 헤더 — 큐레이션 선언 */
.header {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 20px 16px;
}
.header h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.header .sub {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}
.header .sub b { color: var(--ember); }

/* 통과 전 필터 잠금 — 흐릿하게, 누르면 게이트로 유도 */
body.locked .topics, body.locked .attrs { opacity: .45; }
body.locked .topic, body.locked .attr { cursor: pointer; }

/* 1줄: 주제(키워드) — 큰 칩 */
.topics {
  max-width: 1080px;
  margin: 18px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.topic {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s;
  min-height: 42px;
}
.topic[aria-selected="true"] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.topic .n { opacity: .55; font-weight: 500; margin-left: 5px; }

/* 2줄: 속성 — 작은 텍스트 토글 */
.attrs {
  max-width: 1080px;
  margin: 10px auto 8px;
  padding: 0 20px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.attr {
  background: none;
  border: none;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
}
.attr[aria-selected="true"] { color: var(--ember); }
.attr .n { opacity: .5; font-weight: 500; margin-left: 3px; }
.attr + .attr::before {
  content: "·";
  color: var(--line);
  margin-right: 8px;
}

/* 그리드 */
.grid {
  max-width: 1080px;
  margin: 8px auto 80px;
  padding: 12px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
/* 게이트 켜짐: 그리드 아래로 갈수록 사라지는 mask(정석, PaidMembershipsPro).
   첫 줄 선명 → 둘째 줄 fade-out. 게이트 카드는 그리드 밖 형제라 mask 영향 없음.
   picsum식 픽셀 계산 없이 CSS만으로 "뒤에 더 있다" 표현. */
.grid.gated {
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent 78%);
          mask-image: linear-gradient(to bottom, #000 45%, transparent 78%);
}

/* 카드 — Foreplay 1:1 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
}
.card-head .adv {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.card-head .ext {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px;
  min-width: 28px;
  text-align: center;
}
.card-head .ext:hover { color: var(--text); }

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px 8px;
  font-size: 13px;
}
.badge {
  font-weight: 800;
  color: var(--ember);
  font-size: 15px;
}
.badge .u { font-weight: 600; font-size: 12px; color: var(--muted); margin-left: 2px; }
.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 3px rgba(61,220,132,.18);
  margin-left: auto;
}

/* 미디어 — full-bleed, 고정 비율. 단 미디어 없으면 컴팩트 */
.media {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--surface-2);
  overflow: hidden;
}
.card.no-media .media { aspect-ratio: auto; min-height: 84px; }
.media img, .media video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 영상 커스텀 컨트롤 오버레이 — 정지 시 ▶ 버튼 + 지속시간 표시, 재생 중엔 숨김 */
.video-wrap { position: absolute; inset: 0; cursor: pointer; }
.video-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 중앙 재생 버튼 (반투명 검정 원 + 흰 삼각형) */
.video-play {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 48px; height: 48px;
  border: none; border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .18s, transform .18s, background .18s;
  pointer-events: none;   /* 클릭은 wrap이 받는다 */
}
.video-play::before {
  content: "";
  width: 0; height: 0;
  border-style: solid;
  border-width: 9px 0 9px 15px;
  border-color: transparent transparent transparent #fff;
  margin-left: 3px;   /* 삼각형 시각 중심 보정 */
}
.video-wrap:hover .video-play { background: rgba(0, 0, 0, .72); transform: translate(-50%, -50%) scale(1.06); }

/* 지속시간 배지 (우하단) */
.video-time {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0, 0, 0, .65);
  color: #fff; font-size: 12px; font-weight: 600;
  padding: 2px 7px; border-radius: 6px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.video-time:empty { display: none; }   /* metadata 로드 전엔 숨김 */

/* 재생 중이면 버튼·시간 숨겨 영상에 집중 */
.video-wrap.playing .video-play,
.video-wrap.playing .video-time { opacity: 0; }

.media .placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; color: var(--muted); font-size: 13px;
}
.media .placeholder a {
  color: var(--text); text-decoration: none;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; font-size: 13px;
}
.media .placeholder a:hover { border-color: var(--accent); color: var(--accent); }

/* 후킹 — 3줄 clamp */
.hook {
  padding: 10px 12px 14px;
  font-size: 14px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 소프트 게이트 — 그리드 위에 겹치는 오버레이. 미리보기 둘째 줄이 fade 뒤로 반쯤 걸쳐
   "여기서 막혔다 + 뒤에 더 있다"를 표현. 뒤 카드는 렌더 안 함 → 우회 불가.
   그리드(.gated=relative) 하단에 붙어 카드 아래쪽 ~55%를 fade로 덮는다. */
/* 게이트 카드 — 그리드 기준 absolute 오버레이. mask된 카드 위에 겹쳐 뜬다.
   top을 %로 잡아 둘째 줄 근처에 오게 → 화면/콘텐츠 변화에도 픽셀 재계산 불필요.
   mask:none으로 게이트만 선명(그리드 mask 상속 해제). */
.gate-block {
  position: absolute;
  left: 0; right: 0;
  top: 52%;                      /* 그리드 세로 52% 지점 = 둘째 줄 중상단에 게이트가 얹힘 */
  padding: 0 20px;
  z-index: 5;
  display: flex;
  justify-content: center;
  -webkit-mask: none;
          mask: none;
}
.gate-card {
  position: relative;
  pointer-events: auto;          /* 오버레이는 통과, 카드만 클릭·입력 가능 */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  max-width: 440px;
  margin: 0 auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.gate-card .pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px;
  font-size: 13px; color: var(--text); margin-bottom: 16px;
}
.gate-card .pill b { color: var(--ember); }
.gate-card h2 { font-size: 19px; font-weight: 800; margin: 0 0 6px; letter-spacing: -0.01em; }
.gate-card p { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.gate-form { display: flex; gap: 8px; }
.gate-form input {
  flex: 1; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; color: var(--text);
  font-size: 15px; min-height: 46px;
}
.gate-form input:focus { outline: none; border-color: var(--accent); }
.gate-form button {
  background: var(--accent); color: #fff; border: none;
  border-radius: 10px; padding: 0 18px; font-size: 15px; font-weight: 700;
  cursor: pointer; min-height: 46px; white-space: nowrap;
}
.gate-form button:disabled { opacity: .6; cursor: default; }
.gate-card .err { color: #ff6b6b; font-size: 13px; margin-top: 8px; min-height: 16px; }

/* 성공 토스트 */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 12px 20px; border-radius: 999px; font-weight: 700; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 50;
  opacity: 0; transition: opacity .25s;
}
.toast.show { opacity: 1; }

/* 요청 보내기 위젯 — 우측 하단 플로팅 + 팝오버 (모달 아님, 백드롭 없음) */
.req {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 60;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}
.req-fab {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ember); color: #fff; border: none;
  border-radius: 999px; padding: 12px 18px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  min-height: 48px;
  transition: transform .12s, box-shadow .12s;
}
.req-fab:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(255,92,56,.35); }
.req-fab-ico { font-size: 15px; line-height: 1; }

/* 팝오버 — 기본 숨김. 열릴 때 fade+slide */
.req-pop {
  width: 320px; max-width: calc(100vw - 40px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  opacity: 0; transform: translateY(8px);
  pointer-events: none;
  transition: opacity .16s, transform .16s;
}
.req.open .req-pop { opacity: 1; transform: translateY(0); pointer-events: auto; }
.req.open .req-fab { display: none; }   /* 열리면 버튼 숨겨 중복 안 보이게 */

.req-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.req-head b { font-size: 15px; font-weight: 800; flex: 1; letter-spacing: -0.01em; }
.req-x {
  background: none; border: none; color: var(--muted);
  font-size: 14px; cursor: pointer; padding: 4px; line-height: 1;
  min-width: 28px; min-height: 28px;
}
.req-x:hover { color: var(--text); }
.req-desc { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.req-form { display: flex; flex-direction: column; gap: 6px; }
.req-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.req-opt { font-weight: 500; opacity: .8; }
.req-form textarea, .req-form input {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; color: var(--text);
  font-size: 14px; font-family: inherit; width: 100%; resize: vertical;
}
.req-form textarea { min-height: 64px; }
.req-form input { min-height: 44px; }
.req-form textarea:focus, .req-form input:focus { outline: none; border-color: var(--accent); }
.req-send {
  background: var(--accent); color: #fff; border: none;
  border-radius: 10px; padding: 0 18px; font-size: 14px; font-weight: 700;
  cursor: pointer; min-height: 44px; margin-top: 8px;
}
.req-send:disabled { opacity: .6; cursor: default; }
.req-err { color: #ff6b6b; font-size: 12px; min-height: 15px; margin-top: 2px; }

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px; }
  .header { padding: 28px 16px 12px; }
  .header h1 { font-size: 22px; }
  /* 모바일도 2줄(미리보기 4개)이지만 카드가 세로로 길다.
     첫 줄(그리드 ~78%까지)은 선명하게 두고, 둘째 줄만 fade + 게이트가 둘째 줄 상단에 얹힘. */
  .grid.gated {
    -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 96%);
            mask-image: linear-gradient(to bottom, #000 72%, transparent 96%);
  }
  .gate-block { top: 68%; }
  .req { right: 14px; bottom: 14px; }
  .req-fab-txt { display: none; }   /* 모바일은 아이콘만 */
  .req-fab { padding: 14px; }
}
