/*
 * 융자 신청 자가진단 — 화면 스타일
 * 모든 선택자는 .ksc- 로 시작해 홈페이지 기존 스타일과 섞이지 않게 함.
 * 색은 아래 변수만 바꾸면 됨. 흰 글자를 올리는 색은 모두 흰 바탕 대비 4.5:1 이상.
 */
/* 글꼴: Pretendard(OFL)에서 한글 2,350자 등만 남긴 'KSC Sans'. 경로는 이 CSS 파일 기준 (fonts/ 폴더를 함께 올림).
   팝업을 열 때만 내려받음. 파일이 없으면 홈페이지 글꼴로 표시됨. 다시 만들기: tools/build_font.py */
@font-face { font-family: "KSC Sans"; font-weight: 100 400; font-display: swap; src: url("fonts/ksc-sans-400.woff2") format("woff2"); }
@font-face { font-family: "KSC Sans"; font-weight: 500 600; font-display: swap; src: url("fonts/ksc-sans-600.woff2") format("woff2"); }
@font-face { font-family: "KSC Sans"; font-weight: 700 900; font-display: swap; src: url("fonts/ksc-sans-700.woff2") format("woff2"); }

.ksc-root, .ksc-overlay {
  --ksc-blue: #0075af;        /* 재단 홈페이지 파랑(#008BD0)을 글자 대비에 맞게 한 단계 진하게 */
  --ksc-green: #0b7a50;
  --ksc-amber: #b54708;
  --ksc-red: #b42318;
  --ksc-ink: #14212e;
  --ksc-muted: #556270;
  --ksc-line: #dbe2e9;
  --ksc-paper: #f3f6f9;
  --ksc-white: #ffffff;
  --ksc-ease: cubic-bezier(.2, .8, .2, 1);
  --ksc-z: 10000;             /* 홈페이지 상단 메뉴보다 위 */
}

/* ── 기본 정리 (홈페이지 CSS 영향 차단) ── */
.ksc-root, .ksc-root * { box-sizing: border-box; }
.ksc-root h2, .ksc-root h3, .ksc-root p, .ksc-root ol, .ksc-root ul, .ksc-root li {
  margin: 0; padding: 0; border: 0; background: none; list-style: none; text-indent: 0; letter-spacing: normal;
}
.ksc-root h2::before, .ksc-root h2::after, .ksc-root h3::before, .ksc-root h3::after,
.ksc-root li::before, .ksc-root li::after { content: none; }
.ksc-root button {
  margin: 0; font: inherit; color: inherit; background: none; border: 0; border-radius: 0;
  cursor: pointer; text-align: left; -webkit-appearance: none; appearance: none;
}
.ksc-root [tabindex="-1"]:focus { outline: none; }
.ksc-root :focus-visible { outline: 3px solid #ffbf47; outline-offset: 2px; }

/* ── 시트 (팝업·단독 공통 틀) ── */
.ksc-root.ksc-sheet {
  display: flex; flex-direction: column;
  font-family: "KSC Sans", "Pretendard", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 16px; line-height: 1.55; color: var(--ksc-ink);
  word-break: keep-all; overflow-wrap: anywhere; text-align: left;
  background: var(--ksc-paper);
}
.ksc-root.ksc-sheet:not(.ksc-is-modal) {
  max-width: 460px; min-height: 640px; margin: 0 auto;
  border-radius: 26px; overflow: hidden;
  box-shadow: 0 24px 60px -24px rgba(0, 60, 95, .35);
}
.ksc-root.ksc-is-modal { height: 100%; }

/* ── 위쪽 색 판 ── */
.ksc-root .ksc-top {
  position: relative; overflow: hidden; flex: none;
  padding: 18px 26px 30px;
  color: var(--ksc-white);
  background-color: var(--ksc-blue);
  background-image: radial-gradient(110% 80% at 0% 0%, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 60%);
  transition: background-color .35s var(--ksc-ease);
}
.ksc-root.ksc-tone-green .ksc-top { background-color: var(--ksc-green); }
.ksc-root.ksc-tone-amber .ksc-top { background-color: var(--ksc-amber); }
.ksc-root.ksc-tone-red .ksc-top { background-color: var(--ksc-red); }

.ksc-root .ksc-topbar { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-bottom: 14px; }
/* 로고: 색 판(파랑·초록·주황·빨강) 위에서 모두 보이도록 흰색 반전 로고로 표시 (원본 컬러 PNG를 CSS로 흰색 처리) */
.ksc-root .ksc-logo { display: inline-flex; align-items: center; height: 40px; }
.ksc-root .ksc-logo img { display: block; height: 30px; width: auto; max-width: none; border: 0; filter: brightness(0) invert(1); }
.ksc-root .ksc-brand { font-size: 13px; font-weight: 700; letter-spacing: .02em; opacity: .85; }
.ksc-root .ksc-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin-right: -10px; border-radius: 50%;
  font-size: 30px; line-height: 1; color: var(--ksc-white);
  transition: background-color .2s;
}
.ksc-root .ksc-close:hover { background: rgba(255, 255, 255, .16); }

/* 배경의 큰 글자: 질문 번호 / ? / O·△·X */
.ksc-root .ksc-giant {
  position: absolute; right: -8px; bottom: -34px; z-index: 0;
  font-size: 176px; font-weight: 800; line-height: 1; letter-spacing: -.06em;
  color: rgba(255, 255, 255, .13);
  pointer-events: none; user-select: none;
  font-variant-numeric: tabular-nums;
}
.ksc-root .ksc-giant-mark { bottom: -26px; right: 4px; font-size: 190px; letter-spacing: 0; }

.ksc-root .ksc-kicker, .ksc-root .ksc-heading, .ksc-root .ksc-lead,
.ksc-root .ksc-steps, .ksc-root .ksc-help-toggle, .ksc-root .ksc-help { position: relative; z-index: 1; }
.ksc-root .ksc-kicker { font-size: 14px; font-weight: 700; opacity: .9; margin-bottom: 8px; }
.ksc-root .ksc-heading {
  max-width: 340px;
  font-size: 24px; font-weight: 800; line-height: 1.35; letter-spacing: -.02em;
  color: var(--ksc-white); white-space: pre-line; text-wrap: balance;
}
.ksc-root .ksc-key { color: #ffd66b; }   /* 질문 속 핵심어: 파랑 판 위 노랑 (큰 굵은 글자 대비 3:1 이상) */
.ksc-root .ksc-qsub { position: relative; z-index: 1; max-width: 340px; margin-top: 8px; font-size: 14.5px; line-height: 1.5; opacity: .9; }
.ksc-root .ksc-heading-xl { font-size: 30px; line-height: 1.28; letter-spacing: -.03em; }
.ksc-root .ksc-lead { max-width: 320px; margin-top: 12px; font-size: 16px; line-height: 1.6; opacity: .92; }

/* 진행 칸 */
.ksc-root .ksc-steps { display: flex; gap: 5px; margin-bottom: 18px; max-width: 220px; }
.ksc-root .ksc-steps li { flex: 1; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .28); }
.ksc-root .ksc-steps li.is-done { background: rgba(255, 255, 255, .75); }
.ksc-root .ksc-steps li.is-now { background: var(--ksc-white); }

/* 도움말 */
.ksc-root .ksc-help-toggle {
  display: inline-flex; align-items: center; min-height: 32px; margin-top: 12px; padding: 0;
  font-size: 14px; font-weight: 700; color: var(--ksc-white);
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 4px;
}
.ksc-root .ksc-help-toggle[aria-expanded="true"] { text-decoration-style: solid; }
.ksc-root .ksc-help {
  max-width: 380px; margin-top: 8px; padding: 12px 14px; border-radius: 14px;
  background: rgba(0, 30, 50, .22); font-size: 14.5px; line-height: 1.6;
}
.ksc-root .ksc-help[hidden] { display: none; }

/* ── 아래쪽 ── */
.ksc-root .ksc-body { flex: 1; overflow-y: auto; padding: 22px 22px 26px; -webkit-overflow-scrolling: touch; }

/* 답 칸: 한 덩어리를 가는 선으로 나눈 타일 */
.ksc-root .ksc-tiles {
  display: grid; gap: 2px; padding: 2px;
  background: #c9d3dd; border-radius: 16px; overflow: hidden;
}
.ksc-root .ksc-tiles-grid, .ksc-root .ksc-tiles-binary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ksc-root .ksc-tiles-scale { grid-template-columns: repeat(var(--ksc-cols, 3), minmax(0, 1fr)); }
.ksc-root .ksc-tile {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 118px; padding: 14px 14px 13px;
  background: var(--ksc-white); color: var(--ksc-ink); border-radius: 4px;
  transition: background-color .18s, box-shadow .18s, color .18s;
}
.ksc-root .ksc-tile-label { font-size: 18px; font-weight: 800; line-height: 1.25; letter-spacing: -.02em; }
.ksc-root .ksc-tile-hint { margin-top: 3px; font-size: 13.5px; line-height: 1.35; color: var(--ksc-muted); }
.ksc-root .ksc-tile-key { position: absolute; top: 10px; left: 13px; font-size: 12.5px; font-weight: 800; color: #7d8a97; }
.ksc-root .ksc-tile-check {
  position: absolute; top: 10px; right: 10px; display: none;
  width: 22px; height: 22px; border-radius: 50%; background: var(--ksc-white); color: var(--ksc-blue);
  font-size: 13px; font-weight: 900; line-height: 22px; text-align: center;
}
.ksc-root .ksc-tile-muted { background: var(--ksc-paper); }
.ksc-root .ksc-tile-muted .ksc-tile-label { color: #3d4a57; }

/* 큰 두 칸 (예/아니요) */
.ksc-root .ksc-tiles-binary .ksc-tile:not(.ksc-tile-strip) { min-height: 168px; }
.ksc-root .ksc-tiles-binary .ksc-tile-label { font-size: 28px; }

/* 눈금 (충원율): 막대·숫자·설명이 칸마다 같은 높이에 오도록 위에서부터 쌓고, 숫자는 2줄 높이를 고정 */
.ksc-root .ksc-tiles-scale .ksc-tile:not(.ksc-tile-strip) { justify-content: flex-start; min-height: 150px; padding: 14px 12px 14px; }
.ksc-root .ksc-tiles-scale .ksc-tile-label { display: flex; align-items: flex-end; min-height: 2.5em; margin-top: auto; padding-top: 14px; font-size: 22px; line-height: 1.25; }
.ksc-root .ksc-gauge { display: flex; gap: 3px; }
.ksc-root .ksc-gauge i { width: 14px; height: 18px; border-radius: 3px; background: #e1e7ed; }
.ksc-root .ksc-gauge i.is-on { background: var(--ksc-blue); }

/* 모르겠어요 띠 (binary·scale) */
.ksc-root .ksc-tile-strip {
  grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: center;
  min-height: 56px; padding: 0 16px; background: var(--ksc-paper);
}
.ksc-root .ksc-tiles .ksc-tile.ksc-tile-strip .ksc-tile-label { min-height: 0; margin: 0; font-size: 16px; color: #3d4a57; }

/* 마우스 올림 (마우스가 있는 기기만) · 누름 · 고름 */
@media (hover: hover) {
  .ksc-root .ksc-tile:hover { background: #e3f1f9; box-shadow: inset 0 0 0 2px var(--ksc-blue); }
  .ksc-root .ksc-tile:hover .ksc-tile-label { color: #005f8f; }
}
.ksc-root .ksc-tile:focus-visible { outline: none; box-shadow: inset 0 0 0 3px #ffbf47; }
.ksc-root .ksc-tile:active { background: #d4eaf6; }
.ksc-root .ksc-tile.is-chosen, .ksc-root .ksc-tile.is-chosen:hover { background: var(--ksc-blue); color: var(--ksc-white); box-shadow: none; }
.ksc-root .ksc-tile.is-chosen .ksc-tile-label { color: var(--ksc-white); }
.ksc-root .ksc-tile.is-chosen .ksc-tile-hint, .ksc-root .ksc-tile.is-chosen .ksc-tile-key { color: #d7ebf6; }
.ksc-root .ksc-tile.is-chosen .ksc-tile-check { display: block; }
.ksc-root .ksc-tile.is-chosen .ksc-gauge i { background: rgba(255, 255, 255, .3); }
.ksc-root .ksc-tile.is-chosen .ksc-gauge i.is-on { background: var(--ksc-white); }

/* 이전·다시 (글자 버튼) */
.ksc-root .ksc-back {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-top: 12px; padding: 0 4px;
  font-size: 15px; font-weight: 700; color: var(--ksc-muted);
  transition: color .2s;
}
.ksc-root .ksc-back:hover { color: var(--ksc-ink); }

/* 시작 버튼 */
.ksc-root .ksc-cta {
  display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 62px;
  padding: 0 24px; border-radius: 18px;
  background: var(--ksc-ink); color: var(--ksc-white);
  font-size: 18px; font-weight: 800; letter-spacing: -.01em; text-decoration: none;
  transition: transform .2s var(--ksc-ease), background-color .2s;
}
.ksc-root .ksc-cta:hover { background: #22364a; }
.ksc-root .ksc-cta:active { transform: scale(.985); }
.ksc-root .ksc-cta-arrow { font-size: 22px; transition: transform .25s var(--ksc-ease); }
.ksc-root .ksc-cta:hover .ksc-cta-arrow { transform: translateX(4px); }
.ksc-root .ksc-cta-sm { min-height: 54px; font-size: 16px; }
.ksc-root .ksc-meta { margin-top: 14px; font-size: 13.5px; color: var(--ksc-muted); text-align: center; }
.ksc-root.ksc-view-intro .ksc-body { display: flex; }
.ksc-root .ksc-intro { display: flex; flex-direction: column; width: 100%; padding-top: 4px; }
.ksc-root .ksc-topics-title { font-size: 14px; font-weight: 800; color: var(--ksc-blue); margin-bottom: 4px; }
.ksc-root .ksc-topics li {
  display: flex; align-items: baseline; gap: 14px; padding: 11px 0;
  font-size: 16px; font-weight: 600; border-bottom: 1px solid var(--ksc-line);
}
.ksc-root .ksc-topics li:last-child { border-bottom: 0; }
.ksc-root .ksc-topic-num { font-size: 13px; font-weight: 800; color: var(--ksc-muted); font-variant-numeric: tabular-nums; }
.ksc-root .ksc-intro .ksc-cta { margin-top: auto; }
.ksc-root .ksc-intro .ksc-topics { margin-bottom: 24px; }

/* 결과 */
.ksc-root .ksc-limit { margin-bottom: 22px; padding: 16px 18px; border-radius: 16px; background: var(--ksc-white); border: 1px solid var(--ksc-line); }
.ksc-root .ksc-limit-title { font-size: 14px; font-weight: 800; color: var(--ksc-blue); }
.ksc-root .ksc-limit-amount { margin-top: 4px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.3; color: var(--ksc-ink); }
.ksc-root .ksc-limit-note { margin-top: 4px; font-size: 14.5px; color: #3d4a57; }
.ksc-root .ksc-limit-rate { display: flex; align-items: baseline; gap: 12px; margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--ksc-paper); }
.ksc-root .ksc-limit-rate dt { flex: none; margin: 0; font-size: 13px; font-weight: 800; color: var(--ksc-blue); }
.ksc-root .ksc-limit-rate dd { margin: 0; font-size: 14.5px; font-weight: 600; color: var(--ksc-ink); }
.ksc-root .ksc-limit-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--ksc-line); font-size: 12.5px; line-height: 1.55; color: var(--ksc-muted); }
.ksc-root .ksc-group + .ksc-group { margin-top: 22px; }
.ksc-root .ksc-group-title { font-size: 14px; font-weight: 800; margin-bottom: 6px; }
.ksc-root .ksc-group-exclude .ksc-group-title { color: var(--ksc-red); }
.ksc-root .ksc-group-collateral .ksc-group-title { color: var(--ksc-amber); }
.ksc-root .ksc-group-unknown .ksc-group-title { color: var(--ksc-blue); }
.ksc-root .ksc-group-note { font-size: 13.5px; color: var(--ksc-muted); margin-bottom: 4px; }
.ksc-root .ksc-list li {
  position: relative; padding: 11px 0 11px 18px;
  font-size: 15.5px; font-weight: 600; border-bottom: 1px solid var(--ksc-line);
}
.ksc-root .ksc-list li:last-child { border-bottom: 0; }
.ksc-root .ksc-list li::before {
  content: ""; position: absolute; left: 0; top: 19px; width: 8px; height: 8px; border-radius: 2px;
  background: var(--ksc-blue);
}
.ksc-root .ksc-group-exclude .ksc-list li::before { background: var(--ksc-red); }
.ksc-root .ksc-group-collateral .ksc-list li::before { background: var(--ksc-amber); transform: rotate(45deg); }
.ksc-root .ksc-group-unknown .ksc-list li::before { border-radius: 50%; }
.ksc-root .ksc-notes { margin-top: 24px; padding: 14px 16px; border-radius: 14px; background: #e8edf2; }
.ksc-root .ksc-notes p { font-size: 13px; line-height: 1.6; color: var(--ksc-muted); }
.ksc-root .ksc-notes p + p { margin-top: 6px; }
.ksc-root .ksc-notes p:first-child { color: var(--ksc-ink); font-weight: 600; }
.ksc-root.ksc-view-result .ksc-body { display: flex; }
.ksc-root .ksc-result { display: flex; flex-direction: column; width: 100%; }
.ksc-root .ksc-actions { display: flex; flex-direction: column; align-items: stretch; margin-top: auto; padding-top: 20px; }
.ksc-root .ksc-actions .ksc-back { align-self: flex-start; margin-top: 6px; }
.ksc-root .ksc-contact { margin-top: 4px; font-size: 14px; color: var(--ksc-muted); }

/* ── 화면 전환 움직임 ── */
.ksc-root .ksc-heading, .ksc-root .ksc-enter > *, .ksc-root .ksc-tiles > * {
  animation: ksc-rise .42s var(--ksc-ease) both;
}
.ksc-root .ksc-tiles > * { animation-delay: calc(60ms + var(--ksc-i, 0) * 45ms); }
.ksc-root .ksc-giant { animation: ksc-drift .7s var(--ksc-ease) both; }
@keyframes ksc-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes ksc-drift { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ── 팝업 ── */
.ksc-overlay {
  position: fixed; inset: 0; z-index: var(--ksc-z);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(8, 28, 44, .55);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: ksc-fade .2s ease both;
}
.ksc-overlay.is-leaving { animation: ksc-fade .18s ease reverse both; }
.ksc-overlay .ksc-dialog {
  width: min(460px, 100%); height: min(660px, 100%);
  border-radius: 26px; overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(0, 35, 60, .55);
  animation: ksc-pop .32s var(--ksc-ease) both;
}
@keyframes ksc-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ksc-pop { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }

/* 휴대폰: 화면 전체를 씀 (홈페이지 모바일 기준 440px) */
@media (max-width: 440px) {
  .ksc-overlay { padding: 0; }
  .ksc-overlay .ksc-dialog { width: 100%; height: 100%; border-radius: 0; }
  .ksc-root.ksc-sheet:not(.ksc-is-modal) { border-radius: 0; min-height: 100vh; min-height: 100dvh; box-shadow: none; }
  .ksc-root .ksc-top { padding: 14px 20px 26px; }
  .ksc-root .ksc-body { padding: 18px 16px 24px; }
  .ksc-root .ksc-heading { font-size: 22px; }
  .ksc-root .ksc-key { color: #ffd66b; }   /* 질문 속 핵심어: 파랑 판 위 노랑 (큰 굵은 글자 대비 3:1 이상) */
.ksc-root .ksc-qsub { position: relative; z-index: 1; max-width: 340px; margin-top: 8px; font-size: 14.5px; line-height: 1.5; opacity: .9; }
.ksc-root .ksc-heading-xl { font-size: 27px; }
  .ksc-root .ksc-giant { font-size: 150px; }
  .ksc-root .ksc-tiles-scale .ksc-tile-label { font-size: 20px; }
  .ksc-root .ksc-tiles-binary .ksc-tile:not(.ksc-tile-strip) { min-height: 140px; }
  .ksc-root .ksc-tiles-scale .ksc-tile:not(.ksc-tile-strip) { min-height: 136px; }
}

@media (prefers-reduced-motion: reduce) {
  .ksc-root *, .ksc-overlay, .ksc-overlay * { animation: none !important; transition: none !important; }
}
