/* ==========================================================================
   BLACKDECK Global Styles (Unified)
   - 목적: 네비게이션(데스크톱/모바일), 본문 레이아웃, 풋터를 일관성 있게 제공
   - 핵심: 중복 제거, 반응형, 접근성(포커스/명도 대비), i18n UI(언어 셀렉트) 호환
   - 작성일: 2025-11-12
   ========================================================================== */

/* ========== 0) Reset & Base ================================================= */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  --maxw: 1200px;
  --nav-h: 56px;

  /* 색상 토큰(다크 테마 네비게이션) */
  --nav-bg: #0f172a;            /* slate-900 */
  --nav-fg: #e2e8f0;            /* slate-200 */
  --nav-fg-muted: #cbd5e1;      /* slate-300 */
  --nav-border: rgba(255,255,255,.08);
  --nav-hover-bg: #1e293b;      /* slate-800 - Hover 대비 강화 */
  --nav-input-bg: #0b1220;      /* 약간 더 어두운 배경 */
  --nav-input-border: #334155;  /* slate-700 */
  --focus: #93c5fd;             /* sky-300 */

  /* 본문/푸터 */
  --body-fg: #111;
  --muted: #6b7280;             /* gray-500 */
  --card-bg: #0b1220;
  --card-border: #1f2a3a;
  --footer-border: #e5e7eb;     /* gray-200 */
}

body {
  color: var(--body-fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
               "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

::selection {color: #e2e8f0;  background-color: #0f172a;}

/* ========== 1) Top Navigation ==============================================
   역할: 상단 고정 네비게이션(데스크톱 hover, 모바일 토글)
   구성: 좌측(브랜드+메뉴), 우측(검색/언어/로그인)
   ========================================================================== */

.nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--nav-h);
  background: var(--nav-bg);
  color: var(--nav-fg);
  border-bottom: 1px solid var(--nav-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
}

/* 내부 래퍼: 중앙 정렬 + 최대 폭 제한 */
.nav .wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* 브랜드 로고 / 사이트명 */
.nav .brand {
  font-weight: 700;
  letter-spacing: .2px;
  color: var(--nav-fg);
  text-decoration: none;
}

/* 좌측 메뉴 그룹 컨테이너 */
.nav .groups {
  display: flex;
}
.nav .groups .row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Right 영역과의 공간 밀어내기 (flex-grow 역할) */
.nav .spacer {
  flex: 1;
}

/* 공통 링크/버튼 스타일 */
.nav a,
.nav button {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--nav-fg);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background .12s ease, color .12s ease;
}

/* Hover 대비 강화: 짙은 배경 + 텍스트 흰색 */
.nav a:hover,
.nav button:hover {
  background: var(--nav-hover-bg);
  color: #fff;
}

/* 드롭다운 컨테이너 (부모) */
.dropdown {
  position: relative;
}
.dropdown > button {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 드롭다운 메뉴 패널 (기본: 숨김 상태)
   - 데스크톱: hover 시 opacity/visibility만 변경
   - 모바일: 아래 @media(<=820px)에서 display 기반으로 재정의 */
.dropdown .menu {
  position: absolute;
  left: 0;
  top: 100%;                    /* 버튼 바로 아래에 붙이기 */
  min-width: 200px;
  background: #101827;
  border: 1px solid var(--nav-border);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,.35);

  /* display:none 사용 X → 마우스 이동 유예시간을 주기 위해 opacity/visibility 사용 */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition:
    opacity .12s ease,
    transform .12s ease,
    visibility 0s linear .12s;  /* 숨길 때만 0.12s 딜레이 */
}

/* 드롭다운 메뉴 항목 */
.dropdown .menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--nav-fg-muted);
}
.dropdown .menu a:hover {
  background: var(--nav-hover-bg);
  color: #fff;
}

/* 데스크톱/마우스 환경: hover 시 메뉴 표시 (숨김 지연) */
@media (hover:hover) {
  .dropdown:hover .menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition-delay: 0s;       /* 표시할 때는 지연 없음 */
  }
}

/* 모바일용 체크박스 토글(HTML에 있는 input[id^=dd-*]을 통해 제어)
   - 토글 인풋 자체는 숨김
   - 주 사용처: 모바일에서 탭으로 열고 닫기 */
.dropdown > input[type="checkbox"] {
  display: none;
}

/* 우측 슬롯(검색/언어/로그인) */
.nav .right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav .right form {
  margin: 0;
}

/* 검색 입력창 */
.nav .right input[type="search"] {
  width: 220px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--nav-input-border);
  background: var(--nav-input-bg);
  color: var(--nav-fg);
  outline: none;
}

/* 언어 선택 셀렉트 */
.nav .right select {
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--nav-input-border);
  background: var(--nav-input-bg);
  color: var(--nav-fg);
  padding: 0 8px;
}

/* 햄버거(모바일 전용) */
#nav-toggle {
  display: none;          /* 상단 체크박스 토글 */
}
.nav .hamburger {
  display: none;          /* 820px 미만에서 표시 */
}
.nav .hamburger-btn {
  background: transparent;
  border: 1px solid var(--nav-input-border);
  width: 40px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.nav .hamburger-btn:hover {
  background: var(--nav-hover-bg);
}

/* 포커스 링(접근성 개선) */
.nav .dropdown > button:focus,
.nav a:focus,
.nav .right input[type="search"]:focus,
.nav .right select:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ========== 2) Responsive Rules ============================================
   - 1024px 이하: 간격 조정, 검색창 폭 축소
   - 820px 이하: 햄버거 메뉴 + 드롭다운 정렬/토글 방식 변경
   ========================================================================== */

/* 태블릿(≤ 1024px) 공통 조정 */
@media (max-width: 1024px) {
  .nav .wrap {
    gap: 8px;
  }
  .nav .right input[type="search"] {
    width: 180px;
  }
}

/* 모바일(≤ 820px): 햄버거 + 아코디언형 드롭다운 메뉴 */
@media (max-width: 820px) {
  .nav {
    height: auto;
    padding: 8px 12px;
  }
  .nav .wrap {
    flex-wrap: wrap;
  }

  /* 햄버거 노출, 그룹/우측 재배치 */
  .nav .hamburger {
    display: flex;
    order: 2;
    align-items: center;
    gap: 8px;
  }
  .nav .groups {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 6px;
  }
  .nav .groups .row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .nav .right {
    width: 100%;
    justify-content: space-between;
    order: 3;
  }

  /* 햄버거 체크 시 전체 메뉴 그룹 표시 */
  #nav-toggle:checked ~ .wrap .groups {
    display: flex;
  }

  /* 드롭다운: 전폭 버튼 + 내부 메뉴는 정적 흐름(아코디언) */
  .dropdown {
    width: 100%;
  }
  .dropdown > button {
    justify-content: space-between;
    width: 100%;
    border: 1px solid var(--nav-input-border);
  }

  /* 모바일에서는 position:static + display 기반 토글로 변경 */
  .dropdown .menu {
    position: static;
    display: none;        /* 기본 숨김 → 체크박스로 표시 */
    box-shadow: none;
    border: 0;
    padding: 4px 0;
    background: transparent;
    margin-top: 0;
    opacity: 1;           /* 모바일에서는 그냥 보이게/숨기게 처리 */
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: none;
  }

  /* 체크박스가 ON인 드롭다운은 하위 메뉴 표시
     (HTML에서 <input id="dd-..."> + <button> + <div class="menu"> 구조 필요) */
  .dropdown:has(> input[type="checkbox"]:checked) .menu {
    display: block;
  }

  /* 모바일 드롭다운 메뉴 항목 스타일 (카드 느낌) */
  .dropdown .menu a {
    background: var(--card-bg);
    border: 1px solid #243244;
    margin: 6px 0;
  }

  /* 검색창 폭 축소 */
  .nav .right input[type="search"] {
    width: 140px;
  }
}

/* ========== 3) Main & Footer ===============================================
   - 메인 컨테이너: 공통 여백 및 최대 폭
   - 풋터: 구분선 + 작은 텍스트
   ========================================================================== */

main {
  max-width: var(--maxw);
  margin: 16px auto;
  padding: 0 16px;
}

.footer {
  color: #64748b;
  padding: 24px 16px;
  border-top: 1px solid var(--footer-border);
  opacity: .9;
}
.footer.small {
  font-size: 12px;
}

/* ========== 4) Utilities & Demo Blocks =====================================
   - 랜딩/대시보드에서 재사용 가능한 유틸리티
   ========================================================================== */

/* 섹션 컨테이너 */
.container {
  padding: 8px 0 24px;
}

/* 카드 그리드(랜딩 데모용) */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  color: var(--nav-fg-muted);
}
@media (max-width: 820px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

/* 뮤티드 텍스트 */
.muted {
  color: var(--muted);
}

/* ========== 5) Optional: Motion Preference =================================
   - 사용자의 '애니메이션 줄이기' 설정을 존중
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}



.news-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.news-tab {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  font-size: 0.85rem;
  cursor: pointer;
}

.news-tab.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.news-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.news-table {
  width: 100%;
  border-collapse: collapse;
}

.news-table td {
  padding: 4px 0;
  font-size: 0.9rem;
}

.news-table a {
  text-decoration: none;
}

.news-table a:hover {
  text-decoration: underline;
}

.news-source {
  color: #6b7280;
  font-size: 0.8rem;
}

/* 모바일에서 1열 */
@media (max-width: 768px) {
  .news-grid {
    grid-template-columns: 1fr;
  }
}



/* ==== News (landing page) ================================================= */

/* 카테고리 탭(네모 블록, 조금 크게) */
.news-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 6px;
}

.news-tab {
  padding: 6px 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  color: #111827;
}

.news-tab.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

/* 검색 키워드 Chip (둥근, 더 작게) */
.news-keywords-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 4px 0 16px;
}

.news-keywords-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-right: 4px;
}

.news-keyword-chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  font-size: 0.8rem;
  cursor: pointer;
  color: #374151;
}

.news-keyword-chip.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

/* 2열 레이아웃 (데스크톱) */
.news-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* 테이블 기본 */
.news-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* 컬럼 폭 고정 → 모바일에서 줄바꿈 잘 되게 */
}

/* 각 셀: 위아래 여백 + 회색 구분선 */
.news-table td {
  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}

/* 마지막 줄은 하단 선 제거 */
.news-table tr:last-child td {
  border-bottom: none;
}

/* 한 줄 안에서 단어가 너무 길어도 넘치지 않도록 */
.news-table,
.news-table td,
.news-item,
.news-title,
.news-desc {
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* 1개 뉴스 아이템 구조 */
.news-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 메인 Row: 썸네일 + 텍스트
   - 썸네일이 있든 없든, 한글 뉴스에서 쓰는 높이 안에서 정리되도록
*/
.news-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 60px;            /* 텍스트만 있을 때 기준 높이 */
}

/* 썸네일: 고정 폭/높이, cover
   - "한글 뉴스 영역" 정도만 차지하도록 70x70 제안
*/
.news-thumb {
  width: 70px;
  height: 70px;
  max-width: 70px;
  max-height: 70px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: #e5e7eb;
}

/* 텍스트 박스: 썸네일 옆 영역 */
.news-main-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 70px;           /* 텍스트 영역도 썸네일 높이 안에 들어가도록 제한 */
  overflow: hidden;
}

/* 전체 뉴스 본문 링크 */
.news-link {
  text-decoration: none;
  color: inherit;
}

/* hover 시 타이틀만 살짝 언더라인 */
.news-link:hover .news-title {
  text-decoration: underline;
}

/* 타이틀: 한 줄만 보이게 + ... 처리 (너무 길면 한 줄로 자름) */
.news-title {
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 설명(Desc): 2줄까지만 보여주고 그 이상은 ... 으로 숨김
   - 영어 글로벌 뉴스 Desc 오버 시에도 깔끔하게 잘림
*/
.news-desc {
  font-size: 0.9rem;
  color: #4b5563;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;      /* 최대 2줄 */
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* pubDate: 더 옅고 작은 글씨 */
.news-meta-row {
  font-size: 0.8rem;
  color: #9ca3af;
}

/* 모바일(≤ 768px): 1열 + 폰트/여백 조정 */
@media (max-width: 768px) {
  .news-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .news-title {
    font-size: 0.9rem;
  }

  .news-desc {
    font-size: 0.85rem;
  }

  .news-table td {
    padding: 8px 0;
  }

  .news-main {
    gap: 8px;
  }

  .news-thumb {
    width: 60px;
    height: 60px;
    max-width: 60px;
    max-height: 60px;
  }

  .news-main-text {
    max-height: 60px;
  }
}
