/* Cache bust: NEXT_PUBLIC_CLUB_CSS_VERSION trong .env */
/* library.css — trang Thư viện (/thu-vien) */

.library-page {
  --library-brand: var(--brand-red-mid, #7a1519);
  --library-brand-dark: var(--brand-red-dark, #620305);
  background: var(--surface-cream);
  color: var(--text-primary);
}

.library-page .hero {
  --hero-content-width: min(96%, 42rem);
  min-height: clamp(18rem, 36vw, 27rem);
}

.library-page .hero__tagline {
  max-width: none;
  line-height: 1.35;
  text-wrap: pretty;
}

.library-page .hero__bottom-banner {
  transform: translateY(40%);
}

.library-main {
  position: relative;
  z-index: 10;
  background: var(--surface-section-white);
  margin-top: clamp(-3rem, -6vw, -4.5rem);
  padding-top: clamp(1.5rem, 3vw, 2.25rem);
  padding-bottom: clamp(2.5rem, 5vw, 4rem);
}

.library-main__breadcrumb {
  margin-bottom: clamp(1.25rem, 2.5vw, 2rem);
}

.library-main__layout {
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.5rem);
  align-items: start;
}

@media (min-width: 960px) {
  .library-main__layout {
    grid-template-columns: minmax(15rem, 17.5rem) minmax(0, 1fr);
    gap: clamp(1.75rem, 3vw, 2.75rem);
  }
}

/* Sidebar */
.library-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.library-sidebar__panel {
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--brand-gold) 22%, #ddd);
  border-radius: 0.35rem;
  padding: 1rem 1rem 1.1rem;
  box-shadow: 0 0.15rem 0.5rem rgba(0, 0, 0, 0.04);
}

.library-sidebar__title {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--library-brand);
  text-align: center;
}

.library-sidebar__cats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.library-sidebar__cat {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.3rem;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.86rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.library-sidebar__cat:hover {
  background: color-mix(in srgb, var(--library-brand) 8%, #fff);
  color: var(--library-brand);
}

.library-sidebar__cat--active {
  background: color-mix(in srgb, var(--library-brand) 12%, #fff);
  color: var(--library-brand);
  font-weight: 700;
}

.library-sidebar__cat-icon {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--library-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
}

.library-sidebar__cat-label {
  flex: 1;
  line-height: 1.3;
}

.library-sidebar__cat-count {
  flex-shrink: 0;
  min-width: 1.65rem;
  padding: 0.12rem 0.35rem;
  border-radius: 999px;
  background: var(--library-brand);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
}

/* Filter */
.library-filter {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.library-filter__field {
  display: block;
}

.library-filter__select,
.library-filter__input {
  width: 100%;
  border: 1px solid #d4cfc4;
  border-radius: 0.25rem;
  padding: 0.5rem 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  background: #fff;
  color: var(--text-primary);
}

.library-filter__select:focus,
.library-filter__input:focus {
  outline: none;
  border-color: var(--library-brand);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--library-brand) 15%, transparent);
}

.library-filter__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  margin-top: 0.15rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--library-brand-dark) 85%, #000);
  border-radius: 0.28rem;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--library-brand) 92%, #fff) 0%,
    var(--library-brand) 50%,
    var(--library-brand-dark) 100%
  );
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.library-filter__submit:hover {
  filter: brightness(1.05);
}

/* Grid panel */
.library-grid-panel {
  min-width: 0;
}

.library-grid__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: clamp(1rem, 2vw, 1.35rem);
}

.library-grid__head-text {
  flex: 1 1 14rem;
  min-width: 0;
}

.library-grid__total {
  margin: 0.35rem 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.library-grid__sort {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.library-grid__sort-select {
  border: 1px solid #d4cfc4;
  border-radius: 0.25rem;
  padding: 0.35rem 0.55rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  background: #fff;
}

.library-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.75rem, 1.5vw, 1rem);
}

@media (min-width: 640px) {
  .library-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .library-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1320px) {
  .library-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.library-grid__empty {
  margin: 2rem 0;
  padding: 1.25rem;
  text-align: center;
  background: var(--surface-cream);
  border: 1px dashed #ccc;
  border-radius: 0.35rem;
  color: var(--text-muted);
}

/* Card */
.library-card {
  height: 100%;
}

.library-card__link {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
  border: 1px solid color-mix(in srgb, var(--brand-gold) 18%, #e8e2d8);
  border-radius: 0.35rem;
  overflow: hidden;
  background: #fff;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.library-card__link:hover {
  box-shadow: 0 0.35rem 0.85rem rgba(0, 0, 0, 0.08);
  transform: translateY(-0.06rem);
}

.library-card__link--static {
  cursor: default;
}

.library-card__link--static:hover {
  box-shadow: none;
  transform: none;
}

.library-card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--placeholder-bg-light);
  overflow: hidden;
}

@supports not (aspect-ratio: 4 / 3) {
  .library-card__media {
    height: clamp(7.5rem, 16vw, 10rem);
  }
}

.library-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.library-card__type {
  position: absolute;
  left: 0.4rem;
  bottom: 0.4rem;
  padding: 0.18rem 0.45rem;
  border-radius: 0.2rem;
  background: rgba(98, 3, 5, 0.88);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.library-card__play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.library-card__play i {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  padding-left: 0.12rem;
}

.library-card__body {
  padding: 0.55rem 0.6rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.library-card__title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  max-height: 2.7em;
  overflow: hidden;
}

.library-card__meta {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.library-card__meta li {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Pagination — đồng bộ với tin tức / thành viên */
.library-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  margin-top: clamp(1.75rem, 4vw, 2.5rem);
  padding-top: 1.5rem;
  border-top: var(--section-divider);
}

.library-pagination__pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.library-pagination__btn,
.library-pagination__page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--library-brand-dark);
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--brand-gold) 35%, var(--border-ui));
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.library-pagination__btn:hover,
.library-pagination__page:hover {
  border-color: var(--brand-gold);
  color: var(--library-brand-dark);
  background: color-mix(in srgb, var(--brand-gold) 12%, #fff);
}

.library-pagination__page--current {
  background: var(--library-brand-dark);
  color: #fff;
  border-color: var(--library-brand-dark);
}

.library-pagination__btn--icon {
  min-width: 2.35rem;
  padding-inline: 0.5rem;
}

.library-pagination__btn--disabled {
  opacity: 0.45;
  pointer-events: none;
}

.library-pagination__ellipsis {
  padding: 0 0.25rem;
  color: var(--text-muted);
  font-weight: 700;
}
/* mobile toggle */
.library-sidebar__mobile-toggle {
  width: 100%;
  border: 0;
  background: #111827;
  color: #fff;
  padding: 16px 18px;
  display: none;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.library-sidebar__mobile-toggle i {
  transition: transform 0.3s ease;
}

/* mobile */
@media (max-width: 992px) {
  .library-page .hero {
    min-height: auto;
  }
  .library-page .hero__content {
    padding: clamp(0.75rem, 2.5vw, 1rem) 0 clamp(0.65rem, 2vw, 0.85rem);
  }
  .library-page .hero__bottom-banner {
    transform: translateY(42%);
  }
  .library-main {
    margin-top: clamp(0.75rem, 2vw, 1.25rem);
  }
}

/* mobile */
@media (max-width: 768px) {

  .library-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
  }

  .library-sidebar__panel {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }

  .library-sidebar__mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;

    width: 100%;

    background: #ffffff;

    color: #7d0000;

    border: 1px solid #ead8c7;
    border-radius: 12px;

    padding: 12px 14px;

    font-size: 13px;
    font-weight: 700;

    box-shadow:
      0 2px 10px rgba(0,0,0,.03);

    transition:
      all .25s ease;
  }

  .library-sidebar__mobile-toggle:hover {
    border-color: #d5b18b;
  }

  .library-sidebar__mobile-toggle:active {
    transform: scale(.985);
  }

  .library-sidebar__mobile-toggle-left {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .library-sidebar__mobile-toggle-left i {
    font-size: 13px;
    color: #7a1519;
  }

  .library-sidebar__mobile-toggle > i {
    font-size: 11px;
    opacity: .85;
    transition: transform .3s ease;
  }

  .library-sidebar__title {
    display: none;
  }

  .library-sidebar__cats,
  .library-filter {
    max-height: 0;
    overflow: hidden;
    opacity: 0;

    margin-top: 0;

    transition:
      max-height .35s ease,
      opacity .25s ease,
      margin-top .25s ease;
  }

  .library-sidebar__panel.is-open
  .library-sidebar__cats,
  .library-sidebar__panel.is-open
  .library-filter {
    max-height: 1000px;
    opacity: 1;
    margin-top: 8px;
  }

  .library-sidebar__panel.is-open
  .library-sidebar__mobile-toggle {
    background: #ffffff;
    border-color: #7a1519;
  }

  .library-sidebar__panel.is-open
  .library-sidebar__mobile-toggle > i {
    transform: rotate(180deg);
  }

  .library-sidebar__cats {
    padding: 0;
  }

  .library-filter {
    padding: 0;
  }
}