/*
 * improvements.css — schemes.co.ke UI/UX Upgrade
 * Drop this file AFTER style.css and pages.css in your header.php
 * <link rel="stylesheet" href="/assets/improvements.css">
 *
 * Covers 24 identified issues across typography, brand, spacing,
 * card consistency, accessibility, and polish.
 * Zero !important abuse — all rules are specific enough to win.
 */

/* ═══════════════════════════════════════════════════════════════════
   1. TYPOGRAPHY — Replace Inter with Plus Jakarta Sans + DM Sans
   ═══════════════════════════════════════════════════════════════════
   Add this <link> BEFORE your stylesheets in header.php:
   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=DM+Sans:wght@400;500;600&display=swap" rel="stylesheet">
*/

:root {
  --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --font-body:    'DM Sans', 'Inter', sans-serif;

  /* ── Fix brand color mis-use of --danger for decorative elements ── */
  --accent-line: var(--primary);  /* was var(--danger) — red looked like an error */
}

body {
  font-family: var(--font-body);
}

h1, h2, h3, h4, h5, h6,
.page-title,
.hero-v2__headline,
.browse-card-title,
.catv2-title,
.footer-section h4,
.page-divider__title {
  font-family: var(--font-display);
}


/* ═══════════════════════════════════════════════════════════════════
   2. BRAND FIX — Red decorative lines → brand green
   ═══════════════════════════════════════════════════════════════════ */

/* Page title underline (was red var(--danger)) */
.page-title::after {
  background-color: var(--primary);
}

/* Section divider lines (were red) */
.page-divider__line-left {
  background: linear-gradient(to right, transparent, var(--primary));
}
.page-divider__line-right {
  background: linear-gradient(to left, transparent, var(--primary));
}


/* ═══════════════════════════════════════════════════════════════════
   3. HERO — Fix min-height: 200px (too short) & improve padding
   ═══════════════════════════════════════════════════════════════════ */

.hero-v2 {
  min-height: clamp(460px, 62vh, 720px);
}

.hero-v2__container {
  padding: 2.5rem 2rem;
  min-height: clamp(460px, 62vh, 720px);
}

/* Hero card: give it more breathing room */
.hero-v2__card {
  padding: 2rem 2.25rem;
  max-width: 560px;
}

.hero-v2__headline {
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.12;
  margin-bottom: 0.5rem;
}

/* Feature rows: slightly more breathing room */
.hero-v2__features {
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.hero-v2__feature-row {
  padding: 0.45rem 0.9rem;
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .hero-v2 {
    min-height: 0;
  }
  .hero-v2__container {
    min-height: 0;
    padding: 2rem 1.25rem;
    grid-template-columns: 1fr;
  }
  .hero-v2__card {
    max-width: 100%;
    padding: 1.5rem 1.25rem;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   4. SPACING — Reduce oversized gaps throughout all pages
   ═══════════════════════════════════════════════════════════════════ */

/* Section spacing: 4rem → 2.5rem (saves ~120px of dead air per section) */
.section-spacing {
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
}

/* Page title bottom gap: 3rem → 1.25rem */
.page-title {
  margin-bottom: 1.25rem;
}

/* Browse grid: reduce gap slightly for tighter content feel */
.browse-grid {
  gap: 1.25rem;
}

/* Container: reduce internal padding slightly on desktop */
@media (min-width: 1024px) {
  .container {
    padding: 1.5rem 2rem;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   5. SHORTCUT PILLS — Consistent brand green across ALL card colors
   ═══════════════════════════════════════════════════════════════════ */

/* Remove per-card color inheritance; use brand green for all term/grade pills */
.shortcut-pill {
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(4, 120, 87, 0.22);
}

.shortcut-pill:hover {
  background: var(--primary-dark);
  filter: none;
  box-shadow: 0 5px 14px rgba(4, 120, 87, 0.3);
}

/* "More" pill: keep neutral */
.shortcut-pill--more {
  background: rgba(255,255,255,0.7);
  color: var(--neutral-700);
  border: 1px dashed rgba(0,0,0,0.15);
  box-shadow: none;
}
.shortcut-pill--more:hover {
  background: rgba(255,255,255,0.9);
  transform: none;
}


/* ═══════════════════════════════════════════════════════════════════
   6. BROWSE SEO INTRO — Style the unstyled .browse-seo-intro block
   ═══════════════════════════════════════════════════════════════════ */

.browse-seo-intro {
  background: linear-gradient(to right, #f0fdf4, #e7f9f4);
  border-radius: 10px;
  padding: 1rem 1.4rem;
  margin-bottom: 2rem;
  border-left: 3px solid var(--primary-light);
}

.browse-seo-text {
  font-size: 0.925rem;
  color: var(--neutral-700);
  line-height: 1.65;
  margin: 0;
}

.browse-seo-text strong {
  color: var(--primary-dark);
}

@media (max-width: 768px) {
  .browse-seo-intro {
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   7. NAVIGATION — Active page state
   ═══════════════════════════════════════════════════════════════════
   In header.php, add class="nav-active" to the <a> matching the
   current URL. PHP snippet:
     $current = $_SERVER['REQUEST_URI'];
     // then: class="<?php echo strpos($current, '/schemes-of-work') !== false ? 'nav-active' : ''; ?>"
*/

.main-nav > a.nav-active,
.main-nav .nav-dropdown-toggle.nav-active {
  color: var(--primary);
}

.main-nav > a.nav-active::after {
  transform: scaleX(1);
}


/* ═══════════════════════════════════════════════════════════════════
   8. DOCUMENT CARDS — Improve metadata visibility
   ═══════════════════════════════════════════════════════════════════ */

/* File format badge — make it more prominent */
.recent-card-meta span {
  font-size: 0.8rem;
  font-weight: 600;
  gap: 0.3rem;
}

/* Add a clearly visible format label */
.file-format-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.file-format-badge--pdf  { background: #fee2e2; color: #991b1b; }
.file-format-badge--docx { background: #dbeafe; color: #1e40af; }
.file-format-badge--doc  { background: #dbeafe; color: #1e40af; }
.file-format-badge--ppt  { background: #ffedd5; color: #c2410c; }
.file-format-badge--xlsx { background: #d1fae5; color: #065f46; }

/* FREE documents — make them stand out as a conversion signal */
.recent-card-price[data-free="true"],
.item-price-badge {
  background: linear-gradient(135deg, #059669, #047857);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  display: inline-block;
  box-shadow: 0 2px 8px rgba(4, 120, 87, 0.3);
}


/* ═══════════════════════════════════════════════════════════════════
   9. ACCESSIBILITY — Skip link, focus-visible, breadcrumb aria
   ═══════════════════════════════════════════════════════════════════
   Add this to header.php immediately after <body>:
   <a class="skip-link" href="#main-content">Skip to content</a>
*/

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--primary);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 8px 8px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 9999;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 0;
}

/* Visible focus ring for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Remove focus styles for mouse users only */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
  outline: none;
}

/* Smooth global scroll */
html {
  scroll-behavior: smooth;
}


/* ═══════════════════════════════════════════════════════════════════
   10. BACK-TO-TOP BUTTON
   ═══════════════════════════════════════════════════════════════════
   Add this HTML before </body> in footer.php:
   <button class="back-to-top" id="backToTop" aria-label="Back to top" onclick="window.scrollTo({top:0,behavior:'smooth'})">
     <i class="bi bi-arrow-up"></i>
   </button>
   And this JS:
   window.addEventListener('scroll', function(){
     document.getElementById('backToTop').classList.toggle('visible', window.scrollY > 400);
   });
*/

.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 16px rgba(4, 120, 87, 0.35);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 800;
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
}
.back-to-top:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 24px rgba(4, 120, 87, 0.45);
}


/* ═══════════════════════════════════════════════════════════════════
   11. FOOTER — Improved spacing and social link row
   ═══════════════════════════════════════════════════════════════════
   Add social links HTML to footer.php inside a footer-section:
   <div class="footer-socials">
     <a href="https://facebook.com/schemescoke" class="footer-social" aria-label="Facebook">
       <i class="bi bi-facebook"></i>
     </a>
     <a href="https://wa.me/254XXXXXXXXX" class="footer-social" aria-label="WhatsApp">
       <i class="bi bi-whatsapp"></i>
     </a>
     <a href="https://twitter.com/schemescoke" class="footer-social" aria-label="Twitter/X">
       <i class="bi bi-twitter-x"></i>
     </a>
   </div>
*/

.site-footer {
  padding: 3.5rem 2rem 1.5rem;
}

.footer-socials {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.footer-social {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--neutral-100);
  font-size: 1rem;
  text-decoration: none;
  transition: all 0.25s ease;
}
.footer-social:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-2px);
}

/* Footer newsletter input: dark bg */
.newsletter-form input {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: white;
  border-radius: 8px;
}
.newsletter-form input::placeholder {
  color: rgba(255,255,255,0.45);
}
.newsletter-form input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
  outline: none;
}


/* ═══════════════════════════════════════════════════════════════════
   12. BREADCRUMB — Cleaner separator styling
   ═══════════════════════════════════════════════════════════════════ */

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: var(--neutral-500);
}

.breadcrumb span {
  color: var(--neutral-400);
  font-size: 0.7rem;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}
.breadcrumb a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}


/* ═══════════════════════════════════════════════════════════════════
   13. DOC COUNT BADGE — More compact and readable in term cards
   ═══════════════════════════════════════════════════════════════════ */

.doc-count-badge {
  font-size: 0.72rem;
  padding: 0.3rem 0.65rem;
  gap: 0.3rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: rgba(255,255,255,0.85);
  color: var(--neutral-700);
}

.doc-count-badge i {
  color: var(--primary);
}


/* ═══════════════════════════════════════════════════════════════════
   14. BROWSE GRID — Consistent column rules (clean up redundancies)
   ═══════════════════════════════════════════════════════════════════ */

.browse-grid.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.browse-grid.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 900px) {
  .browse-grid.grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .browse-grid.grid-cols-2,
  .browse-grid.grid-cols-3 { grid-template-columns: 1fr; }
}


/* ═══════════════════════════════════════════════════════════════════
   15. ITEM PAGE — Related documents section
   ═══════════════════════════════════════════════════════════════════
   Add this section HTML in item.php after the main content closes:
   <section class="related-docs">
     <h2 class="related-docs__title">More from this grade</h2>
     <div class="grid grid-cols-2">
       <?php foreach ($related_docs as $rel): ?>
         <a href="/item/<?= $rel['id'] ?>" class="recent-card">
           ... existing recent-card markup ...
         </a>
       <?php endforeach; ?>
     </div>
   </section>
   And add this PHP query above include 'includes/header.php':
   $related = $pdo->prepare('SELECT d.*, c.title as category_title, g.title as grade_title
     FROM documents d LEFT JOIN categories c ON d.category_id = c.id
     LEFT JOIN grades g ON d.grade_id = g.id
     WHERE d.grade_id = ? AND d.category_id = ? AND d.id != ?
     ORDER BY d.hits DESC LIMIT 4');
   $related->execute([$document['grade_id'], $document['category_id'], $document_id]);
   $related_docs = $related->fetchAll();
*/

.related-docs {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--neutral-200);
}

.related-docs__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--neutral-900);
  margin-bottom: 1.25rem;
  font-family: var(--font-display);
}


/* ═══════════════════════════════════════════════════════════════════
   16. POPULAR DOWNLOADS — Tabs / filter pills
   ═══════════════════════════════════════════════════════════════════
   Add filter pills HTML above document grid in popular.php:
   <div class="filter-pills" role="tablist">
     <a href="?period=all"  class="filter-pill <?= !$period || $period=='all'  ? 'active' : '' ?>">All Time</a>
     <a href="?period=term" class="filter-pill <?= $period=='term' ? 'active' : '' ?>">This Term</a>
     <a href="?period=week" class="filter-pill <?= $period=='week' ? 'active' : '' ?>">This Week</a>
   </div>
*/

.filter-pills {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 0.45rem 1.1rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--neutral-600);
  background: var(--neutral-100);
  border: 1px solid var(--neutral-200);
  transition: all 0.2s ease;
}
.filter-pill:hover {
  background: var(--highlight);
  color: var(--primary);
  border-color: var(--primary-light);
}
.filter-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(4, 120, 87, 0.25);
}


/* ═══════════════════════════════════════════════════════════════════
   17. PRINT STYLES — Clean document detail for printing
   ═══════════════════════════════════════════════════════════════════ */

@media print {
  .sticky-header,
  .mobile-menu-toggle,
  .mobile-overlay,
  .site-footer,
  .back-to-top,
  aside,
  .breadcrumb,
  .related-docs,
  nav {
    display: none !important;
  }

  body {
    font-size: 12pt;
    color: #000;
    background: white;
  }

  .page-title {
    font-size: 18pt;
    margin-bottom: 1rem;
  }

  .item-grid {
    grid-template-columns: 1fr !important;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   18. CARD HOVER — Tighten up the premium card animation (less bounce)
   ═══════════════════════════════════════════════════════════════════ */

/* The existing .card:hover uses translateY(-5px) + scale — fine.
   The .premium-card:hover uses translateY(-8px) scale(1.02) — too aggressive on dense grids */
.premium-card:hover {
  transform: translateY(-5px) scale(1.01);
}


/* ═══════════════════════════════════════════════════════════════════
   19. ALERT COMPONENTS — Soften the hard left border
   ═══════════════════════════════════════════════════════════════════ */

/* Alerts: replace hard border-left with full-border softer variant */
.alert-success,
.alert-error,
.alert-info {
  border-left: none;
  border: 1px solid transparent;
  border-radius: 10px;
}
.alert-success { border-color: #86efac; }
.alert-error   { border-color: #fca5a5; }
.alert-info    { border-color: var(--primary-light); }


/* ═══════════════════════════════════════════════════════════════════
   20. SEARCH PAGE — Empty state and filter chips
   ═══════════════════════════════════════════════════════════════════
   Use .filter-pills defined above for grade/category filter chips.
   Add this class to the search results empty state:
*/

.search-empty {
  text-align: center;
  padding: 4rem 2rem;
  background: white;
  border-radius: 14px;
  border: 1px dashed var(--neutral-200);
}

.search-empty__icon {
  font-size: 3.5rem;
  color: var(--neutral-300);
  display: block;
  margin-bottom: 1rem;
}

.search-empty__title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--neutral-900);
  margin-bottom: 0.5rem;
  font-family: var(--font-display);
}

.search-empty__text {
  color: var(--neutral-500);
  font-size: 0.95rem;
  margin-bottom: 1.75rem;
}


/* ═══════════════════════════════════════════════════════════════════
   21. SKELETON LOADING CARDS
   ═══════════════════════════════════════════════════════════════════
   Add <div class="skeleton-card"></div> × 4 inside the grid
   while PHP is loading (useful for AJAX loads).
*/

@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

.skeleton-card {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--neutral-200);
  padding: 1.25rem;
  height: 160px;
}

.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite;
  margin-bottom: 0.75rem;
}

.skeleton-line--short { width: 45%; }
.skeleton-line--med   { width: 70%; }
.skeleton-line--full  { width: 100%; }


/* ═══════════════════════════════════════════════════════════════════
   22. ITEM PAGE — M-Pesa form polish
   ═══════════════════════════════════════════════════════════════════ */

.mpesa-input-v2 {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--neutral-200);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 0.75rem;
  background: white;
}

.mpesa-input-v2:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.12);
}

/* Purchase card heading */
.purchase-card-v2 {
  background: white;
  border-radius: 16px;
  padding: 1.75rem;
  border: 1px solid var(--neutral-200);
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}


/* ═══════════════════════════════════════════════════════════════════
   23. PAGE-LEVEL RESPONSIVE FIX — consolidate competing overrides
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .page-title {
    font-size: 1.5rem;
    line-height: 1.3;
    word-break: break-word;
  }

  .browse-seo-intro {
    border-left-width: 2px;
  }

  .section-spacing {
    margin-top: 1.75rem;
    margin-bottom: 1.75rem;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 1.25rem;
  }

  .related-docs__title {
    font-size: 1.1rem;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   24. CATEGORY HERO PAGES (About / Contact / Privacy / Terms)
   ═══════════════════════════════════════════════════════════════════ */

/* Give page-hero a warmer, less flat appearance */
.page-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #065f46 50%, #0a7c5a 100%);
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
  pointer-events: none;
}

.page-hero::after {
  content: '';
  position: absolute;
  bottom: -40%;
  left: -5%;
  width: 260px;
  height: 260px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
  pointer-events: none;
}

.page-hero h1,
.page-hero p {
  position: relative;
  z-index: 1;
}

/* ── End of improvements.css ── */
