/* ======================================
   Rampaga home.css — v0.1
   Назначение: главная страница сайта
   Популярное + лента публикаций
   ====================================== */

body.page--home {
  background: var(--page-background-color, #eef2f6);
  color: var(--text-color, #20262d);
}

/* ===== Shell ===== */

.home-shell {
  --home-shell-width: 960px;
  --home-shell-gap: 0.875rem;
  --home-shell-radius: 1.125rem;
  --home-shell-padding: 1.5625rem;

  --home-feed-width: 760px;
  --home-flow-space: 1.25rem;
  --home-card-space: 1.125rem;

  padding: clamp(1.25rem, 2vw, 2rem) 0 clamp(2.5rem, 4vw, 4.5rem);
}

.home-layout {
  width: min(100% - 2rem, var(--home-shell-width));
  margin: 0 auto;
  display: grid;
  gap: var(--home-shell-gap);
}

/* ===== Popular ===== */

.home-popular {
  padding: 1rem var(--home-shell-padding);
  border-radius: var(--home-shell-radius);
  background: var(--surface-color, #f7f9fb);
  box-shadow: 0 0.5rem 1.5rem rgba(15, 23, 42, 0.04);

  & .home-popular__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    max-width: 760px;
    margin: 0 auto 0.875rem;
  }

  & .home-popular__title {
    color: var(--text-strong-color, #181c22);
    font-size: clamp(1.125rem, 1.03rem + 0.35vw, 1.35rem);
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  & .home-popular__note {
    margin: 0;
    color: var(--text-muted-color, #6b7280);
    font-size: var(--font-size-caption, 0.875rem);
    line-height: 1.4;
    white-space: nowrap;
  }

  & .home-popular__list {
    margin: 0 auto;
    max-width: 760px;
    display: grid;
  }

  & .home-popular__item {
    min-width: 0;
    &:nth-child(n + 6) {
      opacity: 0.75;
    }
  }

  & .home-popular__link {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    padding: 0.375rem 0.5rem;
    border-radius: 0.75rem;
    color: inherit;
    transition:
      background-color var(--transition-fast, 150ms ease),
      color var(--transition-fast, 150ms ease),
      transform var(--transition-fast, 150ms ease);

    &:hover,
    &:focus-visible {
      background: color-mix(in srgb, var(--surface-subtle-color, #e8eef3) 84%, white);
      color: var(--text-strong-color, #181c22);
    }
  }

  & .home-popular__time {
    flex: 0 0 auto;
    min-width: 3rem;
    color: var(--text-muted-color, #6b7280);
    font-size: 0.8125rem;
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
    opacity: 0.7;
  }

  & .home-popular__text {
    min-width: 0;
    color: inherit;
    font-size: clamp(0.98rem, 0.94rem + 0.15vw, 1.06rem);
    line-height: 1.45;
    overflow: hidden;
    text-overflow: ellipsis;
    /* white-space: nowrap; */
  }
}

/* ===== Feed ===== */

.home-feed {
  padding: var(--home-shell-padding) 0;
  /* border: 1px solid var(--border-color, rgba(17, 24, 39, 0.08)); */
  border-radius: var(--home-shell-radius);
  background: var(--surface-color, #f7f9fb);
  box-shadow: 0 0.5rem 1.5rem rgba(15, 23, 42, 0.04);
}

.feed-list {
  max-width: calc(var(--home-feed-width) + calc(var(--layout-padding-inline) * 2));
  margin: 0 auto;
  padding-inline: var(--layout-padding-inline);
}

.feed-card {
  position: relative;

  /* &:not(:last-child) { */
  border-bottom: 1px solid var(--border-color, rgba(17, 24, 39, 0.08));
  /* } */

  & .feed-card__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-bottom: 0.625rem;
    padding-top: var(--home-card-space);
    color: var(--text-muted-color, #6b7280);
    font-size: 0.8125rem;
    line-height: 1.4;
  }

  & .feed-card__meta-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    min-width: 0;
  }

  & .feed-card__category {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 1.75rem;
    padding: 0.1875rem 0.5rem;
    border-radius: var(--radius-pill, 999px);
    background: color-mix(in srgb, var(--surface-subtle-color, #e8eef3) 88%, white);
    color: var(--text-soft-color, #475569);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex: 0 0 auto;

    &::before {
      content: "";
      width: 0.45rem;
      height: 0.45rem;
      border-radius: 50%;
      background: var(--accent-color, #1677c8);
      flex: 0 0 auto;
    }
  }

  & .feed-card__date {
    color: var(--text-muted-color, #6b7280);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  & .feed-card__follow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    flex: 0 0 auto;
    min-height: 2rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color, rgba(17, 24, 39, 0.08));
    border-radius: var(--radius-pill, 999px);
    background: color-mix(in srgb, var(--surface-subtle-color, #e8eef3) 72%, white);
    color: var(--text-soft-color, #475569);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition:
      background-color var(--transition-fast, 150ms ease),
      border-color var(--transition-fast, 150ms ease),
      color var(--transition-fast, 150ms ease),
      transform var(--transition-fast, 150ms ease);

    &:hover,
    &:focus-visible {
      background: color-mix(in srgb, var(--surface-subtle-color, #e8eef3) 90%, white);
      border-color: color-mix(in srgb, var(--accent-color, #1677c8) 22%, var(--border-color, rgba(17, 24, 39, 0.08)));
      color: var(--accent-color, #1677c8);
    }

    &:active {
      transform: translateY(1px);
    }

    &[aria-pressed="true"],
    &.is-active {
      background: color-mix(in srgb, var(--accent-color, #1677c8) 12%, white);
      border-color: color-mix(in srgb, var(--accent-color, #1677c8) 26%, var(--border-color, rgba(17, 24, 39, 0.08)));
      color: var(--accent-color, #1677c8);
    }
  }

  & .feed-card__follow-icon {
    flex: 0 0 auto;
    font-size: 0.95em;
    line-height: 1;
  }

  & .feed-card__link {
    display: block;
    padding-bottom: var(--home-card-space);
    color: inherit;
    text-decoration: none;
    transition:
      color var(--transition-fast, 150ms ease),
      opacity var(--transition-fast, 150ms ease);

    &:hover,
    &:focus-visible {
      color: inherit;
    }

    &:hover .feed-card__title,
    &:focus-visible .feed-card__title {
      color: var(--accent-color, #1677c8);
    }

    &:hover .feed-card__media img,
    &:focus-visible .feed-card__media img {
      /* transform: scale(1.018); */
    }
  }

  & .feed-card__title,
  & .feed-card__excerpt {
    max-width: 46rem;
  }

  & .feed-card__title {
    margin: 0;
    color: var(--text-strong-color, #181c22);
    font-size: clamp(1.5rem, 1.35rem + 0.55vw, 1.95rem);
    line-height: 1.12;
    font-weight: 700;
    letter-spacing: -0.03em;
    transition: color var(--transition-fast, 150ms ease);
  }

  & .feed-card__excerpt {
    margin: 0.75rem 0 0;
    color: var(--text-soft-color, #475569);
    font-size: clamp(0.98rem, 0.94rem + 0.15vw, 1.06rem);
    line-height: 1.58;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  & .feed-card__media {
    margin-top: 1rem;
    overflow: hidden;
    border-radius: 1rem;
    background: var(--surface-strong-color, #dde5ea);

    & img {
      width: 100%;
      /* aspect-ratio: 16 / 9; */
      object-fit: cover;
      transform: scale(1);
      transition: transform var(--transition-base, 300ms ease-out);
    }
  }
}

@media (max-width: 640px) {
  .feed-card {
    & .feed-card__meta {
      align-items: flex-start;
      gap: 0.625rem;
      padding-top: var(--home-card-space);
    }

    & .feed-card__meta-main {
      gap: 0.45rem 0.625rem;
    }

    & .feed-card__follow {
      min-height: 1.875rem;
      padding-inline: 0.6875rem;
      font-size: 0.78rem;
    }

    & .feed-card__title,
    & .feed-card__excerpt {
      max-width: none;
    }
  }
}

/* ===== Feed actions ===== */

.home-feed__more {
  max-width: calc(var(--home-feed-width) + calc(var(--layout-padding-inline) * 2));
  margin: 0 auto;
  padding: 0.75rem var(--layout-padding-inline) 0;
}

.home-feed__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color, rgba(17, 24, 39, 0.08));
  border-radius: var(--radius-pill, 999px);
  background: color-mix(in srgb, var(--surface-subtle-color, #e8eef3) 74%, white);
  color: var(--text-strong-color, #181c22);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color var(--transition-fast, 150ms ease),
    color var(--transition-fast, 150ms ease),
    transform var(--transition-fast, 150ms ease),
    border-color var(--transition-fast, 150ms ease);

  &:hover,
  &:focus-visible {
    background: color-mix(in srgb, var(--surface-subtle-color, #e8eef3) 92%, white);
    border-color: color-mix(in srgb, var(--accent-color, #1677c8) 22%, var(--border-color, rgba(17, 24, 39, 0.08)));
    color: var(--accent-color, #1677c8);
  }

  &:active {
    transform: translateY(1px);
  }
}

/* ===== Dense variation for later, if needed ===== */

.feed-card--compact {
  & .feed-card__title {
    font-size: clamp(1.22rem, 1.1rem + 0.4vw, 1.55rem);
    line-height: 1.16;
  }

  & .feed-card__excerpt {
    -webkit-line-clamp: 2;
  }
}

/* ===== Responsive ===== */

@media (min-width: 961px) {
  .home-shell {
    --home-card-space: 1.5rem;
  }
}

@media (max-width: 900px) {
  .home-shell {
    --home-shell-width: 100%;
    --home-feed-width: 100%;
  }

  .home-layout {
    width: min(100% - 1.5rem, var(--home-shell-width));
  }
}

@media (max-width: 640px) {
  .home-shell {
    --home-shell-gap: 0.75rem;
    --home-shell-padding: 1rem;
    --home-card-space: 1rem;

    padding-top: 0.875rem;
  }

  .home-layout {
    width: min(100% - 1.25rem, 100%);
  }

  .home-popular,
  .home-feed {
    border-radius: 0.875rem;
  }

  .home-popular {
    & .home-popular__head {
      flex-direction: column;
      align-items: flex-start;
      gap: 0.35rem;
    }

    & .home-popular__link {
      gap: 0.625rem;
      /* padding-block: 0.45rem; */
    }

    & .home-popular__time {
      min-width: 2.7rem;
      font-size: 0.75rem;
      display: none;
    }

    & .home-popular__text {
      font-size: 0.95rem;
    }
  }

  .feed-list,
  .home-feed__more {
    padding-inline: 1rem;
  }

  .feed-card {
    & .feed-card__title {
      font-size: clamp(1.24rem, 1.12rem + 0.7vw, 1.5rem);
      line-height: 1.14;
      text-wrap: pretty;
    }

    & .feed-card__excerpt {
      margin-top: 0.625rem;
      font-size: 0.95rem;
      -webkit-line-clamp: 3;
    }

    & .feed-card__media {
      margin-top: 0.875rem;
      border-radius: 0.875rem;
    }

    & .feed-card__meta {
      margin-bottom: 0.55rem;
    }
  }

  .home-feed__button {
    width: 100%;
  }
}
