/* ============================================================
   CECICUG Blog Display v2 — style.css
   5-per-row grid · hover animations · related posts panel
   ============================================================ */

/* ── Reset / base ───────────────────────────────────────── */
.cbd-wrap *,
.cbd-wrap *::before,
.cbd-wrap *::after { box-sizing: border-box; margin: 0; padding: 0; }

.cbd-wrap {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #11172a;
  margin: 2.5rem 0;
}

/* ── Top bar ────────────────────────────────────────────── */
.cbd-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1.5px solid #e2e8f4;
}
.cbd-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Live pulsing ring */
.cbd-live-ring {
  position: relative;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.cbd-live-ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,85,165,.15);
  animation: cbd-pulse 1.8s ease-in-out infinite;
}
.cbd-live-core {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #0055a5;
  position: relative; z-index: 1;
}
@keyframes cbd-pulse {
  0%,100%{ transform:scale(1); opacity:.9; }
  50%     { transform:scale(1.6); opacity:.3; }
}

.cbd-topbar-label { font-size: 13px; color: #5a6580; }
.cbd-topbar-label strong { color: #0055a5; }

.cbd-all-link {
  font-size: 12px; font-weight: 600;
  color: #0055a5; text-decoration: none;
  border: 1px solid #b8d0ef; border-radius: 20px;
  padding: 4px 14px;
  transition: background .2s, color .2s;
}
.cbd-all-link:hover { background: #0055a5; color: #fff; border-color: #0055a5; }

/* ── Grid: 5 per row ─────────────────────────────────────── */
.cbd-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}
@media (max-width: 1100px) { .cbd-grid { grid-template-columns: repeat(4,1fr); } }
@media (max-width:  860px) { .cbd-grid { grid-template-columns: repeat(3,1fr); } }
@media (max-width:  600px) { .cbd-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width:  420px) { .cbd-grid { grid-template-columns: 1fr; } }

/* ── Card ────────────────────────────────────────────────── */
.cbd-card {
  position: relative;
  background: #fff;
  border: 1px solid #dde4f0;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  outline: none;

  /* entry animation */
  opacity: 0;
  transform: translateY(22px);
  animation: cbd-enter .45s ease forwards;
}
.cbd-card:nth-child(1)  { animation-delay: .04s; }
.cbd-card:nth-child(2)  { animation-delay: .08s; }
.cbd-card:nth-child(3)  { animation-delay: .12s; }
.cbd-card:nth-child(4)  { animation-delay: .16s; }
.cbd-card:nth-child(5)  { animation-delay: .20s; }
.cbd-card:nth-child(6)  { animation-delay: .26s; }
.cbd-card:nth-child(7)  { animation-delay: .30s; }
.cbd-card:nth-child(8)  { animation-delay: .34s; }
.cbd-card:nth-child(9)  { animation-delay: .38s; }
.cbd-card:nth-child(10) { animation-delay: .42s; }

@keyframes cbd-enter {
  to { opacity: 1; transform: none; }
}

/* Hover lift + glow border */
.cbd-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
  border: 2px solid transparent;
  transition: border-color .3s, box-shadow .3s;
  pointer-events: none;
  z-index: 3;
}
.cbd-card:hover::after,
.cbd-card:focus-visible::after {
  border-color: #0055a5;
  box-shadow: 0 0 0 3px rgba(0,85,165,.15);
}
.cbd-card:hover,
.cbd-card:focus-visible {
  transform: translateY(-5px) scale(1.015);
  box-shadow: 0 12px 32px rgba(0,85,165,.16);
  z-index: 2;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1), box-shadow .28s ease;
}
.cbd-card:not(:hover):not(:focus-visible) {
  transition: transform .22s ease, box-shadow .22s ease;
}

/* Active (selected) state */
.cbd-card.cbd-active {
  border-color: #0055a5;
  box-shadow: 0 0 0 3px rgba(0,85,165,.25);
}

/* Shimmer hover sweep */
.cbd-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,.55) 50%, transparent 100%);
  background-size: 200% 100%;
  background-position: -100% 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.cbd-card:hover .cbd-shimmer {
  opacity: 1;
  animation: cbd-shimmer-sweep .6s ease forwards;
}
@keyframes cbd-shimmer-sweep {
  from { background-position: -100% 0; }
  to   { background-position:  200% 0; }
}

/* ── Thumbnail ───────────────────────────────────────────── */
.cbd-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #eef2fb;
  flex-shrink: 0;
}
.cbd-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform .4s cubic-bezier(.25,.46,.45,.94);
}
.cbd-card:hover .cbd-thumb img { transform: scale(1.08); }

.cbd-no-img {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: #b0bbcc;
}

/* Gradient overlay on thumb */
.cbd-thumb-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(11,24,58,.45));
  opacity: 0;
  transition: opacity .3s;
}
.cbd-card:hover .cbd-thumb-overlay { opacity: 1; }

/* Category badge on image */
.cbd-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 20px;
  background: rgba(0,85,165,.9); color: #fff;
  backdrop-filter: blur(4px);
}

/* ── Card content ────────────────────────────────────────── */
.cbd-content {
  padding: .7rem .8rem .85rem;
  display: flex; flex-direction: column; gap: .4rem;
  flex: 1;
}
.cbd-title {
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.4;
  color: #0d1b3e;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cbd-card:hover .cbd-title { color: #0055a5; }

.cbd-excerpt {
  font-size: .7rem;
  line-height: 1.55;
  color: #6b7591;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cbd-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: .65rem; color: #9aa3b8; margin-top: .1rem;
}
.cbd-meta-bit {
  display: flex; align-items: center; gap: 3px;
}
.cbd-meta-bit svg { flex-shrink: 0; color: #b8c2d8; }

.cbd-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: .45rem;
}
.cbd-read {
  font-size: .68rem; font-weight: 700; color: #0055a5;
  text-decoration: none; border: 1px solid #b8d0ef; border-radius: 5px;
  padding: 3px 9px;
  transition: background .2s, color .2s;
  flex-shrink: 0;
}
.cbd-read:hover { background: #0055a5; color: #fff; border-color: #0055a5; }

.cbd-rel-hint {
  font-size: .62rem; color: #b0bbcc; font-style: italic;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity .25s, transform .25s;
}
.cbd-card:hover .cbd-rel-hint,
.cbd-card:focus-visible .cbd-rel-hint { opacity: 1; transform: none; }

/* ── Related Posts Panel ─────────────────────────────────── */
.cbd-panel {
  margin-top: 1.5rem;
  border: 1.5px solid #0055a5;
  border-radius: 14px;
  overflow: hidden;
  background: #f7f9fd;

  /* slide-down entrance */
  animation: cbd-panel-in .35s cubic-bezier(.34,1.4,.64,1) forwards;
}
.cbd-panel[hidden] { display: none; }

@keyframes cbd-panel-in {
  from { opacity:0; transform: translateY(-12px) scaleY(.97); }
  to   { opacity:1; transform: none; }
}

.cbd-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.1rem;
  background: #0055a5;
  color: #fff;
}
.cbd-panel-title-row {
  display: flex; align-items: center; gap: 8px;
}
.cbd-panel-icon { font-size: 1rem; }
.cbd-panel-label { font-weight: 700; font-size: .9rem; }
.cbd-panel-source {
  font-size: .75rem; opacity: .75; font-style: italic;
}
.cbd-close {
  background: rgba(255,255,255,.15); border: none; color: #fff;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 1.1rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}
.cbd-close:hover { background: rgba(255,255,255,.3); }

.cbd-panel-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5,1fr);
  gap: 12px;
  padding: 1rem 1.1rem;
}
@media (max-width:1000px) { .cbd-panel-list { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 600px) { .cbd-panel-list { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 400px) { .cbd-panel-list { grid-template-columns: 1fr; } }

/* Related card (smaller) */
.cbd-rel-card {
  background: #fff;
  border: 1px solid #dde4f0;
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex; flex-direction: column;
  transition: transform .25s cubic-bezier(.34,1.4,.64,1), box-shadow .25s;

  opacity: 0;
  transform: translateY(14px);
  animation: cbd-rel-in .35s ease forwards;
}
.cbd-rel-card:nth-child(1) { animation-delay: .05s; }
.cbd-rel-card:nth-child(2) { animation-delay: .10s; }
.cbd-rel-card:nth-child(3) { animation-delay: .15s; }
.cbd-rel-card:nth-child(4) { animation-delay: .20s; }
.cbd-rel-card:nth-child(5) { animation-delay: .25s; }
@keyframes cbd-rel-in {
  to { opacity:1; transform:none; }
}

.cbd-rel-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 22px rgba(0,85,165,.14);
  border-color: #0055a5;
}

.cbd-rel-thumb {
  width: 100%; aspect-ratio: 16/9;
  overflow: hidden; background: #eef2fb;
  flex-shrink: 0;
}
.cbd-rel-thumb img { width:100%; height:100%; object-fit:cover; display:block; transition: transform .35s ease; }
.cbd-rel-card:hover .cbd-rel-thumb img { transform: scale(1.07); }
.cbd-rel-no-img { width:100%; height:100%; display:flex; align-items:center; justify-content:center; color:#c0ccdd; }

.cbd-rel-body { padding: .5rem .65rem .65rem; }
.cbd-rel-cat {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: #0055a5; margin-bottom: 3px;
}
.cbd-rel-title {
  font-size: .72rem; font-weight: 700; line-height: 1.35; color: #0d1b3e;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.cbd-rel-date { font-size: .62rem; color: #9aa3b8; margin-top: 4px; }

/* ── Messages ────────────────────────────────────────────── */
.cbd-msg { padding: .85rem 1.1rem; border-radius: 8px; font-size: .9rem; }
.cbd-error { background:#fff0f0; color:#b91c1c; border:1px solid #fca5a5; }

/* ── Source badge ────────────────────────────────────── */
.cbd-source-badge {
  display: inline-block;
  font-size: 10px; font-weight: 600; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 20px;
  background: #e8f5ee; color: #1a6b3c;
  border: 1px solid #b3dfc5;
  margin-left: 8px; vertical-align: middle;
}

/* ── Error box ───────────────────────────────────────── */
.cbd-error-box {
  background: #fff8f8;
  border: 1.5px solid #f5c6c6;
  border-left: 4px solid #c0392b;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-size: .88rem;
  line-height: 1.7;
  color: #5a1a1a;
}
.cbd-error-box strong { color: #c0392b; }
.cbd-error-box a { color: #c0392b; }

/* ── Column variants ─────────────────────────────────── */
.cbd-cols-1 { grid-template-columns: 1fr !important; }
.cbd-cols-2 { grid-template-columns: repeat(2,1fr) !important; }
.cbd-cols-3 { grid-template-columns: repeat(3,1fr) !important; }
.cbd-cols-4 { grid-template-columns: repeat(4,1fr) !important; }
.cbd-cols-5 { grid-template-columns: repeat(5,1fr) !important; }
