
/* Global Reset & Layout Protection */
*, *::before, *::after {
    box-sizing: border-box;
    min-width: 0; /* Critical: Allows flex children to shrink below content size */
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 140px;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden; /* Prevent horizontal scroll on document */
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    overflow-x: hidden; 
    width: 100%;
    max-width: 100vw; /* Hard limit on width */
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* --- Typography Scaling (Optimized for Mobile) --- */
/* Desktop Sizes */
h1 { font-size: 1.75rem !important; line-height: 1.5 !important; }
h2 { font-size: 1.5rem !important; line-height: 1.5 !important; }
h3 { font-size: 1.25rem !important; line-height: 1.5 !important; }
p, li { font-size: 1rem !important; line-height: 1.8 !important; }

/* Mobile Sizes (Small Screens) */
@media (max-width: 640px) {
    h1 { font-size: 1.35rem !important; line-height: 1.4 !important; }
    h2 { font-size: 1.2rem !important; line-height: 1.4 !important; }
    h3 { font-size: 1.1rem !important; line-height: 1.4 !important; }
    p, li, span, a { font-size: 0.95rem !important; line-height: 1.7 !important; }
    
    /* Ensure containers have padding but don't overflow */
    main {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        width: 100%;
    }
}

/* --- Critical Text Wrapping Fixes (Scoped to Content) --- */
/* FIX: Restrict forced wrapping to prose content only to avoid breaking UI like ticker */
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6, 
.prose p, .prose span, .prose a, .prose li, .prose div, .prose blockquote, .prose pre {
    overflow-wrap: break-word !important; 
    word-wrap: break-word !important; 
    word-break: break-word !important; 
    white-space: normal !important; 
    max-width: 100%;
}

/* Specific Override for Ticker to ensure it never wraps */
.ticker-text, .animate-marquee span, .whitespace-nowrap {
    white-space: nowrap !important;
}

/* Prevent link buttons from overflowing text */
a.btn-wrapped-link span {
    white-space: normal !important;
    text-align: center;
}

/* --- Media Containment --- */
/* FIX: Removed global height: auto !important which broke object-fit: cover in cards */
img, iframe, video, object, embed {
    max-width: 100% !important;
    display: block;
}

/* Restore height auto only for content images to maintain aspect ratio */
.prose img {
    height: auto !important;
}

/* --- AdSense Strict Containment --- */
.adsbygoogle-container {
    width: 100%;
    max-width: 100%;
    overflow: hidden; /* Cut off anything that overflows */
    margin: 1.5rem 0;
    padding: 0.5rem;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0.75rem;
    box-sizing: border-box;
}

.adsbygoogle {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* --- Video Container (16:9) --- */
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 0.75rem;
    margin: 1.5rem 0;
    background-color: #000;
    width: 100%;
    max-width: 100%; /* Force width limit */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: 0;
}

/* --- Utilities --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
.dark ::-webkit-scrollbar-track { background: #1f2937; }
::-webkit-scrollbar-thumb { background: #888; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Animations */
@keyframes marquee {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
.animate-marquee { animation: marquee 30s linear infinite; }

@keyframes fadeIn {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeIn 0.5s ease-out; }

/* Link Buttons */
.btn-wrapped-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.9) 0%, rgba(29, 78, 216, 0.9) 100%);
    color: white !important; 
    font-weight: 700;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    text-decoration: none;
    transition: all 0.3s ease;
    width: 100%; /* Full width on mobile */
    max-width: 100%;
    box-sizing: border-box;
    margin: 1rem 0;
}

.btn-wrapped-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(37, 99, 235, 0.3);
}

/* Article Prose Fixes */
.prose {
    max-width: 100% !important;
    overflow-x: hidden;
    font-size: 1rem;
}

.prose img {
    border-radius: 0.5rem;
    margin: 1rem auto;
    width: 100%;
    height: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Post Card Wrappers */
.post-card-wrapper {
    display: block;
    width: 100%;
    max-width: 100%;
}

.post-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-radius: 1rem;
    transition: transform 0.3s ease;
    background-color: white;
    width: 100%;
}
.dark .post-card { background-color: #1f2937; }
.post-card:hover { transform: translateY(-4px); }

/* Table Reset for Mobile */
table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}
