/* ==========================================================================
   해피나눔 디자인 시스템 (단일 CSS — 예산 120KB 이하)
   모바일 퍼스트. CSS 변수 기반. 웹폰트 없음(시스템 폰트 스택).
   변수 명명 체계는 사이트군 공통 규약(--c-*, --font-sans, --tap)을 따른다.
   ========================================================================== */

/* ---------- 1. 변수 ---------- */
:root {
  /* 색상 — 복지·나눔 톤(신뢰 그린 + 중립 그레이 + 포인트 앰버) */
  --c-primary: #047857;
  --c-primary-hover: #065f46;
  --c-primary-soft: #ecfdf5;
  --c-accent: #b45309;
  --c-accent-soft: #fffbeb;
  --c-bg: #f8faf9;
  --c-surface: #ffffff;
  --c-text: #111827;
  --c-muted: #5b6672;
  --c-border: #e3e8e5;
  --c-danger: #dc2626;
  --c-danger-soft: #fef2f2;
  --c-ok: #047857;

  /* 타이포 — 시스템 폰트 스택 (웹폰트 금지: LCP 예산) */
  --font-sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Pretendard Variable", Pretendard, "Malgun Gothic", "맑은 고딕",
    "Segoe UI", Roboto, "Noto Sans KR", sans-serif;

  /* 크기 */
  --maxw: 1080px;
  --maxw-narrow: 760px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(17, 24, 39, .07), 0 4px 14px rgba(17, 24, 39, .05);
  --tap: 44px; /* 최소 터치 타깃 */
}

/* ---------- 2. 리셋/베이스 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  word-break: keep-all; /* 한국어 줄바꿈 */
}
img { max-width: 100%; height: auto; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
ul { margin: 0; padding: 0; }
table { border-collapse: collapse; width: 100%; }
select, button { font-family: inherit; font-size: 1rem; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.container-narrow { max-width: var(--maxw-narrow); }
.section { padding: 28px 0 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--c-primary); color: #fff; padding: 10px 16px; z-index: 100;
}
.skip-link:focus { left: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0;
}

/* ---------- 3. 헤더 ---------- */
.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 50;
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; gap: 12px;
}
.brand { font-size: 1.25rem; font-weight: 800; color: var(--c-text); }
.brand:hover { text-decoration: none; }
.brand-accent { color: var(--c-primary); }

.nav-toggle {
  display: flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap);
  background: none; border: 0; cursor: pointer; color: var(--c-text);
}
.nav-toggle svg { width: 24px; height: 24px; }

.site-nav { display: none; }
.site-nav.is-open {
  display: block;
  position: absolute; top: 56px; left: 0; right: 0;
  background: var(--c-surface); border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow);
}
.site-nav ul { list-style: none; }
.site-nav a {
  display: flex; align-items: center; min-height: var(--tap);
  padding: 4px 16px; color: var(--c-text); font-weight: 600;
}
.site-nav a:hover { background: var(--c-primary-soft); text-decoration: none; }

@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .site-nav { display: block; position: static; box-shadow: none; border: 0; }
  .site-nav ul { display: flex; gap: 4px; }
  .site-nav a { padding: 4px 14px; border-radius: var(--radius-sm); }
}

/* ---------- 4. 히어로 = 자가체크 도구 ---------- */
.hero {
  background: linear-gradient(160deg, var(--c-primary-soft), var(--c-bg) 70%);
  padding: 36px 0 32px;
}
.hero h1 { font-size: 1.9rem; letter-spacing: -.01em; }
.hero-sub { color: var(--c-muted); margin-bottom: 20px; }

.hero-tool {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px;
  max-width: 560px;
}
.hero-tool-row { margin-bottom: 14px; }
.hero-tool label {
  display: block; font-weight: 700; font-size: .95rem; margin-bottom: 6px;
}
.label-optional { color: var(--c-muted); font-weight: 400; }
.hero-tool select {
  width: 100%; min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-surface); color: var(--c-text);
}
.hero-tool-note { color: var(--c-muted); font-size: .85rem; margin: 10px 0 0; }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 8px 20px;
  background: var(--c-primary); color: #fff;
  border: 0; border-radius: var(--radius-sm);
  font-weight: 700; cursor: pointer;
}
.btn-primary:hover { background: var(--c-primary-hover); text-decoration: none; }
.btn-lg { width: 100%; font-size: 1.05rem; }

/* ---------- 5. 링크 그리드 (생애주기/가구상황/시도) ---------- */
.link-grid {
  list-style: none;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.link-grid a {
  display: flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 10px;
  background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  font-weight: 600; color: var(--c-text); text-align: center;
}
.link-grid a:hover {
  border-color: var(--c-primary); color: var(--c-primary);
  text-decoration: none; background: var(--c-primary-soft);
}
@media (min-width: 640px) { .link-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .link-grid { grid-template-columns: repeat(6, 1fr); } }
@media (min-width: 900px) { .link-grid-region { grid-template-columns: repeat(6, 1fr); } }

/* ---------- 6. benefit 카드 ---------- */
.benefit-card-list {
  list-style: none;
  display: grid; grid-template-columns: 1fr; gap: 12px;
}
@media (min-width: 640px) { .benefit-card-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .benefit-card-list { grid-template-columns: repeat(3, 1fr); } }

.benefit-card a {
  display: flex; flex-direction: column; gap: 8px; height: 100%;
  padding: 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--radius);
  color: var(--c-text);
}
.benefit-card a:hover { border-color: var(--c-primary); text-decoration: none; box-shadow: var(--shadow); }
.benefit-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.benefit-card-agency { color: var(--c-muted); font-size: .85rem; }
.benefit-card-title { font-weight: 700; line-height: 1.4; }
.benefit-card-more { margin-top: auto; color: var(--c-primary); font-size: .9rem; font-weight: 600; }

/* 상태 칩 */
.chip {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700;
}
.chip-open   { background: var(--c-primary-soft); color: var(--c-primary); }
.chip-always { background: #eff6ff; color: #1d4ed8; }
.chip-closed { background: #f1f5f9; color: var(--c-muted); }

.term-chip {
  display: inline-flex; align-items: center;
  padding: 3px 12px; margin: 0 6px 6px 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: 999px;
  font-size: .85rem; font-weight: 600; color: var(--c-text);
}
.term-chip:hover { border-color: var(--c-primary); color: var(--c-primary); text-decoration: none; }
.term-chip-region { border-style: dashed; }

/* ---------- 7. 서비스 상세 (YMYL 고정 3요소 포함) ---------- */
.benefit-single { padding: 24px 0 40px; }
.benefit-header { margin-bottom: 20px; }
.benefit-meta-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.benefit-title { margin-bottom: 12px; }

/* [YMYL 1] 갱신일 배지 */
.badge-synced {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  font-size: .8rem; color: var(--c-muted);
}
.badge-synced svg { width: 14px; height: 14px; }
.badge-synced-days { color: var(--c-muted); }
.badge-synced-stale { background: var(--c-danger-soft); border-color: var(--c-danger); color: var(--c-danger); }

/* 핵심 요약 표 */
.benefit-summary {
  background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 16px;
}
.summary-table th, .summary-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border);
  text-align: left; vertical-align: top;
  font-size: .95rem;
}
.summary-table tr:last-child th, .summary-table tr:last-child td { border-bottom: 0; }
.summary-table th {
  width: 92px; background: var(--c-bg);
  color: var(--c-muted); font-weight: 700; white-space: nowrap;
}
.field-empty { color: var(--c-muted); }

/* [YMYL 2] 정부 원문 링크 버튼 */
.btn-source {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  position: relative;
  min-height: var(--tap);
  padding: 14px 16px 12px 46px;
  margin-bottom: 16px;
  background: var(--c-primary); color: #fff;
  border-radius: var(--radius);
  font-weight: 700;
}
.btn-source:hover { background: var(--c-primary-hover); text-decoration: none; }
.btn-source svg { position: absolute; left: 16px; top: 16px; width: 20px; height: 20px; }
.btn-source-sub { font-size: .8rem; font-weight: 400; opacity: .9; }
.source-missing {
  padding: 12px 16px; margin-bottom: 16px;
  background: var(--c-danger-soft); border: 1px solid var(--c-danger);
  border-radius: var(--radius-sm); color: var(--c-danger); font-weight: 600;
}

/* [YMYL 3] 공식 채널 안내 박스 */
.notice-official {
  padding: 14px 16px; margin-bottom: 24px;
  background: var(--c-accent-soft);
  border: 1px solid #fcd34d; border-left: 4px solid var(--c-accent);
  border-radius: var(--radius-sm);
  font-size: .95rem;
}
.notice-official-title { display: block; margin-bottom: 4px; color: var(--c-accent); }
.notice-official p { margin: 0; }
.notice-official a { font-weight: 700; text-decoration: underline; }

.benefit-related, .benefit-guides { margin-top: 32px; }
.benefit-related-more { margin-top: 12px; font-weight: 600; }

/* ---------- 8. 허브/목록 ---------- */
.hub-header { padding: 24px 0 4px; }
.hub-note { color: var(--c-muted); font-size: .9rem; }
.hub-count { color: var(--c-muted); font-size: .9rem; margin-bottom: 12px; }
.hub-empty {
  padding: 32px 16px; text-align: center;
  background: var(--c-surface);
  border: 1px dashed var(--c-border); border-radius: var(--radius);
  color: var(--c-muted);
}
.hub-children { margin-bottom: 20px; }

.post-list { list-style: none; }
.post-list li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--c-border);
}
.post-list a { color: var(--c-text); font-weight: 600; }
.post-list a:hover { color: var(--c-primary); }
.post-list time { color: var(--c-muted); font-size: .85rem; white-space: nowrap; }
.post-list-lg li { padding: 14px 0; }

.pagination { display: flex; gap: 6px; justify-content: center; margin: 24px 0; flex-wrap: wrap; }
.pagination .page-numbers {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--tap); min-height: var(--tap); padding: 4px 10px;
  background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  color: var(--c-text);
}
.pagination .current { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* ---------- 9. 본문 타이포 (매거진/정적 페이지) ---------- */
.article-header { padding: 24px 0 8px; }
.article-meta { color: var(--c-muted); font-size: .9rem; display: flex; gap: 12px; flex-wrap: wrap; }
.article-body { font-size: 1.02rem; padding-bottom: 40px; }
.article-body h2 { margin-top: 1.6em; }
.article-body h3 { margin-top: 1.3em; }
.article-body table th, .article-body table td {
  padding: 8px 10px; border: 1px solid var(--c-border); font-size: .95rem;
}
.article-body table th { background: var(--c-bg); }
.article-body blockquote {
  margin: 1em 0; padding: 10px 16px;
  border-left: 4px solid var(--c-primary);
  background: var(--c-primary-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.article-body img { border-radius: var(--radius-sm); }

/* ---------- 10. 푸터 ---------- */
.site-footer {
  margin-top: 40px; padding: 28px 0 32px;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  color: var(--c-muted); font-size: .85rem;
}
.footer-notice { max-width: 640px; }
.footer-disclaimer { font-weight: 700; }
.footer-nav { display: flex; gap: 4px 18px; flex-wrap: wrap; margin: 14px 0; }
.footer-nav a { color: var(--c-muted); display: inline-flex; align-items: center; min-height: 32px; }
.footer-copy { margin: 0; }

/* ---------- 11. 404 ---------- */
.page-404 { padding: 60px 16px; text-align: center; }

/* 병합 서비스 보조 원문(복지로) 버튼 — 주 버튼과 톤 구분 */
.btn-source-secondary { background: var(--c-surface); color: var(--c-primary); border: 1px solid var(--c-primary); margin-top: -8px; }
.btn-source-secondary:hover { background: var(--c-primary-soft); }
.btn-source-secondary .btn-source-sub { opacity: .8; color: var(--c-muted); }

/* ---------- 마감 D-day 캘린더 ---------- */
.cal-section { margin-bottom: 28px; }
.cal-list { list-style: none; }
.cal-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 8px;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
}
.cal-dday {
  flex: 0 0 auto; min-width: 62px; text-align: center;
  padding: 6px 8px; border-radius: var(--radius-sm);
  font-weight: 800; font-size: .95rem;
}
.dday-urgent { background: var(--c-danger-soft); color: var(--c-danger); }
.dday-soon   { background: var(--c-accent-soft); color: var(--c-accent); }
.dday-far    { background: var(--c-primary-soft); color: var(--c-primary); }
.cal-body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-title { font-weight: 700; color: var(--c-text); }
.cal-title:hover { color: var(--c-primary); }
.cal-meta { color: var(--c-muted); font-size: .85rem; }
.cal-raw { display: none; }
@media (min-width: 720px) { .cal-raw { display: inline; } }
.cal-more { flex: 0 0 auto; color: var(--c-primary); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.cal-always { padding: 16px; background: var(--c-bg); border: 1px dashed var(--c-border); border-radius: var(--radius); }
