/* 카드 목록: 카드, 펼친 카드, 하트, TOP 10 순위·Pick, 좁은 카드, 안내 표시, 관리자 수정 버튼 */

/* 카드: 전체가 사이트 링크(.card-link 확장), 만든 사람 링크만 그 위에 따로 */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.card:hover,
.card:focus-within {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 16px 36px -20px rgba(0, 0, 0, .4);
}

.card { cursor: pointer; }

.card-link {
  color: inherit;
  text-decoration: none;
  outline: none;
}

.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 1;
}

.card-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }

.thumb {
  position: relative;
  aspect-ratio: 1200 / 630;
  background: var(--thumb);
  border-radius: 12px;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s ease;
}

.card:hover .thumb img { transform: scale(1.04); }

.thumb-label {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(20, 18, 16, .62);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff6ec;
  font-size: 12px;
  font-weight: 600;
}

.thumb-fallback {
  height: 100%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 30%, #f0a35e 0%, #b4532a 45%, #2a1710 100%);
  color: #fff6ec;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.card-main { position: relative; flex: 1; display: flex; flex-direction: column; }

.body {
  padding: 12px 6px 10px;
  flex: 1;
}

.card h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 첫 클릭 때 카드 위로 펼쳐지는 자세한 정보 (클릭은 아래 링크로 그대로 전달) */
.detail {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .2s ease, transform .2s ease;
}

.card.open .detail { opacity: 1; transform: none; z-index: 2; }

/* 펼친 카드 안의 '더 알아보기' → 사이트별 소개 페이지 (이 링크만 클릭을 받음) */
.detail-more {
  align-self: flex-start;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.card.open .detail-more { pointer-events: auto; }
.card.open .thumb img { transform: none; }

.detail p { margin: 0; }
.detail-name { font-size: 12px; font-weight: 600; color: var(--accent); }
.detail-title { font-size: 15px; font-weight: 700; line-height: 1.4; letter-spacing: -.01em; }

.detail-desc {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.detail-host { margin-top: auto !important; font-size: 12px; color: var(--muted); opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 아래 줄: 기본 = 서버 상태 ← → 하트 · 입장 / 활성화 = 자세히보기 ← → 하트 · 입장 */
.foot-row .comment-link { margin-left: auto; }

/* 카드 말풍선: 의견 수 → 상세 페이지 의견으로 */
.comment-link { display: inline-flex; align-items: center; gap: 4px; padding: 6px 9px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; text-decoration: none; line-height: 1; }
.comment-link svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.comment-link:hover { color: var(--text); border-color: var(--text); }
.cta-details { display: none; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.cta-details:hover { color: var(--accent); }
.cta-enter { margin-left: 4px; font-size: 13px; font-weight: 700; color: var(--accent); text-decoration: none; white-space: nowrap; }
.cta-enter:hover { text-decoration: underline; text-underline-offset: 3px; }
.card.open .foot-row .health { display: none; }
.card.open .cta-details { display: inline; }

/* 설명: 기본 보기에서 항상, 자르지 않음 (같은 줄 카드 높이는 함께 맞춰짐) */
.card-desc { margin: 6px 0 0; font-size: 13px; line-height: 1.55; color: var(--muted); }
.card-pick { color: var(--text); }
.card-pick::before { content: "“"; margin-right: 2px; color: #c99a1c; font-weight: 800; }

/* 움직이는 미리보기(GIF): 활성화되면 썸네일 위에 */
.thumb-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.card.open .thumb-preview[src] { opacity: 1; }
.card.open { border-color: var(--accent); }

.card-foot {
  display: grid;
  gap: 10px;
  margin: 0 -8px -8px;
  padding: 10px 12px 12px;
  border-top: 1px dashed var(--line);
}

/* 하트 · 서버 상태 · 자세히보기/입장 */
.foot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.foot-row .enter { margin-left: auto; white-space: nowrap; }

.creator {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  justify-self: start;
  max-width: 100%;
}

a.creator:hover .creator-text { color: var(--accent); }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f0a35e, #b4532a);
  color: #fff6ec;
  font-size: 13px;
  font-weight: 700;
}

.creator-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.creator-text small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}



.enter {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

@media (max-width: 480px) {
  .page { padding: 48px 16px 40px; }
}

/* 모바일 2열: 작게, 서버 상태는 점만 */
@media (max-width: 640px) {
  .card { padding: 6px; border-radius: 14px; }
  .thumb { border-radius: 9px; }
  .thumb-label { display: none; }
  .body { padding: 9px 4px 8px; }
  .card h2 { font-size: 13.5px; }
  .card-foot { margin: 0 -6px -6px; padding: 8px 8px 10px; gap: 8px; }
  .foot-row { gap: 6px; }
  .creator { gap: 6px; font-size: 12px; }
  .avatar { width: 22px; height: 22px; font-size: 11px; }
  .creator-text small { display: none; }
  .health-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .enter { font-size: 12px; }
  .heart { padding: 4px 8px 4px 6px; }
  .detail { padding: 10px 9px; gap: 4px; border-radius: 9px; }
  .detail-title { font-size: 13.5px; }
  .detail-desc { font-size: 12px; }
  .admin-edit { top: 12px; right: 12px; padding: 3px 9px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .thumb img { transition: none; }
  .card:hover { transform: none; }
}

.heart {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

.heart svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.heart:hover { color: #e0475b; border-color: #e0475b; }
.heart.on { color: #e0475b; border-color: color-mix(in srgb, #e0475b 40%, transparent); background: color-mix(in srgb, #e0475b 10%, var(--surface)); }
.heart.on svg { fill: currentColor; }
.heart:focus-visible { outline: 2px solid #e0475b; outline-offset: 2px; }
.heart.pop svg { animation: heart-pop .35s ease-out; }

@keyframes heart-pop {
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .heart.pop svg { animation: none; }
}
/* 하트 숫자: TOP 10에서만 (HEARTS_PUBLIC_COUNT=1 이면 항상) */
.grid:not(.grid-top):not(.hearts-public) .heart-count { display: none; }
.grid:not(.grid-top):not(.hearts-public) .heart,
.heart:not(:has(.heart-count)) { padding: 6px; }

/* 관리자로 로그인한 브라우저에서만 보이는 카드 '수정' 버튼 */
.admin-edit {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}

.admin-edit:hover { background: var(--accent); color: #fff; }

.card[hidden] { display: none; }

/* ── TOP 10 순위, Editor's Pick ── */
.rank-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, .5);
}
.pick-badge {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #f4c542;
  color: #2a2000;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
}
.card.picked { border-color: color-mix(in srgb, #f4c542 60%, var(--line)); }
.detail-pick { font-size: 13px; line-height: 1.55; }
.detail-pick strong { display: block; margin-bottom: 2px; font-size: 11px; color: #c99a1c; }

@media (max-width: 640px) {
  .rank-badge { left: 6px; bottom: 6px; min-width: 24px; height: 24px; font-size: 13px; }
  .pick-badge { right: 6px; top: 6px; font-size: 10px; padding: 2px 7px; }
  .detail-pick { font-size: 12px; }
}

/* 만든 사람: 아이디만 */
.creator { font-size: 12px; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.creator:hover { color: var(--accent); }
@media (max-width: 640px) { .creator { font-size: 11.5px; } }

/* TOP 10: PC에서는 한 줄에 5개 (5 × 2) */
@media (min-width: 1100px) {
  .grid-top { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
}

/* 카드 아래 줄이 좁을 때 (TOP 10 5열, 휴대폰 2열): 촘촘하게, 서버 상태는 점만,
   펼친 상태에선 '자세히보기'가 아래 줄에 */
.card-foot, .card .body { container-type: inline-size; }
@container (max-width: 215px) {
  .foot-row { gap: 5px; }
  .health-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .comment-link, .heart { padding: 5px 6px; gap: 3px; }
  .cta-enter { margin-left: 2px; }
  /* 펼치면 '자세히보기'가 아래 줄에 스르륵 나타남 (말풍선을 가리지 않게). 닫혀 있을 땐 빈칸 없음 */
  .foot-row { flex-wrap: wrap; row-gap: 0; }
  .foot-row .cta-details { display: block; order: 10; flex-basis: 100%; text-align: center; line-height: 20px;
    max-height: 0; margin-top: 0; overflow: hidden; opacity: 0; transition: max-height .2s ease, margin-top .2s ease, opacity .2s ease; }
  .card.open .foot-row .cta-details { max-height: 24px; margin-top: 8px; opacity: 1; }
}

/* 안내 표시 (로그인 필요·광고 있음…): 경고색 없이 회색 정보로 */
.card-notices { display: flex; flex-wrap: wrap; gap: 2px 10px; margin: 2px 0 8px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.card-notice { white-space: nowrap; }
.card-notice + .card-notice::before { content: "·"; margin-right: 10px; opacity: .6; }
@container (max-width: 215px) {
  .card-notice-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .card-notices { gap: 2px 6px; font-size: 14px; }
  .card-notice + .card-notice::before { content: none; }
}
