/* ==========================================================================
   Modern Design System: MyCommunity Today News & Stories
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --news-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --news-primary: #0284c7;
    --news-primary-hover: #0369a1;
    --news-primary-light: #e0f2fe;
    --news-primary-glow: rgba(2, 132, 199, 0.2);
    --news-gradient: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    --news-accent: #0ea5e9;

    --news-bg-page: #f8fafc;
    --news-bg-card: #ffffff;
    --news-bg-subtle: #f1f5f9;
    --news-bg-hover: #f8fafc;
    --news-border: #e2e8f0;
    --news-border-hover: #cbd5e1;

    --news-text-main: #0f172a;
    --news-text-muted: #64748b;
    --news-text-light: #94a3b8;

    --news-radius-sm: 8px;
    --news-radius-md: 12px;
    --news-radius-lg: 18px;
    --news-radius-pill: 9999px;

    --news-shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.05), 0 1px 2px 0 rgba(15, 23, 42, 0.03);
    --news-shadow-card: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --news-shadow-hover: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
    --news-shadow-popover: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
}

[data-theme="dark"] {
    --news-bg-page: #0b1120;
    --news-bg-card: #1e293b;
    --news-bg-subtle: #0f172a;
    --news-bg-hover: #243248;
    --news-border: #334155;
    --news-border-hover: #475569;

    --news-text-main: #f8fafc;
    --news-text-muted: #94a3b8;
    --news-text-light: #64748b;

    --news-primary-light: rgba(2, 132, 199, 0.18);
    --news-shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --news-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    --news-shadow-popover: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --news-bg-page: #0b1120;
        --news-bg-card: #1e293b;
        --news-bg-subtle: #0f172a;
        --news-bg-hover: #243248;
        --news-border: #334155;
        --news-border-hover: #475569;

        --news-text-main: #f8fafc;
        --news-text-muted: #94a3b8;
        --news-text-light: #64748b;

        --news-primary-light: rgba(2, 132, 199, 0.18);
        --news-shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
        --news-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
        --news-shadow-popover: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
    }
}

/* Page Layout Container */
.news-page-wrapper {
    width: 100%;
    min-height: calc(100vh - 80px);
    background-color: var(--news-bg-page);
    font-family: var(--news-font);
    color: var(--news-text-main);
    padding: 32px 24px 64px;
    box-sizing: border-box;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.news-main-container {
    max-width: 1320px;
    margin: 0 auto;
    width: 100%;
}

/* ==========================================================================
   Header & Hero Section
   ========================================================================== */
.news-hero-section {
    margin-bottom: 32px;
}

.news-hero-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.news-hero-titles {
    flex: 1 1 500px;
}

.news-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--news-radius-pill);
    background: var(--news-primary-light);
    color: var(--news-primary);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 12px;
}

.news-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: newsPulse 2s infinite;
}

@keyframes newsPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.news-hero-title {
    font-size: clamp(26px, 3.2vw, 36px);
    font-weight: 800;
    line-height: 1.2;
    margin: 0 0 8px 0;
    color: var(--news-text-main);
    letter-spacing: -0.02em;
}

.news-hero-subtitle {
    font-size: 15px;
    line-height: 1.5;
    color: var(--news-text-muted);
    margin: 0;
    max-width: 680px;
}

/* Toolbar: Tabs, Search & Refresh */
.news-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--news-bg-card);
    border: 1px solid var(--news-border);
    border-radius: var(--news-radius-lg);
    padding: 12px 16px;
    box-shadow: var(--news-shadow-sm);
}

.news-tabs-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--news-bg-subtle);
    padding: 4px;
    border-radius: var(--news-radius-md);
    flex-wrap: wrap;
}

.news-tab-btn {
    border: none;
    background: transparent;
    color: var(--news-text-muted);
    font-family: var(--news-font);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--news-radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.news-tab-btn i {
    font-size: 18px;
}

.news-tab-btn:hover {
    color: var(--news-text-main);
}

.news-tab-btn.active {
    background: var(--news-bg-card);
    color: var(--news-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.news-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 320px;
    justify-content: flex-end;
}

.news-search-box {
    position: relative;
    flex: 1;
    max-width: 360px;
}

.news-search-box i.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--news-text-light);
    font-size: 20px;
    pointer-events: none;
}

.news-search-input {
    width: 100%;
    padding: 10px 36px 10px 40px;
    border: 1px solid var(--news-border);
    border-radius: var(--news-radius-md);
    background: var(--news-bg-subtle);
    color: var(--news-text-main);
    font-family: var(--news-font);
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
    transition: all 0.2s ease;
}

.news-search-input:focus {
    border-color: var(--news-primary);
    background: var(--news-bg-card);
    box-shadow: 0 0 0 3px var(--news-primary-glow);
}

.news-clear-search {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--news-text-light);
    cursor: pointer;
    padding: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.news-clear-search:hover {
    color: var(--news-text-main);
}

.news-refresh-btn {
    border: 1px solid var(--news-border);
    background: var(--news-bg-card);
    color: var(--news-text-main);
    padding: 10px 16px;
    border-radius: var(--news-radius-md);
    font-family: var(--news-font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.news-refresh-btn:hover {
    background: var(--news-bg-subtle);
    border-color: var(--news-border-hover);
    color: var(--news-primary);
}

.news-refresh-btn.is-spinning i {
    animation: newsSpin 0.8s linear infinite;
}

@keyframes newsSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Section Headers
   ========================================================================== */
.news-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 36px 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--news-border);
}

.news-section-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.news-section-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--news-radius-md);
    background: var(--news-primary-light);
    color: var(--news-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.news-section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--news-text-main);
    margin: 0;
}

.news-section-count {
    background: var(--news-bg-subtle);
    color: var(--news-text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--news-radius-pill);
}

/* ==========================================================================
   News Grid Layout
   ========================================================================== */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
    width: 100%;
}

@media screen and (max-width: 768px) {
    .news-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }
}

/* ==========================================================================
   News Card (The Cell)
   ========================================================================== */
.news-card {
    background: var(--news-bg-card);
    border: 1px solid var(--news-border);
    border-radius: var(--news-radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--news-shadow-card);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease;
    cursor: pointer;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.news-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--news-shadow-hover);
    border-color: var(--news-primary);
}

.news-card:focus-visible {
    outline: 3px solid var(--news-primary);
    outline-offset: 2px;
}

/* Media / Thumbnail */
.news-card-media {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--news-bg-subtle);
    overflow: hidden;
}

.news-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.news-card:hover .news-card-img {
    transform: scale(1.04);
}

/* Media Fallback Graphic */
.news-card-media-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.12) 0%, rgba(14, 165, 233, 0.05) 100%);
    color: var(--news-primary);
    gap: 8px;
}

.news-card-media-fallback i {
    font-size: 42px;
    opacity: 0.8;
}

.news-card-media-fallback span {
    font-size: 13px;
    font-weight: 600;
    color: var(--news-text-muted);
}

/* Type Badge Overlay */
.news-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    padding: 5px 12px;
    border-radius: var(--news-radius-pill);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.news-badge.local {
    background: rgba(16, 185, 129, 0.9);
    color: #ffffff;
}

.news-badge.global {
    background: rgba(2, 132, 199, 0.9);
    color: #ffffff;
}

/* Card Body Content */
.news-card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Meta Line */
.news-meta-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 12.5px;
    color: var(--news-text-muted);
}

.news-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
    color: var(--news-primary);
}

.news-source-badge i {
    font-size: 15px;
}

.news-dot {
    color: var(--news-text-light);
}

.news-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.news-time i {
    font-size: 14px;
}

/* Title & Description */
.news-card-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--news-text-main);
    margin: 0 0 10px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

.news-card:hover .news-card-title {
    color: var(--news-primary);
}

.news-card-title a {
    color: inherit;
    text-decoration: none;
}

.news-card-desc {
    font-size: 14px;
    line-height: 1.55;
    color: var(--news-text-muted);
    margin: 0 0 20px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

/* Footer & Actions Bar */
.news-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--news-border);
    margin-top: auto;
}

.news-read-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--news-radius-md);
    background: var(--news-primary-light);
    color: var(--news-primary);
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
}

.news-read-btn i {
    font-size: 16px;
    transition: transform 0.2s ease;
}

.news-card:hover .news-read-btn {
    background: var(--news-primary);
    color: #ffffff;
}

.news-card:hover .news-read-btn i {
    transform: translate(2px, -2px);
}

/* Share Button & Floating Popover Menu */
.news-share-wrap {
    position: relative;
}

.news-share-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--news-border);
    background: var(--news-bg-card);
    color: var(--news-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.news-share-btn i {
    font-size: 18px;
}

.news-share-btn:hover {
    background: var(--news-bg-subtle);
    border-color: var(--news-primary);
    color: var(--news-primary);
}

.news-share-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    width: 200px;
    background: var(--news-bg-card);
    border: 1px solid var(--news-border);
    border-radius: var(--news-radius-md);
    box-shadow: var(--news-shadow-popover);
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 50;
    animation: newsFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.news-share-menu.show {
    display: flex;
}

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

.news-share-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--news-radius-sm);
    color: var(--news-text-main);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    width: 100%;
    box-sizing: border-box;
    transition: background 0.15s ease, color 0.15s ease;
}

.news-share-item i,
.news-share-item svg {
    font-size: 16px;
    width: 18px;
    height: 18px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    fill: currentColor;
}

.news-share-item:hover {
    background: var(--news-bg-subtle);
    color: var(--news-primary);
}

/* ==========================================================================
   Skeleton Shimmer Loading States (Design System Compliant)
   ========================================================================== */
.news-skeleton-card {
    background: var(--news-bg-card);
    border: 1px solid var(--news-border);
    border-radius: var(--news-radius-lg);
    overflow: hidden;
    box-shadow: var(--news-shadow-card);
    display: flex;
    flex-direction: column;
}

.news-skeleton-media {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 0 !important;
}

.news-skeleton-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.news-skeleton-line {
    height: 14px;
    border-radius: var(--news-radius-pill);
}

.news-skeleton-line.short { width: 40%; }
.news-skeleton-line.medium { width: 70%; }
.news-skeleton-line.title { height: 22px; width: 90%; }
.news-skeleton-line.btn { height: 36px; width: 35%; border-radius: var(--news-radius-md) !important; margin-top: 6px; }

/* Design System Shimmer Animation */
.mc-skeleton,
.news-shimmer {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: mcShimmer 1.5s infinite;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .mc-skeleton,
[data-theme="dark"] .news-shimmer {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
    background-size: 200% 100%;
}

@keyframes mcShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   Toast Notification & Empty State
   ========================================================================== */
.news-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--news-text-main);
    color: var(--news-bg-card);
    padding: 12px 24px;
    border-radius: var(--news-radius-pill);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.news-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.news-toast i {
    color: #10b981;
    font-size: 20px;
}

.news-empty-state {
    text-align: center;
    padding: 64px 20px;
    background: var(--news-bg-card);
    border: 1px dashed var(--news-border);
    border-radius: var(--news-radius-lg);
    margin: 24px 0;
}

.news-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--news-primary-light);
    color: var(--news-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.news-empty-icon i {
    font-size: 32px;
}

.news-empty-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--news-text-main);
    margin: 0 0 8px 0;
}

.news-empty-desc {
    font-size: 14px;
    color: var(--news-text-muted);
    margin: 0 0 20px 0;
}

.news-reset-filter-btn {
    padding: 10px 20px;
    background: var(--news-primary);
    color: #ffffff;
    border-radius: var(--news-radius-md);
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--news-font);
}

/* ==========================================================================
   Backwards Compatibility Hooks
   ========================================================================== */
.local-news-container, .global-news-container {
    width: 100%;
}
.news-heading {
    display: none;
}