/*
  프레임워크 없이. 외부 요청이 0이라 첫 렌더가 빠르고, 이게 검색 순위(Core Web
  Vitals)와 광고 수익(노출 전 이탈 감소)에 직접 영향을 준다.
  모바일 우선 — 이런 계산기 트래픽은 대부분 모바일 검색에서 온다.
*/

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --text-muted: #61656e;
  --border: #e3e5ea;
  --accent: #1f5fd0;
  --accent-soft: #eaf1fd;
  --danger: #c0392b;
  --refund: #1d7a4f;
  --refund-soft: #e6f4ec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 22, 28, 0.06), 0 4px 16px rgba(20, 22, 28, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2026;
    --text: #eceef2;
    --text-muted: #a0a5b0;
    --border: #2c3038;
    --accent: #6ea3f5;
    --accent-soft: #1d2a41;
    --danger: #ef6a5c;
    --refund: #5fcf95;
    --refund-soft: #16301f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
               "Noto Sans KR", system-ui, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  /* 한글은 어절 단위로 줄바꿈한다. 기본값이면 제목이 낱말 중간에서 끊긴다 */
  word-break: keep-all;
  overflow-wrap: break-word;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── 헤더 / 푸터 ───────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header__logo {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

/* 계산기가 늘어나면 좁은 화면에서 넘친다 — 줄바꿈 대신 가로 스크롤로 처리해
   헤더 높이가 들쭉날쭉해지는 것을 막는다. 로고와 한 줄에 두어 sticky 로 붙어도
   화면을 덜 가린다. 스크롤바는 숨기는 대신 잘린 쪽 가장자리를 흐리게 해 더 있다는 것을 보여 준다
   (src/site.js 가 has-more-* 클래스를 붙인다). */
.site-header__nav {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.site-header__nav::-webkit-scrollbar { display: none; }
.site-header__nav a { flex: 0 0 auto; }

.site-header__nav.has-more-end {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}
.site-header__nav.has-more-start {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent);
}
.site-header__nav.has-more-start.has-more-end {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}

.site-header__nav a {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}

.site-header__nav a:hover { background: var(--accent-soft); color: var(--text); }

.site-header__nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.site-footer {
  padding: 28px 20px 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.site-footer nav {
  display: flex;
  gap: 10px 18px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.site-footer a { color: var(--text-muted); }
.site-footer__copy { margin: 0; }

/* ── 레이아웃 ──────────────────────────────────────────────── */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 8px;
}

h1 {
  margin: 8px 0 6px;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.0625rem;
}

.lede {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.card--muted { background: transparent; box-shadow: none; }

/* 지급 대상 아님 등 주의 상태. color-mix를 쓰지 않는 이유는 구형 브라우저에서
   배경이 아예 사라지기 때문 — 테두리만으로 상태를 전달한다. */
.card--warn { border-color: var(--danger); border-width: 1.5px; }
.card--warn h2 { color: var(--danger); }

/* 본문 안의 보조 안내 (통상임금 비교 등) */
.notice {
  margin: 12px 0 0;
  padding: 11px 13px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.8125rem;
  line-height: 1.55;
}

/* 요율 설정 오류·최저임금 미달처럼 신뢰도에 직접 영향을 주는 경고 */
.notice--warn {
  background: transparent;
  border: 1.5px solid var(--danger);
}

/* result 최상단에 놓이는 경고는 카드들과 같은 간격을 갖게 한다 */
.result > .notice { margin: 0 0 16px; }

/* ── 폼 ────────────────────────────────────────────────────── */

.field { margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 0; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

@media (min-width: 560px) {
  .field-grid { grid-template-columns: repeat(3, 1fr); }
  .field-grid--2 { grid-template-columns: repeat(2, 1fr); }
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-wrap { position: relative; }

.input-wrap__suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

input[type="text"], input[type="date"], input[type="number"], select {
  width: 100%;
  padding: 12px 34px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

select, input[type="date"] { padding-right: 12px; }

/* iOS Safari가 date 입력을 기본 높이로 줄이는 것을 막는다 */
input[type="date"] { min-height: 46px; -webkit-appearance: none; appearance: none; }

input[type="text"]:focus, input[type="date"]:focus, input[type="number"]:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.hint {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn {
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover { filter: brightness(1.05); }

.error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 600;
}

/* ── 결과 ──────────────────────────────────────────────────── */

.card--accent {
  background: var(--accent-soft);
  border-color: transparent;
  text-align: center;
}

.result__label {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
}

.result__amount {
  margin: 4px 0 6px;
  font-size: 2.125rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.result__summary {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.breakdown { margin-bottom: 4px; }

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}

.row:last-child { border-bottom: 0; }
.row__label { color: var(--text-muted); }
.row__value { font-variant-numeric: tabular-nums; }

.row--total {
  border-bottom: 0;
  border-top: 2px solid var(--border);
  font-weight: 700;
}

.row--total .row__label { color: var(--text); }

/* ── 표 ────────────────────────────────────────────────────── */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.table th, .table td {
  padding: 9px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table thead th:first-child { text-align: left; }

.table thead th {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.table tbody th {
  text-align: left;
  font-weight: 600;
  /* 가로로 스크롤할 때 행 이름이 사라지지 않게 첫 열을 고정한다 */
  position: sticky;
  left: 0;
  background: var(--surface);
}

.table tbody tr:hover > * { background: var(--accent-soft); }
.tr--current > * { background: var(--accent-soft) !important; }

.num--strong { font-weight: 700; color: var(--accent); }

/* ── FAQ ───────────────────────────────────────────────────── */

.faq { margin: 0; }

.faq dt {
  margin-top: 14px;
  font-weight: 700;
  font-size: 0.9375rem;
}

.faq dt:first-child { margin-top: 0; }

.faq dd {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── 광고 슬롯 ─────────────────────────────────────────────── */

/*
  최소 높이를 지정해 광고가 늦게 로드되면서 본문을 밀어내는 현상(레이아웃 시프트)을
  막는다. CLS는 검색 순위 지표이면서, 오클릭을 유발해 계정 위험도 만든다.
*/
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 16px;
}

/* AdSense 승인 전에는 슬롯을 아예 렌더하지 않는다.
   점선 빈 박스가 페이지마다 보이면 심사자에게 미완성 사이트로 읽히고,
   사용자에게는 아무 정보도 주지 않는다.
   승인 후 광고 코드 주석을 풀 때 이 클래스도 함께 제거한다
   (test/ads.test.js 가 둘의 동기화를 강제한다). */
.ad-slot--pending {
  display: none;
}

/* ── 면책 ──────────────────────────────────────────────────── */

.disclaimer {
  margin: 4px 0 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.disclaimer__rates {
  display: block;
  margin-top: 6px;
  opacity: 0.85;
}

/* ── 정책 문서 페이지 ──────────────────────────────────────── */

.doc { max-width: 720px; margin: 0 auto; padding: 24px 16px; }
.doc h2 { margin-top: 28px; }
/* h2 아래 단계. 브라우저 기본값은 본문(0.9375rem)보다 커서 h2 와 구분이 안 된다. */
.doc h3 { margin-top: 20px; font-size: 1rem; }
.doc p, .doc li { color: var(--text-muted); font-size: 0.9375rem; }
.doc a { color: var(--accent); }

/* ── 가이드 글 ────────────────────────────────────────────── */
/* 정책 문서보다 길게 읽히는 글이라 본문색·행간을 읽기용으로 올린다 */
.doc--guide p, .doc--guide li { color: var(--text); font-size: 1rem; line-height: 1.8; }
.doc--guide h1 { font-size: 1.625rem; line-height: 1.35; margin-bottom: 8px; }
.doc--guide h2 {
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  font-size: 1.25rem;
  letter-spacing: -0.015em;
  line-height: 1.4;
}
.doc--guide h3 { margin-top: 26px; font-size: 1.0625rem; }
.doc--guide .table-scroll { margin: 16px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.doc--guide .table { font-size: 0.9375rem; }
.doc--guide .sources li { font-size: 0.8125rem; line-height: 1.6; }
.doc__meta { color: var(--text-muted) !important; font-size: 0.8125rem !important; margin-top: 0; margin-bottom: 20px; }
.guide-list { padding-left: 0; list-style: none; display: grid; gap: 12px; }
.guide-list li {
  margin: 0;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.9375rem;
  line-height: 1.65;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.guide-list li:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.guide-list li br { display: none; }
.guide-list li a { display: block; margin-bottom: 4px; text-decoration: none; }
.guide-list li a strong { font-size: 1.0625rem; letter-spacing: -0.01em; }
.sources li { font-size: 0.8125rem; color: var(--text-muted); }

/* 표에서 현재 입력 조건에 해당하는 행 강조 — 사용자가 자기 위치를 바로 찾게 한다 */
.tr--current { background: var(--accent-soft); }
.tr--current th, .tr--current td { font-weight: 700; }

/* 표의 보조 설명 칸 (요율 등) — 금액보다 약하게 */
.cell--note { color: var(--text-muted); font-size: 0.75rem; }

/* 환급일 때 강조색을 바꿔 "돌려받는다"를 즉시 알 수 있게 한다 */
.card--refund { background: var(--refund-soft); }
.card--refund .result__label { color: var(--refund); }


/* ── 접근성 ────────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 30;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus { top: 12px; }

/* 고정 헤더에 가려지지 않게 앵커 이동 위치를 띄운다 */
main [id], .doc--guide h2[id] { scroll-margin-top: 72px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

/* ── 버튼 변형 ─────────────────────────────────────────────── */

.btn { transition: filter 0.15s, transform 0.05s; }
.btn:active { transform: translateY(1px); }

.btn--ghost {
  width: auto;
  margin-top: 14px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.8125rem;
}
.btn--ghost:hover { background: var(--accent); color: #fff; filter: none; }

/* ── 가이드 목차 ───────────────────────────────────────────── */

.toc {
  margin: 20px 0 8px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.toc__title { margin: 0 0 6px; font-size: 0.8125rem !important; font-weight: 700; color: var(--text-muted) !important; }
.toc ol { margin: 0; padding-left: 20px; }
.toc li { margin: 2px 0; font-size: 0.9375rem !important; line-height: 1.6 !important; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }

/* ── 계산기 모음 (홈) ──────────────────────────────────────── */

.calc-group + .calc-group { margin-top: 18px; }
.calc-group h3 {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.calc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 560px) {
  .calc-grid { grid-template-columns: repeat(2, 1fr); }
}
.calc-card {
  display: block;
  height: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.1s;
}
.calc-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.calc-card strong { display: block; font-size: 0.9375rem; }
.calc-card span { display: block; margin-top: 2px; color: var(--text-muted); font-size: 0.8125rem; line-height: 1.5; }

/* ── 인쇄 ──────────────────────────────────────────────────── */

@media print {
  .site-header, .site-footer, .ad-slot, .skip-link, .btn, .toc, .calc-group { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .disclaimer { box-shadow: none; border-color: #bbb; }
}
