---
import SiteNav from '../../SiteNav.astro';
import { site } from '../../../lib/siteConfig';
import type { TagSummary } from '../../../lib/posts';

type Props = {
  tags: TagSummary[];
};

const { tags } = Astro.props;
---

<main class="yar-tags-page">
  <div class="yar-shell">
    <header class="yar-header">
      <div class="yar-header-inner">
        <div class="yar-title-box">
          <h1 class="yar-title">{site.title}</h1>
        </div>
        <SiteNav />
      </div>
    </header>

    <section class="yar-tags-section" aria-label="Tags">
      {tags.length === 0 ? (
        <p class="yar-empty">No tags yet.</p>
      ) : (
        <ul class="yar-tag-index">
          {tags.map((tag) => (
            <li>
              <a href={`/tags/${tag.slug}/`}>
                <span>{tag.name}</span>
                <strong>{tag.count}</strong>
              </a>
            </li>
          ))}
        </ul>
      )}
    </section>

    <footer class="yar-footer">
      <p>由 osaet 构建</p>
      <p>© 2026 Osaet. All rights reserved.</p>
    </footer>
  </div>
</main>

<style>
  .yar-tags-page {
    min-height: 100vh;
    background: #ffffff;
    color: #1c211b;
  }

  .yar-shell {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    width: 100%;
    padding: 40px 0 5vh;
  }

  .yar-header {
    border-bottom: 1px solid rgba(28, 33, 27, 0.18);
  }

  .yar-header-inner {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    width: 50vw;
    margin: 0 auto;
    padding-bottom: 28px;
  }

  .yar-shell :global(.site-nav) {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25em;
    justify-content: flex-end;
    margin: 0;
    border-radius: 0.75em;
    background: #ffffff;
    box-shadow: 0 0em 0.2em rgb(29 53 87 / 13%);
    padding: 0.5em 1.4em;
    color: #53605a;
    font-family:
      ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
      sans-serif;
    font-size: 0.86rem;
  }

  .yar-shell :global(.site-nav a) {
    border-radius: 0.65em;
    color: inherit;
    padding: 0.55em 0.8em;
    text-decoration: none;
  }

  .yar-shell :global(.site-nav a:hover) {
    background: #eef1ed;
    text-decoration: none;
  }

  .yar-title-box {
    border-radius: 0.7em;
    background: #1d3557;
    padding: 1em 1.4em;
  }

  .yar-title {
    margin: 0;
    color: #ffffff;
    font-family:
      "Heti Hei", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
      sans-serif;
    font-size: 1em;
    letter-spacing: 0.16em;
    line-height: 1.15;
  }

  .yar-tags-section {
    width: 50vw;
    margin: 0 auto;
    padding: 36px 0 0;
    color: #3d3d3f;
    font-family:
      "Heti Hei", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
      "Noto Sans CJK SC", "Source Han Sans SC", "Source Han Sans CN",
      sans-serif;
    font-size: 16px;
    letter-spacing: 1px;
    line-height: 1.7em;
  }

  .yar-tag-index {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8em;
    padding: 0;
    margin: 0;
    list-style: none;
  }

  .yar-tag-index a {
    display: inline-flex;
    gap: 0.7em;
    align-items: center;
    border-radius: 999em;
    background: #f3f6f4;
    box-shadow: inset 0 0 0 1px rgb(29 53 87 / 7%);
    color: #53605a;
    padding: 0.7em 1em;
    text-decoration: none;
  }

  .yar-tag-index a:hover {
    background: #e8eee9;
  }

  .yar-tag-index strong {
    color: #1d3557;
    font-family:
      ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
      sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
  }

  .yar-empty {
    margin: 0;
    color: #596254;
    text-align: center;
  }

  .yar-footer {
    width: 50vw;
    margin: auto auto 0;
    color: #8a9089;
    font-family:
      ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
      sans-serif;
    font-size: 0.78rem;
    line-height: 1.8;
    text-align: center;
  }

  .yar-footer p {
    margin: 0;
  }

  @media (max-width: 760px) {
    .yar-shell {
      padding-top: 24px;
    }

    .yar-header-inner,
    .yar-tags-section,
    .yar-footer {
      width: calc(100% - 28px);
    }

    .yar-header-inner {
      flex-direction: column;
      align-items: flex-start;
      gap: 16px;
    }
  }
</style>
