/* 페이퍼크래프트 디자인 시스템 · 공통 컴포넌트 (tokens.css 뒤에 불러온다)
   규칙: 누르는 영역은 --touch(48px) 이상, 포커스 링은 늘 보이게, 움직임은 prefers-reduced-motion 에서 끈다. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-ui); font-size: var(--fs-body); line-height: var(--lh-body);
  word-break: keep-all; overflow-wrap: anywhere; font-variant-numeric: lining-nums; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
img, video, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-sm); }
.on-dark :focus-visible, .on-dark:focus-visible { outline-color: var(--gold-light); }
::selection { background: var(--gold-light); color: var(--ink); }

/* ── 글 ── */
.display, .h1, .h2 { font-family: var(--font-display); font-weight: 300; letter-spacing: -.02em; line-height: var(--lh-tight); }
.display { font-size: var(--fs-display); }
.h1 { font-size: var(--fs-h1); }
.h2 { font-size: var(--fs-h2); }
.h3 { font-family: var(--font-ui); font-weight: 600; font-size: var(--fs-h3); line-height: 1.5; }
.eyebrow { font-family: var(--font-caps); font-weight: 600; font-size: .75rem; letter-spacing: .32em; text-transform: uppercase; color: var(--gold-ink); }
.on-dark .eyebrow { color: var(--gold-light); }
.lead { font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.85; color: var(--ink-soft); max-width: var(--measure); }
.prose { font-family: var(--font-body); line-height: 1.85; max-width: var(--measure); }
.prose p + p { margin-top: var(--s4); }
.muted { color: var(--ink-soft); }
.small { font-size: var(--fs-small); }
.num { font-family: var(--font-latin); font-weight: 500; font-variant-numeric: lining-nums; }
.link { color: var(--gold-ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link:hover { color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--s4); top: -80px; z-index: 100; background: var(--ink); color: var(--on-dark); padding: var(--s3) var(--s4); border-radius: var(--r-md); }
.skip:focus { top: var(--s3); }

/* ── 배치 ── */
.container { width: min(100% - 2 * var(--gutter), 1120px); margin-inline: auto; }
.narrow { width: min(100% - 2 * var(--gutter), 720px); margin-inline: auto; }
.stack > * + * { margin-top: var(--stack, var(--s4)); }
.row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.on-dark { background: var(--night); color: var(--on-dark); }
.on-dark .muted, .on-dark .lead { color: var(--on-dark-soft); }

/* ── 금박 선: 한 화면에 한두 번만 ── */
.rule { display: flex; align-items: center; justify-content: center; gap: var(--s3); color: var(--gold); }
.rule::before, .rule::after { content: ""; width: 56px; height: 1px; background: currentColor; }
.rule i { width: 6px; height: 6px; rotate: 45deg; background: currentColor; }
.rule.left { justify-content: flex-start; }
.rule.left::before { display: none; }

/* ── 아이콘(icons.js 가 인라인 SVG 로 채운다. 선 굵기 1.5, 둥근 끝) ── */
.ic { display: inline-block; width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.ic svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 16px; height: 16px; vertical-align: -3px; }
.ic.lg { width: 28px; height: 28px; }

/* ── 버튼 ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--touch); padding: 0 var(--s5);
  border: 1px solid var(--ink); border-radius: var(--r-pill); background: transparent; color: var(--ink); font-family: var(--font-ui); font-weight: 500;
  font-size: 1rem; line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background var(--dur-1), color var(--dur-1), border-color var(--dur-1), transform var(--dur-1), box-shadow var(--dur-2); }
.btn:hover { background: rgba(47, 40, 32, .06); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--on-dark); }
.btn.primary:hover { background: #453b30; }
.btn.seal { background: var(--seal); border-color: var(--seal); color: var(--on-seal); box-shadow: 0 8px 22px rgba(143, 47, 42, .22); }
.btn.seal:hover { background: var(--seal-deep); border-color: var(--seal-deep); }
.btn.quiet { border-color: var(--line); background: var(--card); }
.btn.quiet:hover { border-color: var(--field-line); }
.btn.ghost { border-color: transparent; padding: 0 var(--s3); color: var(--gold-ink); }
.btn.ghost:hover { background: rgba(122, 92, 40, .08); }
.btn.sm { min-height: 44px; min-width: 44px; padding: 0 var(--s4); font-size: var(--fs-small); }
.btn.block { display: flex; width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
.on-dark .btn { border-color: var(--on-dark-soft); color: var(--on-dark); }
.on-dark .btn:hover { background: rgba(251, 243, 226, .1); }
.on-dark .btn.seal { border-color: var(--seal); }
.on-dark .btn.light { background: var(--on-dark); border-color: var(--on-dark); color: var(--ink); }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--on-dark); border-right-color: transparent; animation: spin .8s linear infinite; }
.btn.busy:not(.primary):not(.seal)::after { border-color: var(--ink); border-right-color: transparent; }
@keyframes spin { to { rotate: 360deg; } }
.spinner { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gold-ink); border-right-color: transparent; animation: spin .8s linear infinite; vertical-align: -3px; }

/* ── 카드 ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s5); }
.card.raised { box-shadow: var(--shadow-1); }
.card.framed { position: relative; }
.card.framed::after { content: ""; position: absolute; inset: 6px; border: 1px solid var(--gold); opacity: .45; border-radius: calc(var(--r-lg) - 5px); pointer-events: none; }

/* ── 입력 ── */
.field { display: block; }
.field + .field { margin-top: var(--s4); }
.label { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); font-size: var(--fs-small); font-weight: 500; color: var(--ink); margin-bottom: 6px; }
.label .opt, .label .count { font-weight: 400; color: var(--ink-soft); font-size: var(--fs-tiny); }
.label .req { color: var(--seal); margin-left: 2px; }
.label .count.over { color: var(--seal); font-weight: 600; }
.input { display: block; width: 100%; min-height: var(--touch); padding: 11px 14px; font-size: 1rem; /* 16px: iOS 확대 방지 */ line-height: 1.5;
  background: var(--white); border: 1px solid var(--field-line); border-radius: var(--r-md); transition: border-color var(--dur-1), box-shadow var(--dur-1); }
textarea.input { resize: vertical; min-height: 96px; }
.input::placeholder { color: #736859; }
.input:hover { border-color: var(--ink-soft); }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); border-radius: var(--r-md); }
.input[aria-invalid="true"] { border-color: var(--seal); box-shadow: 0 0 0 1px var(--seal); }
.hint { font-size: var(--fs-tiny); color: var(--ink-soft); margin-top: 6px; line-height: 1.55; }
.error { display: flex; gap: 6px; align-items: flex-start; font-size: var(--fs-tiny); color: var(--seal); margin-top: 6px; line-height: 1.55; }
.error:empty { display: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.grid-2 > .field + .field { margin-top: 0; }

/* 체크 카드: 줄 전체가 누르는 영역 */
.check { display: flex; gap: var(--s3); align-items: flex-start; min-height: var(--touch); padding: var(--s3) var(--s4); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; transition: border-color var(--dur-1), background var(--dur-1); }
.check:hover { border-color: var(--field-line); }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 22px; height: 22px; margin: 1px 0 0; border: 1.5px solid var(--field-line); border-radius: 5px; background: var(--white); display: grid; place-items: center; cursor: pointer; }
.check input[type="radio"] { border-radius: 50%; }
.check input::after { content: ""; width: 11px; height: 6px; border-left: 2px solid var(--on-dark); border-bottom: 2px solid var(--on-dark); rotate: -45deg; translate: 0 -1px; opacity: 0; }
.check input[type="radio"]::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--on-dark); rotate: none; translate: none; }
.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after { opacity: 1; }
.check:has(input:checked) { border-color: var(--ink); background: var(--white); }
.check:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.check:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.check b { font-weight: 600; }
.check .tag { font-size: var(--fs-tiny); color: var(--ink-soft); font-weight: 400; margin-left: 4px; }
.check .tag.req { color: var(--seal); }

/* ── 배지·알림 ── */
.badge { display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--fs-tiny); font-weight: 500; line-height: 1;
  background: var(--paper-deep); color: var(--ink); white-space: nowrap; }
.badge.gold { background: transparent; box-shadow: inset 0 0 0 1px var(--gold); color: var(--gold-ink); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--seal); }
.badge.ink { background: var(--ink); color: var(--on-dark); }
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--paper-deep); border-left: 3px solid var(--gold); font-size: var(--fs-small); line-height: 1.6; }
.alert.warn { background: var(--warn-bg); border-color: var(--warn); color: #4f3209; }
.alert.danger { background: var(--danger-bg); border-color: var(--seal); color: #5d1a17; }
.alert.ok { background: var(--ok-bg); border-color: var(--ok); color: #1f3b24; }
.alert .ic { margin-top: 1px; }

/* ── 단계 표시 ── */
.steps { display: flex; gap: 6px; }
.steps li { flex: 1; }
.steps button { display: block; width: 100%; min-height: 44px; padding: 0; border: 0; background: none; text-align: left; font-size: var(--fs-tiny); color: var(--ink-soft); }
.steps button::before { content: ""; display: block; height: 3px; border-radius: 2px; background: var(--line); margin-bottom: 6px; transition: background var(--dur-2); }
.steps .done button::before { background: var(--gold); }
.steps .now button::before { background: var(--ink); }
.steps .now button { color: var(--ink); font-weight: 600; }
.steps button:disabled { cursor: default; }
.steps span { display: none; }
.steps .now span { display: inline; }

/* ── 진행 타임라인 ── */
.timeline { position: relative; display: grid; gap: var(--s5); padding-left: 34px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 10px; bottom: 10px; width: 1px; background: var(--line); }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: -34px; top: 3px; width: 19px; height: 19px; border-radius: 50%; background: var(--paper); border: 1px solid var(--field-line); }
.timeline .past::before { background: var(--gold); border-color: var(--gold); box-shadow: inset 0 0 0 4px var(--paper); }
.timeline .now::before { background: var(--seal); border-color: var(--seal); box-shadow: 0 0 0 5px rgba(143, 47, 42, .14); animation: pulse 2.4s var(--ease) infinite; }
.timeline .fail::before { background: var(--seal); border-color: var(--seal); }
.timeline b { display: block; font-weight: 600; color: var(--ink-soft); }
.timeline .past b, .timeline .now b { color: var(--ink); }
.timeline small { display: block; color: var(--ink-soft); font-size: var(--fs-tiny); line-height: 1.6; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(143, 47, 42, 0); } }

/* ── 표 ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.table th, .table td { padding: 10px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table th { font-weight: 600; font-size: var(--fs-tiny); color: var(--ink-soft); background: var(--paper-deep); position: sticky; top: 0; }
.table tr:last-child td { border-bottom: 0; }
.table td.wrap { white-space: normal; min-width: 12em; }
.empty { padding: var(--s6) var(--s4); text-align: center; color: var(--ink-soft); font-size: var(--fs-small); }

/* ── 수치 타일 ── */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s4); }
.stat b { display: block; font-family: var(--font-latin); font-weight: 500; font-size: 2rem; line-height: 1.1; }
.stat span { font-size: var(--fs-tiny); color: var(--ink-soft); }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }

/* ── 탭 ── */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { min-height: var(--touch); padding: 0 var(--s4); border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-soft); font-weight: 500; white-space: nowrap; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button .n { margin-left: 6px; font-size: var(--fs-tiny); color: var(--ink-soft); }

/* ── 대화상자 ── */
dialog.dialog { width: min(100vw - 32px, 480px); max-height: min(100dvh - 32px, 720px); padding: 0; border: 0; border-radius: var(--r-lg); background: var(--card); color: var(--ink); box-shadow: var(--shadow-2); overflow: auto; }
dialog.dialog.wide { width: min(100vw - 32px, 640px); }
dialog.dialog::backdrop { background: rgba(33, 28, 22, .55); }
.dialog-body { padding: var(--s5); }
.dialog-body h2 { margin-bottom: var(--s3); }
.dialog-actions { display: flex; gap: var(--s3); justify-content: flex-end; flex-wrap: wrap; margin-top: var(--s5); }

/* ── 토스트 ── */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); translate: -50% 12px; z-index: 60; max-width: calc(100vw - 32px); padding: 12px 20px; border-radius: var(--r-pill);
  background: var(--ink); color: var(--on-dark); font-size: var(--fs-small); box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transition: opacity var(--dur-2), translate var(--dur-2) var(--ease); }
.toast.show { opacity: 1; translate: -50% 0; }

/* ── 왁스 실링 ── */
.wax { display: grid; place-items: center; width: 64px; height: 64px; clip-path: var(--seal-shape); color: #f6d9cd; font-family: var(--font-latin); font-style: italic; font-size: 1.75rem;
  background: radial-gradient(circle at 35% 30%, #b8493f, var(--seal) 55%, var(--seal-deep)); }
.wax.sm { width: 40px; height: 40px; font-size: 1.125rem; }

/* ── 휴대폰 틀 ── */
.phone { position: relative; width: 100%; max-width: 320px; aspect-ratio: 9 / 18.5; margin-inline: auto; padding: 9px; border-radius: 38px; background: #1c1814; box-shadow: var(--shadow-2), inset 0 0 0 1px #3a322a; }
.phone > * { width: 100%; height: 100%; border: 0; border-radius: 30px; object-fit: cover; background: #000; }

/* ── 아코디언 ── */
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 64px; padding: var(--s3) 0; cursor: pointer; list-style: none; font-weight: 500; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: ""; flex: none; width: 9px; height: 9px; border-right: 1.5px solid var(--gold-ink); border-bottom: 1.5px solid var(--gold-ink); rotate: 45deg; translate: -4px -3px; transition: rotate var(--dur-2) var(--ease), translate var(--dur-2); }
.faq details[open] summary::after { rotate: 225deg; translate: -4px 3px; }
.faq details > div { padding: 0 0 var(--s5); color: var(--ink-soft); font-family: var(--font-body); max-width: var(--measure); }

/* ── 등장: 한 번, 천천히 ── */
.reveal { opacity: 0; translate: 0 18px; transition: opacity var(--dur-3) var(--ease), translate var(--dur-3) var(--ease); }
.reveal.in { opacity: 1; translate: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; translate: none; }
}
