@use 'abstracts';

@keyframes skeleton-shimmer {
  from { background-position: -400px 0; }
  to   { background-position:  400px 0; }
}

.blog-list {
  min-height: calc(100vh - var(--nav-height));
  padding-block: calc(var(--space-4) * 2);

  &__wrapper {
    @include abstracts.container-wrapper;
  }

  &__header {
    text-align: center;
    margin-bottom: calc(var(--space-4) * 1.5);

    h1 {
      font-size: var(--font-size-xl);
      margin-bottom: var(--space-2);
    }

    p {
      font-size: var(--font-size-lg);
    }
  }

  &__label {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: var(--space-2);
  }

  &__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);

    @include abstracts.breakpoint('md') {
      grid-template-columns: repeat(2, 1fr);
    }

    @include abstracts.breakpoint('lg') {
      grid-template-columns: repeat(3, 1fr);
    }
  }

  &__error,
  &__empty {
    text-align: center;
    padding: var(--space-4);
    color: var(--text-muted);
    font-size: var(--font-size-lg);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
  }
}

.blog-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  background-color: var(--bg-surface);
  color: var(--text-main);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.25s ease,
              border-color 0.25s ease;

  &:hover {
    transform: translateY(-6px);
    border-color: var(--accent);
    box-shadow: 0 16px 48px oklch(0% 0 0 / 0.1);
  }

  &__image {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background-color: var(--bg-muted);
    flex-shrink: 0;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
      transition: transform 0.4s ease;

      .blog-card:hover & {
        transform: scale(1.05);
      }
    }
  }

  &__image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-muted) 0%, var(--border-color) 100%);
    color: var(--text-muted);
    opacity: 0.5;
  }

  &__read-time {
    position: absolute;
    bottom: var(--space-2);
    right: var(--space-2);
    background: oklch(0% 0 0 / 0.7);
    backdrop-filter: blur(8px);
    color: var(--color-white);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
  }

  &__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
    flex: 1;
  }

  &__tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
  }

  &__tag {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, oklch(from var(--accent) l c h / 0.12) 0%, oklch(from var(--accent) l c h / 0.08) 100%);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  &__title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    line-height: 1.3;
    transition: color 0.2s ease;

    .blog-card:hover & {
      color: var(--accent);
    }
  }

  &__summary {
    font-size: var(--font-size-base);
    color: var(--text-muted);
    line-height: 1.65;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  &__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
  }

  &__date {
    font-size: 0.8rem;
    color: var(--text-muted);
  }

  &__cta {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    transition: gap 0.2s ease;

    .blog-card:hover & {
      gap: var(--space-2);
    }
  }

  &--skeleton {
    pointer-events: none;

    .blog-card__image--skeleton {
      background-color: var(--bg-muted);
    }
  }
}

.skeleton-line {
  height: 1em;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--bg-muted) 25%,
    var(--border-color) 50%,
    var(--bg-muted) 75%
  );
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;

  &--title {
    height: 1.4em;
    width: 80%;
    margin-bottom: var(--space-1);
  }

  &--text {
    width: 100%;
  }

  &--short {
    width: 50%;
  }
}
