/*
Theme Name: Economast
Theme URI: https://economast.com
Author: Economast
Description: WSJ 스타일 경제·정책·AI 전문 미디어 테마
Version: 2.0
Text Domain: economast
*/

/* ══════════════════════════════════════
   FONTS & BASE
══════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=Source+Serif+4:ital,wght@0,400;0,600;1,400&family=Inter:wght@300;400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black:   #1a1a1a;
  --dark:    #2d2d2d;
  --mid:     #666;
  --light:   #999;
  --border:  #ddd;
  --bg:      #f5f4f0;
  --white:   #ffffff;
  --accent:  #c41e3a;   /* WSJ red */
  --accent2: #0057b7;
  --serif:   'Source Serif 4', Georgia, serif;
  --display: 'Playfair Display', Georgia, serif;
  --sans:    'Inter', -apple-system, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--black);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* ══════════════════════════════════════
   HEADER
══════════════════════════════════════ */
.site-header {
  background: var(--white);
  border-bottom: 3px solid var(--black);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* 상단 바: 날짜 + 로고 + 검색 */
.header-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.header-date {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--light);
  letter-spacing: 0.5px;
}

.site-title {
  text-align: center;
  font-family: var(--display);
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
}

.site-title a {
  color: var(--black);
  transition: color 0.15s;
}
.site-title a:hover { color: var(--accent); }

/* 검색 영역 */
.header-search {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.search-form {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.search-form:focus-within { border-color: var(--black); }

.search-form input[type="search"] {
  border: none;
  outline: none;
  padding: 7px 12px;
  font-family: var(--sans);
  font-size: 12px;
  width: 180px;
  background: var(--white);
  color: var(--black);
}
.search-form input::placeholder { color: var(--light); }

.search-form button {
  background: var(--black);
  border: none;
  cursor: pointer;
  padding: 7px 12px;
  color: var(--white);
  font-size: 13px;
  transition: background 0.15s;
}
.search-form button:hover { background: var(--accent); }

/* 네비게이션 */
.site-nav {
  padding: 8px 0;
}

.site-nav ul {
  list-style: none;
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}

.site-nav ul li a {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--dark);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 5px 14px;
  transition: color 0.15s;
  position: relative;
}

.site-nav ul li a::after {
  content: '';
  position: absolute;
  right: 0; top: 25%; bottom: 25%;
  width: 1px;
  background: var(--border);
}
.site-nav ul li:last-child a::after { display: none; }

.site-nav ul li a:hover,
.site-nav ul li.current-menu-item a { color: var(--accent); }

/* ══════════════════════════════════════
   LAYOUT WRAPPER
══════════════════════════════════════ */
.site-body {
  max-width: 1180px;
  margin: 0 auto;
  padding: 36px 24px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 48px;
  align-items: start;
}

/* ══════════════════════════════════════
   POST LIST (홈/아카이브)
══════════════════════════════════════ */
.archive-header {
  padding-bottom: 14px;
  border-bottom: 2px solid var(--black);
  margin-bottom: 28px;
}

.archive-title {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  color: var(--black);
}

.posts-list { list-style: none; }

.post-item {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
}
.post-item:first-child { border-top: 1px solid var(--border); }

.post-item-content { min-width: 0; }

.post-item-cat {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.post-item-title {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--black);
  margin-bottom: 8px;
  display: block;
  transition: color 0.15s;
  word-break: keep-all;
}
.post-item-title:hover { color: var(--accent); }

.post-item-excerpt {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--mid);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: keep-all;
}

.post-item-meta {
  margin-top: 10px;
  font-size: 11px;
  color: var(--light);
  display: flex;
  gap: 10px;
  align-items: center;
}
.post-item-meta span + span::before { content: '·'; margin-right: 10px; }

/* 썸네일 (목록) */
.post-item-thumb {
  flex-shrink: 0;
  width: 110px;
}
.post-item-thumb img {
  width: 110px;
  height: 74px;
  object-fit: cover;
  border-radius: 2px;
}
.post-item-thumb-empty { display: none; }

/* ══════════════════════════════════════
   SINGLE POST
══════════════════════════════════════ */
.post-wrapper {
  background: var(--white);
  border-radius: 2px;
  margin-bottom: 0;
}

/* 무한스크롤로 이어지는 각 article */
.infinite-article {
  background: var(--white);
  padding: 36px 40px 40px;
  margin-bottom: 12px;
  border-radius: 2px;
}
.infinite-article + .infinite-article {
  border-top: 3px solid var(--black);
  margin-top: 4px;
}

/* 글 헤더 */
.entry-header { margin-bottom: 24px; }

.entry-cat {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.entry-title {
  font-family: var(--display);
  font-size: clamp(24px, 3.5vw, 34px);
  font-weight: 900;
  line-height: 1.2;
  color: var(--black);
  margin-bottom: 14px;
  word-break: keep-all;
}

.entry-meta {
  font-size: 12px;
  color: var(--light);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  align-items: center;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  margin-bottom: 24px;
}
.entry-meta span + span::before { content: '·'; margin: 0 8px; color: var(--border); }

/* 썸네일: 오른쪽 상단 float */
.entry-thumb-float {
  float: right;
  margin: 0 0 20px 28px;
  max-width: 260px;
  border-radius: 2px;
  overflow: hidden;
}
.entry-thumb-float img {
  width: 260px;
  height: 174px;
  object-fit: cover;
}
.entry-thumb-caption {
  font-size: 11px;
  color: var(--light);
  padding: 5px 0 0;
  font-style: italic;
}

/* 본문 */
.entry-content {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.9;
  color: var(--dark);
  word-break: keep-all;
}

.entry-content::after { content: ''; display: table; clear: both; }

.entry-content p { margin-bottom: 1.5em; }

.entry-content h2 {
  font-family: var(--display);
  font-size: 1.4em;
  font-weight: 700;
  color: var(--black);
  margin: 2em 0 0.7em;
  padding-bottom: 0.5em;
  border-bottom: 2px solid var(--black);
  clear: both;
}

.entry-content h3 {
  font-family: var(--display);
  font-size: 1.15em;
  font-weight: 700;
  color: var(--black);
  margin: 1.8em 0 0.6em;
}

.entry-content ul, .entry-content ol {
  margin: 0.5em 0 1.4em 1.6em;
}
.entry-content li { margin-bottom: 0.5em; }

.entry-content strong { font-weight: 700; color: var(--black); }

.entry-content em { font-style: italic; }

.entry-content blockquote {
  border-left: 4px solid var(--black);
  margin: 1.8em 0;
  padding: 10px 0 10px 20px;
  font-size: 1.05em;
  font-style: italic;
  color: var(--mid);
}

/* 표 */
.entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.8em 0;
  font-size: 14px;
  font-family: var(--sans);
}
.entry-content th {
  background: var(--black);
  color: var(--white);
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.5px;
}
.entry-content td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.55;
}
.entry-content tr:hover td { background: #fafaf8; }

/* 광고 슬롯 */
.ad-slot {
  margin: 28px 0;
  background: #f9f9f7;
  border: 1px dashed #ccc;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-size: 11px;
  color: #bbb;
  letter-spacing: 1px;
  text-transform: uppercase;
  clear: both;
}

/* ══════════════════════════════════════
   무한스크롤 연결부
══════════════════════════════════════ */
.next-post-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 12px 40px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--light);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.next-post-divider::before,
.next-post-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.infinite-loading {
  text-align: center;
  padding: 40px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--light);
  letter-spacing: 1px;
}
.infinite-loading .dot-pulse {
  display: inline-flex;
  gap: 5px;
  margin-top: 10px;
}
.infinite-loading .dot-pulse span {
  width: 6px; height: 6px;
  background: var(--light);
  border-radius: 50%;
  animation: dotPulse 1.2s infinite ease-in-out;
}
.infinite-loading .dot-pulse span:nth-child(2) { animation-delay: 0.2s; }
.infinite-loading .dot-pulse span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse { 0%,80%,100% { opacity: 0.2; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

.infinite-end {
  text-align: center;
  padding: 32px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--light);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.sidebar-block {
  background: var(--white);
  padding: 20px 22px;
  border-radius: 2px;
}

.sidebar-title {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--black);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--black);
}

/* 사이드바 검색 */
.sidebar-search .search-form { width: 100%; }
.sidebar-search .search-form input { width: 100%; flex: 1; }

/* 사이드바 최신글 */
.sidebar-posts { list-style: none; }

.sidebar-post-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}
.sidebar-post-item:last-child { border-bottom: none; padding-bottom: 0; }
.sidebar-post-item:first-child { padding-top: 0; }

.sidebar-post-cat {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 3px;
  display: block;
}

.sidebar-post-title {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--black);
  display: block;
  transition: color 0.15s;
  word-break: keep-all;
}
.sidebar-post-title:hover { color: var(--accent); }

.sidebar-post-date {
  font-size: 10px;
  color: var(--light);
  white-space: nowrap;
  margin-top: 2px;
}

/* 사이드바 썸네일 */
.sidebar-post-thumb img {
  width: 60px;
  height: 40px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
}

/* 사이드바 카테고리 */
.sidebar-cat-list { list-style: none; }
.sidebar-cat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sidebar-cat-item:last-child { border-bottom: none; }
.sidebar-cat-item a {
  color: var(--dark);
  font-weight: 500;
  transition: color 0.15s;
}
.sidebar-cat-item a:hover { color: var(--accent); }
.sidebar-cat-count {
  font-size: 11px;
  color: var(--light);
  background: var(--bg);
  padding: 1px 7px;
  border-radius: 10px;
}

/* ══════════════════════════════════════
   PAGINATION
══════════════════════════════════════ */
.pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 36px 0 10px;
}

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--mid);
  border: 1px solid var(--border);
  border-radius: 2px;
  transition: all 0.15s;
  background: var(--white);
}
.pagination a:hover { border-color: var(--black); color: var(--black); }
.pagination .current { background: var(--black); color: var(--white); border-color: var(--black); }

/* ══════════════════════════════════════
   SEARCH RESULTS
══════════════════════════════════════ */
.search-header {
  padding-bottom: 14px;
  border-bottom: 2px solid var(--black);
  margin-bottom: 28px;
}
.search-header h1 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
}
.search-count {
  font-size: 13px;
  color: var(--mid);
  margin-top: 6px;
}
.search-keyword { color: var(--accent); font-weight: 600; }

/* ══════════════════════════════════════
   FOOTER
══════════════════════════════════════ */
.site-footer {
  background: var(--black);
  color: #aaa;
  padding: 32px 0 24px;
  margin-top: 20px;
}

.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-logo {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 900;
  color: var(--white);
}

.footer-copy {
  font-size: 12px;
  color: #777;
}


/* ══════════════════════════════════════
   MOBILE SEARCH OVERLAY
══════════════════════════════════════ */
/* PC에서 모바일 버튼 숨김 */
.mobile-search-btn  { display: none; }
.mobile-search-overlay { display: none; }

.mobile-search-overlay.open {
  display: block;
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--white);
  z-index: 9999;
  padding: 12px 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  border-bottom: 2px solid var(--black);
}

.mobile-search-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.mobile-search-form input[type="search"] {
  flex: 1;
  padding: 10px 14px;
  font-size: 16px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  outline: none;
  font-family: var(--sans);
  -webkit-appearance: none;
}
.mobile-search-form input:focus { border-color: var(--black); }

.mobile-search-form button {
  background: var(--black);
  border: none;
  color: var(--white);
  width: 42px; height: 42px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}
#mobileSearchClose {
  background: transparent;
  color: var(--mid);
  border: 1px solid var(--border);
}

/* ══════════════════════════════════════
   RESPONSIVE — 태블릿 (900px 이하)
══════════════════════════════════════ */
@media (max-width: 900px) {
  .site-body { grid-template-columns: 1fr; gap: 24px; padding: 20px 16px; }
  .sidebar { position: static; }
  .entry-thumb-float { float: none; max-width: 100%; margin: 0 0 20px 0; }
  .entry-thumb-float img { width: 100%; height: 220px; object-fit: cover; }
  .infinite-article { padding: 24px 20px; }
  .entry-content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ══════════════════════════════════════
   RESPONSIVE — 모바일 (600px 이하)
══════════════════════════════════════ */
@media (max-width: 600px) {

  /* ── 가로 스크롤 완전 차단 ── */
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  /* ── 헤더 ── */
  .header-inner { padding: 0 14px; }

  .header-top {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 10px;
    gap: 8px;
  }

  .header-date { display: none !important; }

  .site-title {
    font-size: 20px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    flex: 1 !important;
    min-width: 0 !important;
    text-align: left !important;
  }

  /* 모바일 검색 버튼 표시 */
  .mobile-search-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: var(--black);
    border: none;
    color: var(--white);
    border-radius: 3px;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
  }

  /* ── 네비 ── */
  .site-nav ul {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .site-nav ul::-webkit-scrollbar { display: none; }
  .site-nav ul li a { padding: 5px 10px; font-size: 11px; }
  .site-nav ul li a::after { display: none; }

  /* ── 레이아웃 ── */
  .site-body {
    padding: 16px 14px !important;
    gap: 20px;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── 글 목록 ── */
  .post-item { grid-template-columns: 1fr !important; padding: 16px 0; gap: 8px; }
  .post-item-thumb { display: none !important; }
  .post-item-title { font-size: 17px; line-height: 1.35; word-break: keep-all; }
  .post-item-excerpt { font-size: 13px; }
  .archive-header { margin-bottom: 20px; }

  /* ── 단일 글 컨테이너 ── */
  .post-wrapper { width: 100%; box-sizing: border-box; }
  .infinite-article {
    padding: 18px 14px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  /* ── 제목 ── */
  .entry-title {
    font-size: 20px !important;
    line-height: 1.3 !important;
    word-break: keep-all !important;
    overflow-wrap: break-word !important;
  }

  /* ── 본문 ── */
  .entry-content {
    font-size: 15px !important;
    line-height: 1.85 !important;
    overflow: hidden !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* 모든 본문 자식 요소 너비 제한 */
  .entry-content * {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* 이미지/미디어 */
  .entry-content img {
    width: 100% !important;
    height: auto !important;
    object-fit: cover;
  }
  .entry-content video { width: 100% !important; height: auto !important; }
  .entry-content iframe {
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: 16/9;
    height: auto !important;
  }

  /* 표: 표만 가로 스크롤 */
  .entry-content table {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    font-size: 13px !important;
    white-space: nowrap;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* 코드 */
  .entry-content pre, .entry-content code {
    overflow-x: auto !important;
    white-space: pre-wrap !important;
    word-break: break-all !important;
    font-size: 13px !important;
  }

  /* 썸네일 float 해제 */
  .entry-thumb-float {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 16px 0 !important;
  }
  .entry-thumb-float img { width: 100% !important; height: 200px; object-fit: cover; }

  /* 광고 */
  .ad-slot { min-height: 60px; font-size: 10px; }

  /* 사이드바 */
  .sidebar { gap: 16px; }
  .sidebar-block { padding: 16px; }
  .sidebar-search .search-form { width: 100%; }
  .sidebar-search .search-form input { width: 100%; font-size: 16px; }

  /* 푸터 */
  .footer-inner { flex-direction: column; text-align: center; gap: 6px; padding: 20px 14px; }
  .footer-logo { font-size: 16px; }
  .footer-copy { font-size: 11px; }
}
