/* ============================================================
   ITET Learn — features.css
   Back to Top | Dark Mode | TOC | Bookmark |
   Sticky Header | Copy Code | Share Buttons | Mobile fixes
   ============================================================ */

/* ============================================================
   MOBILE RESPONSIVE FIXES (applied site-wide)
   ============================================================ */

/* ---- Header: keep nav visible on mobile, just compact it ---- */
@media (max-width: 640px) {
  .header-nav { display: flex !important; gap: 8px; align-items: center; }
  .header-nav a { font-size: 0.78rem; }
  .header-nav .btn-main { padding: 6px 12px; font-size: 0.75rem; }
  /* Make the "Tutorials" link icon-only on phones */
  .header-nav a[href="/tutorials/"] {
    font-size: 0;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(245, 156, 13, 0.10);
    border-radius: 8px;
    padding: 0;
  }
  .header-nav a[href="/tutorials/"]::before {
    content: '🛠️';
    font-size: 1rem;
  }
  /* Blog link icon-only too if present */
  .header-nav a[href="/"]:not(.logo-mark) {
    font-size: 0;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 0;
  }
  .header-nav a[href="/"]:not(.logo-mark)::before { content: '📖'; font-size: 1rem; }
  html.dark .header-nav a[href="/"]:not(.logo-mark) { background: #1e293b; }
  /* Sign-in button compact */
  .hdr-auth-btn { padding: 6px 12px; font-size: 0.75rem; }
  /* Dark mode toggle slightly smaller */
  .dark-toggle { width: 32px; height: 32px; margin-right: 4px; }
  /* Avatar smaller */
  .hdr-avatar { width: 32px; height: 32px; font-size: 0.78rem; }
}

/* Very small screens: tighten the logo + header padding */
@media (max-width: 420px) {
  .header-inner { padding: 0 12px; height: 56px; }
  .logo-img { height: 30px; }
  .logo-learn-badge { font-size: 0.62rem; padding: 2px 6px; }
}

/* ---- Hero: scale text on small screens ---- */
@media (max-width: 480px) {
  .hero { padding: 32px 16px 28px; }
  .hero h1 { font-size: 1.6rem; line-height: 1.2; }
  .hero p { font-size: 0.88rem; }
  .hero-topics { gap: 6px; }
  .hero-topic { font-size: 0.7rem; padding: 4px 10px; }
}

/* ---- AI search bar on small screens ---- */
@media (max-width: 480px) {
  .ai-search-wrap { padding: 0 14px; margin-top: 22px; }
  .ai-search-box { padding: 6px 6px 6px 16px; gap: 6px; }
  .ai-search-input { font-size: 0.9rem; padding: 7px 0; }
  .ai-mic-btn { width: 34px; height: 34px; font-size: 0.92rem; }
  .ai-search-btn { height: 34px; padding: 0 14px; font-size: 0.8rem; }
  .ai-search-label { font-size: 0.72rem; }
}
@media (max-width: 360px) {
  .ai-search-btn-text { display: none; }
  .ai-search-btn { padding: 0 12px; }
}

/* ---- AI results on mobile ---- */
@media (max-width: 480px) {
  .ai-results { padding: 0 14px; }
  .ai-answer { padding: 14px 16px; gap: 10px; }
  .ai-answer-avatar { width: 34px; height: 34px; min-width: 34px; font-size: 1rem; }
  .ai-answer-text { font-size: 0.88rem; }
  .ai-result { padding: 14px 16px; gap: 12px; }
  .ai-result-emoji { width: 44px; height: 44px; font-size: 1.4rem; }
  .ai-result h3 { font-size: 0.92rem; }
  .ai-result-reason { font-size: 0.8rem; }
  .ai-results-title { font-size: 0.95rem; }
}

/* ---- Filter bar wraps cleanly ---- */
@media (max-width: 640px) {
  .filters-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .filters-inner { padding: 0 14px; flex-wrap: nowrap; min-width: max-content; }
  .filter-btn { white-space: nowrap; font-size: 0.78rem; padding: 6px 12px; }
}

/* ---- Post cards 1-col below 480px ---- */
@media (max-width: 480px) {
  .posts-grid { grid-template-columns: 1fr; gap: 14px; }
  .post-card .card-body { padding: 14px 16px; }
  .card-title { font-size: 0.98rem; }
  .card-excerpt { font-size: 0.82rem; }
  .section-title { font-size: 1.1rem; }
}

/* ---- "Most Popular" cards still scroll nicely ---- */
@media (max-width: 480px) {
  .popular-section { padding: 22px 0 6px; }
  .popular-inner { padding: 0 14px; }
  .popular-card { flex: 0 0 170px; }
  .popular-card-img { height: 84px; font-size: 1.6rem; }
}

/* ---- Tutorial cards on mobile ---- */
@media (max-width: 480px) {
  .tut-hero { padding: 40px 14px 32px; }
  .tut-hero h1 { font-size: 1.4rem; }
  .tut-hero p { font-size: 0.88rem; }
  .tut-hero .stats { gap: 24px; }
  .tut-section { padding: 28px 14px 40px; }
  .tut-grid { grid-template-columns: 1fr; gap: 16px; }
  .tut-filters-inner { padding: 0 14px; gap: 12px; }
  .filter-group { gap: 6px; }
}

/* ---- Tutorial page content on mobile ---- */
@media (max-width: 520px) {
  .tut-page-hero { padding: 36px 14px 44px; }
  .tut-page-hero h1 { font-size: 1.45rem; }
  .tut-page-hero .tagline { font-size: 0.92rem; }
  .preview-box { padding: 0 14px; }
  .preview-card { padding: 18px 18px; }
  .tut-content { padding: 0 14px 40px; }
  .step-header { padding: 14px 16px; gap: 10px; }
  .step-num-big { width: 32px; height: 32px; min-width: 32px; font-size: 0.95rem; }
  .step-header h2 { font-size: 1rem; }
  .step-body { padding: 16px 18px; }
  .step-body p { font-size: 0.88rem; }
  .tcode { font-size: 0.78rem; padding: 14px 14px; }
  .req-box { padding: 16px 18px; }
  .final-result { padding: 20px 18px; }
}

/* ---- Login wall on mobile ---- */
@media (max-width: 480px) {
  .auth-card { padding: 28px 22px 24px; border-radius: 14px; }
  .auth-card h1 { font-size: 1.3rem; }
  .auth-lead { font-size: 0.86rem; }
  .auth-tab { font-size: 0.8rem; padding: 8px; }
  .auth-field input { font-size: 0.9rem; padding: 10px 12px; }
  .auth-submit { font-size: 0.9rem; padding: 11px; }
}

/* ---- Post page hero + content on mobile ---- */
@media (max-width: 520px) {
  .post-hero { padding: 36px 16px 40px; }
  .post-hero h1 { font-size: 1.45rem; line-height: 1.25; }
  .post-content-wrap { padding: 0 14px; }
  .post-body h2 { font-size: 1.15rem; }
  .post-body h3 { font-size: 1rem; }
  .post-body p, .post-body li { font-size: 0.92rem; }
  .post-body blockquote { padding: 14px 18px; }
  .post-body blockquote p { font-size: 0.9rem; }
  /* Make post tables scrollable */
  .post-body table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .post-body code { font-size: 0.82em; }
  .related-inner { padding: 0 14px; }
}

/* ---- Admin dashboard mobile ---- */
@media (max-width: 720px) {
  .admin-shell { padding: 18px 14px 50px; }
  .admin-title { font-size: 1.2rem; }
  .admin-title .badge { font-size: 0.6rem; padding: 3px 8px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 22px; }
  .stat-card { padding: 14px 14px; }
  .stat-label { font-size: 0.62rem; }
  .stat-value { font-size: 1.45rem; }
  .stat-sub { font-size: 0.66rem; }
  .admin-section { padding: 16px 16px; }
  .admin-section h2 { font-size: 0.95rem; }
  .chart-wrap { height: 220px; }
  .admin-row { grid-template-columns: 1fr; gap: 14px; }
  .admin-table { font-size: 0.78rem; }
  .admin-table th, .admin-table td { padding: 8px 10px; }
  .admin-section-header { gap: 8px; }
  .insight-card { padding: 12px 14px; }
  .insight-headline { font-size: 0.85rem; }
  .insight-detail { font-size: 0.78rem; }
  .query-row { padding: 8px 10px; }
  .query-text { font-size: 0.82rem; }
  .query-meta { font-size: 0.68rem; }
}
@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.2rem; }
  .admin-table { font-size: 0.72rem; }
  .admin-table th, .admin-table td { padding: 6px 8px; }
}

/* ---- WhatsApp banner on mobile ---- */
@media (max-width: 600px) {
  .wa-section .wa-inner { flex-direction: column; gap: 14px; text-align: center; padding: 24px 18px; }
  .wa-inner h2 { font-size: 1.05rem; }
  .wa-inner p { font-size: 0.85rem; }
  .wa-banner-inner { flex-wrap: wrap; gap: 10px; padding: 16px 18px; }
  .wa-banner-text strong { font-size: 0.88rem; }
  .wa-banner-text span { font-size: 0.78rem; }
}

/* ---- TOC on mobile ---- */
@media (max-width: 520px) {
  .toc-box { margin: 18px 0; }
  .toc-header { padding: 10px 14px; font-size: 0.84rem; }
  .toc-list { padding: 8px 14px 12px; }
  .toc-list li a { font-size: 0.8rem; padding: 4px 0; }
}

/* ---- Footer on mobile ---- */
@media (max-width: 480px) {
  .footer-inner { flex-direction: column; gap: 14px; text-align: center; padding: 22px 16px; }
  .footer-links { flex-wrap: wrap; justify-content: center; gap: 12px; }
  .footer-links a { font-size: 0.82rem; }
  .footer-copy { font-size: 0.75rem; }
}

/* ---- Reading progress bar always full width ---- */
#readProgress { left: 0 !important; right: 0 !important; }

/* ---- Back to top button position adjustment on mobile ---- */
@media (max-width: 480px) {
  #backToTop { bottom: 18px; right: 14px; width: 40px; height: 40px; font-size: 1.1rem; }
}


/* ========================
   STICKY HEADER
   ======================== */
.site-header {
  position: sticky !important;
  top: 0;
  z-index: 500;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.site-header.hdr-hidden {
  transform: translateY(-100%);
}
.site-header.hdr-scrolled {
  box-shadow: 0 2px 20px rgba(0,0,0,0.10) !important;
}
html.dark .site-header.hdr-scrolled {
  box-shadow: 0 2px 20px rgba(0,0,0,0.40) !important;
}

/* ========================
   COPY CODE BUTTON
   ======================== */
.code-wrap {
  position: relative;
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: #94a3b8;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.3px;
  transition: all 0.2s;
  opacity: 0;
  pointer-events: none;
}
.code-wrap:hover .copy-btn {
  opacity: 1;
  pointer-events: auto;
}
.copy-btn:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}
.copy-btn.copied {
  background: #22c55e !important;
  border-color: #22c55e !important;
  color: #fff !important;
  opacity: 1 !important;
  pointer-events: none;
}

/* ========================
   SOCIAL SHARE BUTTONS
   ======================== */
.social-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.wa-share {
  background: #25d366;
  color: #fff;
}
.wa-share:hover { background: #1db954; transform: translateY(-1px); }
.tw-share {
  background: #000;
  color: #fff;
}
.tw-share:hover { background: #333; transform: translateY(-1px); }
html.dark .tw-share { background: #1e293b; border: 1px solid #334155; }
html.dark .tw-share:hover { background: #334155; }

/* ========================
   DARK MODE
   ======================== */
html.dark { background: #0f172a; color: #e2e8f0; }
html.dark body { background: #0f172a; color: #e2e8f0; }
html.dark .site-header { background: #1e293b !important; border-bottom: 1px solid #334155 !important; box-shadow: 0 1px 0 #334155; }
html.dark .logo-learn-badge { background: #f97316 !important; }
html.dark .hero { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important; }
html.dark .hero h1, html.dark .hero p { color: #f1f5f9 !important; }
html.dark .hero-topic { background: #1e293b !important; border-color: #334155 !important; color: #94a3b8 !important; }
html.dark .filters-bar { background: #1e293b !important; border-bottom: 1px solid #334155 !important; }
html.dark .filter-btn { background: #0f172a !important; color: #94a3b8 !important; border: 1px solid #334155 !important; }
html.dark .filter-btn.active { background: #f97316 !important; color: #fff !important; border-color: #f97316 !important; }
html.dark .posts-section { background: #0f172a !important; }
html.dark .section-title { color: #f1f5f9 !important; }
html.dark .post-card { background: #1e293b !important; border-color: #334155 !important; }
html.dark .card-title { color: #f1f5f9 !important; }
html.dark .card-excerpt { color: #94a3b8 !important; }
html.dark .card-date { color: #64748b !important; }
html.dark .card-footer { border-color: #334155 !important; }
html.dark .read-time { color: #64748b !important; }
html.dark .card-image-placeholder { background: #1e293b !important; }
html.dark .popular-section { background: #0f172a !important; }
html.dark .popular-title { color: #f1f5f9 !important; }
html.dark .popular-card { background: #1e293b !important; border-color: #334155 !important; }
html.dark .popular-card-body h4 { color: #f1f5f9 !important; }
html.dark .popular-card-likes { color: #64748b !important; }
html.dark .search-box { background: #1e293b !important; border-color: #334155 !important; }
html.dark .search-box input { color: #f1f5f9 !important; background: transparent !important; }
html.dark .search-box input::placeholder { color: #475569 !important; }
html.dark .search-results-info { color: #64748b !important; }
/* Post pages */
html.dark .post-hero { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important; }
html.dark .post-hero h1 { color: #f1f5f9 !important; }
html.dark .post-hero-meta span { color: #94a3b8 !important; }
html.dark .post-breadcrumb a { color: #94a3b8 !important; }
html.dark .post-body { color: #cbd5e1 !important; }
html.dark .post-body h2 { color: #f1f5f9 !important; }
html.dark .post-body h3, html.dark .post-body h4 { color: #e2e8f0 !important; }
html.dark .post-body p, html.dark .post-body li { color: #cbd5e1 !important; }
html.dark .post-body a { color: #fb923c !important; }
html.dark .post-body blockquote { background: #1e293b !important; border-left-color: #f97316 !important; }
html.dark .post-body blockquote p { color: #94a3b8 !important; }
html.dark .post-body table td, html.dark .post-body table th { border-color: #334155 !important; }
html.dark .post-body .divider { border-color: #334155 !important; }
html.dark .faq-item { border-bottom-color: #334155 !important; }
html.dark .faq-item h4 { color: #f1f5f9 !important; }
html.dark .faq-item p { color: #94a3b8 !important; }
html.dark .takeaways { background: #1e293b !important; border-color: #334155 !important; }
html.dark .takeaways h4 { color: #f97316 !important; }
html.dark .takeaways li { color: #cbd5e1 !important; }
html.dark .cta-box { background: #1e293b !important; border-color: #334155 !important; }
html.dark .cta-box p { color: #94a3b8 !important; }
html.dark .post-tags .post-tag { background: #1e293b !important; border-color: #334155 !important; color: #94a3b8 !important; }
html.dark .back-link { color: #94a3b8 !important; }
html.dark .related-posts { background: #1e293b !important; }
html.dark .related-posts h3 { color: #f1f5f9 !important; }
html.dark .like-btn { background: #1e293b !important; border-color: #334155 !important; color: #cbd5e1 !important; }
html.dark .share-btn { background: #334155 !important; color: #f1f5f9 !important; }
html.dark .site-footer { background: #1e293b !important; border-top: 1px solid #334155 !important; }
html.dark .footer-logo { color: #f1f5f9 !important; }
html.dark .footer-links a { color: #94a3b8 !important; }
html.dark .footer-copy { color: #64748b !important; }

/* ========================
   DARK MODE TOGGLE BUTTON
   ======================== */
.dark-toggle {
  background: none;
  border: 1.5px solid #e2e8f0;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  transition: border-color 0.2s, background 0.2s;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
}
.dark-toggle:hover { border-color: #f97316; }
html.dark .dark-toggle { border-color: #475569; }
html.dark .dark-toggle:hover { border-color: #f97316; }

/* ========================
   BACK TO TOP BUTTON
   ======================== */
#backToTop {
  position: fixed;
  bottom: 28px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #f97316;
  color: #fff;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(249,115,22,0.45);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s;
  z-index: 1000;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
#backToTop.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
#backToTop:hover { background: #ea6c00; transform: translateY(-2px) !important; }

/* ========================
   TABLE OF CONTENTS
   ======================== */
.toc-box {
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  margin: 24px 0;
  overflow: hidden;
  font-size: 0.85rem;
}
.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #f8fafc;
  font-weight: 700;
  color: #1e293b;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.toc-header:hover { background: #f1f5f9; }
.toc-toggle { font-size: 0.9rem; transition: transform 0.25s; display: inline-block; }
.toc-box.collapsed .toc-toggle { transform: rotate(-90deg); }
.toc-box.collapsed .toc-list { display: none; }
.toc-list {
  list-style: none;
  margin: 0;
  padding: 10px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff;
}
.toc-list li a {
  color: #475569;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.83rem;
  transition: color 0.15s;
  border-bottom: 1px solid #f1f5f9;
}
.toc-list li:last-child a { border-bottom: none; }
.toc-list li a::before { content: '›'; color: #f97316; font-weight: 800; font-size: 1rem; }
.toc-list li a:hover { color: #f97316; }
html.dark .toc-box { border-color: #334155; }
html.dark .toc-header { background: #1e293b; color: #f1f5f9; }
html.dark .toc-header:hover { background: #263347; }
html.dark .toc-list { background: #0f172a; }
html.dark .toc-list li a { color: #94a3b8; border-bottom-color: #1e293b; }
html.dark .toc-list li a:hover { color: #f97316; }

/* ========================
   BOOKMARK / SAVE BUTTON
   ======================== */
.save-btn {
  background: none;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 0.84rem;
  cursor: pointer;
  color: #64748b;
  font-weight: 600;
  transition: all 0.2s;
  font-family: inherit;
}
.save-btn:hover { border-color: #f97316; color: #f97316; background: #fff5ee; }
.save-btn.saved { background: #fff5ee; border-color: #f97316; color: #f97316; }
html.dark .save-btn { border-color: #334155; color: #94a3b8; background: none; }
html.dark .save-btn:hover { border-color: #f97316; color: #f97316; background: #1e293b; }
html.dark .save-btn.saved { background: #1e293b; border-color: #f97316; color: #f97316; }
