/* ═══════════════════════════════════════════════════════════════════
   Community Library — Frontend CSS v1.0.0
   Design tokens: #1a1a2e · #4f46e5 · #818cf8 · 'Segoe UI'
   ═══════════════════════════════════════════════════════════════════ */

#cl-app {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: #f7f8fc;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  /* Desktop: scroll the grid area inside the hub pane */
  height: 100%;
  overflow: hidden;
}

/* ── Top bar ────────────────────────────────────────────────────── */
.cl-topbar {
  background: #fff;
  border-bottom: 1px solid #e8eaf0;
  padding: 14px 20px;
  flex-shrink: 0;
}
.cl-search-row {
  display: flex; gap: 10px; align-items: center;
}
.cl-search-wrap {
  position: relative; flex: 1;
}
.cl-search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 15px; pointer-events: none;
}
.cl-search-input {
  width: 100%; box-sizing: border-box;
  padding: 10px 14px 10px 38px;
  border: 2px solid #e8eaf0; border-radius: 10px;
  font-size: 14px; font-family: inherit; color: #1a1a2e;
  background: #f7f8fc; outline: none;
  transition: border-color .15s;
}
.cl-search-input:focus { border-color: #4f46e5; background: #fff; }
.cl-search-btn {
  background: #4f46e5; color: #fff; border: none; border-radius: 10px;
  padding: 10px 20px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer; flex-shrink: 0;
  transition: background .14s;
}
.cl-search-btn:hover { background: #3730a3; }

/* ── Category pills ─────────────────────────────────────────────── */
.cl-cats {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 14px 20px 8px;
  background: #fff; border-bottom: 1px solid #e8eaf0;
  flex-shrink: 0;
}
.cl-cat {
  padding: 6px 16px; border-radius: 20px;
  border: 1.5px solid #e8eaf0; background: #f7f8fc;
  font-size: 13px; font-weight: 600; color: #555;
  cursor: pointer; font-family: inherit;
  transition: background .13s, border-color .13s, color .13s;
  user-select: none;
}
.cl-cat:hover  { background: #ede9fe; border-color: #818cf8; color: #4f46e5; }
.cl-cat.active { background: #4f46e5; border-color: #4f46e5; color: #fff; }

/* ── Results count ──────────────────────────────────────────────── */
.cl-results-count {
  font-size: 12px; color: #888; font-weight: 600;
  padding: 10px 20px 0;
}

/* ── Grid ───────────────────────────────────────────────────────── */
.cl-scroll-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.cl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 14px 20px 24px;
  align-items: start;
}
@media (max-width: 860px) { .cl-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 480px) { .cl-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
                            .cl-grid { padding: 10px 14px 20px; } }

/* ── Resource card ──────────────────────────────────────────────── */
.cl-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e8eaf0;
  overflow: hidden;
  cursor: pointer;
  transition: transform .13s, box-shadow .13s;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  display: flex; flex-direction: column;
  min-height: 158px;  /* consistent card height whether 2 or 18 on page */
  height: fit-content; /* never stretch beyond natural content height */
}
.cl-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(79,70,229,.12);
}

.cl-card-thumb {
  height: 80px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; flex-shrink: 0;
}
.cl-thumb-pdf       { background: #fde8e8; }
.cl-thumb-video     { background: #e8eaf8; }
.cl-thumb-audio     { background: #fff3e0; }
.cl-thumb-worksheet { background: #e8f5e9; }
.cl-thumb-default   { background: #f0f0f0; }

.cl-card-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

.cl-card-body { padding: 12px 14px; flex-grow: 0; display: flex; flex-direction: column; }
@media (max-width:480px) { .cl-card-body { padding: 9px 10px; } }

.cl-type-pill {
  display: inline-block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  border-radius: 10px; padding: 2px 8px; margin-bottom: 6px;
  width: fit-content;
}
.cl-type-pdf       { background: #fde8e8; color: #c0392b; }
.cl-type-video     { background: #ede9fe; color: #4f46e5; }
.cl-type-audio     { background: #fff3e0; color: #b45309; }
.cl-type-worksheet { background: #e8f5e9; color: #1e7e34; }
.cl-type-default   { background: #f0f0f0; color: #888; }

.cl-card-title {
  font-size: 13px; font-weight: 700; color: #1a1a2e;
  line-height: 1.4; margin-bottom: 6px; flex: 1;
}
.cl-card-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #aaa; margin-top: auto; flex-wrap: wrap; gap: 2px;
}
.cl-card-meta-author { font-weight: 600; color: #888; }

/* ── Loading / empty ────────────────────────────────────────────── */
.cl-loading { text-align: center; padding: 48px 20px; color: #aaa; font-size: 14px; grid-column: 1/-1; }
.cl-empty   { text-align: center; padding: 48px 20px; grid-column: 1/-1; }
.cl-empty-icon { font-size: 44px; margin-bottom: 12px; opacity: .4; }
.cl-empty-text { font-size: 15px; font-weight: 600; color: #888; }
.cl-empty-sub  { font-size: 13px; color: #bbb; margin-top: 5px; }

/* ── Pagination ─────────────────────────────────────────────────── */
.cl-pagination {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
  padding: 4px 20px 20px;
}
.cl-page-btn {
  background: #fff; border: 1px solid #e8eaf0; border-radius: 8px;
  padding: 6px 14px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: background .13s;
}
.cl-page-btn:hover  { background: #ede9fe; color: #4f46e5; }
.cl-page-btn.active { background: #4f46e5; color: #fff; border-color: #4f46e5; cursor: default; }

/* ── Detail modal ───────────────────────────────────────────────── */
.cl-detail-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.52);
  z-index: 99999; display: flex;
  align-items: center; justify-content: center;
  padding: 16px; box-sizing: border-box;
}
.cl-detail-box {
  background: #fff; border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0,0,0,.22);
  width: 100%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: cl-in .18s ease;
}
@keyframes cl-in { from{opacity:0;transform:scale(.95)} to{opacity:1;transform:scale(1)} }
.cl-detail-head {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
  padding: 20px 22px 16px;
  background: #1a1a2e; border-bottom: 1px solid #2d2d50;
  flex-shrink: 0;
}
.cl-detail-title { font-size: 16px; font-weight: 800; color: #fff; margin: 0 0 4px; }
.cl-detail-meta  { font-size: 12px; color: rgba(255,255,255,.55); margin: 0; }
.cl-detail-close {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  font-size: 17px; width: 34px; height: 34px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .14s;
}
.cl-detail-close:hover { background: rgba(255,255,255,.25); }
.cl-detail-body {
  flex: 1; overflow-y: auto; padding: 20px 22px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.cl-detail-row {
  display: flex; align-items: flex-start; gap: 12px;
}
.cl-detail-icon { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.cl-detail-content { flex: 1; min-width: 0; }
.cl-detail-label {
  font-size: 11px; font-weight: 700; color: #aaa;
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px;
}
.cl-detail-value { font-size: 14px; color: #1a1a2e; word-break: break-word; }
.cl-detail-desc {
  font-size: 13px; color: #555; line-height: 1.6;
  background: #f7f8fc; border-radius: 8px;
  padding: 12px 14px; border: 1px solid #e8eaf0;
}
/* Download / Open button */
.cl-download-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: #4f46e5; color: #fff; border: none; border-radius: 10px;
  padding: 12px 22px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit; text-decoration: none;
  transition: background .13s; margin-top: 4px;
  box-shadow: 0 4px 14px rgba(79,70,229,.25);
}
.cl-download-btn:hover { background: #3730a3; color: #fff; }
.cl-ext-btn {
  background: #2D8CFF;
  box-shadow: 0 4px 14px rgba(45,140,255,.25);
}
.cl-ext-btn:hover { background: #1a7ae8; }

/* ── Category pill count badge ──────────────────────────────────── */
.cl-cat-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: rgba(0,0,0,.10);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 5px;
  line-height: 1;
  vertical-align: middle;
  box-sizing: border-box;
}
.cl-cat.active .cl-cat-count {
  background: rgba(255,255,255,.28);
  color: #fff;
}


/* ── Search highlight ───────────────────────────────────────────────────── */
mark.cl-highlight {
  background: #fef08a;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  font-style: normal;
}
