/* ============================================================
   리얼샐러리 — 공통 스타일 (DESIGN-binance.md 기반)
   이원 테마: 라이트(기본, 계산기·정보 페이지) / body.theme-dark(허브)
   플랫 컬러블록 + 헤어라인 · 노랑 단일 액센트 · 숫자는 IBM Plex Sans
   ============================================================ */

:root {
  /* ---- 테마 불변 (브랜드 상수) ---- */
  --primary: #FCD535;
  --primary-active: #F0B90B;
  --on-primary: #181A20;
  --info: #3B82F6;
  --focus-ring: 0 0 0 2px rgba(59, 130, 246, 0.5);
  --r-btn: 6px;
  --r-input: 8px;
  --r-card: 8px;
  --r-elevated: 12px;
  --r-pill: 9999px;
  --font-num: "IBM Plex Sans", "Pretendard Variable", Pretendard, sans-serif;

  /* ---- 라이트 트랜잭션 테마 (기본) ----
     up/down/danger/뮤티드는 흰 바탕 4.5:1 미달인 브랜드 원색 대신
     동일 계열의 진한 변형을 쓴다(다크 테마에서 원색으로 복원). */
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-soft: #FAFAFA;
  --surface-strong: #F5F5F5;
  --border: #EAECEF;
  --border-strong: #CDD1D6;
  --text: #181A20;
  --text-strong: #181A20;
  --text-sub: #5C6773;
  --up: #067647;
  --down: #D9304E;
  --danger: #D9304E;
  --link-underline: #946300;
  color-scheme: light;
}

/* ---- 다크 마케팅 테마 (허브) ---- */
body.theme-dark {
  --bg: #0B0E11;
  --surface: #1E2329;
  --surface-soft: #1E2329;
  --surface-strong: #2B3139;
  --border: #2B3139;
  --border-strong: #474D57;
  --text: #EAECEF;
  --text-strong: #FFFFFF;
  --text-sub: #929AA5;
  --up: #0ECB81;
  --down: #F6465D;
  --danger: #F6465D;
  color-scheme: dark;
}

/* body의 color-scheme은 뷰포트(스크롤바·오버스크롤)까지 승격되지 않으므로
   루트가 명시적으로 light인 상태를 허브에서만 dark로 덮는다 */
html:has(body.theme-dark) { color-scheme: dark; }

/* ---------- 리셋 / 베이스 ---------- */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
  word-break: keep-all;
}

a {
  color: var(--text-strong);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: currentColor; }
body.theme-dark a { color: var(--primary); text-decoration: none; }
body.theme-dark a:hover { text-decoration: underline; text-decoration-color: currentColor; }

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

[hidden] { display: none !important; }

.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;
}

/* ---------- 레이아웃 ---------- */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

.container-wide { max-width: 1120px; }

.section-band { padding: 0 0 48px; }
@media (min-width: 768px) {
  .section-band { padding: 0 0 80px; }
}

/* ---------- 헤더 / 내비게이션 ---------- */

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

.site-header .container {
  max-width: 1120px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
  min-height: 64px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.logo {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.logo:hover { text-decoration: none; }
body.theme-dark .logo { color: var(--text-strong); }
body.theme-dark .logo:hover { text-decoration: none; }

.logo .logo-mark {
  background: var(--primary);
  color: var(--on-primary);
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 2px;
}

.site-nav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.site-nav a {
  padding: 8px 10px;
  border-radius: var(--r-btn);
  font-size: 0.9rem;
  color: var(--text-sub);
  font-weight: 500;
  text-decoration: none;
}
body.theme-dark .site-nav a { color: var(--text-sub); }
.site-nav a:hover,
body.theme-dark .site-nav a:hover {
  text-decoration: none;
  background: var(--surface-strong);
  color: var(--text-strong);
}
.site-nav a[aria-current="page"],
body.theme-dark .site-nav a[aria-current="page"] {
  color: var(--text-strong);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--primary);
  border-radius: var(--r-btn) var(--r-btn) 0 0;
}

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

main { padding: 24px 0 48px; }
body.theme-dark main { padding-top: 0; }

h1 {
  font-size: 1.6rem;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 8px 0 6px;
  color: var(--text-strong);
}

.page-desc {
  color: var(--text-sub);
  margin: 0 0 20px;
  font-size: 0.98rem;
}

h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 40px 0 12px;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}
h3 {
  font-size: 1.06rem;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text-strong);
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-elevated);
  padding: 24px 20px;
}

.field { margin-bottom: 16px; }

.field > label,
.field > .field-label {
  display: block;
  font-weight: 600;
  font-size: 0.94rem;
  margin-bottom: 6px;
  color: var(--text-strong);
}

.field .hint {
  font-weight: 400;
  color: var(--text-sub);
  font-size: 0.85rem;
  margin-left: 4px;
}

input[type="text"],
input[type="date"],
select {
  width: 100%;
  padding: 11px 12px;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  min-height: 46px;
}

input[type="text"] {
  text-align: right;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}
input[type="text"]::placeholder { color: var(--text-sub); text-align: right; }

input:focus, select:focus {
  outline: none;
  border-color: var(--info);
  box-shadow: var(--focus-ring);
}

input.invalid { border-color: var(--danger); }

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 5px;
}

.input-suffix {
  position: relative;
  display: flex;
  align-items: center;
}
.input-suffix input { padding-right: 40px; }
.input-suffix .suffix {
  position: absolute;
  right: 13px;
  color: var(--text-sub);
  font-size: 0.95rem;
  pointer-events: none;
}

/* 2열 배치 (좁은 화면에선 1열) */
.field-row { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 480px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}

/* ---------- 세그먼트 토글 (라디오 기반) ---------- */

.seg {
  display: flex;
  background: var(--surface-strong);
  border-radius: var(--r-input);
  padding: 2px;
  gap: 2px;
}

.seg input[type="radio"] {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.seg label {
  flex: 1;
  text-align: center;
  padding: 9px 8px;
  border-radius: var(--r-btn);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  min-height: 24px;
}

.seg input:checked + label {
  background: var(--surface);
  color: var(--text-strong);
  box-shadow: inset 0 0 0 1px var(--border);
}

.seg input:focus-visible + label {
  outline: 2px solid var(--info);
  outline-offset: 1px;
}

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

.btn-primary {
  display: block;
  width: 100%;
  padding: 13px 24px;
  margin-top: 4px;
  min-height: 48px;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--on-primary);
  background: var(--primary);
  border: none;
  border-radius: var(--r-btn);
  cursor: pointer;
}
.btn-primary:hover,
.btn-primary:active { background: var(--primary-active); }

.btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  margin-top: 0;
  padding: 12px 28px;
  font-size: 0.98rem;
  border-radius: var(--r-pill);
  white-space: nowrap;
}

.btn-ghost {
  display: inline-block;
  padding: 9px 14px;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-strong);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-soft); }
.btn-ghost.copied { color: var(--text-sub); }

/* ---------- 결과 영역 ---------- */

.result { margin-top: 24px; }

.result-total {
  text-align: center;
  padding: 24px 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-elevated);
  margin-bottom: 16px;
}

.result-total .label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
  margin: 0;
}

.result-total .amount {
  font-family: var(--font-num);
  font-size: clamp(2rem, 6vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
  color: var(--text-strong);
  margin: 2px 0;
  line-height: 1.2;
}

.result-total .sub {
  font-size: 0.92rem;
  color: var(--text-sub);
  margin: 0;
}

.result-summary {
  text-align: center;
  font-size: 0.98rem;
  margin: 0 0 14px;
}

/* ---------- 표 ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

caption {
  text-align: left;
  font-weight: 600;
  padding-bottom: 8px;
  color: var(--text-strong);
}

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

thead th {
  font-size: 0.8rem;
  color: var(--text-sub);
  font-weight: 500;
}

td.num, th.num {
  text-align: right;
  font-family: var(--font-num);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

tr.total-row th, tr.total-row td {
  font-weight: 700;
  border-bottom: none;
  border-top: 1px solid var(--border-strong);
}

/* 금액 방향 시맨틱: 들어오는 돈(초록) / 빠져나가는 돈(빨강) */
tr.row-in td.num { color: var(--up); }
tr.row-out td.num { color: var(--down); }

.table-note { font-size: 0.85rem; color: var(--text-sub); margin-top: 8px; }

/* ---------- 가이드 목록 ---------- */

.guide-list { list-style: none; padding: 0; margin: 0 0 28px; }

.guide-list li {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.guide-list li:last-child { border-bottom: 0; }

.guide-list a { text-decoration: none; }
.guide-list a strong { font-size: 1.05rem; }
.guide-list a:hover strong { text-decoration: underline; }

.guide-list p {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--text-sub);
}

/* ---------- 이동 경로 (breadcrumb) ---------- */

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-bottom: 12px;
}

.breadcrumb a { color: var(--text-sub); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb [aria-current="page"] { color: var(--text); }

/* ---------- 고지 / 안내 ---------- */

.disclaimer {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--surface-strong);
  border-radius: var(--r-card);
  font-size: 0.88rem;
  color: var(--text-sub);
}

.notice {
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  background: var(--surface-soft);
  border-radius: 0 var(--r-card) var(--r-card) 0;
  font-size: 0.92rem;
}

/* ---------- 광고 슬롯 ----------
   비어 있는 동안은 표시하지 않고(:empty), 광고 유닛(<ins>)이 삽입되면
   min-height 예약이 살아나 로드 시 레이아웃 시프트(CLS)가 없다. */

.ad-slot {
  min-height: 250px;
  margin: 28px 0;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ad-slot:empty { display: none; }

.ad-slot::before {
  content: "광고";
  font-size: 0.78rem;
  color: var(--text-sub);
}

/* ---------- 아코디언 / FAQ ---------- */

details {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface);
  margin-bottom: 10px;
  padding: 0 16px;
}

summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.97rem;
  padding: 14px 0;
  list-style-position: outside;
  color: var(--text-strong);
}

details[open] summary { border-bottom: 1px solid var(--border); }

details .details-body { padding: 12px 0 14px; font-size: 0.95rem; }

/* ---------- 본문 콘텐츠 (설명 글) ---------- */

.content-prose { font-size: 0.98rem; }
.content-prose > h2:first-child { margin-top: 0; }
.content-prose p { margin: 0 0 14px; }
.content-prose ul, .content-prose ol { margin: 0 0 14px; padding-left: 22px; }
.content-prose li { margin-bottom: 6px; }
.content-prose strong { font-weight: 700; color: var(--text-strong); }
.content-prose table { margin: 14px 0; }

.example-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-elevated);
  padding: 16px;
  margin: 16px 0;
}
.example-box h3 { margin-top: 0; }

/* ---------- 허브: 히어로 / 스탯 / 퀵 계산 ---------- */

.hero { padding: 40px 0 56px; }
@media (min-width: 768px) {
  .hero { padding: 72px 0 88px; }
}

.hero h1 {
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  line-height: 1.15;
  margin: 0 0 12px;
}

.hero .page-desc {
  max-width: 560px;
  margin-bottom: 0;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 48px;
  margin: 36px 0 0;
}

.stat-num {
  display: block;
  font-family: var(--font-num);
  font-size: clamp(1.6rem, 3.5vw, 2.25rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

.stat-label {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--text-sub);
}

.quick-calc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 560px;
  margin: 36px 0 0;
}

.quick-calc input[type="text"] {
  flex: 1;
  min-width: 180px;
  height: 48px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-strong);
}

/* ---------- 허브 카드 ---------- */

.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 20px 0;
}
@media (min-width: 640px) {
  .cards-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
}
@media (min-width: 960px) {
  .cards-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.calc-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-elevated);
  padding: 24px 20px;
  color: var(--text);
  text-decoration: none;
}
body.theme-dark .calc-card {
  color: var(--text);
  border-color: transparent;
}
.calc-card:hover,
body.theme-dark .calc-card:hover {
  text-decoration: none;
  border-color: var(--border-strong);
  background: var(--surface-strong);
}
.calc-card h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-strong);
}
.calc-card p { margin: 0; font-size: 0.92rem; color: var(--text-sub); }

.card-cta {
  display: block;
  margin-top: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-active);
}
body.theme-dark .card-cta { color: var(--primary); }

/* ---------- 프리푸터 CTA 밴드 (cta-band-dark 패턴) ---------- */

.cta-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-elevated);
  padding: 40px 32px;
}

.cta-band h2 {
  margin: 0 0 6px;
  font-size: clamp(1.4rem, 3vw, 1.75rem);
  line-height: 1.25;
}

.cta-band p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-sub);
}

/* 링크형 버튼: 전역 a 규칙(색·언더라인)이 버튼 위에 얹히지 않도록 */
a.btn-primary,
body.theme-dark a.btn-primary {
  color: var(--on-primary);
  text-decoration: none;
}
a.btn-primary:hover,
body.theme-dark a.btn-primary:hover {
  text-decoration: none;
}

/* ---------- 내부 링크 박스 ---------- */

.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
}
.related-links a {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-strong);
  text-decoration: none;
}
body.theme-dark .related-links a { color: var(--text-strong); }
.related-links a:hover,
body.theme-dark .related-links a:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  text-decoration: none;
}
body.theme-dark .related-links a:hover { background: var(--surface-strong); }

/* ---------- 푸터 (전 테마 공통: 라이트 고정 — 다크 페이지 위 라이트 푸터 반전) ---------- */

.site-footer {
  border-top: 1px solid #EAECEF;
  background: #FAFAFA;
  padding: 48px 0 56px;
  font-size: 0.88rem;
  color: #5C6773;
}

.site-footer .container { max-width: 1120px; }

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 12px;
}

.site-footer a,
body.theme-dark .site-footer a {
  color: #181A20;
  font-weight: 500;
  text-decoration: none;
}
.site-footer a:hover,
body.theme-dark .site-footer a:hover {
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.site-footer p { margin: 4px 0; }

/* ---------- 모션 (감소 선호 시 비활성) ---------- */

@media (prefers-reduced-motion: no-preference) {
  a,
  button,
  .site-nav a,
  .seg label,
  .calc-card,
  .related-links a,
  input,
  select {
    transition: background-color 0.15s ease, border-color 0.15s ease,
      color 0.15s ease, box-shadow 0.15s ease, text-decoration-color 0.15s ease;
  }
}

/* ---------- 유틸 ---------- */

.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
