/* ================================================================
   MagazineCMS - Feature Styles
   Dark mode, reading progress, scroll-to-top, push, notifications
   ================================================================ */

/* ---- Dark Mode ---- */
html.dark-mode {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --text: #f1f5f9;
  --text-light: #94a3b8;
  --border: #334155;
}
html.dark-mode body { background: var(--bg); color: var(--text); }
html.dark-mode .site-header { background: #1e293b; border-color: #334155; box-shadow: 0 1px 8px rgba(0,0,0,.2); }
html.dark-mode .main-nav { border-color: #334155; }
html.dark-mode .main-nav a { color: #94a3b8; }
html.dark-mode .main-nav a:hover, html.dark-mode .main-nav a.active { color: var(--primary); }
html.dark-mode .article-card { background: #1e293b; border-color: #334155; }
html.dark-mode .article-card:hover { box-shadow: 0 12px 40px rgba(0,0,0,.3); }
html.dark-mode .article-card .excerpt { color: #94a3b8; }
html.dark-mode .article-card .card-meta { color: #64748b; }
html.dark-mode .sidebar-widget { background: #1e293b; border-color: #334155; }
html.dark-mode .popular-item { border-color: #334155; }
html.dark-mode .popular-item:hover { background: #0f172a; }
html.dark-mode .category-list a { border-color: #334155; }
html.dark-mode .search-form { background: #0f172a; }
html.dark-mode .search-form:focus-within { background: #1e293b; }
html.dark-mode .search-form input { color: #f1f5f9; }
html.dark-mode .article-content { color: #e2e8f0; }
html.dark-mode .article-content blockquote { background: rgba(230,57,70,.08); border-color: var(--primary); }
html.dark-mode .comment { border-color: #334155; }
html.dark-mode .comment-form textarea,
html.dark-mode .comment-form input { background: #0f172a; border-color: #334155; color: #f1f5f9; }
html.dark-mode .tag-pill { background: #1e293b; border-color: #334155; color: #94a3b8; }
html.dark-mode .author-box { background: #1e293b; border-color: #334155; }
html.dark-mode .breadcrumb a { color: #64748b; }
html.dark-mode .breadcrumb .current { color: #f1f5f9; }

/* Dark mode toggle button */
.dark-toggle {
  background: none;
  border: none;
  font-size: 1.05rem;
  color: var(--text-light);
  cursor: pointer;
  padding: .45rem;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .25s;
}
.dark-toggle:hover {
  background: rgba(230,57,70,.1);
  color: var(--primary);
}

/* ---- Reading Progress Bar ---- */
.reading-progress-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 9999;
}
.reading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #ff6b6b);
  transition: width .15s ease-out;
  border-radius: 0 2px 2px 0;
}

/* Reading time remaining */
.reading-time-float {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: .4rem .85rem;
  border-radius: 20px;
  font-size: .75rem;
  color: var(--text-light);
  box-shadow: 0 4px 15px rgba(0,0,0,.1);
  z-index: 90;
  opacity: 0;
  transform: translateY(10px);
  transition: all .3s;
  pointer-events: none;
}
.reading-time-float.visible {
  opacity: 1;
  transform: translateY(0);
}
html.dark-mode .reading-time-float {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 4px 15px rgba(0,0,0,.4);
}

/* ---- Scroll to Top ---- */
.scroll-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: all .3s;
  box-shadow: 0 4px 15px rgba(230,57,70,.3);
  z-index: 90;
}
.scroll-top:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(230,57,70,.4);
}

/* ---- Push Subscribe Button ---- */
.push-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .85rem;
  background: var(--secondary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
}
.push-btn:hover { opacity: .9; }
.push-btn.subscribed { background: var(--success, #10b981); }

/* ---- Notification bar (install PWA) ---- */
.pwa-install-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--secondary);
  color: #fff;
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  font-size: .88rem;
  z-index: 200;
  transform: translateY(100%);
  transition: transform .4s;
}
.pwa-install-bar.show { transform: translateY(0); }
.pwa-install-bar button {
  padding: .4rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.pwa-install-bar .install-btn { background: var(--primary); color: #fff; }
.pwa-install-bar .dismiss-btn { background: rgba(255,255,255,.15); color: #fff; }

/* ---- Related Articles (intelligent) ---- */
.related-grid-smart {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
@media (max-width: 768px) { .related-grid-smart { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .related-grid-smart { grid-template-columns: 1fr; } }

.related-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all .3s;
}
.related-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,.08);
}
.related-card .thumb {
  aspect-ratio: 16/10;
  overflow: hidden;
  background: #eee;
}
.related-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s;
}
.related-card:hover .thumb img { transform: scale(1.05); }
.related-card .body { padding: .85rem; }
.related-card h4 {
  font-family: var(--font-display);
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.related-card .meta {
  font-size: .72rem;
  color: var(--text-light);
  margin-top: .4rem;
}
html.dark-mode .related-card { background: #1e293b; border-color: #334155; }
