---
---
<section
  class="wi-section wi-friends"
  th:if="${theme.config?.home?.home_friends_enabled == true and pluginFinder.available('PluginLinks')}"
>
  <div class="wi-container">
    <div class="wi-section__header">
      <h2 class="wi-section__title" th:text="${theme.config?.home?.home_friends_title ?: '友链'}">友链</h2>
      <span class="wi-section__accent"></span>
    </div>

    <div class="wi-friends__grid">
      <a
        th:each="link : ${linkFinder.list()}"
        th:href="${link.spec.url}"
        th:title="${link.spec.displayName}"
        target="_blank"
        rel="noopener noreferrer"
        class="wi-friends__card"
      >
        <img
          th:if="${link.spec.logo}"
          th:src="${link.spec.logo}"
          th:alt="${link.spec.displayName}"
          class="wi-friends__avatar"
        />
        <div
          th:unless="${link.spec.logo}"
          class="wi-friends__avatar wi-friends__avatar--placeholder"
        >
          <span th:text="${#strings.substring(link.spec.displayName, 0, 1)}"></span>
        </div>
        <div class="wi-friends__info">
          <span class="wi-friends__name" th:text="${link.spec.displayName}"></span>
          <span
            class="wi-friends__desc"
            th:if="${link.spec.description}"
            th:text="${link.spec.description}"
          ></span>
        </div>
      </a>
    </div>
  </div>
</section>

<style>
  .wi-friends__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-lg);
  }

  .wi-friends__card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition:
      transform var(--duration-normal) var(--ease-out-expo),
      box-shadow var(--duration-normal) var(--ease-out-expo),
      border-color var(--duration-normal) var(--ease-out-expo);
  }

  .wi-friends__card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
    color: inherit;
  }

  .wi-friends__avatar {
    width: 48px;
    height: 48px;
    border-radius: 9999px;
    object-fit: cover;
    flex-shrink: 0;
  }

  .wi-friends__avatar--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-bg);
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: var(--text-lg);
    font-weight: 700;
  }

  .wi-friends__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .wi-friends__name {
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .wi-friends__desc {
    font-size: var(--text-sm);
    color: var(--ink-3);
    line-height: var(--leading-snug);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  @media (max-width: 640px) {
    .wi-friends__grid {
      grid-template-columns: 1fr;
      gap: var(--space-md);
    }
  }
</style>
