@layer reset, tokens, base, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: 100%; }
}

@layer tokens {
  :root {
    color-scheme: light;
    --blue-50:  #eef5ff;
    --blue-100: #dbeafe;
    --blue-500: #3182f6;
    --blue-600: #2563eb;
    --n-50:  #f9fafb;
    --n-100: #f2f4f6;
    --n-200: #e5e8eb;
    --n-300: #d1d6db;
    --n-400: #b0b8c1;
    --n-500: #8b95a1;
    --n-600: #6b7684;
    --n-700: #4e5968;
    --n-800: #333d4b;
    --n-900: #191f28;
    --green: #1eb980;
    --red:   #f04452;
    --radius: 16px;
    --shadow: 0 4px 14px rgba(112,129,153,.06), 0 2px 6px rgba(0,0,0,.03);
    --maxw: 920px;
  }
}

@layer base {
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", system-ui, sans-serif;
    background: var(--n-100);
    color: var(--n-800);
    line-height: 1.6;
    word-break: keep-all;
    overflow-wrap: anywhere;
    padding: clamp(16px, 4vw, 48px) 16px;
  }
  h1, h2, h3, h4 { color: var(--n-900); line-height: 1.3; letter-spacing: -.02em; }
  a { color: var(--blue-600); text-decoration: none; }
  a:hover { text-decoration: underline; }
  code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--n-100); padding: .1em .35em; border-radius: 6px; color: var(--n-700); }
  em { font-style: normal; color: var(--blue-600); font-weight: 600; }
  small { font-size: 11px; font-weight: 500; color: var(--n-500); }
}

@layer components {
  .wrap { max-width: var(--maxw); margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

  /* hero */
  .hero { background: linear-gradient(153deg, #f5f9ff 0%, #fefeff 70%); border: 1px solid var(--n-200); border-radius: var(--radius); padding: clamp(24px, 5vw, 48px); box-shadow: var(--shadow); }
  .eyebrow { font-size: 13px; font-weight: 700; color: var(--blue-500); letter-spacing: .02em; margin-bottom: 12px; }
  .hero h1 { font-size: clamp(24px, 4.5vw, 38px); font-weight: 800; }
  .lede { margin-top: 16px; color: var(--n-600); font-size: clamp(14px, 1.8vw, 16px); max-width: 60ch; }
  .verdict { margin-top: 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--blue-100); border-radius: 12px; padding: 14px 18px; }
  .verdict__tag { font-size: 12px; font-weight: 700; color: #fff; background: var(--blue-500); border-radius: 999px; padding: 3px 10px; }
  .verdict__title { font-weight: 700; color: var(--n-900); }
  .verdict__score { margin-left: auto; font-size: 26px; font-weight: 800; color: var(--blue-500); font-variant-numeric: tabular-nums; }
  .verdict__score span { font-size: 14px; color: var(--n-400); font-weight: 600; }

  /* cards */
  .card { background: #fff; border: 1px solid var(--n-200); border-radius: var(--radius); padding: clamp(20px, 3.5vw, 32px); box-shadow: var(--shadow); }
  .card h2 { font-size: clamp(18px, 2.6vw, 22px); font-weight: 700; margin-bottom: 16px; }
  .card__sub { color: var(--n-600); font-size: 14px; margin-bottom: 20px; }
  .muted { color: var(--n-500); font-size: 13px; }

  blockquote { border-left: 3px solid var(--blue-500); background: var(--blue-50); padding: 14px 18px; border-radius: 0 10px 10px 0; color: var(--n-700); }

  details { border: 1px solid var(--n-200); border-radius: 12px; padding: 12px 16px; margin-top: 10px; background: var(--n-50); }
  details[open] { background: #fff; }
  summary { cursor: pointer; font-weight: 600; color: var(--n-800); }
  details > *:not(summary) { margin-top: 12px; }
  details ul { padding-left: 18px; color: var(--n-700); font-size: 14px; }
  details li { margin: 4px 0; }

  /* live demo panel */
  .demo .panel { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 36px 20px; border: 1px solid var(--n-200); border-radius: 14px; background: var(--n-50); }
  .panel__spinner { position: relative; width: 64px; height: 64px; display: grid; place-items: center; }
  .ring { position: absolute; inset: 0; border: 3px solid var(--blue-100); border-top-color: var(--blue-500); border-radius: 50%; animation: spin 1s linear infinite; }
  .spark { color: var(--blue-500); font-size: 20px; animation: pulse 1.6s ease-in-out infinite; }
  .panel__title { font-size: 16px; font-weight: 700; }
  .panel__subtitle { font-size: 13px; color: var(--n-500); margin-top: -10px; }
  .steps { list-style: none; display: flex; flex-direction: column; gap: 10px; background: var(--n-100); border: 1px solid var(--n-200); border-radius: 12px; padding: 14px 18px; min-width: min(340px, 90%); }
  .step { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--n-400); }
  .step .dot { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; border: 2px solid var(--n-300); position: relative; }
  .step--done { color: var(--n-600); }
  .step--done .dot { background: var(--blue-500); border-color: var(--blue-500); }
  .step--done .dot::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
  .step--active { color: var(--n-900); font-weight: 600; background: linear-gradient(90deg, var(--n-900) 25%, var(--blue-500) 50%, var(--n-900) 75%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: shimmer 1.8s linear infinite; }
  .step--active .dot { border-color: var(--blue-500); border-top-color: transparent; animation: spin 1s linear infinite; -webkit-text-fill-color: initial; }
  .demo__note { margin-top: 14px; font-size: 13px; color: var(--n-500); }

  /* options grid */
  .opts { display: grid; gap: 12px; }
  .opts article { border: 1px solid var(--n-200); border-radius: 12px; padding: 16px; background: var(--n-50); }
  .opts h3 { font-size: 15px; margin-bottom: 6px; }
  .opts p { font-size: 14px; color: var(--n-600); }

  .badge { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; vertical-align: middle; }
  .badge--win { background: var(--blue-500); color: #fff; }

  /* tables */
  .scroll-x { overflow-x: auto; }
  .t { width: 100%; border-collapse: collapse; font-size: 14px; }
  .t th, .t td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--n-200); vertical-align: top; }
  .t thead th { background: var(--n-50); font-weight: 700; color: var(--n-700); font-size: 13px; }
  .t .num { text-align: right; font-variant-numeric: tabular-nums; }
  .t .total { font-weight: 800; color: var(--blue-600); }
  .t tfoot td { font-weight: 700; background: var(--n-50); }
  .t--score tbody tr.rank-1 { background: var(--blue-50); }
  .t--score tbody tr.rank-1 td { font-weight: 600; }

  /* pros/cons */
  .pc { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .pc h4 { font-size: 13px; margin-bottom: 6px; color: var(--n-700); }
  .pc ul { padding-left: 16px; font-size: 13px; color: var(--n-600); }
  .why { font-size: 14px; border-radius: 10px; padding: 10px 14px; }
  .why--yes { background: #effaf4; color: #137a55; }
  .why--no { background: #fef0f1; color: #c2353f; }

  .reco { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--n-700); }
  .reco li { padding-left: 4px; }

  .card--final { border-color: var(--blue-100); background: linear-gradient(180deg, #fafcff, #fff); }
  .card--src .src { padding-left: 20px; font-size: 14px; color: var(--n-600); display: flex; flex-direction: column; gap: 7px; }

  .foot { text-align: center; color: var(--n-500); font-size: 13px; padding: 20px 0; }
}

@layer utilities {
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
  @keyframes shimmer { to { background-position: -200% 0; } }

  @media (max-width: 560px) {
    .pc { grid-template-columns: 1fr; }
    .verdict__score { margin-left: 0; }
  }

  @media (prefers-reduced-motion: reduce) {
    .ring, .spark, .step--active, .step--active .dot { animation: none !important; }
    .step--active { -webkit-text-fill-color: var(--n-900); color: var(--n-900); }
  }
}
