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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #1a1a1a;
  background: #f2f4f9;
}

a { color: #1a6fb5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ──────────────────────────────── */
.site-header {
  background: #fff;
  border-bottom: 1px solid #e6e9f2;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.site-header .inner,
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
}

.site-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: #1a1a1a;
  letter-spacing: -0.5px;
}
a.site-title { color: #1a1a1a; }
.site-title:hover { color: #1a6fb5; text-decoration: none; }

.header-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.73rem;
  color: #bbb;
}

#site-meta {
  font-size: 0.73rem;
  color: #bbb;
}

/* ── Hero (compact sticky banner, index only) */
.page-hero {
  background: linear-gradient(135deg, #0f3460 0%, #1a6fb5 55%, #3a9ad9 100%);
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(15,52,96,0.25);
}

.hero-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.page-hero .site-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

/* ── Main layout ─────────────────────────── */
main.index-main {
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ── Search panel ────────────────────────── */
.search-panel {
  padding: 18px 0 4px;
  border-bottom: 1px solid #e0e4ef;
  margin-bottom: 0;
}

.search-input-wrap {
  position: relative;
  margin-bottom: 10px;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 16px;
  border: 1.5px solid #d8dce9;
  border-radius: 10px;
  font-size: 0.92rem;
  font-family: inherit;
  color: #1a1a1a;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: #1a6fb5; }
.search-input::placeholder { color: #bbb; }

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 0.75rem;
  color: #bbb;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.search-clear:hover { color: #555; }

.search-options {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.search-scope-group {
  display: flex;
  gap: 12px;
}

.scope-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: #555;
  cursor: pointer;
  user-select: none;
}
.scope-label input { accent-color: #1a6fb5; }

.search-cat-select {
  padding: 4px 10px;
  border: 1.5px solid #d8dce9;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: inherit;
  color: #555;
  background: #fff;
  outline: none;
  cursor: pointer;
}
.search-cat-select:focus { border-color: #1a6fb5; }

.search-count {
  font-size: 0.75rem;
  color: #1a6fb5;
  font-weight: 600;
  margin-left: auto;
}

/* ── Category tabs ───────────────────────── */
.cat-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 0 14px;
  border-bottom: none;
  margin-bottom: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tabs.hidden { display: none; }

/* Bottom border lives on cat-tabs when no subtabs are shown */
.cat-tabs.bottom-border {
  border-bottom: 1px solid #e0e4ef;
  margin-bottom: 26px;
}

.cat-tab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border: 1.5px solid #d8dce9;
  border-radius: 20px;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
  white-space: nowrap;
  font-family: inherit;
}
.cat-tab:hover {
  border-color: var(--cat-color, #1a6fb5);
  color: var(--cat-color, #1a6fb5);
}
.cat-tab.active {
  background: var(--cat-color, #1a6fb5);
  border-color: var(--cat-color, #1a6fb5);
  color: #fff;
  font-weight: 700;
}

/* Group-level tabs: slightly bolder */
.cat-group-tab {
  font-weight: 600;
  font-size: 0.8rem;
}

.tab-count {
  font-size: 0.65rem;
  font-weight: 600;
  opacity: 0.65;
}

/* ── Sub-category tabs ───────────────────── */
.cat-subtabs:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0 12px;
  border-bottom: 1px solid #e0e4ef;
  margin-bottom: 26px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cat-subtabs::-webkit-scrollbar { display: none; }
.cat-subtabs.hidden { display: none; }

.cat-subtab {
  padding: 4px 12px;
  font-size: 0.74rem;
}

/* ── Card grid ───────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

@media (max-width: 540px) {
  main.index-main { padding: 0 16px 60px; }
  .page-hero { padding: 10px 16px; }
}

/* ── Article card ────────────────────────── */
.article-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 14px rgba(0,0,0,0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  text-decoration: none;
  color: inherit;
}
.article-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1), 0 16px 40px rgba(0,0,0,0.06);
  text-decoration: none;
}

.card-img {
  height: 160px;
  background: #eef0f7 center/cover no-repeat;
  position: relative;
  flex-shrink: 0;
}

/* Gradient overlay when image is present */
.card-img.has-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.42) 100%);
}

.card-cat-badge {
  position: absolute;
  bottom: 10px;
  left: 12px;
  z-index: 1;
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 10px;
  border: 1.5px solid;
}

/* Badge on image: white text */
.card-img.has-image .card-cat-badge {
  color: #fff;
  border-color: rgba(255,255,255,0.45);
  background: rgba(0,0,0,0.28);
}

/* Badge on no-image: colored */
.card-img:not(.has-image) .card-cat-badge {
  bottom: auto;
  top: 10px;
}

.card-body {
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.52;
  color: #111;
  word-break: keep-all;
  flex: 1;
}
.article-card:hover .card-title { color: #1a6fb5; }

.card-date {
  font-size: 0.7rem;
  color: #c0c4d0;
  font-weight: 500;
}

/* ── Empty state ─────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  padding: 60px 0;
  text-align: center;
  color: #aaa;
}
.empty-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state p { font-size: 0.9rem; }
.empty-hint {
  font-size: 0.78rem !important;
  margin-top: 6px;
  opacity: 0.7;
}

/* ── Loading status ──────────────────────── */
#status {
  grid-column: 1 / -1;
  padding: 60px 0;
  text-align: center;
  color: #aaa;
  font-size: 0.88rem;
}

/* ── Footer ──────────────────────────────── */
.site-footer {
  border-top: 1px solid #e6e9f2;
  padding: 22px 20px;
  text-align: center;
  font-size: 0.75rem;
  color: #bbb;
}
.site-footer a { color: #bbb; }
.site-footer a:hover { color: #1a6fb5; }

/* ══════════════════════════════════════════
   Article page
   ══════════════════════════════════════════ */
main.article-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 32px 20px 72px;
}

.breadcrumb {
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 28px;
}
.breadcrumb .sep { margin: 0 6px; }
.breadcrumb a { color: #888; }
.breadcrumb a:hover { color: #1a6fb5; }

.article-title {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.38;
  margin-bottom: 6px;
  color: #111;
  word-break: keep-all;
}

.article-en-title {
  font-size: 0.83rem;
  color: #aaa;
  margin-bottom: 18px;
  font-style: italic;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.article-meta .date { font-size: 0.8rem; color: #aaa; }
.cat-tag {
  font-size: 0.68rem;
  background: #eef3fc;
  color: #4a6fa8;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.article-meta .cat-tag { font-size: 0.72rem; }
.source-link {
  font-size: 0.8rem;
  margin-left: auto;
}

.article-image {
  margin-bottom: 26px;
  border-radius: 8px;
  overflow: hidden;
  background: #f0f0f0;
}
.article-image img { width: 100%; height: auto; display: block; }

.article-summary-box {
  background: #f4f7fd;
  border: 1px solid #d6e2f5;
  border-left: 4px solid #1a6fb5;
  border-radius: 0 10px 10px 0;
  padding: 18px 22px;
  margin-bottom: 32px;
}

.summary-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #1a6fb5;
  margin-bottom: 10px;
}

.article-summary {
  font-size: 1.0rem;
  line-height: 1.75;
  color: #2a2a2a;
  word-break: keep-all;
}

.article-summary p { margin-bottom: 10px; }
.article-summary p:last-child { margin-bottom: 0; }
.article-summary strong {
  display: block;
  font-size: 1.08rem;
  font-weight: 700;
  color: #111;
  margin-bottom: 10px;
  line-height: 1.45;
  letter-spacing: -0.2px;
}
.article-summary ul, .article-summary ol {
  margin: 6px 0 10px 20px;
}
.article-summary li { margin-bottom: 4px; }

.article-body p {
  margin-bottom: 18px;
  color: #222;
  word-break: keep-all;
}

.article-body h2 {
  font-size: 1.12rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 32px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
}

.article-body h3 {
  font-size: 0.98rem;
  font-weight: 700;
  color: #333;
  margin: 22px 0 8px;
}

.article-body ul, .article-body ol {
  margin: 0 0 18px 24px;
  color: #222;
}

.article-body li { margin-bottom: 6px; }
.article-body strong { font-weight: 700; }

.source-credit {
  margin-top: 36px;
  padding-top: 14px;
  border-top: 1px solid #eee;
  font-size: 0.78rem;
  color: #aaa;
}

/* Mobile article page */
@media (max-width: 600px) {
  .article-title { font-size: 1.25rem; }
  .source-link { margin-left: 0; width: 100%; }
  main.article-page { padding: 20px 16px 60px; }
}
