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

@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: #ffffff;
    --fg: #1a1a1a;
    --muted: #6b7280;
    --pri: oklch(58% 0.19 250);
    --pri-soft: color-mix(in oklch, var(--pri), white 88%);
    --line: #e5e7eb;
    --line-soft: #f3f4f6;
    --radius: 0.625rem;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2.5rem;
    --font-sans: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", sans-serif;
  }
}

@layer base {
  body {
    font-family: var(--font-sans);
    line-height: 1.65;
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
  }

  main {
    max-width: 56rem;
    margin-inline: auto;
    padding: var(--space-5) var(--space-4);
  }

  h1 {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-2);
  }

  h2 {
    font-size: 1.25rem;
    letter-spacing: -0.01em;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--line);
  }

  section { margin-block: var(--space-5); }

  header .lead {
    color: var(--muted);
    font-size: 1.05rem;
  }

  code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.9em;
    background: var(--line-soft);
    padding: 0.1em 0.35em;
    border-radius: 0.25rem;
  }

  footer {
    margin-top: var(--space-5);
    padding-top: var(--space-3);
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.875rem;
    text-align: center;
  }
}

@layer components {
  .tldr {
    list-style: none;
    padding: var(--space-3) var(--space-4);
    background: var(--pri-soft);
    border-radius: var(--radius);
    display: grid;
    gap: var(--space-2);

    & li {
      position: relative;
      padding-left: 1.25rem;

      &::before {
        content: "→";
        position: absolute;
        left: 0;
        color: var(--pri);
        font-weight: 600;
      }
    }
  }

  .table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

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

    & th, & td {
      padding: var(--space-2) var(--space-3);
      text-align: left;
      border-bottom: 1px solid var(--line-soft);
    }

    & thead th {
      background: var(--line-soft);
      font-weight: 600;
      font-size: 0.875rem;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }

    & tbody tr:last-child td { border-bottom: none; }

    & tbody tr:hover { background: color-mix(in oklch, var(--pri-soft), white 50%); }

    & strong { color: var(--pri); }
  }

  details {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: var(--space-2);
    overflow: hidden;
    transition: background 0.15s;

    &[open] { background: var(--line-soft); }

    & summary {
      padding: var(--space-3);
      cursor: pointer;
      font-weight: 500;
      user-select: none;

      &:hover { color: var(--pri); }
    }

    & p {
      padding: 0 var(--space-3) var(--space-3);
      color: var(--muted);
    }
  }
}

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