/* ============================================================
   계산기랩 공통 스타일
   - 모바일 우선 · 시스템 폰트 · 라이트/다크(prefers-color-scheme)
   - 흰/회색 기반 + 포인트 컬러 1개(파랑 계열)
   ============================================================ */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6eb;
  --border-strong: #c9cfd8;
  --text: #1b2130;
  --text-sub: #5b6472;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-weak: #edf3fe;
  --focus-ring: rgba(37, 99, 235, 0.22);

  /* 판정 색 — 좋음/주의/나쁨. 계산 결과의 의미를 색으로 알린다.
   * 라이트·다크에서 각각 본문 대비 4.5:1(WCAG AA) 이상이 되도록 값을 나눠 둔다.
   * 예전에는 페이지마다 #2e7d32·#c62828·#ef6c00 을 직접 박았는데,
   * 다크에서 초록 3.26:1·빨강 2.97:1, 라이트에서 주황 3.08:1 로 전부 기준 미달이었다. */
  --ok: #1b5e20;    /* 흰 배경 7.87:1 */
  --warn: #b35309;  /* 흰 배경 5.05:1 */
  --bad: #b71c1c;   /* 흰 배경 6.57:1 */

  /* 흰 글자를 얹는 단색 배지·막대용. 위 --ok/--warn/--bad 와 달리 다크에서도 바뀌지 않는다.
   * (글자가 항상 흰색이라 배경까지 밝아지면 오히려 대비가 무너진다) */
  --ok-solid: #2e7d32;    /* 흰 글자 5.13:1 */
  --warn-solid: #b35309;  /* 흰 글자 5.05:1 — #ef6c00 은 3.08:1 로 미달이었다 */
  --bad-solid: #c62828;   /* 흰 글자 5.62:1 */

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(23, 32, 51, 0.05), 0 2px 8px rgba(23, 32, 51, 0.04);
  --shadow-lift: 0 2px 4px rgba(23, 32, 51, 0.06), 0 6px 16px rgba(23, 32, 51, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131519;
    --surface: #1b1e24;
    --border: #2b303a;
    --border-strong: #3b4250;
    --text: #e6e9ee;
    --text-sub: #99a2b0;
    --accent: #7ba0f6;
    --accent-strong: #a3bdf8;
    --accent-weak: #232c3e;
    --focus-ring: rgba(123, 160, 246, 0.35);

    /* 어두운 배경(#1b1e24)에서 각각 8.52 · 9.02 · 6.99:1 */
    --ok: #81c995;
    --warn: #fcad70;
    --bad: #f28b82;

    --shadow: none;
    --shadow-lift: 0 6px 16px rgba(0, 0, 0, 0.45);
  }
}

/* ---------- 기본 ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto,
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
}

a {
  color: var(--accent);
}

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

/* ---------- 헤더 ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  min-height: 56px;
}

.site-logo {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--accent);
  text-decoration: none;
  /* 모바일 탭 타겟 44px 확보 */
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* [hidden] 표준 동작 복원 — .grid2 등 display 지정 클래스가 UA 스타일을 덮는 것 방지 (QA 영어판 BUG-1) */
[hidden] {
  display: none !important;
}

/* 헤더: 로고 좌 · 언어 전환 우 */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 언어가 3개 이상이 되어 묶음으로 다룬다 — 헤더 space-between 이
   링크를 하나씩 밀어내지 않도록 nav 하나로 감싼 것. */
.lang-switches {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
  text-decoration: none;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
}

.lang-switch:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- 본문 공통 ---------- */

main.wrap {
  padding-top: 32px;
  padding-bottom: 48px;
}

main h1 {
  font-size: 1.45rem;
  letter-spacing: -0.01em;
  margin: 4px 0 6px;
  line-height: 1.35;
}

.page-desc {
  color: var(--text-sub);
  margin: 0 0 18px;
}

/* ---------- 홈 히어로 + 카드 목록 ---------- */

.hero {
  margin: 8px 0 32px;
}

.hero h1 {
  font-size: clamp(1.5rem, 5vw, 1.9rem);
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}

.hero p {
  color: var(--text-sub);
  margin: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 14px 0 8px;
}

/* 본문 끝의 관련 계산기 묶음. 본문과 섞이지 않게 구분선을 둔다. */
.related {
  margin: 40px 0 0;
  padding: 24px 0 0;
  border-top: 1px solid var(--border);
}

.related h2 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-sub);
}

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

.calc-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.calc-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

.calc-card-emoji {
  font-size: 1.6rem;
  line-height: 1.2;
}

.calc-card-name {
  font-weight: 700;
  margin-top: 6px;
}

.calc-card-desc {
  font-size: 0.85rem;
  color: var(--text-sub);
}

/* ---------- 계산기 카드 ---------- */

.calc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}

.calc h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 480px) {
  .grid2 {
    grid-template-columns: 1fr 1fr;
  }
}

.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 4px;
}

.field input {
  width: 100%;
  min-height: 54px;
  padding: 12px 14px;
  font: inherit;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input::placeholder {
  color: var(--text-sub);
  opacity: 0.55;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* 결과 판단문 — 숫자 앞뒤에 놓이는 "이만큼이에요" 한 문장 */
.result-say {
  display: block;
  margin: 16px 0 0;
  font-size: 1.02rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.55;
}

.result-say + .result {
  margin-top: 8px;
}

/* 큰 결과 표시 */
.result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 16px 18px;
  background: var(--accent-weak);
  border-radius: var(--radius-lg);
}

.result-label {
  flex-shrink: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-sub);
}

.result-value {
  font-size: clamp(1.7rem, 7vw, 2.2rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent-strong);
  overflow-wrap: anywhere;
  text-align: right;
  line-height: 1.3;
}

/* ---------- 버튼 ---------- */

.toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 14px 0;
}

.btn-ghost {
  min-height: 44px;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.btn-ghost:hover {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.btn-ghost:disabled {
  opacity: 0.7;
  cursor: default;
}

/* ---------- 설명 콘텐츠(article) ---------- */

main article {
  margin-top: 34px;
  line-height: 1.75;
}

main article h2 {
  font-size: 1.15rem;
  margin: 30px 0 10px;
}

main article h3 {
  font-size: 1rem;
  margin: 20px 0 6px;
}

main article p {
  margin: 0 0 12px;
}

main article ul,
main article ol {
  margin: 0 0 12px;
  padding-left: 1.3rem;
}

main article li {
  margin-bottom: 4px;
}

main article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0 0 12px;
}

main article th,
main article td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

main article th {
  background: var(--accent-weak);
}

.doc-date {
  color: var(--text-sub);
  font-size: 0.875rem;
}

/* ---------- 광고 슬롯 (주석 해제 후 사용) ---------- */

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  margin: 28px 0;
}

/* ---------- 푸터 ---------- */

.site-footer {
  margin-top: 40px;
  padding: 28px 0 44px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-sub);
}

.footer-note {
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 16px;
  margin: 10px 0 0;
}

.footer-links a {
  color: var(--text-sub);
  /* 모바일 탭 타겟 44px 확보 (시각 크기는 유지) */
  display: inline-block;
  padding: 12px 6px;
  margin: -12px -6px;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-copy {
  margin: 8px 0 0;
}

/* ---------- 접근성 ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

