/* ==========================================================================
   base.css — 디자인 토큰 + 리셋 + 기본 컴포넌트
   모바일 우선(mobile-first). 미디어 쿼리는 넓은 화면 쪽으로만 확장합니다.

   색 체계
   - 브랜드/데이터는 하나의 파랑 램프에서 뽑아 씁니다 (100 → 700).
   - 2계열 비교 막대는 blue #2a78d6 / orange #eb6834.
     (색각이상 시뮬레이션 검증 완료: 인접쌍 CVD ΔE 24.7, 일반시야 ΔE 33.6,
      흰 배경 대비 3:1 이상 — 모두 통과)
   - 상태색(good/warn/bad)은 계열색과 겹치지 않게 따로 잡았고,
     항상 텍스트 라벨과 함께 씁니다. 색만으로 의미를 전달하지 않습니다.
   ========================================================================== */

:root {
  color-scheme: light;

  /* 면 */
  --page: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef1f6;

  /* 잉크 */
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #667085;
  --ink-inv: #ffffff;

  /* 선 */
  --line: #e4e7ec;
  --line-strong: #cfd4dc;

  /* 브랜드 (파랑 램프) */
  --brand-700: #0d366b;
  --brand-600: #184f95;
  --brand-500: #256abf;
  --brand: #2a78d6;
  --brand-300: #6da7ec;
  --brand-200: #9ec5f4;
  --brand-100: #cde2fb;
  --brand-50: #eef4ff;

  /* 데이터 계열 */
  --series-1: #2a78d6;
  --series-1-track: #cde2fb;
  --series-2: #eb6834;
  --series-2-track: #fbdccf;

  /* 상태 */
  --good: #0ca30c;
  --good-ink: #046104;
  --good-bg: #edf9ed;
  --warn: #fab219;
  --warn-ink: #8a5a00;
  --warn-bg: #fff8e8;
  --bad: #d03b3b;
  --bad-ink: #b42318;
  --bad-bg: #fdf0ef;

  /* 형태 */
  --r-xs: 6px;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-2: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-3: 0 12px 32px rgba(16, 24, 40, .14);

  --header-h: 56px;
  --maxw: 1120px;

  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
          "Malgun Gothic", "맑은 고딕", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  --font-num: var(--font);
}

/* ------------------------------- 리셋 --------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
a { color: var(--brand-500); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button { font: inherit; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* --------------------------- 버튼 / 링크버튼 --------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .12s, border-color .12s, color .12s;
}

.btn:hover { background: var(--surface-2); border-color: var(--ink-3); text-decoration: none; }
.btn:active { background: var(--surface-3); }

.btn-primary {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: var(--ink-inv);
}
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }

.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-3); border-color: transparent; }

.btn-sm { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ------------------------------- 카드 --------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.card-head h2, .card-head h3 { font-size: 16px; margin: 0; }
.card-body { padding: 16px; }

/* ------------------------------ 입력 폼 -------------------------------- */

.input, .select, .textarea {
  width: 100%;
  min-height: 50px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;              /* iOS 확대 방지: 16px 이상 */
  line-height: 1.4;
}

.input::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-50);
}

.select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23667085' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* 세그먼트 컨트롤 (라디오 대체) */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-3);
}

.seg label {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 8px;
  border-radius: var(--r-xs);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  text-align: center;
  transition: background-color .12s, color .12s;
}

.seg label:has(input:checked) {
  background: var(--surface);
  color: var(--brand-600);
  box-shadow: var(--shadow-1);
}

.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 1px; }

/* 체크박스 */
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 15px;
}

.check input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--brand-500);
}

/* ------------------------------- 배지 --------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-brand { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-600); }
.badge-good { background: var(--good-bg); border-color: #cfe9cf; color: var(--good-ink); }
.badge-warn { background: var(--warn-bg); border-color: #f3e2b8; color: var(--warn-ink); }

/* ------------------------------ 유틸리티 ------------------------------- */

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  padding: 10px 16px;
  background: var(--surface);
  border: 2px solid var(--brand);
  border-radius: var(--r-sm);
  font-weight: 700;
}
.skip-link:focus { left: 8px; top: 8px; }

.stack > * + * { margin-top: 12px; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
