/* ============================================
   Daily Story Flow — Design System
   ============================================ */
:root {
  --bg: #0a0a12;
  --bg2: #12101e;
  --bg3: #1a1730;
  --glass: rgba(255,255,255,0.03);
  --glass-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.07);
  --text: #f1f5f9;
  --text2: #94a3b8;
  --text3: #64748b;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --pink: #ec4899;
  --gradient: linear-gradient(135deg, #8b5cf6, #06b6d4);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --header-h: 64px;
  --font: 'Inter', system-ui, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.container { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* ============= HEADER ============= */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(10,10,18,0.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: transform .3s;
}
.header.hidden { transform: translateY(-100%); }
.header-inner { display: flex; align-items: center; height: var(--header-h); gap: 24px; }
.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.25rem; font-weight: 700; white-space: nowrap;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-icon { font-size: 1.4rem; -webkit-text-fill-color: #8b5cf6; }
.nav-cats {
  display: flex; gap: 4px; overflow-x: auto; flex: 1;
  scrollbar-width: none; -ms-overflow-style: none;
}
.nav-cats::-webkit-scrollbar { display: none; }
.nav-cat {
  padding: 6px 16px; border-radius: 20px; font-size: .85rem; font-weight: 500;
  white-space: nowrap; transition: all .25s; color: var(--text2);
  border: 1px solid transparent;
}
.nav-cat:hover, .nav-cat.active { background: var(--glass-hover); color: var(--text); border-color: var(--border); }
.header-actions { display: flex; gap: 8px; margin-left: auto; }
.btn-icon {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: background .25s; color: var(--text2);
}
.btn-icon:hover { background: var(--glass-hover); color: var(--text); }
.mobile-only { display: none; }

/* Search bar */
.search-bar {
  max-height: 0; overflow: hidden; transition: max-height .3s ease, padding .3s;
  background: var(--bg2); border-top: 1px solid var(--border);
}
.search-bar.open { max-height: 80px; padding: 12px 0; }
.search-bar input {
  width: 100%; padding: 12px 20px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--glass);
  color: var(--text); font-size: 1rem; outline: none;
  transition: border-color .25s;
}
.search-bar input:focus { border-color: var(--purple); }

/* Mobile menu */
.mobile-menu {
  position: fixed; top: 0; right: 0; bottom: 0; width: 300px;
  background: var(--bg2); z-index: 200; transform: translateX(100%);
  transition: transform .35s ease; padding: 20px;
  border-left: 1px solid var(--border);
}
.mobile-menu.open { transform: translateX(0); }
.mobile-menu-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.mobile-menu-nav { display: flex; flex-direction: column; gap: 4px; }
.mobile-menu-nav a {
  display: block; padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 1rem; color: var(--text2); transition: all .2s;
}
.mobile-menu-nav a:hover, .mobile-menu-nav a.active { background: var(--glass-hover); color: var(--text); }
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 150;
  opacity: 0; pointer-events: none; transition: opacity .35s;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* ============= MAIN ============= */
main { padding-top: calc(var(--header-h) + 30px); padding-bottom: 60px; min-height: 70vh; }

/* ============= FEATURED / HERO ============= */
.featured {
  position: relative; border-radius: var(--radius); overflow: hidden;
  margin-bottom: 48px; min-height: 420px; display: flex; align-items: flex-end;
  cursor: pointer; transition: transform .4s;
}
.featured:hover { transform: scale(1.005); }
.featured-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  transition: transform .6s;
}
.featured:hover .featured-bg { transform: scale(1.04); }
.featured-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(10,10,18,0.95) 0%, rgba(10,10,18,0.4) 50%, rgba(10,10,18,0.1) 100%);
}
.featured-content { position: relative; z-index: 2; padding: 40px; width: 100%; }
.featured-badge {
  display: inline-block; padding: 5px 14px; border-radius: 20px;
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 16px;
}
.featured h1 {
  font-family: var(--font-serif); font-size: 2.4rem; font-weight: 700;
  line-height: 1.25; margin-bottom: 12px; max-width: 700px;
}
.featured .excerpt { color: var(--text2); font-size: 1.05rem; max-width: 600px; margin-bottom: 16px; }
.featured .meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text3); font-size: .85rem; }
.featured .meta span { display: flex; align-items: center; gap: 5px; }

/* ============= CONTENT GRID ============= */
.content-grid { display: grid; grid-template-columns: 1fr 340px; gap: 40px; }

/* Post cards */
.posts-section h2 {
  font-size: 1.4rem; font-weight: 700; margin-bottom: 24px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.posts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; margin-bottom: 40px; }

.post-card {
  background: var(--glass); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: transform .3s, box-shadow .3s, border-color .3s;
  animation: fadeUp .5s ease both;
}
.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(139,92,246,0.12);
  border-color: rgba(139,92,246,0.25);
}
.post-card-img {
  position: relative; height: 200px; overflow: hidden;
  background: var(--bg3);
}
.post-card-img img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .5s;
}
.post-card:hover .post-card-img img { transform: scale(1.06); }
.post-card-img .cat-badge {
  position: absolute; top: 12px; left: 12px;
  padding: 4px 12px; border-radius: 16px; font-size: .7rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
}
.post-card-body { padding: 20px; }
.post-card-body h3 {
  font-size: 1.1rem; font-weight: 600; line-height: 1.4;
  margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.post-card-body h3 a { transition: color .2s; }
.post-card-body h3 a:hover { color: var(--purple); }
.post-card-body .excerpt {
  color: var(--text2); font-size: .9rem; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 14px;
}
.post-meta {
  display: flex; gap: 14px; flex-wrap: wrap;
  color: var(--text3); font-size: .8rem;
}
.post-meta span { display: flex; align-items: center; gap: 4px; }

/* Placeholder image */
.img-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; opacity: .15;
}

/* ============= SIDEBAR ============= */
.sidebar { display: flex; flex-direction: column; gap: 28px; }
.widget {
  background: var(--glass); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.widget h3 {
  font-size: 1rem; font-weight: 700; margin-bottom: 16px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
  background: var(--gradient); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.about-text { color: var(--text2); font-size: .9rem; line-height: 1.7; }

/* Popular post item */
.pop-item {
  display: flex; gap: 14px; padding: 10px 0;
  border-bottom: 1px solid var(--border); transition: opacity .2s;
}
.pop-item:last-child { border-bottom: none; }
.pop-item:hover { opacity: .8; }
.pop-item-img {
  width: 72px; height: 54px; border-radius: 8px; overflow: hidden;
  flex-shrink: 0; background: var(--bg3);
}
.pop-item-img img { width: 100%; height: 100%; object-fit: cover; }
.pop-item-info h4 { font-size: .85rem; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.pop-item-info span { font-size: .75rem; color: var(--text3); }

/* Sidebar categories */
.cat-list { display: flex; flex-direction: column; gap: 6px; }
.cat-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-radius: var(--radius-sm);
  transition: background .2s; font-size: .9rem;
}
.cat-item:hover { background: var(--glass-hover); }
.cat-item .dot {
  width: 8px; height: 8px; border-radius: 50%; margin-right: 10px; display: inline-block;
}
.cat-item .count {
  font-size: .75rem; color: var(--text3); background: var(--glass-hover);
  padding: 2px 10px; border-radius: 12px;
}

/* ============= PAGINATION ============= */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.page-btn {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-size: .9rem; font-weight: 500;
  background: var(--glass); border: 1px solid var(--border);
  transition: all .25s; color: var(--text2);
}
.page-btn:hover { border-color: var(--purple); color: var(--text); }
.page-btn.active {
  background: var(--gradient); border-color: transparent;
  color: #fff; font-weight: 700;
}
.page-btn:disabled { opacity: .3; pointer-events: none; }

/* ============= POST DETAIL (Elderly Friendly Reading Mode) ============= */
body.reading-mode {
  background: #f8f5ef;
}
body.reading-mode .footer {
  border-top-color: #e5e7eb;
  color: #6b7280;
}
body.reading-mode .footer-links h4 { color: #111827; }
body.reading-mode .footer-bottom { border-top-color: #e5e7eb; }
body.reading-mode .related h2 { color: #111827; }
body.reading-mode .related-card {
  background: #ffffff; border-color: #e5e7eb; box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}
body.reading-mode .related-card-body h4 { color: #1f2937; }

.post-detail { 
  max-width: 820px; 
  margin: 0 auto; 
  animation: fadeUp .5s ease; 
  background: #ffffff;
  padding: 40px 60px;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
@media (max-width: 768px) {
  .post-detail { padding: 30px 20px; }
}
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: #6b7280; font-size: .95rem; font-weight: 500; margin-bottom: 24px;
  transition: color .2s;
}
.back-link:hover { color: var(--purple); }
.detail-header { margin-bottom: 32px; text-align: center; }
.detail-header .cat-badge {
  display: inline-block; padding: 5px 16px; border-radius: 20px;
  font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 16px;
}
.detail-header h1 {
  font-family: var(--font-serif); font-size: 2.6rem; font-weight: 800;
  line-height: 1.3; margin-bottom: 20px; color: #111827;
}
.detail-meta {
  display: flex; justify-content: center; gap: 20px; flex-wrap: wrap;
  color: #6b7280; font-size: .95rem; font-weight: 500;
}
.detail-meta span { display: flex; align-items: center; gap: 5px; }
.detail-cover {
  border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 40px;
  max-height: 480px;
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-content {
  color: #1f2937; font-size: 20px; line-height: 1.9;
  font-family: Georgia, 'Times New Roman', serif;
}
.detail-content p { margin-bottom: 1.6em; }
.detail-content h2 { font-size: 1.6rem; color: #111827; font-weight: 700; margin: 2em 0 .8em; font-family: var(--font); }
.detail-content h3 { font-size: 1.3rem; color: #111827; font-weight: 700; margin: 1.5em 0 .6em; font-family: var(--font); }
.detail-content blockquote {
  border-left: 4px solid var(--purple); padding: 16px 24px;
  margin: 1.5em 0; background: #f3f4f6; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic; color: #4b5563;
}
.detail-content img { border-radius: var(--radius-sm); margin: 1.5em 0; }
.detail-content a { color: var(--purple); text-decoration: underline; }
.detail-content ul, .detail-content ol { margin: 1em 0; padding-left: 1.5em; }
.detail-content li { margin-bottom: .6em; }
.detail-content pre {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 20px; overflow-x: auto;
  margin: 1.5em 0; font-size: .9rem; font-family: var(--font);
}
.detail-content code { font-family: 'Fira Code', monospace; }

/* Tags */
.tags { display: none; flex-wrap: wrap; gap: 8px; margin-top: 50px; padding-top: 30px; border-top: 1px solid #e5e7eb; }
.tag {
  padding: 6px 16px; border-radius: 20px; font-size: .85rem;
  background: #f3f4f6; border: 1px solid #e5e7eb;
  color: #4b5563; transition: all .2s; font-family: var(--font); font-weight: 500;
}
.tag:hover { border-color: var(--purple); color: var(--purple); background: #fff; }

/* Related posts */
.related { margin-top: 60px; }
.related h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 24px; }
.related-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.related-card {
  background: var(--glass); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
  transition: transform .3s, border-color .3s;
}
.related-card:hover { transform: translateY(-3px); border-color: rgba(139,92,246,0.3); }
.related-card-img { height: 140px; background: var(--bg3); overflow: hidden; }
.related-card-img img { width: 100%; height: 100%; object-fit: cover; }
.related-card-body { padding: 16px; }
.related-card-body h4 {
  font-size: .95rem; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.related-card-body span { font-size: .75rem; color: var(--text3); margin-top: 8px; display: block; }

/* ============= CATEGORY PAGE ============= */
.page-header { margin-bottom: 36px; }
.page-header h1 { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.page-header p { color: var(--text2); }
.page-header .results-count { color: var(--text3); font-size: .9rem; margin-top: 4px; }
.full-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }

/* ============= FOOTER ============= */
.footer {
  border-top: 1px solid var(--border); margin-top: 60px;
  padding: 48px 0 24px; color: var(--text3);
}
.footer-inner { display: flex; justify-content: space-between; gap: 40px; margin-bottom: 32px; }
.footer-brand p { margin-top: 12px; font-size: .9rem; max-width: 340px; line-height: 1.6; }
.footer-links h4 { font-size: .9rem; color: var(--text); margin-bottom: 14px; }
.footer-links a {
  display: block; padding: 4px 0; font-size: .85rem;
  transition: color .2s;
}
.footer-links a:hover { color: var(--purple); }
.footer-bottom { text-align: center; font-size: .8rem; padding-top: 20px; border-top: 1px solid var(--border); }

/* ============= SKELETON ============= */
.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, rgba(255,255,255,0.06) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
.skeleton-text { height: 14px; margin-bottom: 10px; }
.skeleton-title { height: 22px; width: 80%; margin-bottom: 12px; }
.skeleton-img { height: 200px; }

/* ============= EMPTY STATE ============= */
.empty-state {
  text-align: center; padding: 80px 20px; color: var(--text3);
}
.empty-state .icon { font-size: 4rem; margin-bottom: 16px; opacity: .3; }
.empty-state h3 { font-size: 1.3rem; color: var(--text2); margin-bottom: 8px; }

/* ============= ANIMATIONS ============= */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============= RESPONSIVE ============= */
@media (max-width: 1024px) {
  .content-grid { grid-template-columns: 1fr; }
  .sidebar { order: 2; display: grid; grid-template-columns: repeat(2, 1fr); }
  .full-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .nav-cats { display: none; }
  .mobile-only { display: flex; }
  .posts-grid { grid-template-columns: 1fr; }
  .full-grid { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: 1fr; }
  .featured h1 { font-size: 1.7rem; }
  .featured { min-height: 320px; }
  .featured-content { padding: 24px; }
  .detail-header h1 { font-size: 1.8rem; }
  .related-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; }
}
@media (max-width: 480px) {
  .featured h1 { font-size: 1.4rem; }
  .detail-header h1 { font-size: 1.5rem; }
  .detail-meta { flex-direction: column; align-items: center; gap: 8px; }
  .ad, .in-article-ad {
    margin: 30px -20px; /* Full width on mobile */
    width: auto;
  }
}

/* ============= AD PLACEMENTS ============= */
.ad, .in-article-ad {
  display: block;
  margin: 40px 0;
  text-align: center;
  clear: both;
  overflow: hidden; /* Prevent horizontal overflow */
}
.ad-top-article { margin-top: 0; }
.ad-bottom-article { margin-bottom: 0; }

