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

@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; }
  img, picture, video { display: block; max-width: 100%; }
  input, button, textarea { font: inherit; }
}

@layer tokens {
  :root {
    color-scheme: light;
    --bg: #fafafa;
    --surface: #ffffff;
    --fg: #14171f;
    --muted: #5b6472;
    --line: #e6e8ec;
    --pri: oklch(58% 0.17 255);
    --pri-soft: color-mix(in oklch, var(--pri), white 88%);
    --accent: oklch(68% 0.15 35);
    --gain: oklch(60% 0.14 155);
    --code-bg: #f1f3f6;
    --radius: 0.625rem;
    --shadow: 0 1px 2px rgba(20,23,31,.04), 0 4px 12px rgba(20,23,31,.04);
    --font-sans: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", system-ui, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
  }
}

@layer base {
  body {
    font-family: var(--font-sans);
    line-height: 1.65;
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
  code {
    font-family: var(--font-mono);
    background: var(--code-bg);
    padding: 0.1em 0.35em;
    border-radius: 0.3rem;
    font-size: 0.88em;
  }
  a { color: var(--pri); text-decoration: none; }
  a:hover { text-decoration: underline; }
}

@layer layout {
  .wrap {
    max-width: 1040px;
    margin-inline: auto;
    padding-inline: clamp(1rem, 3vw, 2rem);
  }
  main.wrap { padding-block: 2rem 3rem; }
  section { margin-block: 2.5rem; }
  section + section { border-top: 1px solid var(--line); padding-top: 2rem; }
}

@layer components {
  .hero {
    background: linear-gradient(180deg, var(--pri-soft), var(--bg));
    padding-block: clamp(2rem, 6vw, 4rem);
    border-bottom: 1px solid var(--line);
  }
  .kicker {
    color: var(--pri);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
  }
  h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 0.75rem;
  }
  .lede {
    font-size: 1.05rem;
    color: var(--muted);
    max-width: 56ch;
  }
  .meta {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--muted);
    font-family: var(--font-mono);
  }

  h2 {
    font-size: 1.35rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
  }
  h2::before {
    content: "";
    width: 4px;
    height: 1em;
    background: var(--pri);
    border-radius: 2px;
    align-self: center;
  }

  .bullets {
    padding-left: 1.25rem;
  }
  .bullets li {
    margin-block: 0.4rem;
  }

  table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    font-size: 0.92rem;
  }
  table.data th,
  table.data td {
    padding: 0.7rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
  }
  table.data thead th {
    background: color-mix(in oklch, var(--pri), white 92%);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
  }
  table.data tbody tr:last-child td { border-bottom: none; }
  table.data tbody tr:hover { background: color-mix(in oklch, var(--pri), white 96%); }
  table.data .gain {
    color: var(--gain);
    font-weight: 600;
    font-family: var(--font-mono);
  }

  .callout {
    margin-top: 1rem;
    padding: 0.9rem 1.1rem;
    background: color-mix(in oklch, var(--accent), white 88%);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
  }

  ol.actions {
    counter-reset: actions;
    list-style: none;
    padding-left: 0;
  }
  ol.actions li {
    counter-increment: actions;
    position: relative;
    padding: 0.85rem 1rem 0.85rem 3rem;
    margin-block: 0.6rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  ol.actions li::before {
    content: counter(actions);
    position: absolute;
    left: 0.9rem;
    top: 0.85rem;
    width: 1.6rem;
    height: 1.6rem;
    display: grid;
    place-items: center;
    background: var(--pri);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: var(--font-mono);
  }

  .footer-note {
    color: var(--muted);
    font-size: 0.9rem;
    font-style: italic;
  }

  footer {
    border-top: 1px solid var(--line);
    background: var(--surface);
    padding-block: 1.25rem;
    margin-top: 3rem;
  }
  footer p {
    color: var(--muted);
    font-size: 0.82rem;
    font-family: var(--font-mono);
    text-align: center;
  }
}

@container (max-width: 640px) {
  table.data { font-size: 0.85rem; }
}
