/* ========================================================
   O2 NEWS BANGLA — Mobile App Experience & Design Upgrade
   PWA Bottom Navigation, Reading Progress, Skeleton Loaders
   ======================================================== */

/* ─────────────────────────────────────────────────────────
   1. READING PROGRESS BAR
   ───────────────────────────────────────────────────────── */
#reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #d32f2f 0%, #1565c0 100%);
  z-index: 999999;
  transition: width 0.1s linear;
  pointer-events: none;
  border-radius: 0 2px 2px 0;
}

/* ─────────────────────────────────────────────────────────
   2. MOBILE TOP BAR — HIDE ON MOBILE
   ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .top-bar {
    display: none !important;
  }
  
  /* Compact header on mobile */
  .main-header {
    padding: 8px 0 !important;
  }
  
  .brand-logo img {
    height: 42px !important;
  }
  
  /* Bottom padding to avoid content behind bottom nav */
  body {
    padding-bottom: 72px;
  }
  
  /* Body padding for iOS safe area */
  @supports (padding: max(0px)) {
    body {
      padding-bottom: max(72px, calc(72px + env(safe-area-inset-bottom)));
    }
  }
}

/* ─────────────────────────────────────────────────────────
   3. MOBILE BOTTOM NAVIGATION BAR
   ───────────────────────────────────────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  z-index: 9997;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08), 0 -1px 0 rgba(0, 0, 0, 0.06);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  /* iOS safe area */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  background: rgba(255, 255, 255, 0.96);
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
  }
}

.mobile-bottom-nav.hidden {
  transform: translateY(calc(100% + env(safe-area-inset-bottom, 0px)));
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 10px;
  color: #94a3b8;
  text-decoration: none;
  font-family: var(--font-ui, 'Noto Sans Bengali', sans-serif);
  font-size: 0.6rem;
  font-weight: 600;
  transition: color 0.2s ease, transform 0.15s ease;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  min-height: 60px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.02em;
}

.bottom-nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: #1565c0;
  border-radius: 0 0 2px 2px;
  transition: width 0.2s ease;
}

.bottom-nav-item.active {
  color: #1565c0;
}

.bottom-nav-item.active::before {
  width: 32px;
}

.bottom-nav-item:active {
  transform: scale(0.92);
}

.bnav-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: background 0.2s ease, transform 0.15s ease;
}

.bottom-nav-item.active .bnav-icon {
  background: #e3f2fd;
}

.bnav-label {
  line-height: 1;
  white-space: nowrap;
}

/* Center Search Button — slightly elevated design */
.bottom-nav-search-btn .bnav-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  color: #fff;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(21, 101, 192, 0.35);
  transform: translateY(-6px);
}

.bottom-nav-search-btn {
  color: #1565c0;
}

.bottom-nav-search-btn .bnav-label {
  margin-top: -3px;
}

.bottom-nav-search-btn:active .bnav-icon {
  transform: translateY(-6px) scale(0.92);
}

/* ─────────────────────────────────────────────────────────
   4. BACK TO TOP BUTTON
   ───────────────────────────────────────────────────────── */
.back-to-top {
  position: fixed;
  right: 16px;
  bottom: 88px; /* Above bottom nav */
  width: 42px;
  height: 42px;
  background: #1565c0;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(21, 101, 192, 0.3);
  z-index: 9996;
  opacity: 0;
  transform: scale(0) translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.back-to-top.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.back-to-top:active {
  transform: scale(0.9);
}

@media (min-width: 769px) {
  .back-to-top {
    bottom: 28px;
    width: 46px;
    height: 46px;
  }
}

/* ─────────────────────────────────────────────────────────
   5. SKELETON LOADERS
   ───────────────────────────────────────────────────────── */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.news-card-img.loading,
.lead-article-img.loading,
.sub-lead-img.loading,
.gallery-card-img.loading,
.video-card-img.loading {
  background: linear-gradient(90deg, #e2e8f0 25%, #f0f4f8 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
}

/* ─────────────────────────────────────────────────────────
   6. APP INSTALL BANNER
   ───────────────────────────────────────────────────────── */
.app-install-banner {
  display: none;
  position: fixed;
  bottom: 80px;
  left: 12px;
  right: 12px;
  background: #0d47a1;
  color: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  z-index: 9995;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(13, 71, 161, 0.4);
  animation: slideUpIn 0.4s ease;
}

.app-install-banner.visible {
  display: flex;
}

@keyframes slideUpIn {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.install-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #fff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.install-banner-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.install-banner-text {
  flex: 1;
}

.install-banner-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}

.install-banner-subtitle {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 2px;
}

.install-banner-btn {
  background: #fff;
  color: #0d47a1;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.install-banner-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
}

/* ─────────────────────────────────────────────────────────
   7. ENHANCED MOBILE ARTICLE READING EXPERIENCE
   ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Better article reading on mobile */
  .article-main {
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 1.25rem 1rem;
    margin: 0 -1rem; /* Full bleed */
  }
  
  .article-headline {
    font-size: 1.55rem;
    line-height: 1.3;
  }
  
  .article-lead-excerpt {
    font-size: 1.08rem;
  }
  
  .article-author-bar {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }
  
  .article-tools {
    align-self: flex-end;
  }
  
  .article-body-content p {
    font-size: 1.1rem;
    line-height: 1.85;
  }
  
  .article-featured-image img {
    max-height: 240px;
    border-radius: 0;
    margin: 0 -1rem;
    width: calc(100% + 2rem);
    max-width: none;
  }
  
  /* Floating share bar on mobile */
  .social-share-bar {
    position: fixed;
    bottom: 75px;
    left: 0;
    right: 0;
    margin: 0;
    padding: 10px 16px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(8px);
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
    z-index: 100;
    border-radius: 0;
    display: flex;
    gap: 8px;
    justify-content: center;
  }
  
  .share-btn {
    padding: 8px 12px;
    font-size: 0.78rem;
  }
}

/* ─────────────────────────────────────────────────────────
   8. MOBILE TOUCH ENHANCEMENTS
   ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Minimum touch target sizes (44px per Apple HIG) */
  .nav-btn,
  .drawer-nav-link,
  .drawer-accordion-btn {
    min-height: 44px;
  }
  
  /* Remove tap highlight on links */
  a, button {
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Better card press feedback */
  .news-card:active {
    transform: scale(0.98);
    transition-duration: 0.1s;
  }
  
  .news-card-horizontal:active {
    opacity: 0.85;
    transform: none;
    transition-duration: 0.1s;
  }
  
  /* Momentum scrolling on overflow containers */
  .nav-links,
  .drawer-accordion-content {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Better grid on mobile */
  .news-grid-2 {
    gap: 0.875rem;
  }
  
  /* Larger breaking news ticker on mobile */
  .breaking-ticker {
    height: 40px;
  }
  
  .ticker-item {
    font-size: 0.9rem;
  }
  
  .breaking-label {
    font-size: 0.82rem;
    padding: 0 12px;
  }
  
  /* Better hero on mobile */
  .lead-article-card {
    height: 300px;
    border-radius: var(--radius-sm);
  }
  
  .lead-title {
    font-size: 1.35rem;
    line-height: 1.3;
  }
  
  .lead-article-overlay {
    padding: 1.25rem;
  }
  
  /* Better section spacing */
  .site-main {
    padding: 1rem 0 2rem;
  }
  
  .section-title {
    font-size: 1.25rem;
  }
}

/* ─────────────────────────────────────────────────────────
   9. SMOOTH PAGE TRANSITIONS
   ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  /* Fade in page content on load */
  .site-main {
    animation: pageFadeIn 0.25s ease;
  }
  
  @keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ─────────────────────────────────────────────────────────
   10. BETTER SIDEBAR WIDGETS ON MOBILE
   ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar-widget {
    border-radius: var(--radius-sm);
  }
}

/* ─────────────────────────────────────────────────────────
   11. IMPROVED BREAKING NEWS MOBILE DESIGN
   ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .breaking-ticker {
    height: 38px;
  }
}

/* ─────────────────────────────────────────────────────────
   12. ENHANCED DESKTOP DESIGN ELEMENTS
   ───────────────────────────────────────────────────────── */

/* Subtle gradient on top of header */
.main-header {
  border-top: 3px solid transparent;
  position: relative;
}

.main-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #d32f2f 0%, #1565c0 50%, #ff8f00 100%);
  z-index: 1;
}

/* Improved section title animation */
.section-indicator {
  background: linear-gradient(180deg, var(--accent-red), #b71c1c);
  box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
}

/* Better hover on news cards */
.news-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 32px rgba(21, 101, 192, 0.12);
}

/* Category tag improved */
.category-tag {
  background: linear-gradient(135deg, #d32f2f, #b71c1c);
  box-shadow: 0 2px 6px rgba(211, 47, 47, 0.3);
}

/* Improved news card badge */
.news-card-badge {
  background: linear-gradient(135deg, #d32f2f, #b71c1c);
  box-shadow: 0 2px 6px rgba(211, 47, 47, 0.3);
}

/* Better trending numbers */
.trending-number {
  font-size: 1.75rem;
  font-weight: 900;
  opacity: 0.7;
}

/* Video section enhanced */
.video-section {
  background: linear-gradient(135deg, #0b132b 0%, #1a237e 100%);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.3);
}

/* Better epaper badge */
.epaper-badge {
  background: linear-gradient(135deg, #ff8f00, #e65100);
  box-shadow: 0 2px 8px rgba(230, 81, 0, 0.3);
}

/* Widget title border animation */
.widget-title {
  border-bottom: 2px solid var(--primary);
  position: relative;
}

.widget-title::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--accent-red);
}

/* ─────────────────────────────────────────────────────────
   13. PRINT STYLES IMPROVEMENT
   ───────────────────────────────────────────────────────── */
@media print {
  .mobile-bottom-nav,
  .back-to-top,
  .app-install-banner,
  .social-share-bar,
  .breaking-ticker,
  .site-footer,
  .sidebar-widget,
  nav.nav-bar,
  .mobile-drawer {
    display: none !important;
  }
  
  .article-container {
    grid-template-columns: 1fr;
  }
  
  .article-main {
    border: none;
    box-shadow: none;
    padding: 0;
  }
}
