/**
 * Salary Lab Design Tokens
 * Source of truth: /DESIGN.md
 * Direction: Editorial / Refined Data — "공공데이터를 신뢰감 있는 신문처럼"
 */

:root {
  /* ─── Typography ─────────────────────────────── */
  --font-display: 'Source Serif 4', 'Pretendard Variable', Pretendard,
                  'Apple SD Gothic Neo', 'Noto Serif KR', serif;
  --font-body:    'Pretendard Variable', Pretendard,
                  'Apple SD Gothic Neo', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'D2Coding', 'Source Code Pro',
                  ui-monospace, 'SFMono-Regular', monospace;

  /* ─── Ink (text) ─────────────────────────────── */
  --ink:          #1A1A1A;
  --ink-muted:    #5C5C5C;
  --ink-soft:     #9A9A9A;

  /* ─── Paper (surfaces) ───────────────────────── */
  --paper:        #FAF8F4;
  --surface:      #FFFFFF;
  --surface-sunk: #F3EFE7;
  --rule:         #E8E4DA;
  --rule-strong:  #C9C2B3;

  /* ─── Accent (단 1색 — 샐러리 그린) ──────────── */
  --accent:       #5B8A4A;
  --accent-hover: #4A7239;
  --accent-soft:  #EDF5EA;

  /* ─── Semantic ──────────────────────────────── */
  --positive:      #1F5E3A;
  --positive-soft: #E6F0E8;
  --negative:      #A6321F;
  --negative-soft: #F8E6DF;
  --warning:       #8A5B00;
  --warning-soft:  #FAF0D6;
  --info:          #2C3E5C;
  --info-soft:     #E5EAF2;

  /* ─── Radius (8px max) ───────────────────────── */
  --radius-sm:   4px;
  --radius-md:   6px;
  --radius-lg:   8px;
  --radius-pill: 9999px;
}

/* ─── Base ─────────────────────────────────────── */
html, body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv11';
}

body {
  font-size: 15px;
  line-height: 1.6;
}

/* Display headlines use serif */
h1, h2, h3, .font-display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  /* Korean: prefer breaking at word boundaries, not arbitrary characters */
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* Numerics — tabular figures by default */
.num, .tabular,
[class*="font-mono"] {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum', 'ss01';
  font-variant-numeric: tabular-nums;
}

/* ─── Type scale utilities (paired with Tailwind) ─ */
.text-display-xl { font-family: var(--font-display); font-size: 48px; line-height: 56px; font-weight: 700; }
.text-display-lg { font-family: var(--font-display); font-size: 36px; line-height: 44px; font-weight: 600; }
.text-title      { font-size: 20px; line-height: 28px; font-weight: 700; }
.text-heading    { font-size: 16px; line-height: 24px; font-weight: 600; }
.text-body       { font-size: 15px; line-height: 24px; font-weight: 400; }
.text-small      { font-size: 13px; line-height: 20px; font-weight: 400; }
.text-data-lg    { font-family: var(--font-mono); font-size: 20px; line-height: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }
.text-data       { font-family: var(--font-mono); font-size: 15px; line-height: 20px; font-variant-numeric: tabular-nums; }
.text-data-sm    { font-family: var(--font-mono); font-size: 13px; line-height: 18px; font-variant-numeric: tabular-nums; }

/* ─── Cards: border instead of shadow ─────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
}

.card-sunk {
  background: var(--surface-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
}

/* ─── Links ─────────────────────────────────── */
a.link, .link {
  color: var(--accent);
  text-decoration: none;
}
a.link:hover, .link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}
a.link:visited, .link:visited {
  color: var(--accent-hover);
}

/* ─── Badge / pill ─────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--surface-sunk);
  color: var(--ink-muted);
  white-space: nowrap;
}
.badge-accent  { background: var(--accent-soft);   color: var(--accent); }
.badge-positive{ background: var(--positive-soft); color: var(--positive); }
.badge-negative{ background: var(--negative-soft); color: var(--negative); }
.badge-warning { background: var(--warning-soft);  color: var(--warning); }
.badge-info    { background: var(--info-soft);     color: var(--info); }

/* ─── Rank chip (replaces 🥇🥈🥉) ────────────── */
.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  width: 22px;
  text-align: center;
}
.rank-1, .rank-2, .rank-3 { color: var(--accent); font-weight: 700; }

/* ─── Section heading divider (newspaper rule) ─ */
.section-rule {
  border-top: 1px solid var(--rule-strong);
  padding-top: 12px;
  margin-bottom: 12px;
}

/* ─── Slider thumb (touch target ≥ 22px) ───── */
input[type="range"]::-webkit-slider-thumb {
  background: var(--accent) !important;
  width: 22px !important;
  height: 22px !important;
  border: 2px solid var(--surface) !important;
  border-radius: var(--radius-pill);
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
input[type="range"]::-moz-range-thumb {
  background: var(--accent) !important;
  width: 22px !important;
  height: 22px !important;
  border: 2px solid var(--surface) !important;
  border-radius: var(--radius-pill);
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}

/* ─── Focus ring ─────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.rank:focus-visible,
.badge:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ─── Skip-to-content link ─────────────── */
.skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  background: var(--accent);
  color: var(--surface);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 500;
  z-index: 100;
  transition: top 150ms ease-out;
}
.skip-link:focus {
  top: 8px;
}

/* ─── Reduced motion ─────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Ranking row hover (CSS-only, replaces JS onmouseover) ─ */
.rank-row {
  cursor: pointer;
  transition: background-color 150ms ease-out;
  border-bottom: 1px solid var(--rule);
}
.rank-row:hover {
  background: var(--accent-soft);
}

/* ─── Filter bar (mobile collapse) ─ */
@media (min-width: 640px) {
  details.filter-bar > summary { display: none !important; }
  details.filter-bar > div { margin-top: 0 !important; }
}
details.filter-bar > summary::-webkit-details-marker { display: none; }
details.filter-bar > summary { list-style: none; }

/* ─── Methodology details ─ */
details.methodology {
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 6px;
}
details.methodology summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--surface-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--radius-pill);
  list-style: none;
  user-select: none;
}
details.methodology summary::-webkit-details-marker { display: none; }
details.methodology summary::before {
  content: 'i';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-pill);
  background: var(--ink-muted);
  color: var(--surface);
  font-family: var(--font-display);
  font-size: 10px;
  font-style: italic;
  font-weight: 700;
}
details.methodology[open] summary {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
details.methodology[open] summary::before {
  background: var(--accent);
}
details.methodology > div {
  margin-top: 8px;
  padding: 12px;
  background: var(--surface-sunk);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  line-height: 1.6;
}

/* ─── Tabular numerics in Chart.js tooltips ─── */
.chartjs-tooltip { font-family: var(--font-mono); }

/* ─── Metric color classes (used by metricClass()) ─ */
.metric-positive { color: var(--positive); }
.metric-negative { color: var(--negative); }
.metric-warning  { color: var(--warning); }
.metric-accent   { color: var(--accent); }
.metric-muted    { color: var(--ink-soft); }

/* ─── Correlation matrix cells (used by corrCellClass()) ─ */
.corr-diag        { background: var(--surface-sunk); color: var(--ink-muted); }
.corr-pos-strong  { background: #BBD9C5; color: #0F3C24; font-weight: 700; }
.corr-pos-mid     { background: var(--positive-soft); color: var(--positive); }
.corr-pos-weak    { background: #F2F8F4; color: var(--positive); }
.corr-neg-strong  { background: #F0C7BC; color: #5C1A0E; font-weight: 700; }
.corr-neg-mid     { background: var(--negative-soft); color: var(--negative); }
.corr-neg-weak    { background: #FCF1ED; color: var(--negative); }
.corr-zero        { color: var(--ink-soft); }
