/* ═══════════════════════════════════════════════════════════════════
   Community Feed — Frontend CSS v1.2.0
   Grid / List toggle. Full-width grid. Pagination.
   ═══════════════════════════════════════════════════════════════════ */

#cf-app {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: #f7f8fc;
  display: flex; flex-direction: column;
  box-sizing: border-box;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────────── */
.cf-header {
  background: linear-gradient(135deg, #1a3a2e 0%, #1e7e34 100%);
  padding: 16px 22px; flex-shrink: 0;
}
.cf-header-inner {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.cf-header-text { flex: 1; min-width: 0; }
.cf-header-title { font-size: 18px; font-weight: 800; color: #fff; margin-bottom: 3px; }
.cf-header-sub   { font-size: 13px; color: rgba(255,255,255,.7); }

.cf-header-right {
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
}
.cf-search-wrap { position: relative; }
.cf-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 13px; pointer-events: none; opacity: .7;
}
.cf-search-input {
  width: 180px; box-sizing: border-box;
  padding: 8px 32px 8px 32px;
  border: none; border-radius: 20px;
  font-size: 13px; font-family: inherit;
  background: rgba(255,255,255,.18); color: #fff; outline: none;
  transition: background .15s, width .2s;
}
.cf-search-input::placeholder { color: rgba(255,255,255,.6); }
.cf-search-input:focus { background: rgba(255,255,255,.28); width: 220px; }
.cf-search-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: rgba(255,255,255,.7);
  font-size: 14px; cursor: pointer; padding: 0; line-height: 1;
}
.cf-search-clear:hover { color: #fff; }
.cf-search-btn {
  background: rgba(255,255,255,.2); color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 20px; padding: 7px 14px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap; transition: background .14s;
}
.cf-search-btn:hover { background: rgba(255,255,255,.32); }

/* View toggle */
.cf-view-toggle {
  display: flex; align-items: center; gap: 2px;
  background: rgba(255,255,255,.15); border-radius: 8px; padding: 2px; flex-shrink: 0;
}
.cf-view-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; border-radius: 6px;
  background: transparent; color: rgba(255,255,255,.7);
  cursor: pointer; transition: background .15s, color .15s;
}
.cf-view-btn:hover  { background: rgba(255,255,255,.2); color: #fff; }
.cf-view-btn.active { background: rgba(255,255,255,.3); color: #fff; }

@media (max-width: 560px) {
  .cf-header-inner { flex-direction: column; align-items: stretch; gap: 10px; }
  .cf-header-right { width: 100%; justify-content: space-between; }
  .cf-search-wrap  { flex: 1; }
  .cf-search-input { width: 100%; }
  .cf-search-input:focus { width: 100%; }
}

/* ── Category pills ─────────────────────────────────────────────── */
.cf-cats {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 20px 8px;
  background: #fff; border-bottom: 1px solid #e8eaf0; flex-shrink: 0;
}
.cf-cat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; 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;
}
.cf-cat:hover  { background: #e8f5e9; border-color: #28a745; color: #1e7e34; }
.cf-cat.active { background: #1e7e34; border-color: #1e7e34; color: #fff; }
.cf-cat-count {
  font-size: 10px; font-weight: 800;
  background: rgba(0,0,0,.10); border-radius: 10px;
  padding: 1px 7px; min-width: 18px; text-align: center; line-height: 1.5;
}
.cf-cat.active .cf-cat-count { background: rgba(255,255,255,.25); }
.cf-cat-count:empty { display: none; }

/* ── Scroll area (feed + pagination, scrolls under sticky header+cats) ── */
.cf-scroll-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Search label sits inside scroll area */
.cf-search-label {
  padding: 8px 20px 0;
  font-size: 13px; font-weight: 600; color: #1e7e34;
}

/* ════════════════════════════════════════════════════════════════════
   FEED CONTAINER
   ════════════════════════════════════════════════════════════════════ */
.cf-feed {
  flex: 1;
  padding: 20px;
  box-sizing: border-box;
  /* Default = GRID */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  align-content: start;
}
@media (max-width: 640px) {
  .cf-feed { padding: 14px; gap: 14px;
    grid-template-columns: 1fr;
  }
}
@media (min-width: 641px) and (max-width: 900px) {
  .cf-feed { grid-template-columns: repeat(2, 1fr); }
}

/* ── Grid card (default) — image on top, content below ─────────── */
.cf-card {
  display: flex;
  flex-direction: column;      /* image top, body bottom */
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e8eaf0;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  overflow: hidden;
  cursor: pointer;
  transition: transform .13s, box-shadow .13s;
}
.cf-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
}

/* Grid thumbnail — square-ish, full card width */
.cf-card-img {
  width: 100%;
  height: 140px;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; flex-shrink: 0;
  background: #f0fdf4;
}
.cf-card-img img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

.cf-card-body {
  padding: 14px 16px 14px;
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}

/* Tags */
.cf-tag {
  display: inline-block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  border-radius: 10px; padding: 2px 9px;
  margin-bottom: 8px; width: fit-content;
}
.cf-tag-announcement { background: #e8f5e9; color: #1e7e34; }
.cf-tag-event        { background: #fff3e0; color: #b45309; }
.cf-tag-update       { background: #ede9fe; color: #4f46e5; }
.cf-tag-resource     { background: #e8eaf8; color: #3730a3; }
.cf-tag-achievement  { background: #fff9c4; color: #856404; }
.cf-tag-default      { background: #f0f0f0; color: #888; }

.cf-card-title {
  font-size: 15px; font-weight: 700; color: #1a1a2e;
  line-height: 1.4; margin-bottom: 6px;
}
.cf-card-excerpt {
  font-size: 13px; color: #666; line-height: 1.6; margin-bottom: 10px;
  flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.cf-card-foot {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #aaa; margin-top: auto;
}
.cf-av {
  width: 24px; height: 24px; border-radius: 50%;
  background: #4f46e5; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; flex-shrink: 0;
}
.cf-author { font-weight: 600; color: #555; }
.cf-date   { margin-left: auto; white-space: nowrap; }

/* ════════════════════════════════════════════════════════════════════
   LIST VIEW — horizontal card (image left, text right)
   ════════════════════════════════════════════════════════════════════ */
#cf-feed.cf-feed-list {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: unset !important;
  gap: 12px !important;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}
#cf-feed.cf-feed-list .cf-card {
  flex-direction: row !important;
  min-height: 110px;
}
#cf-feed.cf-feed-list .cf-card-img {
  width: 110px !important; min-width: 110px !important;
  height: auto !important; min-height: 110px;
  border-radius: 0; font-size: 32px !important;
}
#cf-feed.cf-feed-list .cf-card-body {
  padding: 14px 18px;
}
#cf-feed.cf-feed-list .cf-card-excerpt {
  -webkit-line-clamp: 2 !important;
}

/* ════════════════════════════════════════════════════════════════════
   PAGINATION
   ════════════════════════════════════════════════════════════════════ */
.cf-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 16px 20px 24px; flex-wrap: wrap;
}
.cf-page-btn {
  min-width: 36px; height: 36px; padding: 0 10px;
  border: 1.5px solid #e8eaf0; border-radius: 8px;
  background: #fff; color: #555;
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: background .13s, border-color .13s, color .13s;
  display: inline-flex; align-items: center; justify-content: center;
}
.cf-page-btn:hover:not(:disabled) { background: #e8f5e9; border-color: #28a745; color: #1e7e34; }
.cf-page-btn.active { background: #1e7e34; border-color: #1e7e34; color: #fff; cursor: default; }
.cf-page-btn:disabled { opacity: .4; cursor: not-allowed; }
.cf-page-ellipsis { color: #aaa; font-size: 13px; padding: 0 4px; line-height: 36px; }

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

/* ── Detail modal ───────────────────────────────────────────────── */
.cf-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;
}
.cf-detail-box {
  background: #fff; border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0,0,0,.22);
  width: 100%; max-width: 680px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: cf-in .18s ease;
}
@keyframes cf-in { from{opacity:0;transform:scale(.95)} to{opacity:1;transform:scale(1)} }

.cf-detail-head {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
  padding: 20px 22px 16px;
  background: linear-gradient(135deg, #1a3a2e, #1e7e34); flex-shrink: 0;
}
.cf-detail-title { font-size: 17px; font-weight: 800; color: #fff; margin: 0 0 6px; }
.cf-detail-meta  { font-size: 12px; color: rgba(255,255,255,.75); margin: 0;
                   display: flex; align-items: center; gap: 8px; }
.cf-detail-close {
  background: rgba(255,255,255,.15); 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;
}
.cf-detail-close:hover { background: rgba(255,255,255,.28); }
.cf-detail-body {
  flex: 1; overflow-y: auto; padding: 22px 24px 20px;
  font-size: 14px; color: #1a1a2e; line-height: 1.75;
}
.cf-detail-body p        { margin: 0 0 14px; }
.cf-detail-body h2       { font-size: 18px; font-weight: 800; margin: 18px 0 10px; }
.cf-detail-body h3       { font-size: 16px; font-weight: 700; margin: 16px 0 8px; }
.cf-detail-body ul,
.cf-detail-body ol       { padding-left: 22px; margin: 0 0 14px; }
.cf-detail-body li       { margin-bottom: 4px; }
.cf-detail-body blockquote {
  border-left: 4px solid #1e7e34; margin: 14px 0;
  padding: 10px 16px; background: #f0fff4;
  border-radius: 0 8px 8px 0; font-style: italic;
}
.cf-detail-body a      { color: #1e7e34; text-decoration: underline; }
.cf-detail-body img    { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.cf-detail-body pre    { background: #f7f8fc; border: 1px solid #e8eaf0;
                         border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 13px; }
.cf-detail-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 24px; border-top: 1px solid #e8eaf0;
  flex-shrink: 0; font-size: 13px; color: #888; background: #fafafa;
}
.cf-detail-av {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff; flex-shrink: 0;
}

/* ── Hub feed tab badge ─────────────────────────────────────────── */
.ch-feed-tab-badge {
  display: none;
  position: absolute; top: -6px; right: -8px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: #dc3545; color: #fff;
  font-size: 10px; font-weight: 700;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  line-height: 17px; border-radius: 9px; text-align: center;
  box-sizing: border-box; pointer-events: none;
}
.ch-feed-tab-badge--visible { display: block; animation: cf-badge-pop .2s ease; }
@keyframes cf-badge-pop {
  from { transform: scale(.5); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
