/* ═══════════════════════════════════════════════════════
   WorldOfAI Tech - Complete Stylesheet
   ═══════════════════════════════════════════════════════ */

/* ─── CSS Custom Properties ─────────────────────────── */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-nav: rgba(255,255,255,0.9);
  --bg-modal: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #eef2ff;
  --green: #10b981;
  --red: #ef4444;
  --orange: #f59e0b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.14);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.06);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --nav-height: 64px;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #1e293b;
  --bg-card: #1e293b;
  --bg-nav: rgba(15,23,42,0.92);
  --bg-modal: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --border-light: #1e293b;
  --accent-light: #1e1b4b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.25);
}

/* ─── Reset & Base ───────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth;-webkit-text-size-adjust:100%}
body{
  font-family:var(--font-sans);
  background:var(--bg-primary);
  color:var(--text-primary);
  line-height:1.6;
  transition:background var(--transition),color var(--transition);
  overflow-x:hidden;
}
a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}
img{max-width:100%;display:block}
button{cursor:pointer;border:none;background:none;font:inherit}

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after{animation-duration:0.01ms!important;transition-duration:0.01ms!important}
}

/* ─── Typography ─────────────────────────────────────── */
h1,h2,h3,h4{line-height:1.25;font-weight:700;letter-spacing:-0.02em}
h1{font-size:clamp(1.75rem,4vw,2.5rem)}
h2{font-size:clamp(1.35rem,3vw,1.85rem)}
h3{font-size:clamp(1rem,2.5vw,1.2rem)}

/* ─── Layout ─────────────────────────────────────────── */
.container{max-width:1280px;margin:0 auto;padding:0 1rem}
@media(min-width:768px){.container{padding:0 1.5rem}}
@media(min-width:1200px){.container{padding:0 2rem}}

/* ─── Navbar ─────────────────────────────────────────── */
#navbar{
  position:sticky;top:0;z-index:900;
  height:var(--nav-height);
  background:var(--bg-nav);
  backdrop-filter:blur(16px) saturate(180%);
  -webkit-backdrop-filter:blur(16px) saturate(180%);
  border-bottom:1px solid var(--border);
  transition:background var(--transition),box-shadow var(--transition);
}
#navbar.scrolled{box-shadow:var(--shadow-md)}
.nav-inner{
  height:100%;
  display:flex;align-items:center;gap:1rem;
  max-width:1280px;margin:0 auto;padding:0 1rem;
}
@media(min-width:768px){.nav-inner{padding:0 1.5rem}}

.nav-logo{
  display:flex;align-items:center;gap:.5rem;
  font-weight:800;font-size:1.15rem;
  color:var(--text-primary);
  white-space:nowrap;
  text-decoration:none;
  flex-shrink:0;
}
.nav-logo:hover{text-decoration:none;color:var(--accent)}
.logo-icon{font-size:1.4rem}
.logo-text{background:linear-gradient(135deg,#6366f1,#8b5cf6,#06b6d4);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}

.nav-links{
  display:none;align-items:center;gap:.25rem;flex:1;
}
@media(min-width:900px){.nav-links{display:flex}}
.nav-link{
  padding:.4rem .75rem;
  border-radius:var(--radius-sm);
  color:var(--text-secondary);
  font-size:.9rem;font-weight:500;
  transition:all var(--transition);
  text-decoration:none;
}
.nav-link:hover,.nav-link.active{color:var(--accent);background:var(--accent-light);text-decoration:none}

.nav-actions{display:flex;align-items:center;gap:.5rem;margin-left:auto}
.btn-icon{
  width:38px;height:38px;
  display:flex;align-items:center;justify-content:center;
  border-radius:var(--radius-sm);
  color:var(--text-secondary);font-size:1.1rem;
  transition:all var(--transition);
  position:relative;
}
.btn-icon:hover{background:var(--bg-tertiary);color:var(--text-primary)}
.saved-count{
  position:absolute;top:-4px;right:-4px;
  background:var(--accent);color:#fff;
  border-radius:50%;width:18px;height:18px;
  font-size:.65rem;font-weight:700;
  display:flex;align-items:center;justify-content:center;
}

#menuToggle{display:flex;font-size:1.3rem}
@media(min-width:900px){#menuToggle{display:none}}

/* Mobile Nav */
#mobileNav{
  display:none;position:fixed;
  top:var(--nav-height);left:0;right:0;
  background:var(--bg-primary);
  border-bottom:1px solid var(--border);
  padding:1rem;z-index:899;
  flex-direction:column;gap:.25rem;
  box-shadow:var(--shadow-md);
}
#mobileNav.open{display:flex}
.mobile-nav-link{
  padding:.75rem 1rem;
  border-radius:var(--radius-sm);
  color:var(--text-secondary);
  font-weight:500;
  transition:all var(--transition);
  text-decoration:none;
}
.mobile-nav-link:hover,.mobile-nav-link.active{color:var(--accent);background:var(--accent-light);text-decoration:none}

/* ─── Ad Slots ───────────────────────────────────────── */
.ad-slot{
  background:var(--bg-tertiary);
  border:2px dashed var(--border);
  border-radius:var(--radius-md);
  display:flex;align-items:center;justify-content:center;
  position:relative;
  overflow:hidden;
}
.ad-slot::before{content:'';position:absolute;inset:0;background:linear-gradient(135deg,transparent 40%,rgba(99,102,241,.04))}
.ad-label{
  font-size:.7rem;color:var(--text-muted);
  text-transform:uppercase;letter-spacing:.1em;font-weight:600;
}
.ad-banner{width:100%;min-height:80px;max-height:100px;margin:.5rem 0}
.ad-infeed{width:100%;min-height:180px;grid-column:1/-1;margin:.5rem 0}
.ad-sidebar{width:100%;min-height:250px;margin-bottom:1.5rem}
.ad-mobile-sticky{
  position:fixed;bottom:0;left:0;right:0;
  min-height:56px;z-index:800;
  background:var(--bg-card);
  border-top:1px solid var(--border);
  display:flex;align-items:center;justify-content:center;
  padding:.5rem;
}
@media(min-width:900px){.ad-mobile-sticky{display:none}}

/* ─── Ticker ─────────────────────────────────────────── */
.ticker-wrap{
  background:linear-gradient(135deg,#1e40af,#4f46e5,#7c3aed);
  color:#fff;padding:.55rem 0;overflow:hidden;
}
.ticker-inner{display:flex;align-items:center;gap:1rem}
.ticker-badge{
  flex-shrink:0;
  background:rgba(255,255,255,0.25);
  border-radius:4px;padding:.15rem .6rem;
  font-size:.75rem;font-weight:700;letter-spacing:.05em;
  white-space:nowrap;
}
.ticker-track-wrap{overflow:hidden;flex:1}
.ticker-track{
  display:flex;gap:2.5rem;
  animation:ticker 40s linear infinite;
  white-space:nowrap;
}
.ticker-track:hover{animation-play-state:paused}
.ticker-item{font-size:.83rem;font-weight:500;flex-shrink:0}
@keyframes ticker{0%{transform:translateX(0)}100%{transform:translateX(-50%)}}

/* ─── Hero / Featured ────────────────────────────────── */
.hero-section{margin:1.5rem 0}
.featured-card{
  border-radius:var(--radius-xl);overflow:hidden;
  cursor:pointer;position:relative;
  box-shadow:var(--shadow-lg);
}
.featured-image{
  min-height:420px;
  background-size:cover;background-position:center;
  display:flex;align-items:flex-end;
  position:relative;
}
@media(min-width:768px){.featured-image{min-height:500px}}
.featured-image::after{
  content:'';position:absolute;inset:0;
  background:linear-gradient(to top,rgba(0,0,0,.85) 0%,rgba(0,0,0,.3) 50%,transparent 100%);
}
.featured-overlay{
  position:relative;z-index:1;
  padding:2rem;color:#fff;width:100%;
}
@media(min-width:768px){.featured-overlay{padding:2.5rem 3rem;max-width:75%}}
.featured-meta{display:flex;align-items:center;gap:.75rem;margin-bottom:1rem}
.featured-label{
  background:linear-gradient(135deg,#f59e0b,#ef4444);
  color:#fff;padding:.2rem .7rem;
  border-radius:20px;font-size:.72rem;font-weight:700;letter-spacing:.05em;
}
.featured-title{
  font-size:clamp(1.4rem,4vw,2.2rem);
  font-weight:800;color:#fff;margin-bottom:.75rem;
  text-shadow:0 2px 4px rgba(0,0,0,.3);
}
.featured-desc{
  font-size:.95rem;color:rgba(255,255,255,.85);
  margin-bottom:1.25rem;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
}
.article-footer{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center;font-size:.82rem;color:rgba(255,255,255,.8)}

/* ─── Main Layout ────────────────────────────────────── */
.main-layout{
  display:grid;
  grid-template-columns:1fr;
  gap:2rem;
  padding:1.5rem 0 4rem;
}
/* Grid items must have min-width:0 to prevent blowout */
.feed-column{min-width:0}
@media(min-width:1100px){
  .main-layout{grid-template-columns:1fr 300px}
}

/* ─── Category Tabs ──────────────────────────────────── */
.feed-header{margin-bottom:1.5rem}
.feed-title{font-size:1.3rem;font-weight:700;color:var(--text-primary);margin-bottom:1rem}
#categoryTabs{
  display:flex;gap:.5rem;
  overflow-x:auto;
  -ms-overflow-style:none;scrollbar-width:none;
  padding-bottom:.25rem;
}
#categoryTabs::-webkit-scrollbar{display:none}
.cat-tab{
  display:flex;align-items:center;gap:.35rem;
  padding:.5rem 1rem;
  border-radius:50px;
  background:var(--bg-tertiary);
  color:var(--text-secondary);
  font-size:.85rem;font-weight:600;
  white-space:nowrap;
  transition:all var(--transition);
  border:1.5px solid transparent;
}
.cat-tab:hover{background:var(--accent-light);color:var(--accent)}
.cat-tab.active{background:var(--accent);color:#fff;border-color:var(--accent)}
.tab-icon{font-size:.95rem}

/* ─── Article Grid ───────────────────────────────────── */
#articlesGrid{
  display:grid;
  grid-template-columns:1fr;
  gap:1.5rem;
  min-width:0;
}
@media(min-width:600px){#articlesGrid{grid-template-columns:repeat(2,1fr)}}
@media(min-width:900px){#articlesGrid{grid-template-columns:repeat(3,1fr)}}

/* ─── Article Card ───────────────────────────────────── */
.article-card{
  background:var(--bg-card);
  border-radius:var(--radius-lg);
  overflow:hidden;
  box-shadow:var(--shadow-card);
  border:1px solid var(--border);
  cursor:pointer;
  transition:transform var(--transition),box-shadow var(--transition);
  display:flex;flex-direction:column;
  /* Reduce layout recalculation on long lists */
  contain:layout style;
  content-visibility:auto;
  contain-intrinsic-size:0 320px;
}
.article-card:hover{
  transform:translateY(-4px);
  box-shadow:var(--shadow-lg);
  border-color:var(--accent);
}
.card-image-wrap{position:relative;overflow:hidden;aspect-ratio:16/9}
.card-image{
  width:100%;height:100%;object-fit:cover;
  transition:transform .5s ease;
}
.article-card:hover .card-image{transform:scale(1.05)}
.card-image-overlay{
  position:absolute;inset:0;
  background:linear-gradient(to top,rgba(0,0,0,.3),transparent);
  pointer-events:none;
}
.source-badge{
  position:absolute;top:.75rem;left:.75rem;
  padding:.25rem .65rem;
  border-radius:20px;
  color:#fff;font-size:.7rem;font-weight:700;
  letter-spacing:.04em;z-index:1;
  backdrop-filter:blur(4px);
}
.card-body{padding:1rem;flex:1;display:flex;flex-direction:column;gap:.5rem}
.card-tags{display:flex;flex-wrap:wrap;gap:.35rem}
.article-tag{
  background:var(--accent-light);color:var(--accent);
  padding:.15rem .55rem;border-radius:4px;
  font-size:.68rem;font-weight:600;
}
.card-title{
  font-size:1rem;font-weight:700;
  color:var(--text-primary);
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
  flex:1;
}
.card-desc{
  font-size:.83rem;color:var(--text-secondary);
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
}
.card-footer{
  display:flex;justify-content:space-between;align-items:center;
  margin-top:.25rem;
  padding-top:.75rem;
  border-top:1px solid var(--border-light);
}
.card-meta{display:flex;flex-wrap:wrap;align-items:center;gap:.25rem;font-size:.75rem;color:var(--text-muted)}
.card-dot{color:var(--border)}
.card-actions{display:flex;gap:.35rem}
.btn-action{
  width:30px;height:30px;
  display:flex;align-items:center;justify-content:center;
  border-radius:6px;font-size:.9rem;
  transition:all var(--transition);
  color:var(--text-muted);
}
.btn-action:hover{background:var(--bg-tertiary);color:var(--text-primary)}
.btn-action.saved{color:#f59e0b}

/* ─── Skeleton Loading ───────────────────────────────── */
@keyframes shimmer{
  0%{background-position:-400px 0}
  100%{background-position:400px 0}
}
.skeleton-card{
  background:var(--bg-card);
  border-radius:var(--radius-lg);
  overflow:hidden;
  border:1px solid var(--border);
}
.skeleton{
  background:linear-gradient(90deg,var(--bg-tertiary) 25%,var(--border) 50%,var(--bg-tertiary) 75%);
  background-size:800px 100%;
  animation:shimmer 1.5s infinite;
  border-radius:4px;
}
.skeleton-img{width:100%;aspect-ratio:16/9}
.skeleton-body{padding:1rem;display:flex;flex-direction:column;gap:.65rem}
.skeleton-tag{height:20px;width:80px}
.skeleton-title{height:18px;width:100%}
.skeleton-title.short{width:65%}
.skeleton-desc{height:14px;width:100%}
.skeleton-desc.short{width:80%}
.skeleton-meta{height:12px;width:55%}

/* ─── Sidebar ────────────────────────────────────────── */
.sidebar{display:none;position:sticky;top:calc(var(--nav-height) + 1rem);align-self:start;gap:1.5rem;flex-direction:column}
@media(min-width:1100px){.sidebar{display:flex}}

.sidebar-widget{
  background:var(--bg-card);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  overflow:hidden;
}
.widget-header{
  padding:.9rem 1.1rem;
  border-bottom:1px solid var(--border);
  font-weight:700;font-size:.95rem;
}
.widget-body{padding:.75rem}

/* Trending */
.trending-item{
  display:flex;align-items:center;gap:.75rem;
  padding:.6rem .5rem;border-radius:var(--radius-sm);
  cursor:pointer;transition:background var(--transition);
}
.trending-item:hover{background:var(--bg-tertiary)}
.trending-rank{
  width:24px;height:24px;
  display:flex;align-items:center;justify-content:center;
  background:var(--accent-light);color:var(--accent);
  border-radius:50%;font-size:.72rem;font-weight:700;flex-shrink:0;
}
.trending-info{display:flex;flex-direction:column;gap:.1rem}
.trending-tag{font-size:.85rem;font-weight:600;color:var(--text-primary)}
.trending-count{font-size:.72rem;color:var(--text-muted)}

/* Saved widget */
.saved-widget-content{
  padding:1rem;text-align:center;
}
.saved-widget-count{font-size:2.5rem;font-weight:800;color:var(--accent);line-height:1}
.saved-widget-label{font-size:.8rem;color:var(--text-muted);margin:.25rem 0 .75rem}
.btn-view-saved{
  width:100%;padding:.6rem;
  background:var(--accent);color:#fff;
  border-radius:var(--radius-sm);font-weight:600;font-size:.85rem;
  transition:background var(--transition);
}
.btn-view-saved:hover{background:var(--accent-hover)}

/* ─── Loading Spinner ────────────────────────────────── */
#loadingSpinner{
  display:none;justify-content:center;align-items:center;
  padding:2rem;grid-column:1/-1;
}
.spinner{
  width:40px;height:40px;
  border:3px solid var(--border);
  border-top-color:var(--accent);
  border-radius:50%;
  animation:spin .8s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}
#scrollSentinel{height:1px;grid-column:1/-1}

/* ─── Empty State ────────────────────────────────────── */
.empty-state{
  grid-column:1/-1;
  text-align:center;padding:4rem 2rem;
  color:var(--text-muted);
}
.empty-icon{font-size:3rem;display:block;margin-bottom:.75rem}

/* ─── Modals ─────────────────────────────────────────── */
.modal-backdrop{
  position:fixed;inset:0;z-index:1000;
  background:rgba(0,0,0,.6);
  backdrop-filter:blur(4px);
  display:flex;align-items:center;justify-content:center;
  padding:1rem;
  opacity:0;pointer-events:none;
  transition:opacity var(--transition);
}
.modal-backdrop.active{opacity:1;pointer-events:all}

.modal-box{
  background:var(--bg-modal);
  border-radius:var(--radius-xl);
  box-shadow:var(--shadow-lg);
  width:100%;max-width:720px;
  max-height:90vh;overflow-y:auto;
  transform:scale(0.95);
  transition:transform var(--transition);
  position:relative;
}
.modal-backdrop.active .modal-box{transform:scale(1)}

.modal-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:1.25rem 1.5rem;
  border-bottom:1px solid var(--border);
  position:sticky;top:0;
  background:var(--bg-modal);z-index:1;
}
.modal-title{font-size:1.1rem;font-weight:700}
.modal-close{
  width:32px;height:32px;
  display:flex;align-items:center;justify-content:center;
  border-radius:50%;font-size:1.2rem;
  color:var(--text-muted);
  transition:all var(--transition);
}
.modal-close:hover{background:var(--bg-tertiary);color:var(--text-primary)}

/* Article Modal */
.modal-article{}
.modal-article-image{
  width:100%;max-height:320px;object-fit:cover;
}
.modal-article-body{padding:1.5rem}
.modal-article-meta{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;margin-bottom:1rem}
.modal-time,.modal-readtime{font-size:.8rem;color:var(--text-muted)}
.modal-article-title{font-size:1.5rem;font-weight:800;margin-bottom:.5rem;color:var(--text-primary)}
.modal-article-author{font-size:.85rem;color:var(--text-muted);margin-bottom:1rem}
.modal-article-desc{font-size:.95rem;color:var(--text-secondary);line-height:1.8;margin-bottom:1rem}
.modal-article-tags{display:flex;flex-wrap:wrap;gap:.4rem;margin-bottom:1.5rem}
.modal-article-actions{display:flex;flex-wrap:wrap;gap:.75rem}
.mock-notice{
  margin-top:1.25rem;padding:1rem;
  background:var(--accent-light);border-radius:var(--radius-sm);
  font-size:.82rem;color:var(--accent);border-left:3px solid var(--accent);
}

/* Search Modal */
.search-modal-box{max-width:600px}
.search-input-wrap{position:relative;padding:1.25rem 1.5rem;border-bottom:1px solid var(--border)}
.search-input{
  width:100%;padding:.85rem 1.25rem .85rem 3rem;
  background:var(--bg-tertiary);
  border:2px solid transparent;border-radius:var(--radius-md);
  color:var(--text-primary);font-size:1rem;
  transition:border-color var(--transition);
}
.search-input:focus{outline:none;border-color:var(--accent);background:var(--bg-primary)}
.search-icon{position:absolute;left:2.25rem;top:50%;transform:translateY(-50%);font-size:1.1rem;pointer-events:none}
.search-actions{padding:1rem 1.5rem;display:flex;justify-content:flex-end;gap:.75rem}

/* Saved Panel */
.saved-item{
  display:flex;align-items:center;gap:.75rem;
  padding:.75rem;
  border-radius:var(--radius-sm);
  cursor:pointer;
  transition:background var(--transition);
  border-bottom:1px solid var(--border-light);
}
.saved-item:hover{background:var(--bg-tertiary)}
.saved-thumb{width:64px;height:48px;object-fit:cover;border-radius:var(--radius-sm);flex-shrink:0}
.saved-info{flex:1;min-width:0}
.saved-title{font-size:.85rem;font-weight:600;color:var(--text-primary);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.saved-source{font-size:.72rem;font-weight:600}
.btn-remove-saved{font-size:.8rem;color:var(--text-muted);padding:.25rem .5rem;border-radius:4px;transition:all var(--transition)}
.btn-remove-saved:hover{background:var(--red);color:#fff}
.empty-saved{text-align:center;padding:2rem;color:var(--text-muted)}
.saved-list-inner{padding:.5rem .25rem;max-height:60vh;overflow-y:auto}

/* ─── Buttons ─────────────────────────────────────────── */
.btn-primary{
  padding:.65rem 1.25rem;
  background:var(--accent);color:#fff;
  border-radius:var(--radius-sm);
  font-weight:600;font-size:.9rem;
  transition:all var(--transition);
  display:inline-flex;align-items:center;gap:.4rem;
}
.btn-primary:hover{background:var(--accent-hover);transform:translateY(-1px);box-shadow:0 4px 12px rgba(99,102,241,.3)}
.btn-secondary{
  padding:.65rem 1.25rem;
  background:var(--bg-tertiary);color:var(--text-primary);
  border-radius:var(--radius-sm);border:1px solid var(--border);
  font-weight:600;font-size:.9rem;
  transition:all var(--transition);
  display:inline-flex;align-items:center;gap:.4rem;
}
.btn-secondary:hover{background:var(--bg-secondary);border-color:var(--accent);color:var(--accent)}
.btn-secondary.saved{color:var(--orange);border-color:var(--orange)}
.btn-save-modal{}

/* ─── Toast ───────────────────────────────────────────── */
#toast{
  position:fixed;bottom:1.5rem;right:1.5rem;
  background:var(--text-primary);color:var(--bg-primary);
  padding:.7rem 1.25rem;border-radius:var(--radius-md);
  font-size:.88rem;font-weight:600;
  box-shadow:var(--shadow-lg);z-index:9999;
  opacity:0;transform:translateY(12px);
  transition:all .28s ease;pointer-events:none;
}
#toast.visible{opacity:1;transform:translateY(0)}
@media(max-width:900px){#toast{bottom:4.5rem}}

/* ─── Back to Top ─────────────────────────────────────── */
#backToTop{
  position:fixed;bottom:1.5rem;left:1.5rem;
  width:44px;height:44px;z-index:800;
  background:var(--accent);color:#fff;
  border-radius:50%;font-size:1.2rem;
  display:flex;align-items:center;justify-content:center;
  box-shadow:var(--shadow-md);
  opacity:0;transform:translateY(16px);
  transition:all .3s ease;pointer-events:none;
}
#backToTop.visible{opacity:1;transform:translateY(0);pointer-events:all}
#backToTop:hover{background:var(--accent-hover);transform:translateY(-2px)}
@media(max-width:900px){#backToTop{bottom:4.5rem}}

/* ─── Footer ─────────────────────────────────────────── */
footer{
  background:var(--bg-secondary);
  border-top:1px solid var(--border);
  padding:3rem 0 2rem;
  margin-top:2rem;
}
.footer-grid{
  display:grid;
  grid-template-columns:1fr;gap:2rem;
  margin-bottom:2.5rem;
}
@media(min-width:640px){.footer-grid{grid-template-columns:repeat(2,1fr)}}
@media(min-width:900px){.footer-grid{grid-template-columns:2fr 1fr 1fr 1fr}}
.footer-brand{display:flex;flex-direction:column;gap:.75rem}
.footer-logo{font-size:1.25rem;font-weight:800;color:var(--text-primary)}
.footer-desc{font-size:.85rem;color:var(--text-muted);line-height:1.7}
.footer-socials{display:flex;gap:.75rem;margin-top:.5rem}
.social-link{
  width:36px;height:36px;
  display:flex;align-items:center;justify-content:center;
  background:var(--bg-tertiary);border-radius:8px;
  color:var(--text-secondary);font-size:1rem;
  transition:all var(--transition);
  text-decoration:none;
}
.social-link:hover{background:var(--accent);color:#fff;text-decoration:none;transform:translateY(-2px)}
.footer-col h4{font-size:.9rem;font-weight:700;margin-bottom:.75rem;color:var(--text-primary)}
.footer-links{display:flex;flex-direction:column;gap:.5rem}
.footer-links a{font-size:.85rem;color:var(--text-muted);transition:color var(--transition);text-decoration:none}
.footer-links a:hover{color:var(--accent);text-decoration:none}
.footer-bottom{
  display:flex;flex-wrap:wrap;gap:.75rem;
  justify-content:space-between;align-items:center;
  padding-top:1.5rem;border-top:1px solid var(--border);
  font-size:.8rem;color:var(--text-muted);
}
.footer-legal{display:flex;flex-wrap:wrap;gap:1rem}
.footer-legal a{color:var(--text-muted);transition:color var(--transition);text-decoration:none}
.footer-legal a:hover{color:var(--accent)}

/* ─── Misc ────────────────────────────────────────────── */
.section-sep{height:1px;background:var(--border);margin:1rem 0}
.pill{
  display:inline-flex;align-items:center;gap:.35rem;
  padding:.3rem .75rem;border-radius:50px;
  font-size:.78rem;font-weight:600;
}
.pill-green{background:#d1fae5;color:#065f46}
[data-theme="dark"] .pill-green{background:#064e3b;color:#6ee7b7}

/* ─── Scrollbar styling ──────────────────────────────── */
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:var(--bg-secondary)}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}
::-webkit-scrollbar-thumb:hover{background:var(--text-muted)}

/* ═══════════════════════════════════════════════════════
   MOBILE RESPONSIVE IMPROVEMENTS
   Optimized for Android & iOS devices (320px – 768px)
   ═══════════════════════════════════════════════════════ */

/* ─── Touch Targets for touch/pointer devices ────────────
   Applied via hover:none + pointer:coarse to target actual
   touch screens without bloating desktop button sizes.
   iOS HIG: ≥ 44×44 px  |  Material Design: ≥ 48×48 dp  */
@media(hover:none) and (pointer:coarse){
  .btn-action{width:44px;height:44px;border-radius:8px;font-size:1rem}
  .btn-icon{width:44px;height:44px}
  .modal-close{width:44px;height:44px}
  .btn-remove-saved{
    min-width:44px;min-height:44px;
    display:flex;align-items:center;justify-content:center;
  }
  .btn-primary,.btn-secondary{min-height:44px}
}
/* Structural min-heights for nav/tabs apply on all touch-size screens */
.cat-tab{min-height:44px}
.mobile-nav-link{min-height:48px;display:flex;align-items:center}

/* ─── Tablets & Large Phones: 481px – 768px ─────────── */
@media(max-width:768px){
  /* Prevent iOS auto-zoom on focused inputs (requires ≥16px) */
  input,select,textarea{font-size:16px!important}

  /* Bottom clearance for fixed sticky ad (≈56 px) */
  footer{padding-bottom:calc(2rem + 60px)}

  /* Featured card */
  .featured-image{min-height:300px}
  .featured-overlay{padding:1.5rem}
  .featured-desc{display:none}

  /* Article modal */
  .modal-box{border-radius:var(--radius-lg)}
  .modal-article-title{font-size:1.3rem}
  .modal-article-actions{flex-direction:column;gap:.5rem}
  .modal-article-actions .btn-primary,
  .modal-article-actions .btn-secondary{
    width:100%;justify-content:center;padding:.75rem 1.25rem
  }

  /* Spacing */
  .hero-section{margin:.875rem 0}
  .main-layout{padding-bottom:5rem}
  .feed-header{margin-bottom:1rem}

  /* Ad banner – appropriate mobile height */
  .ad-banner{min-height:50px;max-height:90px}
}

/* ─── Mobile Phones: up to 480px ────────────────────── */
@media(max-width:480px){
  /* Compact nav for small screens */
  .nav-inner{gap:.5rem}
  .logo-text{font-size:1rem}
  .nav-actions{gap:.2rem}
  /* Keep min-height 44px; reduce visual size slightly via padding trick */
  .btn-icon{width:44px;height:44px;font-size:1rem}

  /* Mobile nav drawer */
  #mobileNav{padding:.75rem}
  .mobile-nav-link{padding:.875rem 1rem;font-size:.95rem}

  /* Featured card */
  .featured-image{min-height:200px}
  .featured-title{font-size:1.25rem;line-height:1.3}
  .featured-overlay{padding:1.25rem}
  .featured-meta{margin-bottom:.5rem}
  .article-footer{font-size:.75rem;gap:.4rem}

  /* Article grid & cards */
  #articlesGrid{gap:1rem}
  .card-body{padding:.875rem;gap:.4rem}
  .card-title{font-size:.93rem}
  .card-desc{font-size:.8rem}
  .card-meta{font-size:.7rem}
  .card-footer{padding-top:.6rem}

  /* Feed */
  .feed-title{font-size:1.1rem}
  .cat-tab{padding:.5rem .75rem;font-size:.8rem}

  /* Ad slots – mobile-appropriate sizes */
  .ad-banner{min-height:50px;max-height:60px;margin:.5rem 0}
  .ad-infeed{min-height:200px}

  /* Ticker */
  .ticker-item{font-size:.78rem}
  .ticker-badge{font-size:.68rem;padding:.12rem .5rem}

  /* Spacing */
  .hero-section{margin:.75rem 0}
  .main-layout{gap:1.25rem;padding-top:.75rem;padding-bottom:5rem}
  footer{padding:1.5rem 0 calc(1.5rem + 60px)}

  /* Search / modal inner spacing */
  .search-input-wrap{padding:1rem 1.25rem}
  .search-actions{padding:.75rem 1.25rem}
  .modal-header{padding:1rem 1.25rem}
  .modal-article-body{padding:1.25rem}
}

/* ─── Very small phones: up to 360px ────────────────── */
@media(max-width:360px){
  .nav-inner{gap:.25rem}
  .logo-text{font-size:.88rem}
  .logo-icon{font-size:1.15rem}
  /* Hide theme toggle to free space for logo + nav actions */
  #themeToggle{display:none}
  .cat-tab{padding:.45rem .6rem;font-size:.75rem}
  .card-title{font-size:.88rem}
  .featured-title{font-size:1.1rem}
}

/* ─── Landscape on phones ────────────────────────────── */
@media(max-width:768px) and (orientation:landscape){
  .featured-image{min-height:180px}
  .modal-box{max-height:92vh}
}

/* ─── Disable hover transforms on touch devices ─────────
   Prevents janky scale/lift effects on tap in mobile     */
@media(hover:none) and (pointer:coarse){
  .article-card:hover{transform:none;box-shadow:var(--shadow-card);border-color:var(--border)}
  .article-card:hover .card-image{transform:none}
  .social-link:hover{transform:none}
  .btn-primary:hover{transform:none}
}

/* ─── Image responsive guarantees ───────────────────────
   Ensure no image ever causes horizontal scrolling.
   Note: .card-image uses height:100% + object-fit:cover
   intentionally within its aspect-ratio container.        */
.modal-article-image{max-height:280px;object-fit:cover}
@media(max-width:480px){
  .modal-article-image{max-height:200px}
}
