/* ============================================
   GOOD NEWS 24 - ENHANCEMENTS
   Dark/Light mode, animations, share, related, newsletter popup
   ============================================ */

/* ---- Dark Mode Variables ---- */
[data-theme="dark"] {
    --text-dark: #F3F4F6;
    --text-medium: #D1D5DB;
    --text-light: #9CA3AF;
    --background-white: #111827;
    --background-cream: #1F2937;
    --background-light: #1a2332;
    color-scheme: dark;
}
[data-theme="dark"] body { background: #111827; color: #F3F4F6; }
[data-theme="dark"] .main-header { background: #1F2937; border-bottom: 1px solid #374151; }
[data-theme="dark"] .nav-links a { color: #D1D5DB; }
[data-theme="dark"] .nav-links a:hover, [data-theme="dark"] .nav-links a.active { background: #374151; color: #FFD93D; }
[data-theme="dark"] .story-card, [data-theme="dark"] .featured-card { background: #1F2937; }
[data-theme="dark"] .story-content h3, [data-theme="dark"] .featured-content h3 { color: #F3F4F6; }
[data-theme="dark"] .story-content p, [data-theme="dark"] .featured-content p { color: #D1D5DB; }
[data-theme="dark"] .section-header h2 { color: #F3F4F6; }
[data-theme="dark"] .quote-section { background: #1F2937; }
[data-theme="dark"] .quote-section blockquote p { color: #F3F4F6; }
[data-theme="dark"] .categories-section { background: #1a2332; }
[data-theme="dark"] .featured-story { background: #1a2332; }
[data-theme="dark"] .main-footer { background: #0F172A; }
[data-theme="dark"] .nav-links { background: #1F2937; }
/* Dark mode for story article pages (inline styled) */
[data-theme="dark"] .article-container { background: #1F2937 !important; color: #F3F4F6 !important; }
[data-theme="dark"] .article-container h1, [data-theme="dark"] .article-container h2 { color: #F3F4F6 !important; }
[data-theme="dark"] .article-content, [data-theme="dark"] .article-content p { color: #D1D5DB !important; }
[data-theme="dark"] .article-content strong { color: #F3F4F6 !important; }
[data-theme="dark"] .highlight-box { background: linear-gradient(135deg, #374151, #4B5563) !important; border-left-color: #FFD93D !important; color: #F3F4F6 !important; }
[data-theme="dark"] .quote-box { background: linear-gradient(135deg, #374151, #4B5563) !important; border-left-color: #818CF8 !important; color: #D1D5DB !important; }
[data-theme="dark"] .meta { color: #9CA3AF !important; }

/* ---- Theme Toggle Button ---- */
.theme-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: #1F2937;
    color: #FFD93D;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
[data-theme="dark"] .theme-toggle { background: #FFD93D; color: #1F2937; }
.theme-toggle:hover { transform: scale(1.1); }

/* ---- Enhanced Card Animations ---- */
.story-card {
    opacity: 0;
    transform: translateY(40px) scale(0.97);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.3s ease;
}
.story-card.gn-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.story-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.15);
}
.story-card:hover .story-image img {
    transform: scale(1.08);
}
.category-card {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.category-card.gn-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Reading Time Badge ---- */
.gn-reading-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    color: #6B7280;
    font-weight: 600;
    margin-top: 6px;
}
[data-theme="dark"] .gn-reading-time { color: #9CA3AF; }

/* ---- Share Buttons ---- */
.gn-share-bar {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.gn-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 20px;
    border: none;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-decoration: none;
    color: white;
}
.gn-share-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.gn-share-btn.copy { background: #6B7280; }
.gn-share-btn.whatsapp { background: #25D366; }
.gn-share-btn.email { background: #3B82F6; }
.gn-share-btn.x { background: #000; }
.gn-share-btn .copied { display: none; }
.gn-share-btn.show-copied .copied { display: inline; }
.gn-share-btn.show-copied .default { display: none; }

/* ---- Related Articles ---- */
.gn-related {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #E5E7EB;
}
[data-theme="dark"] .gn-related { border-top-color: #374151; }
.gn-related h3 {
    font-size: 1.3rem;
    margin-bottom: 16px;
    color: inherit;
}
.gn-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.gn-related-card {
    padding: 16px;
    background: #F9FAFB;
    border-radius: 12px;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    display: block;
}
[data-theme="dark"] .gn-related-card { background: #374151; }
.gn-related-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.1); }
.gn-related-card h4 {
    font-size: 0.95rem;
    line-height: 1.4;
    margin: 0;
}

/* ---- Newsletter Popup ---- */
.gn-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}
.gn-popup-overlay.active { opacity: 1; visibility: visible; }
.gn-popup {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 25px 60px rgba(0,0,0,0.2);
}
[data-theme="dark"] .gn-popup { background: #1F2937; color: #F3F4F6; }
.gn-popup-overlay.active .gn-popup { transform: scale(1) translateY(0); }
.gn-popup-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #9CA3AF;
    line-height: 1;
}
.gn-popup-close:hover { color: #EF4444; }
.gn-popup .emoji { font-size: 3rem; margin-bottom: 12px; }
.gn-popup h3 { font-size: 1.4rem; margin-bottom: 8px; }
.gn-popup p { color: #6B7280; margin-bottom: 20px; font-size: 0.95rem; }
[data-theme="dark"] .gn-popup p { color: #9CA3AF; }
.gn-popup-form {
    display: flex;
    gap: 8px;
}
.gn-popup-form input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    background: transparent;
    color: inherit;
}
[data-theme="dark"] .gn-popup-form input { border-color: #4B5563; }
.gn-popup-form input:focus { outline: none; border-color: #FF9F1C; }
.gn-popup-form button {
    padding: 12px 20px;
    background: linear-gradient(135deg, #FFD93D, #FF9F1C);
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    transition: transform 0.2s;
}
.gn-popup-form button:hover { transform: scale(1.05); }
.gn-popup .no-thanks {
    display: block;
    margin-top: 12px;
    color: #9CA3AF;
    font-size: 0.82rem;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
}

/* ============================================
   MOBILE EXPERIENCE IMPROVEMENTS
   ============================================ */

/* Better touch targets on mobile */
@media (max-width: 768px) {
    .nav-links a {
        padding: 12px 16px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .story-card {
        margin-bottom: 16px;
    }
    
    .story-card:hover {
        transform: none; /* Disable hover effects on touch */
    }
    
    /* Improve article readability on mobile */
    .article-content,
    .article-page .article-content {
        font-size: 1.05rem;
        line-height: 1.8;
        padding: 0 8px;
    }
    
    .article-content h2 {
        font-size: 1.4rem;
        margin-top: 32px;
    }
    
    .article-header h1 {
        font-size: 1.6rem;
        line-height: 1.3;
    }
    
    /* Better share buttons on mobile */
    .gn-share-bar {
        justify-content: center;
    }
    
    .gn-share-btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
    
    /* Newsletter popup mobile */
    .gn-popup {
        padding: 24px 20px;
        width: 95%;
    }
    
    .gn-popup-form {
        flex-direction: column;
    }
    
    .gn-popup-form button {
        width: 100%;
    }
    
    /* Related articles single column on small screens */
    .gn-related-grid {
        grid-template-columns: 1fr;
    }
    
    /* Improve footer touch targets */
    .main-footer a {
        padding: 8px 4px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* Small phones */
@media (max-width: 375px) {
    .article-header h1 {
        font-size: 1.3rem;
    }
    
    .article-content {
        font-size: 1rem;
    }
}

/* ============================================
   PERFORMANCE: Reduce layout shifts
   ============================================ */
.story-image {
    aspect-ratio: 16/9;
    overflow: hidden;
    background: #f0f0f0;
}

[data-theme="dark"] .story-image {
    background: #374151;
}

.story-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

/* Smooth scroll for in-page navigation */
html {
    scroll-behavior: smooth;
}

/* Focus visible for accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 3px solid #FF9F1C;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Skip to content link for accessibility */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #FF8C42;
    color: white;
    padding: 8px 16px;
    z-index: 10001;
    font-weight: 600;
    transition: top 0.2s;
}

.skip-to-content:focus {
    top: 0;
}
