@use 'sass:map';
@use '../abstracts' as *;

// ============================================================
// The post list — home, archives, search (grouped by year)
// ============================================================

.min-wrap { max-width: 680px; margin: 0 auto; }

// ---- Archive / search header ----
.archive-header {
  margin-bottom: 56px;

  // the_archive_title()'s "Category:" prefix — inside the h1, on its own line
  .archive-label {
    display: block;
    font-family: $font-sans;
    line-height: 1.6;
    font-size: 13px;
    letter-spacing: 0.14em;
    color: var(--ink-faint);
    margin-bottom: 6px;
  }

  .archive-title {
    font-family: $font-serif;
    font-size: clamp(26px, 3.6vw, 34px);
    font-weight: 400;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }

  .archive-description {
    margin-top: 12px;
    color: var(--ink-soft);
    font-size: 16px;
    font-weight: 300;
    max-width: 52ch;

    > * + * { margin-top: 0.8em; }
  }

  .search-form { margin-top: 24px; }
}

// ---- Year ----
.min-year {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 54px 0 6px;
  font-family: $font-serif;
  font-size: 14px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);

  &::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--rule);
  }

  &:first-child { margin-top: 0; }
}

// The current year has no label; after the pinned posts it still needs a
// break: a plain rule, nothing more
.min-divider {
  height: 1px;
  margin: 54px 0 6px;
  border: 0;
  background: var(--rule);
}

// ---- One post per row ----
.min-post {
  display: flex;
  align-items: baseline;
  gap: 22px;
  padding: 15px 0;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: padding-left 0.35s $ease-out-soft;

  &:hover { padding-left: 10px; }

  &:focus-visible {
    outline: 2px solid var(--accent-deep);
    outline-offset: 3px;
    border-radius: 8px;
  }

  .date {
    flex-shrink: 0;
    width: 66px;
    font-size: 13.5px;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
  }

  .title {
    flex: 1;
    min-width: 0; // let long words wrap (PLAYBOOK §2)
    font-family: $font-serif;
    font-size: 19px;
    font-weight: 400;
    line-height: 1.55;
    color: var(--ink);
    overflow-wrap: anywhere;
    transition: color 0.28s ease;
  }

  &:hover .title { color: var(--accent-deep); }

  .kind {
    flex-shrink: 0;
    font-size: 12.5px;
    color: var(--ink-faint);
  }

  &.is-note .title { font-style: italic; }

  @include below(mobile) {
    flex-wrap: wrap;
    gap: 4px 14px;
    padding: 14px 0;

    .date { width: auto; order: 2; }
    .title { flex: 1 1 100%; order: 1; font-size: 18px; }
    .kind { order: 3; }
  }
}

// ---- Older / newer posts ----
.min-pagination {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 40px;

  // A lone "newer" link stays on the left; "older" sits on the right
  .min-more--newer:only-child { margin-right: auto; }
  .min-more--older { margin-left: auto; }
  .min-more--older:only-child { margin-left: 0; }
}

.min-more {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--ink-soft);
  text-decoration: none;
  transition: gap 0.3s ease, color 0.3s ease;

  &:hover { gap: 16px; color: var(--accent-deep); }
}

// ---- Nothing found ----
.no-results {
  color: var(--ink-soft);
  font-size: 16.5px;
  font-weight: 300;

  .search-form { margin-top: 24px; }
}

// ---- Featured image preview on hover ----
.min-preview {
  position: fixed;
  top: 0;
  left: calc(50% - 340px - 32px);
  width: 148px;
  height: 104px;
  transform: translate(-100%, -50%) scale(0.94);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--thumb-bg);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.38s ease,
              transform 0.5s $ease-out-soft,
              top 0.5s $ease-out-soft;

  &.is-visible {
    opacity: 1;
    transform: translate(-100%, -50%) scale(1);
  }

  img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    filter: var(--img-filter);
  }

  // For a post with no featured image
  &.is-empty {
    display: flex; align-items: center; justify-content: center;
    background:
      radial-gradient(circle at 25% 25%, var(--fallback-sheen), transparent 60%),
      var(--fallback-grad);
  }

  .letter {
    font-family: $font-serif;
    font-size: 36px;
    color: var(--fallback-letter);
  }

  &.is-empty img { display: none; }
  &:not(.is-empty) .letter { display: none; }

  // No room in the margin on narrow screens.
  // Include .is-empty, or its display: flex (higher specificity) wins
  @media (hover: none), (max-width: map.get($breakpoints, preview)) {
    &, &.is-empty { display: none; }
  }
}

// ---- Theme switcher: in the corner on list views ----
body.is-minimal {
  .theme-switcher {
    top: auto;
    bottom: 22px;
    right: 22px;
    transform: none;
    flex-direction: row;
    padding: 5px 6px;
    gap: 2px;
  }

  .theme-btn { width: 32px; height: 32px; }
  .theme-btn svg { width: 15px; height: 15px; }
  .theme-btn::after { display: none; }
}
