---
import type { Entry } from '../lib/entries';

interface Props {
  entries: Entry[];
}

const { entries } = Astro.props;

const fmt = new Intl.DateTimeFormat('en-US', {
  year: 'numeric',
  month: 'short',
  day: 'numeric',
});
---

<ul class="entry-list">
  {
    entries.map((entry) => (
      <li>
        <a href={entry.href} class="row">
          <div class="text">
            <span class="primary">{entry.primary}</span>
            {entry.secondary && <span class="secondary">{entry.secondary}</span>}
          </div>
          <time datetime={entry.date.toISOString()}>{fmt.format(entry.date)}</time>
        </a>
      </li>
    ))
  }
</ul>

<style>
  .entry-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  .entry-list li {
    border-bottom: 1px solid var(--rule);
  }
  .entry-list .row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.85rem 0;
    color: inherit;
  }
  .entry-list .row:hover { text-decoration: none; }
  .entry-list .row:hover .primary { color: var(--accent); }
  .text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
  }
  .primary {
    font-family: ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--fg);
    letter-spacing: -0.01em;
  }
  .secondary {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.35;
  }
  time {
    color: var(--muted);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
    align-self: flex-start;
    padding-top: 0.15rem;
  }
</style>
