/* 재직증명서 양식 작성기(#2887). 형제 proxy-form-1264/styles.css 와 같은 토큰·짜임(한 칸 ≤1279px, 두 칸 ≥1280px, A4 미리보기, 인쇄 1쪽). */
:root {
  --font: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #f2f6fb;
  --surface: #ffffff;
  --ink: #16202b;
  --sub: #55636f;
  --line: #d7e0ea;
  --accent: #1f5fae;
  --accent-soft: #e6eef8;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --warn-bg: #fff6e5;
  --warn-ink: #7a4300;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

::selection { background: #cfe0f5; color: var(--ink); }

img, svg { max-width: 100%; }

.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 {
  padding: 24px 16px 8px;
  max-width: 1100px;
  margin: 0 auto;
}
.site-header .brand { margin: 0 0 4px; font-weight: 700; color: var(--accent); font-size: 0.9rem; }
.site-header h1 { margin: 0 0 8px; font-size: clamp(1.4rem, 4vw, 1.9rem); }
.site-header .lead { margin: 0; color: var(--sub); max-width: 70ch; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.form-panel, .preview-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.form-panel h2, .preview-panel h2 { margin: 0 0 12px; font-size: 1.1rem; }
.pv-sub { font-size: 0.85rem; font-weight: 600; color: var(--sub); margin-left: 6px; }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0 0 16px;
  padding: 12px;
  min-width: 0;
}
legend { font-weight: 700; padding: 0 6px; }

.field { margin-bottom: 14px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.field-row .field:last-child { margin-bottom: 14px; }
fieldset .field-row:last-child .field:last-child { margin-bottom: 0; }

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.95rem; }
.opt {
  display: inline-block;
  margin-left: 4px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #234a78;
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: 1px;
}

input[type="text"],
input[type="date"],
input[type="tel"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  caret-color: var(--accent);
}
input[type="date"] { -webkit-appearance: none; appearance: none; }
input[aria-invalid="true"] { border-color: var(--danger); }

input:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible,
.chip input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.help-text { margin: 6px 0 0; font-size: 0.85rem; color: var(--sub); }
.field-error { margin: 6px 0 0; font-size: 0.85rem; color: var(--danger); font-weight: 600; }
.field-error:empty { display: none; }

/* 체크 상자: 글자까지 눌러지는 44px 줄 */
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0;
  cursor: pointer;
}
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: 0 0 auto; }

.note {
  margin: 4px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 0.9rem;
}

/* 용도 칩(라디오) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { margin: 0; position: relative; cursor: pointer; font-weight: 600; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  transition: background-color 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out;
}
.chip:hover span { border-color: #9fb6d1; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips-set #customField { margin-top: 12px; }

.privacy-note { margin: 14px 0 0; font-size: 0.85rem; color: var(--sub); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s ease-out, transform 0.1s ease-out;
}
.btn-main { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
/* 좁은 화면(≤1279px)은 미리보기가 폼 아래라 버튼 옆에 바로 내려가는 링크(바름 r1 권고 2). 두 칸 화면에서는 숨김 */
.to-preview {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 6px;
  color: var(--accent);
  font-weight: 700;
  text-underline-offset: 3px;
}
.btn:hover { filter: brightness(0.96); }
.btn:active { transform: translateY(1px); }

/* ---- A4 미리보기 ---- */
.a4-scale-wrap {
  width: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start; /* 늘이기(stretch)를 끄지 않으면 A4 높이가 상자 높이로 잡혀 넘침을 못 잰다 */
  background: #e7ecf2;
  border-radius: 8px;
  padding: 8px 0;
}

.a4 {
  background: #ffffff;
  color: #111;
  width: 210mm;
  min-height: 297mm;
  padding: 18mm 18mm 14mm;
  box-shadow: 0 2px 10px rgba(22, 32, 43, 0.14);
  font-family: var(--font);
  font-size: 11pt;
  line-height: 1.5;
  transform-origin: top center;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}

.a4-no { margin: 0 0 6mm; font-size: 9.5pt; color: #333; }
.a4-no[hidden] { display: none; }
.a4-no-label { font-weight: 600; margin-right: 2mm; }

.a4-title {
  text-align: center;
  font-size: 24pt;
  font-weight: 800;
  letter-spacing: 0.45em;
  text-indent: 0.45em; /* 자간 때문에 오른쪽으로 쏠리는 것 보정 */
  margin: 2mm 0 10mm;
}

.a4-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border-top: 2px solid #111;
  border-bottom: 2px solid #111;
}
.a4-table th, .a4-table td {
  border: 1px solid #444;
  padding: 2.6mm 3mm;
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
  word-break: keep-all;
}
.a4-table tr:first-child th, .a4-table tr:first-child td { border-top: 0; }
.a4-table tr:last-child th, .a4-table tr:last-child td { border-bottom: 0; }
.a4-table th:first-child { border-left: 0; }
.a4-table td:last-child { border-right: 0; }
.c-group { width: 24mm; }
.c-label { width: 34mm; }
.a4-table .a4-group {
  white-space: nowrap;
  padding-left: 1.5mm;
  padding-right: 1.5mm;
  background: #eef1f5;
  text-align: center !important;
  font-weight: 700;
}
.a4-label {
  white-space: nowrap;
  background: #f7f8fa;
  font-weight: 600;
}
.a4-val { height: 10mm; }

.a4-statement {
  text-align: center;
  font-size: 13pt;
  font-weight: 600;
  margin: 13mm 0 8mm;
}
.a4-date { text-align: center; font-size: 12pt; margin: 0 0 11mm; letter-spacing: 0.04em; }

.a4-sign { margin-left: auto; width: 112mm; font-size: 12pt; }
.a4-sign p { display: flex; align-items: flex-end; margin: 0 0 5mm; }
.a4-sign-label { flex: 0 0 auto; width: 24mm; font-weight: 700; white-space: pre; }
.a4-line {
  display: inline-block;
  min-width: 30mm;
  border-bottom: 1px solid #333;
  padding: 0 2mm 0.5mm;
}
.a4-line-wide { flex: 1 1 auto; min-width: 0; }
.a4-seal { flex: 0 0 auto; margin-left: 3mm; color: #555; }

.a4.measuring { min-height: 0; }
/* 긴 입력: app.js fitDensity 가 A4 높이를 넘을 때만 한 단계씩 붙인다(인쇄 1쪽 유지) */
.a4.dense-1 { font-size: 10pt; padding-top: 15mm; padding-bottom: 12mm; }
.a4.dense-1 .a4-title { font-size: 21pt; margin-bottom: 8mm; }
.a4.dense-1 .a4-table th, .a4.dense-1 .a4-table td { padding: 1.8mm 2.6mm; }
.a4.dense-1 .a4-val { height: 9mm; }
.a4.dense-1 .a4-statement { margin: 10mm 0 7mm; font-size: 12pt; }
.a4.dense-1 .a4-date { margin-bottom: 9mm; }
.a4.dense-2 { font-size: 9pt; line-height: 1.4; padding-top: 12mm; padding-bottom: 10mm; }
.a4.dense-2 .a4-no { margin-bottom: 3mm; }
.a4.dense-2 .a4-title { font-size: 19pt; margin: 0 0 6mm; }
.a4.dense-2 .a4-table th, .a4.dense-2 .a4-table td { padding: 1.3mm 2.2mm; }
.a4.dense-2 .a4-val { height: 7.5mm; }
.a4.dense-2 .a4-statement { margin: 8mm 0 6mm; font-size: 11pt; }
.a4.dense-2 .a4-date { margin-bottom: 7mm; font-size: 11pt; }
.a4.dense-2 .a4-sign { font-size: 11pt; }
.a4.dense-2 .a4-sign p { margin-bottom: 3mm; }

/* ---- 도움말 ---- */
.help {
  max-width: 1100px;
  margin: 8px auto 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.help h2 { margin-top: 0; font-size: 1.1rem; }
.help h3 { font-size: 1rem; margin-top: 24px; }
.help-list { padding-left: 1.2em; }
.help-list li { margin-bottom: 8px; }
.law { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fafcfe; }
.law-src { margin: 0 0 6px; font-weight: 700; }
.law-src a { color: var(--accent); text-underline-offset: 3px; display: inline-flex; align-items: center; min-height: 44px; } /* 한 줄을 따로 차지하는 탭 대상(바름 r1 권고 1) */
.law blockquote { margin: 0 0 12px; padding: 0 0 0 12px; border-left: 1px solid #9fb6d1; color: var(--ink); }
.law blockquote p { margin: 0 0 6px; }
.asof { margin: 0; font-size: 0.85rem; color: var(--sub); }
.help details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.help summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.help details p { margin: 8px 0 0; color: var(--sub); }
.related { margin: 16px 0 0; }
.related a { color: var(--accent); display: inline-flex; align-items: center; min-height: 44px; text-underline-offset: 3px; }

/* ---- 바닥글 ---- */
.site-footer {
  max-width: 1100px;
  margin: 24px auto 0;
  padding: 16px;
  color: var(--sub);
  font-size: 0.85rem;
}
.site-footer .footer-brand { font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.footer-links { list-style: none; padding: 0; display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.footer-links a { color: var(--accent); display: inline-flex; align-items: center; min-height: 44px; }

/* 본문 바로가기·터치 반응·제목 줄바꿈 (proxy-form 과 같음) */
.skip { position: absolute; left: 8px; top: -60px; z-index: 10; padding: 8px 14px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; }
.skip:focus-visible { top: 8px; }
button, a, summary, .chip, .check { touch-action: manipulation; -webkit-tap-highlight-color: rgba(31, 95, 174, 0.15); }
h1, h2, h3 { text-wrap: balance; }

/* ---- 좁은 화면(갤럭시 Z 폴드5 접힘 약 360px · 펼침 약 1,100px 포함): 1279px 까지 한 칸 ---- */
@media (max-width: 1279px) {
  .layout { grid-template-columns: 1fr; }
}
@media (min-width: 480px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}
/* 1280px 이상에서만 입력·미리보기를 나란히, 미리보기는 따라 내려온다 */
@media (min-width: 1280px) {
  .to-preview { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; max-width: 1240px; }
  .preview-panel { position: sticky; top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .chip span, .btn { transition: none; }
}

/* ---- 인쇄: A4 한 장 ---- */
@page {
  size: A4;
  margin: 0;
}
@media print {
  html, body { margin: 0; padding: 0; background: #fff; }
  .skip,
  .site-header,
  .form-panel,
  .help,
  .site-footer,
  .preview-panel > h2 { display: none !important; }
  .layout,
  .preview-panel,
  .a4-scale-wrap {
    display: block;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    position: static;
    height: auto !important;
    overflow: visible;
  }
  .a4 {
    width: 210mm;
    min-height: 0;
    height: 296mm; /* 한 장 높이에 맞춤(297mm 는 반올림으로 빈 둘째 장이 붙을 수 있음) */
    margin: 0;
    box-shadow: none;
    transform: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: avoid;
  }
  .a4-table, .a4-table tr, .a4-sign, .a4-statement, .a4-date { break-inside: avoid; page-break-inside: avoid; }
}
