---
interface Props {
  token: string;
  hex: string;
  name: string;
  usage?: string;
}
const { token, hex, name, usage } = Astro.props as Props;
---

<div class="swatch">
  <div class="swatch__chip" style={`background:${hex}`} aria-hidden="true"></div>
  <div class="swatch__meta">
    <strong class="swatch__name">{name}</strong>
    <code class="swatch__token">{token}</code>
    <code class="swatch__hex">{hex}</code>
    {usage && <p class="swatch__usage">{usage}</p>}
  </div>
</div>

<style>
  .swatch {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 1.2rem;
    align-items: center;
    padding: 0.75rem 0;
    margin: 0;
    border-bottom: 1px solid rgba(31, 27, 46, 0.08);
  }
  .swatch:last-child { border-bottom: 0; }

  .swatch__chip {
    width: 96px;
    height: 64px;
    border-radius: 3px;
    box-shadow:
      inset 0 0 0 1px rgba(0, 0, 0, 0.04),
      0 2px 8px -3px rgba(31, 27, 46, 0.20);
  }

  .swatch__meta {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
  }

  .swatch__name {
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    font-variation-settings: 'opsz' 24, 'wght' 600;
    letter-spacing: -0.018em;
    color: var(--ink, #1f1b2e);
    font-size: 1.05rem;
    margin-bottom: 0.05rem;
  }

  .swatch__token {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.74rem;
    color: var(--iris-deep, #5e548c);
    background: transparent;
    padding: 0;
    border: 0;
  }

  .swatch__hex {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.74rem;
    color: var(--ink-faint, #847b94);
    background: transparent;
    padding: 0;
    border: 0;
  }

  .swatch__usage {
    margin: 0.4rem 0 0;
    font-size: 0.85rem;
    color: var(--ink-soft, #4a4258);
    line-height: 1.55;
    max-width: 38rem;
    font-variation-settings: 'opsz' 14, 'wght' 400;
  }

  :root[data-theme='dark'] .swatch { border-bottom-color: rgba(236, 230, 243, 0.10); }
  :root[data-theme='dark'] .swatch__name { color: #ece6f3; }
  :root[data-theme='dark'] .swatch__token { color: #c2dcec; }
  :root[data-theme='dark'] .swatch__hex { color: #9c92ad; }
  :root[data-theme='dark'] .swatch__usage { color: #c5bfd1; }
</style>
