/* ==========================================================================
   Библиотека знаний — category grid, article list, article detail + paywall
   ========================================================================== */

.page-hero {
  padding-block: var(--space-2xl) var(--space-xl);
  text-align: center;
  background: var(--color-sand);
}

.page-hero h1 {
  max-width: 20ch;
  margin-inline: auto;
}

.page-hero p {
  margin-top: var(--space-sm);
  font-size: var(--fs-body-lg);
  color: var(--color-ember-60);
  max-width: 46ch;
  margin-inline: auto;
}

.library {
  background: var(--color-mist);
}

.library__loading,
.library__empty {
  text-align: center;
  color: var(--color-ember-60);
  padding-block: var(--space-xl);
}

.library__grid[hidden],
.library__list[hidden],
.library-article[hidden] {
  display: none;
}

/* ---------- Breadcrumb ---------- */

.library__breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: var(--fs-body-sm);
  color: var(--color-ember-60);
  margin-bottom: var(--space-lg);
}

.library__breadcrumb a,
.library__breadcrumb button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--color-marigold);
  font-weight: 600;
  cursor: pointer;
}

.library__breadcrumb a:hover,
.library__breadcrumb button:hover {
  color: var(--color-terracotta-rose);
}

.library__breadcrumb .sep {
  opacity: 0.5;
}

/* ---------- Category / subcategory grid ---------- */

.library__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 640px) {
  .library__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1000px) {
  .library__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.library-card {
  position: relative;
  display: block;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--gradient-dawn);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  border: none;
  padding: 0;
  text-align: left;
  transition: transform 0.25s var(--ease-breath), box-shadow 0.25s var(--ease-breath);
}

.library-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
}

.library-card__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-card__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.library-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(42, 33, 28, 0) 40%, rgba(42, 33, 28, 0.78) 100%);
}

.library-card__content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--space-md);
  color: var(--color-white);
}

.library-card__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: var(--lh-snug);
  margin-bottom: 0.25rem;
}

.library-card__count {
  font-size: var(--fs-caption);
  opacity: 0.85;
}

/* ---------- Article list ---------- */

.library__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.library-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-white);
  border: 1px solid var(--color-ember-12);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: box-shadow 0.25s var(--ease-breath), border-color 0.25s;
}

.library-row:hover {
  box-shadow: var(--shadow-soft);
  border-color: transparent;
}

.library-row__cover {
  flex-shrink: 0;
  width: 84px;
  height: 84px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-sand);
}

.library-row__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-row__body {
  min-width: 0;
}

.library-row__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: var(--lh-snug);
  margin-bottom: 0.2rem;
}

.library-row__subtitle {
  font-size: var(--fs-body-sm);
  color: var(--color-ember-60);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.library-row__meta {
  margin-top: 0.35rem;
  font-size: var(--fs-caption);
  color: var(--color-ember-35);
}

/* ---------- Article detail ---------- */

.library-article__back {
  background: none;
  border: none;
  padding: 0;
  margin-bottom: var(--space-md);
  font-size: var(--fs-body-sm);
  font-weight: 600;
  color: var(--color-marigold);
  cursor: pointer;
}

.library-article__back:hover {
  color: var(--color-terracotta-rose);
}

.library-article__cover {
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-soft);
}

.library-article__cover img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  display: block;
}

.library-article__title {
  max-width: 32ch;
}

.library-article__subtitle {
  margin-top: var(--space-sm);
  font-size: var(--fs-body-lg);
  color: var(--color-ember-60);
  max-width: 60ch;
}

.library-article__content {
  margin-top: var(--space-lg);
  max-width: 68ch;
  color: var(--color-ember);
  line-height: var(--lh-normal);
}

.library-article__content p {
  margin-bottom: var(--space-sm);
}

.library-article__content h2,
.library-article__content h3 {
  font-family: var(--font-display);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

.library-article__content img {
  max-width: 100%;
  border-radius: var(--radius-md);
  margin-block: var(--space-sm);
}

.library-article__content ul,
.library-article__content ol {
  margin-bottom: var(--space-sm);
  padding-left: 1.4rem;
}

/* Fade the tail of the truncated teaser so the cut feels intentional */
.library-article__paywall {
  position: relative;
  max-width: 68ch;
  margin-top: -3.5rem;
  padding: 4.5rem var(--space-lg) var(--space-lg);
  text-align: center;
  background: linear-gradient(180deg, rgba(250, 246, 240, 0) 0%, var(--color-mist) 55%);
  border-radius: var(--radius-lg);
}

.library-article__paywall h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.library-article__paywall p {
  color: var(--color-ember-60);
  margin-bottom: var(--space-md);
}
