/* ========== 외국인 관심 뉴스 위젯 ========== */
:root{
  --fg-bg:#f6f8fb;
  --fg-card:#ffffff;
  --fg-text:#1f2937;
  --fg-muted:#6b7280;
  --fg-primary:#4f46e5;    /* 포인트 보라블루 */
  --fg-primary-weak:#eef2ff;
  --fg-accent:#f97316;     /* HOT */
  --fg-border:#e5e7eb;
  --radius-xl:20px;
  --radius-lg:14px;
  --shadow-sm:0 2px 8px rgba(0,0,0,.06);
  --shadow-md:0 10px 30px rgba(79,70,229,.12);
}

.fg-news{
  max-width: 960px;
  margin: 30px auto 60px;
  padding: 28px 22px 40px;
  background: #f6f8fb;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  font-family: 'Noto Sans KR', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--fg-text);
}
/* 카드 공통 */
.fg-card {
  background:#fff;
  border-radius:16px;
  padding:16px;
  box-shadow:0 2px 10px rgba(0,0,0,.06);
}

/* 썸네일 있는 카드만 2행 2열 + 상단 헤드 전체 폭 */
.fg-card.has-thumb {
  display:grid;
  grid-template-columns: 160px 1fr;   /* 왼쪽 썸네일 폭 | 텍스트 영역 */
  grid-template-areas:
    "head  head"
    "thumb content";
  gap:16px;
  align-items:start;
}

/* 그리드 영역 매핑 */
.fg-card__head    { grid-area: head;    display:flex; align-items:center; gap:8px; }
.fg-card__thumb   { grid-area: thumb;   display:block; border-radius:12px; overflow:hidden; }
.fg-card__content { grid-area: content; display:grid; grid-template-rows:auto auto 1fr; row-gap:6px; }

/* 썸네일 이미지 */
.fg-card__thumb img { width:100%; height:auto; object-fit:cover; display:block; }

/* 텍스트 스타일 */
.fg-card__title { margin:0; font-size:18px; line-height:1.35; }
.fg-card__title a { color:#0f1a2a; text-decoration:none; }
.fg-card__title a:hover { text-decoration:underline; }
.fg-card__subtitle { margin:0; color:#3a4a5a; }
.fg-card__excerpt  { margin:6px 0 0; color:#556575; }

/* 배지/시간 */
.badge{display:inline-flex;align-items:center;padding:4px 8px;border-radius:999px;font-size:12px;font-weight:700;}
.badge--source{background:#eef2ff;color:#334155;}
.badge--hot{background:#ffe9e6;color:#b91c1c;}
.fg-card__time{margin-left:auto;font-size:12px;color:#6b7280;}

/* 공통: 배지 둘은 붙여서 왼쪽, 시간은 오른쪽 */
.fg-card__head{
  display:flex;
  align-items:center;
  justify-content:flex-start;   /* ← space-between 금지 */
  gap:8px;                      /* 배지 사이 간격 */
  flex-wrap:wrap;               /* 좁으면 다음 줄로 */
}
.fg-card__time{
  margin-left:auto;             /* 시간만 오른쪽 끝으로 */
  white-space:nowrap;
}

/* 모바일에서도 동일하게 유지 */
@media (max-width:640px){
  .fg-card.has-thumb .fg-card__head{
    justify-content:flex-start !important;  /* 이전 규칙 무효화 */
    gap:6px;
  }
  .fg-card__time{
    margin-left:auto !important;
    font-size:11px;
  }
  .fg-card__head .badge{ white-space:nowrap; }
}

/* === MOBILE FIX (≤ 640px) ===================================== */
@media (max-width: 640px) {
  /* 카드: 2행 그리드 유지 (상단 헤드 전체, 아래 썸네일/내용 2열) */
  .fg-card.has-thumb{
    display: grid !important;
    grid-template-columns: 100px 1fr !important;  /* 썸네일 폭 조절: 96~120px 선호 */
    grid-template-areas:
      "head head"
      "thumb content";
    gap: 12px !important;
    align-items: start !important;
  }

  /* 상단 헤드: 좌측 배지들, 우측 시간 */
  .fg-card__head{
    grid-area: head;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important; /* 배지들-시간 좌우 분리 */
    gap: 8px;
    margin-bottom: 2px;
    flex-wrap: nowrap;  /* 줄바꿈 방지(길면 아래 규칙으로 줄바꿈) */
  }
  /* 배지가 길어서 눌리면 두 줄 허용 */
  .fg-card__head > .badge{ white-space: nowrap; }
  .fg-card__time{ margin-left: 8px !important; font-size: 11px; color:#6b7280; }

  /* 썸네일: 항상 왼쪽 상단에 딱 붙도록 */
  .fg-card__thumb{
    grid-area: thumb;
    align-self: start !important;
    justify-self: start !important;
    margin: 0 !important;
    width: 100px !important;          /* grid 왼쪽 컬럼 너비와 동일 */
    height: 72px !important;          /* 보기 좋은 비율 */
    border-radius: 10px;
    overflow: hidden;
  }
  .fg-card__thumb img{
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;     /* 가득 채우면서 크롭 */
    display: block;
  }

  /* 오른쪽 컨텐츠 : 제목/부제/요약 간격만 간결하게 */
  .fg-card__content{
    grid-area: content;
    display: grid;
    grid-template-rows: auto auto 1fr;
    row-gap: 4px;
  }
  .fg-card__title{ font-size: 15px; line-height: 1.35; margin: 0; }
  .fg-card__subtitle{ font-size: 12px; margin: 0; color:#3a4a5a; }
  .fg-card__excerpt{ font-size: 12px; margin: 4px 0 0; color:#556575; }

  /* 배지 크기 축소 */
  .badge{ padding: 2px 6px; font-size: 11px; line-height: 1.2; }

  /* 예전 레이아웃 잔재가 있으면 무력화 */
  .fg-card__body{ display: contents !important; }  /* 남아있다면 레이아웃 영향 제거 */
}


/* 제목은 약간 강조 */
.fg-card__title {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}
.fg-card__title a { color: #0f1a2a; text-decoration: none; }
.fg-card__title a:hover { text-decoration: underline; }

/* 부제/요약 */
.fg-card__subtitle { margin: 0; color: #3a4a5a; opacity: .9; }
.fg-card__excerpt  { margin: 6px 0 0; color: #556575; }

/* 배지, 시간 */
.badge { display:inline-flex; align-items:center; padding:4px 8px; border-radius:999px; font-size:12px; font-weight:700; }
.badge--source { background:#eef2ff; color:#334155; }
.badge--hot    { background:#ffe9e6; color:#b91c1c; }
.fg-card__time { margin-left:auto; font-size:12px; color:#6b7280; }

/* 반응형: 모바일에서는 1열로 접기 */
@media (max-width: 640px) {
  .fg-card.has-thumb {
    grid-template-columns: 1fr;
  }
  .fg-card__thumb {
    max-width: 70%;
  }
}

.fg-news__header{ text-align: center; margin-bottom: 20px; }
.fg-news__title{
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.fg-news__desc{ font-size: 14px; color: var(--fg-muted); margin: 0 0 10px; }
.fg-news__chips{ display: flex; gap: 8px; justify-content: center; margin-top: 6px; }
.chip{
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--fg-primary-weak);
  color: var(--fg-primary);
  font-size: 12px;
  font-weight: 700;
}
.chip--muted{ background: #eef2f7; color: #64748b; }

/* KPI */
.fg-news__stats{
  margin: 18px 0 22px;
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 12px;
}
.stat-card{
  background: var(--fg-card);
  border: 1px solid var(--fg-border);
  border-radius: 16px;
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-card__value{
  font-size: 26px;
  font-weight: 800;
  color: var(--fg-primary);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-card__label{ font-size: 12px; color: var(--fg-muted); }

/* 리스트 */
.fg-news__list{
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}

.fg-card{
  background: var(--fg-card);
  border: 1px solid var(--fg-border);
  border-radius: var(--radius-lg);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
}
.fg-card:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #d9ddff;
}

/* 카드 본문 레이아웃 – 중복 제거 후 정리 */
.fg-card__body{
  display: grid;
  gap: 14px;
  align-items: start;
  grid-template-columns: 1fr;             /* 기본 한 열 */
}
/* 썸네일 있을 때만 140px + 본문 1fr 두 열 */
.fg-card__body.has-thumb{ grid-template-columns: 140px 1fr; }
/* 썸네일 1열 고정 */
.fg-card__body.has-thumb .fg-card__thumb{ grid-column: 1; }
/* 본문은 항상 가로 전체 사용 (안전장치) */
.fg-card__excerpt{ grid-column: 1 / -1; }
/* 썸네일 있을 때 본문은 2열(오른쪽)에만 위치 */
.fg-card__body.has-thumb .fg-card__excerpt{ grid-column: 2; }

.fg-card__head{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.badge{
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
}
.badge--source{ background: #ebf1ff; color: #1e40af; border: 1px solid #dbe4ff; }
.badge--hot{ background: #fff1e7; color: #9a3412; border: 1px solid #ffd7bf; }
.fg-card__time{ margin-left: auto; font-size: 12px; color: var(--fg-muted); }

/* 제목/링크 */
.fg-card__title{
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  display: -webkit-box;              /* 긴 제목 안정 처리 */
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;             /* 데스크톱 2줄 */
  overflow: hidden;
}
.fg-card__title a{ color: #0f172a; text-decoration: none; }
.fg-card__title a:hover{ text-decoration: underline; }

/* 부제 */
.fg-card__subtitle{
  font-size: 14px;
  color: #374151;
  margin: 0 0 10px;
  display: -webkit-box;              /* 길이 안정 처리 */
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;             /* 데스크톱 2줄 */
  overflow: hidden;
}

/* 썸네일(기본) */
.fg-card__thumb{
  display: block;
  width: 140px;
  height: 96px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--fg-border);
  position: relative; /* 폴백용 기준 컨테이너 */
}
.fg-card__thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease;
}
.fg-card__thumb:hover img{ transform: scale(1.04); }

/* 본문 요약 – 데스크톱 3줄 클램프 */
.fg-card__excerpt{
  font-size: 14px;
  color: #334155;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;   /* ← 데스크톱 3줄 */
  overflow: hidden;
}

/* 더보기 버튼 + 노트 */
.fg-news__more{ display: flex; justify-content: center; margin: 18px 0 6px; }
.btn-primary{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--fg-text);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  border: 1px solid #111827;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.btn-primary:hover{ transform: translateY(-1px); box-shadow: var(--shadow-md); background: #0b1220; }

.fg-news__note{
  text-align: center;
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 8px;
}

/* 반응형 */
@media (max-width: 720px){
  .fg-news{ padding: 22px 14px 28px; }
  .fg-news__stats{ grid-template-columns: repeat(2,1fr); gap: 10px; }

  /* 1열로 정리하고, 요약은 숨김 */
  .fg-card__body{ grid-template-columns: 1fr; }
  .fg-card__excerpt{ display: none !important; }

  /* 이미지: 컨테이너 너비 100% + 16:9 고정 비율 */
  .fg-card__thumb{
    width: 100%;
    height: auto;            /* 고정 높이 제거 */
    border-radius: 14px;
    border: 1px solid var(--fg-border);
    overflow: hidden;

    /* 최신 브라우저용 */
    aspect-ratio: 16 / 9;
  }
  .fg-card__thumb img{
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* 제목/부제 타이트 세팅 */
  .fg-card__title{
    -webkit-line-clamp: 2;    /* 필요 시 1로 변경 */
    font-size: 16px;
  }
  .fg-card__subtitle{
    -webkit-line-clamp: 1;
    font-size: 13px;
    margin-bottom: 8px;
  }
}

/* ▼ aspect-ratio 미지원 브라우저 폴백(패딩 해크) */
@supports not (aspect-ratio: 1) {
  @media (max-width: 720px){
    .fg-card__thumb{
      position: relative;
      width: 720px;
      height: auto;
    }
    .fg-card__thumb::before{
      content: "";
      display: block;
      padding-top: 56.25%; /* 16:9 = 9/16*100 */
    }
    .fg-card__thumb img{
      position: absolute;
      inset: 0;
      width: 100%;
      height: ;
      object-fit: cover;
    }
  }
}
