@layer reset, base, layout, components, util;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, h4, p, ul, ol, table, figure { margin: 0; padding: 0; }
  ul, ol { list-style: none; }
  table { border-collapse: collapse; width: 100%; }
}

@layer base {
  :root {
    color-scheme: light;
    --bg: #fafafa;
    --surface: #ffffff;
    --border: #e5e5e5;
    --border-strong: #d4d4d4;
    --text: #171717;
    --text-muted: #525252;
    --text-subtle: #737373;
    --accent: #1e40af;
    --accent-soft: #dbeafe;
    --success: #15803d;
    --success-soft: #dcfce7;
    --warn: #b45309;
    --warn-soft: #fef3c7;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --gold: #ca8a04;
    --gold-soft: #fef9c3;
    --radius: 8px;
    --radius-lg: 14px;
    --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.04);
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
    --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  }

  html { font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
  body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    font-size: 15px;
  }
}

@layer layout {
  .wrap { max-width: 1180px; margin: 0 auto; padding: 32px 24px 80px; }

  header.hero {
    padding: 28px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 28px;
  }
  header.hero h1 {
    font-size: clamp(22px, 3vw, 30px);
    letter-spacing: -0.02em;
    font-weight: 700;
  }
  header.hero .meta {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 14px;
    display: flex; gap: 12px; flex-wrap: wrap;
  }
  header.hero .meta span { display: inline-flex; align-items: center; gap: 6px; }

  section { margin-bottom: 32px; }
  section h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--text);
    display: flex; align-items: baseline; gap: 10px;
  }
  section h2 .num {
    font-family: var(--font-mono);
    color: var(--text-subtle);
    font-size: 14px;
  }
  section h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 18px 0 10px;
    color: var(--text);
  }
}

@layer components {
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
  }

  .grid { display: grid; gap: 14px; }
  @container (min-width: 720px) {
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
  }
  .row { container-type: inline-size; }

  table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 14px;
  }
  thead { background: #f4f4f5; }
  th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }
  th { font-weight: 600; color: var(--text); white-space: nowrap; }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr:hover { background: #fafafa; }
  td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

  .rank-1 td:first-child { border-left: 4px solid var(--gold); font-weight: 600; }
  .rank-2 td:first-child { border-left: 4px solid #94a3b8; font-weight: 600; }
  .rank-3 td:first-child { border-left: 4px solid #b45309; }

  .total {
    font-weight: 700;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
  }

  .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
  }
  .badge-gold { background: var(--gold-soft); color: var(--gold); }
  .badge-accent { background: var(--accent-soft); color: var(--accent); }
  .badge-success { background: var(--success-soft); color: var(--success); }
  .badge-warn { background: var(--warn-soft); color: var(--warn); }
  .badge-danger { background: var(--danger-soft); color: var(--danger); }

  .winner {
    background: linear-gradient(135deg, #fef9c3 0%, #fef3c7 100%);
    border: 2px solid var(--gold);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
  }
  .winner h3 {
    font-size: 18px;
    margin: 0 0 6px;
    color: var(--text);
  }
  .winner .why { color: var(--text-muted); }

  .kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
  }
  .kpi .label { font-size: 12px; color: var(--text-subtle); text-transform: uppercase; letter-spacing: 0.05em; }
  .kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-family: var(--font-mono); }
  .kpi .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

  .pros-cons { display: grid; gap: 8px; }
  .pros-cons .ph { font-weight: 600; font-size: 13px; color: var(--text-muted); }
  .pros li, .cons li {
    padding: 6px 0 6px 22px;
    position: relative;
    font-size: 14px;
  }
  .pros li::before { content: "+"; position: absolute; left: 4px; color: var(--success); font-weight: 700; }
  .cons li::before { content: "−"; position: absolute; left: 4px; color: var(--danger); font-weight: 700; }

  details.option {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    margin-bottom: 12px;
    overflow: hidden;
  }
  details.option > summary {
    padding: 14px 20px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    font-weight: 600;
    list-style: none;
  }
  details.option > summary::-webkit-details-marker { display: none; }
  details.option > summary::after {
    content: "▾";
    color: var(--text-subtle);
    transition: transform 0.15s;
  }
  details.option[open] > summary::after { transform: rotate(180deg); }
  details.option .body { padding: 0 20px 20px; border-top: 1px solid var(--border); }
  details.option .body > * { margin-top: 14px; }

  .note {
    font-size: 13px;
    color: var(--text-muted);
    padding: 12px 14px;
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
  }
  .note.warn { background: var(--warn-soft); border-color: var(--warn); }

  .source-list { font-size: 13px; color: var(--text-muted); }
  .source-list li { padding: 4px 0; }
  .source-list a { color: var(--accent); text-decoration: none; }
  .source-list a:hover { text-decoration: underline; }

  footer.footer {
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-subtle);
    font-size: 12px;
    text-align: center;
  }
}

@layer util {
  .muted { color: var(--text-muted); }
  .strong { font-weight: 600; }
  .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
}
