:root {
  --bg: #f5f6fa;
  --white: #ffffff;
  --border: #e0e4ea;
  --text-main: #1f2a3c;
  --text-sub: #70788a;
  --accent: #1b69ff;
  --accent-light: #e5efff;
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text-main);
}

/* ===== 레이아웃 ===== */

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1.7fr) 320px;
  height: 100vh;
}

/* 좌측 사이드바 */

.sidebar {
  border-right: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}

/* 사이드바 상단 헤더 (데스크탑용) */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 12px;
}

.sidebar-logo-btn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.sidebar-logo img {
  height: 32px;
  display: block;
}

/* 사이드바 햄버거 (기본은 숨김 – 데스크탑에서는 안씀) */
.sidebar-toggle {
  display: none;
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--white);
  cursor: pointer;
  padding: 0;
  border:solid 0px;
}

.sidebar-toggle span {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--text-main);
  border-radius: 999px;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.sidebar-toggle span:nth-child(1) {
  top: 10px;
}
.sidebar-toggle span:nth-child(2) {
  top: 15px;
}
.sidebar-toggle span:nth-child(3) {
  top: 20px;
}

/* 햄버거 → X 상태 */
.sidebar-toggle.is-open span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}
.sidebar-toggle.is-open span:nth-child(2) {
  opacity: 0;
}
.sidebar-toggle.is-open span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

/* 언론사 목록 */

.source-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  padding-right: 4px;
}

.source-item {
  border: none;
  border-radius: 999px;
  padding: 8px 12px;
  text-align: left;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-main);
  transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease;
}

.source-item:hover {
  background: var(--accent-light);
}

.source-item.active {
  background: var(--accent);
  color: var(--white);
  transform: translateX(2px);
}

/* 언어 전환 */

.lang-switch {
  margin-top: auto;
  display: flex;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.lang-btn {
  flex: 1;
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  padding: 6px 0;
  cursor: pointer;
  border: 1px solid transparent;
}

.lang-btn--active {
  border-color: var(--accent);
  color: var(--accent);
}

/* 메인 */

.main {
  padding: 20px 24px;
  overflow-y: auto;
}

.main-header {
  margin-bottom: 16px;
}

.main-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
}

.main-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-sub);
}

/* 카드 공통 */

.card {
  background: var(--white);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
}

.card-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.card-body {
  padding: 12px 14px 14px;
}

.card-source {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
}

.card-title-ko {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
}

.card-title-vi {
  font-size: 13px;
  color: var(--text-sub);
  margin: 0 0 8px;
  line-height: 1.4;
}

.card-snippet {
  font-size: 13px;
  color: var(--text-sub);
  margin: 0 0 10px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-sub);
}

.card-more-btn {
  margin-left: auto;
}

/* 메인 카드 (대표 기사) */

.featured-article {
  margin-top: 16px;
  margin-bottom: 16px;
}

.featured-article .card {
  flex-direction: row;
  min-height: 220px;
}

.featured-article .card-image-wrap {
  flex: 1.1;
  overflow: hidden;
}

.featured-article .card-image {
  height: 100%;
}

.featured-article .card-body {
  flex: 1.3;
  padding: 16px 18px;
}

/* 서브 카드 2개 */

.sub-articles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

/* 카테고리 섹션 */

.category-section {
  margin-bottom: 24px;
}

.category-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding-bottom: 8px;
  overflow-x: auto;
}

.tab-btn {
  border-radius: 999px;
  background: var(--white);
  padding: 6px 12px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-sub);
  border: 1px solid var(--border);
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.category-articles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
}

/* 우측 패널 */

.right-panel {
  border-left: 1px solid var(--border);
  background: #f8fafc;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.headline-banner {
  border-radius: 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #f1f5ff, #f8fafc);
}

.headline-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.headline-text {
  font-size: 13px;
  font-weight: 600;
}

.right-section-title {
  margin: 0 0 8px;
  font-size: 13px;
}

.right-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
}

.right-list li + li {
  margin-top: 4px;
}

.right-list a {
  color: var(--accent);
  text-decoration: none;
}

/* 모달 */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: #fff;
  width: min(720px, 100vw);
  height: 100vh;
  max-height: 680px;
  margin: auto;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.4);
  animation: slideUp 0.25s ease-out;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.modal-back-btn,
.modal-home-btn {
  border: none;
  background: none;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-sub);
}

.modal-title-wrap {
  flex: 1;
  text-align: center;
}

.modal-source {
  font-size: 12px;
  font-weight: 600;
}

.modal-body {
  padding: 14px 18px 18px;
  overflow-y: auto;
}

.modal-title-vi {
  font-size: 16px;
  margin: 0 0 6px;
}

.modal-title-ko {
  font-size: 14px;
  margin: 0 0 10px;
  color: var(--text-sub);
}

.modal-snippet-vi {
  font-size: 13px;
  margin: 0 0 8px;
}

.modal-meta {
  font-size: 11px;
  color: var(--text-sub);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 12px;
}

.modal-link {
  margin-left: auto;
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
}

.modal-summary {
  border-radius: 12px;
  background: #f9fafb;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.modal-summary h4 {
  margin: 0 0 4px;
  font-size: 13px;
}

.modal-summary p {
  margin: 0;
  font-size: 13px;
}

.modal-related h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.modal-related-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  font-size: 12px;
}

/* 애니메이션 */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.22s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 메인 흐림 효과 (모바일 nav 열렸을 때 JS에서 .fade-out 붙이는 용도) */

.main.fade-out {
  opacity: 0.4;
  transition: opacity 0.15s ease;
}

/* ===== 모바일 상단 헤더 (topbar) ===== */

.topbar {
  display: none; /* 기본은 숨김, 모바일에서만 보이게 */
  height: 50px;
}

.topbar-logo {
  border: none;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.topbar-logo img {
  height: 28px;
}

.topbar-toggle {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--white);
  cursor: pointer;
  border: 0px solid var(--border);
  padding: 0;
}

.topbar-toggle span {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  border-radius: 999px;
  background: var(--text-main);
  transition: transform 0.18s ease, opacity 0.18s ease;
}

/* 세 줄 위치 */
.topbar-toggle span:nth-child(1) {
  top: 10px;
}
.topbar-toggle span:nth-child(2) {
  top: 15px;
}
.topbar-toggle span:nth-child(3) {
  top: 20px;
}

/* 햄버거 → X 상태 (main.js 에서 .is-open 토글) */
.topbar-toggle.is-open span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}
.topbar-toggle.is-open span:nth-child(2) {
  opacity: 0;
}
.topbar-toggle.is-open span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}


/* ===== 홈 피드 (언론사별 상단 3개) ===== */

.home-feed {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 24px;
}

.home-source-block {
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  padding: 16px 18px;
}

.home-source-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.home-source-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

/* 홈 피드 안 카드들은 박스 느낌만 – 그림자 최소화 */
.home-source-block .card {
  box-shadow: none;
  border: 1px solid var(--border);
}

.home-source-block .card + .card {
  margin-top: 12px;
}

/* ===== 모바일 반응형 ===== */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    min-height: 100vh;
  }

  /* 모바일 상단 헤더 보이게 */
  .topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    align-items: center;
    justify-content: space-between;
  }

  /* 좌측 사이드바를 상단 아래 접히는 네비바처럼 */
  .sidebar {
    border-right: none;
    padding: 4px 12px;
    background: var(--white);
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }

  /* nav-open 상태일 때 슬라이드처럼 펼쳐지게 */
  .layout.nav-open .sidebar {
    max-height: 90px; /* 필요하면 숫자 조정 */
  }

  /* 모바일에서는 sidebar-header는 숨기고, topbar만 사용 */
  .sidebar-header {
    display: none;
  }

  /* 언론사 목록: 가로 스크롤 */
  .source-menu {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .source-menu::-webkit-scrollbar {
    height: 4px;
  }

  .source-item {
    white-space: nowrap;
    font-size: 13px;
    flex-shrink: 0;
  }

  .lang-switch {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }

  .main {
    order: 2;
    padding: 16px 12px 20px;
  }

  .right-panel {
    order: 3;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 12px 12px 16px;
  }

  .featured-article .card {
    flex-direction: column;
    min-height: auto;
  }

  .featured-article .card-body {
    padding: 12px 14px;
  }

  .sub-articles {
    grid-template-columns: 1fr;
  }

  .category-articles {
    grid-template-columns: 1fr;
  }

  .modal-content {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }

  .modal-related-list {
    grid-template-columns: 1fr;
  }
}
