/* BrounStack shared learning/catalog card contract
   Public Learning, Student Library and Books Admin use one cover-free card footprint. */

:root{
  --bs-catalog-card-min-height:300px;
  --bs-catalog-card-min-height-mobile:0px;
  --bs-learning-cover-height:220px;
  --bs-learning-cover-height-mobile:200px;
}

/* Shared equal-height catalog grids */
.learning-page .learning-grid,
body[data-page="library"].student-portal-page #libraryGrid.books,
body[data-page="books"] #firestoreBooksGrid,
body[data-page="tutorials"] #tutorialCourseGrid{
  align-items:stretch!important;
  grid-auto-rows:1fr;
}

.learning-page .learning-grid .course-card,
body[data-page="library"].student-portal-page #libraryGrid .learning-card,
body[data-page="books"] #firestoreBooksGrid .book-card,
body[data-page="tutorials"] #tutorialCourseGrid .book-card{
  height:100%!important;
  min-height:var(--bs-catalog-card-min-height)!important;
  display:flex!important;
  flex-direction:column!important;
  min-width:0;
}

/* Shared cover footprint */
.learning-page .learning-grid .course-cover,
body[data-page="library"].student-portal-page #libraryGrid .learning-card>.cover,
body[data-page="books"] #firestoreBooksGrid .admin-learning-cover-preview,
body[data-page="tutorials"] #tutorialCourseGrid .admin-learning-cover-preview{
  display:block!important;
  height:var(--bs-learning-cover-height)!important;
  min-height:var(--bs-learning-cover-height)!important;
  overflow:hidden;
}
.learning-page .learning-grid .course-cover img,
body[data-page="library"].student-portal-page #libraryGrid .learning-card>.cover img,
body[data-page="books"] #firestoreBooksGrid .admin-learning-cover-preview img,
body[data-page="tutorials"] #tutorialCourseGrid .admin-learning-cover-preview img{
  width:100%!important;
  height:100%!important;
  display:block!important;
  object-fit:contain!important;
  object-position:center!important;
}
body[data-page="library"].student-portal-page #libraryGrid .learning-card>.cover>.learning-cover-art{
  height:100%!important;
  border-radius:0!important;
  border:0!important;
  box-shadow:none!important;
}

/* Public Learning card body */
.learning-page .learning-grid .course-body{
  flex:1!important;
  min-height:0!important;
  display:flex!important;
  flex-direction:column!important;
  padding-top:20px!important;
}
.learning-page .learning-grid .course-body>p{
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  overflow:hidden;
}
.learning-page .learning-grid .course-bottom{margin-top:auto!important}

/* Student My Library card body */
body[data-page="library"].student-portal-page #libraryGrid .learning-card>.book-body{
  flex:1!important;
  min-height:0!important;
  display:flex!important;
  flex-direction:column!important;
}
body[data-page="library"].student-portal-page #libraryGrid .book-body .book-subtitle{
  min-height:36px;
  -webkit-line-clamp:2;
}
body[data-page="library"].student-portal-page #libraryGrid .book-language-badges{min-height:22px}
body[data-page="library"].student-portal-page #libraryGrid .library-card-actions{
  display:flex!important;
  gap:8px!important;
  flex-wrap:nowrap!important;
  width:100%;
  margin-top:auto;
}
body[data-page="library"].student-portal-page #libraryGrid .library-card-actions>.book-open-btn{
  min-width:0;
  flex:1 1 0;
  margin-top:10px!important;
  padding-inline:10px!important;
}
body[data-page="library"].student-portal-page #libraryGrid .learning-card[data-learning-type="track"]{
  --book-accent:#38bdf8;
  --book-accent-2:#7656f3;
}
body[data-page="library"].student-portal-page #libraryGrid .learning-card[data-learning-type="practice"]{
  --book-accent:#22c55e;
  --book-accent-2:#0ea5e9;
}
body[data-page="library"].student-portal-page #libraryGrid .library-type-badge.track{
  background:rgba(56,189,248,.10);
  border-color:rgba(56,189,248,.24);
  color:#7dd3fc;
}
body[data-page="library"].student-portal-page #libraryGrid .library-type-badge.practice{
  background:rgba(34,197,94,.10);
  border-color:rgba(34,197,94,.22);
  color:#86efac;
}

/* Student Library compact cover-free cards.
   Keep actions directly under metadata instead of reserving a large spacer. */
body[data-page="library"].student-portal-page #libraryGrid.books{
  grid-auto-rows:auto!important;
  align-items:start!important;
}
body[data-page="library"].student-portal-page #libraryGrid .learning-card{
  height:auto!important;
  min-height:0!important;
}
body[data-page="library"].student-portal-page #libraryGrid .learning-card>.book-body{
  flex:0 0 auto!important;
  min-height:0!important;
}
body[data-page="library"].student-portal-page #libraryGrid .book-body .book-subtitle,
body[data-page="library"].student-portal-page #libraryGrid .book-language-badges{
  min-height:0!important;
}
body[data-page="library"].student-portal-page #libraryGrid .library-card-actions{
  margin-top:12px!important;
}
body[data-page="library"].student-portal-page #libraryGrid .library-card-actions>.book-open-btn{
  margin-top:0!important;
}
body[data-page="library"].student-portal-page #libraryGrid .book-body>.book-open-btn{
  margin-top:12px!important;
}

/* Admin catalog actions stay aligned at the bottom. */
body[data-page="books"] #firestoreBooksGrid .book-card,
body[data-page="tutorials"] #tutorialCourseGrid .book-card{overflow:hidden}
body[data-page="books"] #firestoreBooksGrid .book-card-actions,
body[data-page="tutorials"] #tutorialCourseGrid .tutorial-card-actions{margin-top:auto!important}

/* Books Admin is intentionally content-height so removing cover/repo/delete does not leave a spacer.
   If covers are enabled again later, the card will naturally grow with the cover. */
body[data-page="books"] #firestoreBooksGrid{
  grid-auto-rows:auto!important;
  align-items:start!important;
}
body[data-page="books"] #firestoreBooksGrid .book-card{
  height:auto!important;
  min-height:0!important;
}
body[data-page="books"] #firestoreBooksGrid .book-card-actions{
  margin-top:14px!important;
}

@media(max-width:620px){
  .learning-page .learning-grid .course-cover,
  body[data-page="library"].student-portal-page #libraryGrid .learning-card>.cover,
  body[data-page="books"] #firestoreBooksGrid .admin-learning-cover-preview,
  body[data-page="tutorials"] #tutorialCourseGrid .admin-learning-cover-preview{
    height:var(--bs-learning-cover-height-mobile)!important;
    min-height:var(--bs-learning-cover-height-mobile)!important;
  }
  .learning-page .learning-grid .course-card,
  body[data-page="library"].student-portal-page #libraryGrid .learning-card,
  body[data-page="books"] #firestoreBooksGrid .book-card,
  body[data-page="tutorials"] #tutorialCourseGrid .book-card{
    min-height:var(--bs-catalog-card-min-height-mobile)!important;
  }
  body[data-page="library"].student-portal-page #libraryGrid .library-card-actions{flex-wrap:wrap!important}
  body[data-page="library"].student-portal-page #libraryGrid .library-card-actions>.book-open-btn{flex:1 1 100%}
}
