@charset "utf-8";

/* ================================================================
   공통 컴포넌트 — 태그, 버튼, 기사 카드, 광고 영역, 섹션 제목
   ================================================================ */

/* ---------- 카테고리 태그 (팔레트 색) ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-caption);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.tag--coral  { color: var(--coral-1);  background: var(--coral-5); }
.tag--teal   { color: var(--teal-1);   background: var(--teal-5); }
.tag--orange { color: var(--orange-1); background: var(--orange-5); }
.tag--green  { color: var(--green-1);  background: var(--green-5); }
.tag--purple { color: var(--purple-1); background: var(--purple-5); }
.tag--gray   { color: var(--gray-a2);  background: var(--gray-a5); }

.tag--lg {
  font-size: var(--fs-tag-lg);
  line-height: clamp(18px, calc(18px + 7.6 * var(--fluid)), 25.6px); /* 12/1.5 → 16/1.6 */
}

/* ---------- 버튼 ---------- */
.btn-gray {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  background: var(--gray-a5);
  color: var(--gray-a2);
  font-size: var(--fs-body2);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  transition: background-color var(--transition);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 24px;
  border-radius: var(--radius-btn);
  background: var(--primary);
  color: var(--white);
  font-size: var(--fs-title2);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  transition: background-color var(--transition);
}

.btn-primary:hover {
  background: #0069db;
}

/* ---------- 섹션 제목 ---------- */
.sec-title {
  margin-bottom: var(--title-to-list);
  padding-inline: var(--inset);
  color: var(--gray-a2);
  font-size: var(--fs-heading);
  font-weight: 700;
  line-height: 1.4;
}

/* ---------- 기사 카드 ----------
   MO: 태그 → 14 → 제목 → 12 → 설명(2줄) → 14 → 버튼   (바깥 기준 padding 16)
   PC: 태그 → 16 → 제목 → 16 → 설명(1줄) → 31 → 버튼   (바깥 기준 padding 17)
   버튼은 카드 바닥에 붙어서, 한 줄에 놓인 카드는 높이가 같아도 버튼 위치가 맞는다. */
.card {
  scroll-margin-top: calc(var(--header-h) + 8px); /* 키보드 이동 시 sticky 헤더에 가리지 않게 */
  display: flex;
  flex-direction: column;
  padding: clamp(15px, calc(15px + 1 * var(--fluid)), 16px);
  border: 1px solid var(--gray-a5);
  border-radius: var(--radius-lg);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: var(--gray-a4);
}

.card:hover .btn-gray,
a.btn-gray:hover {
  background: var(--gray-a4);
}

.card__tag {
  align-self: flex-start;
}

.card__title {
  display: -webkit-box;
  margin-top: clamp(14px, calc(14px + 2 * var(--fluid)), 16px);
  overflow: hidden;
  color: var(--gray-a2);
  font-size: var(--fs-title1);
  font-weight: 700;
  line-height: 1.4;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card__desc {
  display: -webkit-box;
  margin-top: clamp(12px, calc(12px + 4 * var(--fluid)), 16px);
  overflow: hidden;
  color: var(--gray-a3);
  font-size: var(--fs-body2);
  font-weight: 500;
  line-height: 1.5;
  -webkit-line-clamp: var(--card-desc-lines, 2);
  -webkit-box-orient: vertical;
}

.card__foot {
  margin-top: auto;
  padding-top: clamp(14px, calc(14px + 17 * var(--fluid)), 31px);
}

.card__chevron {
  display: none;
}

/* 카드 목록 */
.card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--list-gap);
}

.card-grid > li {
  display: flex;
}

.card-grid > li > .card {
  flex: 1;
  min-width: 0;
}

@media (min-width: 768px) {
  .card-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .card {
    --card-desc-lines: 1;
  }
}

@media (min-width: 1280px) {
  .card-grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ---------- 무한 스크롤 기사 목록 (카테고리·검색 결과) ----------
   --ad-every: 몇 개마다 광고를 넣을지 (js/feed.js 가 읽는다) — MO 3 / 2열 4(2행) / 4열 8(2행) */
.feed {
  --ad-every: 3;
}

.feed__ad {
  grid-column: 1 / -1;
}

.feed__ad > .ad-slot {
  flex: 1;
  min-width: 0;
}

.feed-status {
  padding: 24px 0 0;
  color: var(--gray-a3);
  font-size: var(--fs-body2);
  line-height: 1.5;
  text-align: center;
}

.feed-status:empty {
  padding-top: 0; /* 비어 있어도 role=status 노드는 남겨 둔다(스크린리더 알림) */
}

.feed-status:focus {
  outline: none;
}

.feed-status__retry {
  margin-left: 8px;
}

.feed-sentinel {
  height: 1px;
}

.feed-next-wrap {
  align-self: center;
}

.feed-next {
  margin-top: 24px;
}

.feed-empty {
  padding: 48px 0;
  color: var(--gray-a3);
  font-size: var(--fs-title3);
  text-align: center;
}

@media (min-width: 768px) {
  .feed {
    --ad-every: 4;
  }
}

@media (min-width: 1280px) {
  .feed {
    --ad-every: 8;
  }

  /* PC 시안: 광고 위 24 / 아래 8 (그리드 gap 16 기준으로 차이만 준다) */
  .feed__ad {
    margin-top: 8px;
    margin-bottom: -8px;
  }
}

/* 1열 목록(검색 결과): 모든 폭에서 3개마다 광고, 간격 MO 16 → PC 10 */
.feed.feed--list {
  --ad-every: 3;
  gap: clamp(10px, calc(16px - 6 * var(--fluid)), 16px);
}

.feed.feed--list .feed__ad {
  margin: 0;
}

/* ---------- 검색창 ---------- */
.search-bar {
  padding: 16px var(--inset);
}

.search-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--gray-a5);
  color: var(--gray-a3); /* 비어 있을 때 아이콘 a3 */
  cursor: text;
}

.search-input:has(input:not(:placeholder-shown)) {
  color: var(--gray-a4); /* 입력 중 아이콘 a4 (시안) */
}

.search-input:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 0;
}

.search-input input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gray-a2);
  font-size: var(--fs-title3);
  font-weight: 600;
  line-height: 1.6;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.search-input input::placeholder {
  color: var(--gray-a3);
  opacity: 1;
}

/* 브라우저 기본 지우기(×) 버튼 숨김 — 시안에 없음 (모르는 브라우저가 규칙을 버리지 않게 따로 쓴다) */
.search-input input::-webkit-search-cancel-button {
  display: none;
  -webkit-appearance: none;
  appearance: none;
}

.search-input input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

/* ---------- 번호 목록 (추천 검색어 · 관련 기사 · 핵심 내용) ---------- */
.num-list__head {
  padding: clamp(8px, calc(16px - 8 * var(--fluid)), 16px) var(--inset) 8px;
  color: var(--gray-a2);
  font-size: var(--fs-title1);
  font-weight: 700;
  line-height: 1.4;
}

.num-list__items {
  display: flex;
  flex-direction: column;
  gap: clamp(0px, calc(8px - 8 * var(--fluid)), 8px); /* MO 항목 간격 52 = 44 + 8 */
}

.num-list__item {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px var(--inset);
}

/* 키보드로 이동할 때 sticky 헤더 밑에 가려지지 않게 (.card 와 같은 방식) */
.num-list__item,
.num-list__more {
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.num-list__badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 12px;
  border-radius: var(--radius-sm);
  background: var(--fill-elevated);
  color: var(--gray-a2);
  font-size: var(--fs-caption);
  font-weight: 600;
  line-height: 1.5;
}

.num-list__text {
  min-width: 0;
  color: var(--gray-a2);
  font-size: var(--fs-title3);
  font-weight: 600;
  line-height: 1.6;
  transition: color var(--transition);
}

a.num-list__item:hover .num-list__text {
  color: var(--gray-a1);
}

/* 박스형 (기사 상세 aside — 추천 검색어 · 관련 기사)
   박스 위 → 제목 줄: MO 16(8 + 제목 8) / PC 8 + 테두리 1. 아래: 항목 8 + MO 16 / PC 8 */
.num-list--box {
  padding: clamp(0px, calc(8px - 8 * var(--fluid)), 8px) 0 clamp(8px, calc(16px - 8 * var(--fluid)), 16px);
  border: 1px solid var(--fill-elevated);
  border-radius: var(--radius-lg);
}

.num-list--box .num-list__head,
.num-list--key .num-list__head {
  padding: 8px 16px;
}

.num-list--box .num-list__item,
.num-list--key .num-list__item {
  padding-inline: 16px;
}

/* 핵심 내용 먼저 보기 (기사 상세 머리말 아래) — 박스 위 → 제목 줄: MO 16 / PC 24 */
.num-list--key {
  padding: clamp(8px, calc(8px + 8 * var(--fluid)), 16px) 0 16px;
  border-radius: var(--radius-lg);
  background: var(--primary-5);
}

.num-list--key .num-list__head {
  color: var(--primary);
}

.num-list--key .num-list__badge {
  background: var(--white);
  color: var(--primary);
}

/* 관련 기사: 제목 MO 2줄 / PC 1줄 말줄임 + 가운데 '관련 기사 더보기' */
.num-list--related {
  --lines: 2;
  display: flex;
  flex-direction: column;
  padding-bottom: 16px;
}

.num-list--related .num-list__text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--lines);
}

.num-list__more {
  align-self: center;
  margin-top: clamp(8px, calc(24px - 16 * var(--fluid)), 24px); /* 마지막 항목 → 버튼: MO 24 / PC 8 (버튼은 ol 밖이라 목록 gap 이 안 붙음) */
}

@media (min-width: 1024px) {
  .num-list--related {
    --lines: 1;
  }
}

/* ---------- 광고 영역 ----------
   광고 코드가 늦게 떠도 화면이 밀리지 않도록 높이를 미리 잡는다. display:none 금지. */
.ad-slot {
  border-radius: var(--radius-ad);
}

/* 가로형 배너: MO 세로 배치(pill → 제목 → 안내) / PC pill 아래에 제목·안내 가로 배치 */
.ad-slot--banner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-height: 135px;
  padding: 19px;
  border: 1px solid var(--ad-border);
  background: var(--ad-bg);
}

.ad-slot__pill {
  padding: 5px 16px;
  border-radius: var(--radius-pill);
  background: var(--white);
  color: var(--ad-caption);
  font-size: var(--fs-caption);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.ad-slot__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.ad-slot--banner .ad-slot__title {
  color: var(--ad-title);
  font-size: var(--fs-ad-title);
  font-weight: 700;
  line-height: 1.4;
}

.ad-slot__caption {
  color: var(--ad-caption);
  font-size: var(--fs-caption);
  font-weight: 400;
  line-height: 1.5;
}

@media (min-width: 1024px) {
  .ad-slot--banner {
    gap: 20px;
    min-height: 132px;
    padding: 16px 32px;
  }

  .ad-slot--banner .ad-slot__pill {
    padding: 6px 27px;
  }

  .ad-slot--banner .ad-slot__body {
    display: grid;
    grid-template-columns: 47.6% 1fr;
    align-items: center;
    gap: 0;
  }

  .ad-slot--banner .ad-slot__title {
    padding-left: 10px;
  }

  .ad-slot--banner .ad-slot__caption {
    margin-bottom: 4px; /* 시안: 안내문이 제목 줄 가운데보다 2px 위 */
  }
}

/* 세로형(기사 상세 aside) */
.ad-slot--aside {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: clamp(350px, calc(350px + 33 * var(--fluid)), 383px);
  padding: 17px;
  border-radius: var(--radius-lg);
  /* 1px 점선(선 8 · 간격 8, 색 = --ad-aside-border). stroke 2 중 안쪽 1px 만 보인다 */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='100%25' height='100%25' fill='none' rx='16' ry='16' stroke='%239DACC2' stroke-width='2' stroke-dasharray='8 8'/%3E%3C/svg%3E"),
    var(--ad-aside-bg);
  text-align: center;
}

.ad-slot--aside .ad-slot__title {
  color: var(--ad-aside-title);
  font-size: var(--fs-title2);
  font-weight: 600;
  line-height: 1.4;
}

.ad-slot__desc {
  color: var(--ad-aside-desc);
  font-size: var(--fs-body2);
  font-weight: 500;
  line-height: 1.5;
}
