/* ============================================
   Knowledge Library - knowledge.css
   ============================================ */

.active-page { color: var(--green) !important; font-weight: 700 !important; }

/* ===== KB HERO ===== */
.kb-hero {
  position: relative;
  background: linear-gradient(145deg, #0d2137 0%, #1a3a52 50%, #0d2137 100%);
  padding: 120px 0 80px;
  overflow: hidden;
}
.kb-hero::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(76,175,80,.18) 0%, transparent 70%);
  top: -100px; right: -100px;
  border-radius: 50%;
}
.kb-hero::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(0,188,212,.15) 0%, transparent 70%);
  bottom: 0; left: 50px;
  border-radius: 50%;
}

.kb-hero-inner { position: relative; z-index: 1; text-align: center; max-width: 780px; margin: 0 auto; }
.kb-hero .hero-badge { margin: 0 auto 20px; width: fit-content; }

.kb-hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 900;
  color: #fff;
  line-height: 1.25;
  margin-bottom: 18px;
}
.kb-hero p { color: rgba(255,255,255,.78); font-size: 1.05rem; line-height: 1.8; margin-bottom: 28px; }

.kb-search-wrap {
  display: flex;
  gap: 0;
  max-width: 520px;
  margin: 0 auto 28px;
  background: #fff;
  border-radius: 50px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.kb-search-wrap input {
  flex: 1;
  padding: 15px 22px;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: var(--font);
  direction: rtl;
  background: transparent;
}
.kb-search-wrap button {
  padding: 0 22px;
  background: var(--green);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  transition: background .25s;
  border-radius: 0 50px 50px 0;
}
.kb-search-wrap button:hover { background: var(--green-dark); }

.kb-hero-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
}
.kb-hero-stats span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(255,255,255,.7);
  font-size: .9rem;
  font-weight: 500;
}
.kb-hero-stats i { color: var(--green); }

/* ===== FILTER BAR ===== */
.kb-filters-bar {
  background: #fff;
  padding: 16px 0;
  border-bottom: 2px solid var(--gray-border);
  position: sticky;
  top: 72px;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.kb-cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.kb-cats::-webkit-scrollbar { display: none; }

.kbcat {
  padding: 8px 18px;
  border-radius: 50px;
  border: 2px solid var(--gray-border);
  background: #fff;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .22s;
  color: var(--gray);
  display: flex;
  align-items: center;
  gap: 6px;
}
.kbcat:hover, .kbcat.active {
  background: var(--dark);
  border-color: var(--dark);
  color: #fff;
}
.kbcat.active { background: var(--green); border-color: var(--green); }
.cat-count {
  background: rgba(255,255,255,.25);
  border-radius: 50px;
  padding: 1px 7px;
  font-size: .72rem;
}
.kbcat:not(.active) .cat-count { background: var(--gray-light); color: var(--gray); }

/* ===== TRENDING ===== */
.trending-strip {
  background: var(--dark);
  padding: 10px 0;
  font-size: .85rem;
  overflow: hidden;
}
.trending-strip .container { display: flex; align-items: center; gap: 16px; }
.trend-label {
  color: var(--green);
  font-weight: 700;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.trend-items {
  display: flex;
  gap: 12px;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
}
.trend-items a { color: rgba(255,255,255,.8); font-weight: 500; transition: color .2s; }
.trend-items a:hover { color: var(--green); }
.trend-items span { color: rgba(255,255,255,.3); }

/* ===== FEATURED ARTICLE ===== */
.featured-article {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 40px;
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--gray-border);
}

.fa-image-block {
  background: linear-gradient(145deg, #1a3a52, #0d2137);
  min-height: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  position: relative;
}
.fa-img-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,.7);
}
.fa-img-placeholder i { font-size: 4rem; color: var(--green); }
.fa-img-placeholder span { font-weight: 600; font-size: 1.1rem; }
.fa-badges {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
}
.badge-hot, .badge-cat {
  padding: 4px 12px;
  border-radius: 50px;
  font-size: .75rem;
  font-weight: 700;
}
.badge-hot { background: #ef4444; color: #fff; }
.badge-cat { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); }

.fa-content { padding: 36px 36px 36px 0; }
.fa-meta {
  display: flex;
  gap: 18px;
  font-size: .8rem;
  color: var(--gray);
  margin-bottom: 14px;
}
.fa-meta span { display: flex; align-items: center; gap: 5px; }
.fa-content h3 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.3;
  margin-bottom: 14px;
}
.fa-content p { font-size: .95rem; color: var(--gray); line-height: 1.8; margin-bottom: 14px; }

.fa-keypoints {
  background: var(--green-light);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
}
.fa-keypoints strong { display: block; font-weight: 700; color: var(--dark); margin-bottom: 10px; }
.fa-keypoints ul { display: flex; flex-direction: column; gap: 8px; }
.fa-keypoints li { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--dark-2); }
.fa-keypoints li i { color: var(--green); font-size: .85rem; }

.fa-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ===== ARTICLES GRID ===== */
.kb-grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.kb-grid-header h2 { font-size: 1.4rem; font-weight: 800; color: var(--dark); display: flex; align-items: center; gap: 10px; }
.count-badge {
  background: var(--green);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 50px;
}
.sort-wrap { display: flex; align-items: center; gap: 8px; font-size: .875rem; color: var(--gray); }
.sort-wrap select {
  padding: 8px 14px;
  border: 2px solid var(--gray-border);
  border-radius: 8px;
  font-size: .875rem;
  font-family: var(--font);
  background: #fff;
  cursor: pointer;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.article-card {
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all .3s ease;
  cursor: pointer;
  border: 1px solid var(--gray-border);
  display: flex;
  flex-direction: column;
}
.article-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.ac-top {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}
.ac-top.rates     { background: linear-gradient(135deg, #1a3a52, #2563eb); color: #fff; }
.ac-top.mortgage  { background: linear-gradient(135deg, #166534, #4CAF50); color: #fff; }
.ac-top.realestate{ background: linear-gradient(135deg, #7c2d12, #f97316); color: #fff; }
.ac-top.personal  { background: linear-gradient(135deg, #4a1d96, #8b5cf6); color: #fff; }
.ac-top.refi      { background: linear-gradient(135deg, #0e7490, #00BCD4); color: #fff; }
.ac-top.tax       { background: linear-gradient(135deg, #713f12, #d97706); color: #fff; }
.ac-top.invest    { background: linear-gradient(135deg, #134e4a, #14b8a6); color: #fff; }

.ac-body { padding: 20px; flex: 1; display: flex; flex-direction: column; }

.ac-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.ac-meta span:last-child { font-size: .78rem; color: var(--gray); display: flex; align-items: center; gap: 4px; }

.ac-cat {
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 50px;
}
.ac-cat.rates     { background: #dbeafe; color: #1d4ed8; }
.ac-cat.mortgage  { background: #dcfce7; color: #166534; }
.ac-cat.realestate{ background: #ffedd5; color: #c2410c; }
.ac-cat.personal  { background: #ede9fe; color: #6d28d9; }
.ac-cat.refi      { background: #cffafe; color: #0e7490; }
.ac-cat.tax       { background: #fef3c7; color: #92400e; }
.ac-cat.invest    { background: #ccfbf1; color: #0f766e; }

.ac-body h3 {
  font-size: .97rem;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.4;
  margin-bottom: 10px;
  flex: 1;
}
.ac-body p { font-size: .85rem; color: var(--gray); line-height: 1.7; margin-bottom: 12px; }

.ac-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.ac-tags span {
  font-size: .7rem;
  color: var(--gray);
  background: var(--gray-light);
  padding: 2px 8px;
  border-radius: 50px;
}

.ac-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--gray-border);
}
.ac-views { font-size: .78rem; color: var(--gray); display: flex; align-items: center; gap: 5px; }
.read-more-btn {
  background: none;
  border: none;
  color: var(--green);
  font-weight: 700;
  font-size: .82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font);
  transition: gap .2s;
  padding: 0;
}
.read-more-btn:hover { gap: 9px; }

/* ===== NO RESULTS ===== */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray);
}
.no-results i { font-size: 3rem; margin-bottom: 16px; display: block; }
.no-results h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--dark); }
.no-results button {
  background: none;
  border: none;
  color: var(--green);
  font-weight: 700;
  cursor: pointer;
  font-size: 1rem;
  font-family: var(--font);
  text-decoration: underline;
}
.hidden { display: none !important; }

/* ===== NEWSLETTER ===== */
.kb-newsletter {
  background: linear-gradient(135deg, var(--green) 0%, var(--blue) 100%);
  padding: 60px 0;
}
.kb-nl-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}
.kb-nl-text h2 { font-size: 1.5rem; font-weight: 800; color: #fff; margin-bottom: 8px; }
.kb-nl-text p { color: rgba(255,255,255,.85); font-size: .95rem; }
.kb-nl-form {
  display: flex;
  gap: 0;
  background: #fff;
  border-radius: 50px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,.2);
  min-width: 380px;
}
.kb-nl-form input {
  flex: 1;
  padding: 14px 20px;
  border: none;
  outline: none;
  font-size: .95rem;
  font-family: var(--font);
  direction: rtl;
  background: transparent;
}
.kb-nl-form .btn { border-radius: 0 50px 50px 0; }
.nl-success {
  background: rgba(255,255,255,.2);
  color: #fff;
  padding: 14px 24px;
  border-radius: 50px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== ARTICLE MODAL ===== */
.article-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.article-modal-overlay.open { opacity: 1; pointer-events: all; }

.article-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%) scale(.97);
  width: min(720px, 95vw);
  max-height: 88vh;
  background: #fff;
  border-radius: var(--radius-lg);
  z-index: 2001;
  overflow-y: auto;
  padding: 40px;
  opacity: 0;
  pointer-events: none;
  transition: all .3s ease;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
.article-modal.open {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) scale(1);
}
.modal-close {
  position: sticky;
  top: 0;
  float: left;
  background: var(--gray-light);
  border: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  z-index: 1;
}

.modal-article-badge { display: inline-block; padding: 5px 14px; border-radius: 50px; font-size: .78rem; font-weight: 700; margin-bottom: 14px; }
.modal-article-meta { display: flex; gap: 16px; font-size: .8rem; color: var(--gray); margin-bottom: 16px; flex-wrap: wrap; }
.modal-article-meta span { display: flex; align-items: center; gap: 5px; }
.modal-content h2 { font-size: 1.5rem; font-weight: 900; color: var(--dark); line-height: 1.3; margin-bottom: 16px; }
.modal-content h4 { font-size: 1.05rem; font-weight: 700; color: var(--dark); margin: 20px 0 8px; }
.modal-content p { font-size: .95rem; color: #444; line-height: 1.85; margin-bottom: 14px; }
.modal-content ul { margin: 0 0 16px 0; padding-right: 20px; }
.modal-content ul li { font-size: .92rem; color: #444; line-height: 1.8; margin-bottom: 6px; list-style: disc; }
.modal-cta { background: var(--green-light); border-radius: var(--radius); padding: 20px; text-align: center; margin-top: 24px; }
.modal-cta p { font-weight: 700; color: var(--dark); margin-bottom: 12px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .articles-grid { grid-template-columns: repeat(2, 1fr); }
  .featured-article { grid-template-columns: 1fr; }
  .fa-image-block { min-height: 200px; }
  .fa-content { padding: 24px; }
}
@media (max-width: 768px) {
  .articles-grid { grid-template-columns: 1fr; }
  .kb-nl-inner { flex-direction: column; text-align: center; }
  .kb-nl-form { min-width: 280px; width: 100%; max-width: 400px; }
  .trending-strip .container { overflow-x: auto; }
  .article-modal { padding: 24px; }
  .fa-actions { flex-direction: column; }
}

/* ================================================
   KNOWLEDGE MOBILE DEEP OPTIMISATION
   ================================================ */
@media (max-width: 768px) {

  /* Hero */
  .kb-hero { padding: 90px 0 44px; }
  .kb-hero-text h1 { font-size: 1.75rem; line-height: 1.3; }
  .kb-hero-text p { font-size: .88rem; }
  .kb-hero-stats {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }
  .kb-hero-stats span { font-size: .78rem; padding: 5px 12px; }

  /* Search */
  .kb-search-wrap { border-radius: 12px; }
  .kb-search-wrap input {
    font-size: 16px; /* prevent iOS zoom */
    padding: 12px 14px;
  }
  .kb-search-wrap button { padding: 0 16px; }

  /* Category filters */
  .kb-filters-bar { padding: 14px 0; }
  .kb-cats {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 6px;
    scrollbar-width: none;
    gap: 6px;
  }
  .kb-cats::-webkit-scrollbar { display: none; }
  .kbcat {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: .78rem;
    padding: 7px 14px;
  }
  .cat-count { font-size: .7rem; padding: 1px 6px; }

  /* Trending strip */
  .trending-strip { padding: 10px 0; }
  .trend-items {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    white-space: nowrap;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .trend-items::-webkit-scrollbar { display: none; }
  .trend-items a { font-size: .8rem; }

  /* Featured article */
  .kb-featured { padding: 36px 0; }
  .featured-article { border-radius: 14px; }
  .fa-image-block { min-height: 160px; border-radius: 14px 14px 0 0; }
  .fa-img-placeholder i { font-size: 2.5rem; }
  .fa-content { padding: 20px 16px; }
  .fa-content h3 { font-size: 1.15rem; }
  .fa-content p { font-size: .85rem; }
  .fa-keypoints li { font-size: .82rem; }
  .fa-actions .btn { width: 100%; justify-content: center; font-size: .88rem; }

  /* Grid header */
  .kb-grid-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
  }
  .kb-grid-header h2 { font-size: 1.25rem; }
  .sort-wrap select {
    font-size: 16px;
    padding: 8px 12px;
  }

  /* Article cards */
  .article-card { border-radius: 14px; }
  .ac-img { height: 150px; }
  .ac-content { padding: 16px 14px 14px; }
  .ac-title { font-size: .95rem; line-height: 1.45; }
  .ac-excerpt { font-size: .8rem; -webkit-line-clamp: 2; }
  .ac-cat { font-size: .7rem; padding: 3px 10px; }

  /* Newsletter */
  .kb-newsletter { padding: 44px 0; }
  .kb-nl-text h2 { font-size: 1.25rem; }
  .kb-nl-text p { font-size: .85rem; }
  .kb-nl-form input { font-size: 16px; padding: 12px 16px; }

  /* Article modal */
  .article-modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 96vh;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(20px);
    border-radius: 22px 22px 0 0;
    padding: 20px 16px 32px;
  }
  .article-modal.open {
    transform: translateY(0);
  }
  .modal-content h2 { font-size: 1.25rem; }
  .modal-content p  { font-size: .88rem; }
  .modal-content ul li { font-size: .86rem; }
  .modal-close { float: right; }
  .modal-cta .btn { width: 100%; justify-content: center; }
}

@media (max-width: 380px) {
  .kb-hero-text h1 { font-size: 1.5rem; }
  .kb-hero-stats span { font-size: .72rem; }
  .fa-content h3 { font-size: 1.05rem; }
}
