/* stylelint-disable comment-empty-line-before */
/* Infinite Scroll Feed Styles */

/* Shimmer animation for image loading placeholder */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

#feed-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Feed Item */
.feed-item {
    background: transparent;
    border-radius: 12px;
    box-shadow: none;
    margin-bottom: 24px;
    overflow: visible;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

/* Colored background overlay on hover - grows from center */
.feed-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -15px;
    width: calc(100% + 30px);
    height: 100%;
    background: var(--card-color, transparent);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 0;
    border-radius: 12px;
    mix-blend-mode: screen;
}

.feed-item:hover::before {
    opacity: 0.15;
    transform: scale(1);
}

/* Interest tracking indicator (optional visual feedback) */
.feed-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgb(0 123 255 / 50%), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.feed-item.tracking-interest::after {
    opacity: 1;
    animation: interest-pulse 2s ease-in-out infinite;
}

@keyframes interest-pulse {

    /* stylelint-disable-next-line rule-empty-line-before */
    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.7;
    }
}

.feed-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgb(0 0 0 / 15%);
}

.feed-item.expanded {
    box-shadow: 0 8px 32px rgb(0 0 0 / 20%);
}

.feed-item-content {
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* Feed Item Header (Clickable) */
.feed-item-header {
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feed-item-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--text-primary, #fff);
    line-height: 1.3;
}

/* moved below dark-mode block to satisfy specificity order */

/* Feed Item Image - YouTube Style */
.feed-item-image {
    width: 100%;
    max-width: 100%;
    overflow: visible;
    background: transparent;
    border-radius: 12px;
    margin: 16px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    will-change: contents;
}

.feed-item-image img {
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    display: block;
    margin: 0 auto;
    content-visibility: auto;
}

/* Feed Item Header Content */
.feed-item-header-content {
    padding: 0 20px 20px;
    position: relative;
}

/* Expand Indicator */
.expand-indicator {
    position: absolute;
    bottom: 10px;
    right: 20px;
    font-size: 20px;
    color: #999;
    transition: transform 0.3s ease;
}

.feed-item.expanded .expand-indicator {
    transform: rotate(180deg);
}

/* Feed Item Body (deprecated - keeping for compatibility) */
.feed-item-body {
    padding: 20px;
}

.feed-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.feed-item-category {
    display: inline-block;
    padding: 4px 12px;
    background: #051a4d;
    color: #fff;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.feed-item-relevance {
    display: inline-block;
    padding: 4px 12px;
    background: #0f4620;
    color: #fff;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 500;
}

.feed-item-source {
    font-size: 13px;
    color: #999;
    font-style: italic;
}

/* moved earlier to satisfy no-descending-specificity */

.feed-item-description {
    font-size: 18px;
    color: var(--text-secondary, #e0e0e0);
    line-height: 1.7;
    margin: 0 0 12px;
}

.feed-item-summary {
    font-size: 17px;
    color: var(--text-secondary, #e0e0e0);
    line-height: 1.7;
    margin: 0 0 16px;
}

/* Expandable Content Section */
.feed-item-expanded-content {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease-in-out;
    position: relative;
}

/* Background overlay for expanded content */
.feed-item-expanded-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--card-color, transparent);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 0;
    border-radius: 12px;
}

.feed-item:hover .feed-item.expanded .feed-item-expanded-content::before {
    opacity: 0.15;
    transform: scale(1);
}

.feed-item.expanded .feed-item-expanded-content {
    padding: 0 20px 20px;
    max-height: 2000px;
}

.content-inner {
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease-in-out;
}

.feed-item.expanded .content-inner {
    opacity: 1;
    transform: translateY(0);
}

/* Feed Item Actions */
.feed-item-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.btn-read-more,
.btn-source {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgb(0 0 0 / 15%);
}

.btn-read-more {
    background: #1440a6;
    color: #fff;
}

.btn-read-more:hover {
    background: #0d2f6e;
}

.btn-source {
    background: #3a3a3a;
    color: #e0e0e0;
    border: 1px solid #555;
    display: inline-flex;
    align-items: center;
}

.btn-source:hover {
    background: #2a2a2a;
}

.feed-item-time {
    font-size: 13px;
    color: #999;
    margin-left: auto;
}

/* Feed Item Tags */
.feed-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

.tag {
    display: inline-block;
    padding: 4px 10px;
    background: #3a3a3a;
    color: #e0e0e0;
    border-radius: 12px;
    font-size: 12px;
}

/* Related Queries Section */
.feed-item-related {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.related-title {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.related-queries {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.related-query {
    display: inline-block;
    padding: 6px 14px;
    background: linear-gradient(135deg, #3d4a7a 0%, #4a2f5a 100%);
    color: #fff;
    text-decoration: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgb(102 126 234 / 20%);
}

.related-query:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgb(102 126 234 / 30%);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Related Stories Section */
.related-stories-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 2px solid #e9ecef;
}

.related-stories-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
    color: #495057;
}

.related-stories-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.related-story-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 12px 16px;
    transition: all 0.2s;
}

.related-story-card:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateX(4px);
}

.related-story-source {
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.related-story-title {
    font-size: 14px;
    font-weight: 500;
    color: #212529;
    margin-bottom: 8px;
    line-height: 1.4;
}

.related-story-link {
    display: inline-block;
    font-size: 13px;
    color: #1440a6;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.related-story-link:hover {
    color: #0d2f6e;
    text-decoration: underline;
}

/* Loading Indicator */
.feed-loading {
    text-align: center;
    padding: 40px 20px;
    min-height: 100px;
    /* Ensure it has height even when hidden */
}

/* .spinner defined in components.css */

.feed-loading p {
    color: #666;
    font-size: 16px;
}

/* End Message */
.feed-end {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
}

/* Error Message */
.feed-error {
    text-align: center;
    padding: 40px 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    margin: 20px 0;
}

.feed-error p {
    color: #856404;
    margin-bottom: 16px;
}

.feed-error button {
    padding: 10px 24px;
    background: #ffc107;
    color: #000;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.feed-error button:hover {
    background: #e0a800;
}

/* Feed Controls */
.feed-controls {
    max-width: 800px;
    margin: 0 auto 24px;
    padding: 0 20px;
}

.category-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Category buttons styles moved to components.css */

/* Responsive Design */
@media (width <=768px) {
    #feed-container {
        padding: 12px;
    }

    .feed-item {
        margin-bottom: 16px;
        border-radius: 8px;
    }

    .feed-item-image {
        max-width: 100%;
    }

    .feed-item-body {
        padding: 16px;
    }

    .feed-item-title {
        font-size: 20px;
    }

    .feed-item-description,
    .feed-item-summary {
        font-size: 14px;
    }

    .feed-item-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-read-more,
    .btn-source {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .feed-item-time {
        margin-left: 0;
        text-align: center;
    }
}

/* Dark mode overrides moved to end for specificity compliance */

/* Article Modal */
.article-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgb(0 0 0 / 80%);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.article-modal.active {
    display: block;
}

.article-modal-content {
    max-width: 800px;
    margin: 40px auto;
    background: var(--bg-secondary, #222);
    border-radius: 12px;
    padding: 40px;
    position: relative;
    box-shadow: 0 8px 32px rgb(0 0 0 / 30%);
    color: var(--text-primary, #fff);
}

.article-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 36px;
    color: var(--text-secondary, #ccc);
    cursor: pointer;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.article-modal-close:hover {
    background: var(--bg-tertiary, #2a2a2a);
    color: var(--text-primary, #fff);
}

.article-modal-header h1 {
    font-size: 32px;
    line-height: 1.3;
    margin: 0 0 16px;
    color: var(--text-primary, #fff);
    font-weight: 600;
}

.article-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--bg-tertiary, #2a2a2a);
    font-size: 14px;
    color: var(--text-secondary, #ccc);
}

.article-meta span:not(:empty)::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background: var(--text-secondary, #ccc);
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

.article-meta span:first-child::before {
    display: none;
}

.article-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 24px;
}

.article-body {
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-primary, #fff);
}

.article-body p {
    margin-bottom: 20px;
    white-space: pre-line;
    color: var(--text-primary, #fff);
}

.article-related {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 2px solid var(--bg-tertiary, #2a2a2a);
}

.article-related h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary, #fff);
}

.related-items-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.related-item {
    background: var(--bg-tertiary, #2a2a2a);
    border: 1px solid var(--bg-tertiary, #2a2a2a);
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s ease;
    color: var(--text-primary, #fff);
}

.related-item:hover {
    border-color: #1440a6;
    box-shadow: 0 2px 8px rgb(20 64 166 / 30%);
    background: var(--bg-secondary, #222);
}

.related-item-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 12px;
}

.related-item-category {
    background: #1440a6;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.related-item-source {
    color: var(--text-secondary, #ccc);
    padding: 4px 0;
}

.related-item-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary, #fff);
    line-height: 1.4;
}

.related-item-description {
    font-size: 14px;
    color: var(--text-secondary, #ccc);
    line-height: 1.5;
    margin-bottom: 12px;
}

.related-item-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-related-source {
    display: inline-block;
    padding: 8px 16px;
    background: #1440a6;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.btn-related-source:hover {
    background: #0d2f6e;
}

.article-loading {
    text-align: center;
    padding: 60px 20px;
}

.article-error {
    text-align: center;
    padding: 60px 20px;
}

.article-error p {
    font-size: 18px;
    color: #555;
    margin-bottom: 20px;
}

@media (width <=768px) {
    .article-modal {
        padding: 0;
    }

    .article-modal-content {
        margin: 0;
        border-radius: 0;
        padding: 60px 20px 20px;
        min-height: 100vh;
    }

    .article-modal-header h1 {
        font-size: 24px;
    }

    .article-body {
        font-size: 16px;
    }
}

/* Main header and footer moved to base/header CSS where appropriate */
.main-header {
    background: #1440a6;
    color: #fff;
    padding: 20px 0;
    box-shadow: 0 2px 4px rgb(0 0 0 / 10%);
}

.main-header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-header h1 {
    margin: 0;
    font-size: 28px;
}

.main-header nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

.main-header nav a {
    color: #fff;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    transition: background 0.2s;
}

.main-header nav a:hover,
.main-header nav a.active {
    background: rgb(255 255 255 / 20%);
}

#dark-mode-toggle {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    margin-left: 10px;
}

.feed-controls h2 {
    margin: 20px 0 16px;
    font-size: 24px;
}

footer {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    background: #000;
    margin-top: 60px;
}

/* Continue Reading CTA (AdSense Compliance - Facts Only) */
.continue-reading-cta {
    margin: 10px 0 30px;
    padding: 20px;
    background: var(--bg-tertiary, #2a2a2a);
    border-radius: 12px;
    text-align: center;
    border-left: 4px solid #1440a6;
}

.continue-reading-cta .cta-text {
    margin: 20px 0 10px;
    font-weight: bold;
    color: var(--text-secondary, #ccc);
    text-align: center;
}

.btn-continue-reading {
    display: inline-block;
    padding: 14px 32px;
    background: #1440a6;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgb(20 64 166 / 30%);
}

.btn-continue-reading:hover {
    background: #0d2f6e;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgb(20 64 166 / 40%);
}

/* Light Mode Overrides */
html.light-mode .continue-reading-cta {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

html.light-mode .continue-reading-cta .cta-text {
    color: #666;
}

/* Light Mode Overrides */
html.light-mode .feed-item-title {
    color: #1a1a1a;
}

html.light-mode .feed-item-header:hover .feed-item-title {
    color: #1440a6;
}

html.light-mode .feed-item-description {
    color: #222;
}

html.light-mode .feed-item-summary {
    color: #222;
}

html.light-mode .feed-item-source {
    color: #666;
}

html.light-mode .tag {
    background: #f8f9fa;
    color: #495057;
}

html.light-mode .btn-source {
    background: #f8f9fa;
    color: #333;
    border-color: #dee2e6;
}

html.light-mode .article-modal-content {
    background: #fff;
    box-shadow: 0 8px 32px rgb(0 0 0 / 30%);
}

html.light-mode .article-modal-close {
    color: #666;
}

html.light-mode .article-modal-close:hover {
    background: #f0f0f0;
    color: #000;
}

html.light-mode .article-modal-header h1 {
    color: #1a1a1a;
}

html.light-mode .article-meta {
    border-bottom-color: #e0e0e0;
    color: #555;
}

html.light-mode .article-meta span:not(:empty)::before {
    background: #555;
}

html.light-mode .article-body {
    color: #1a1a1a;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 4px solid var(--bg-tertiary, #e0e0e0);
    border-top-color: var(--accent, #007bff);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

html.light-mode .article-loading .spinner {
    border-color: #f3f3f3;
    border-top-color: #1440a6;
}

html.light-mode .article-error p {
    color: #555;
}

html.light-mode .article-related {
    border-top-color: #e0e0e0;
}

html.light-mode .article-related h3 {
    color: #1a1a1a;
}

html.light-mode .related-item {
    background: #f8f9fa;
    border-color: #e0e0e0;
}

html.light-mode .related-item:hover {
    border-color: #1440a6;
    box-shadow: 0 2px 8px rgb(0 86 179 / 10%);
}

html.light-mode .related-item-source {
    color: #666;
}

html.light-mode .related-item-title {
    color: #1a1a1a;
}

html.light-mode .related-item-description {
    color: #555;
}

/* Light mode overrides for feed controls */
html.light-mode .feed-controls h2 {
    color: #1a1a1a;
}

html.light-mode footer {
    background: #fff;
    color: #666;
}

/* Removed duplicate Continue Reading + dark mode block */

/* Loading state spinner */
.feed-item-summary.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    min-height: 100px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}