/**
 * News Section Component
 * Styles for news items and news page
 */

/* News Section Styles */
.news-section {
    margin: 4em auto;
    max-width: 1200px;
    padding: 0 1em;
}

.news-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(350px, 100%), 1fr));
    gap: 1.5em;
    margin-top: 2em;
}

@media (min-width: 1200px) {
    .news-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

    .news-section {
        padding: 0 0.5em;
    }
}

.news-item {
    /* Extends glass-base with news-specific styling */
    background: linear-gradient(135deg,
            rgba(var(--glass-primary-rgb), var(--glass-bg-opacity-base)) 0%,
            rgba(var(--glass-secondary-rgb), 0.08) 50%,
            rgba(var(--glass-accent-rgb), 0.3) 100%);
    backdrop-filter: blur(var(--glass-blur-intro)) saturate(var(--glass-saturation-intro));
    -webkit-backdrop-filter: blur(var(--glass-blur-intro)) saturate(var(--glass-saturation-intro));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1.5em;
    transition: all var(--transition-slow);
    position: relative;
    top: 0;
    /* Ensure top transition works */
    overflow: hidden;
    opacity: 0;
    animation: newsItemFadeIn 0.6s ease-out forwards;
    animation-delay: calc(var(--item-index, 0) * 0.1s);
    isolation: isolate;
    box-shadow:
        var(--shadow-lg),
        0 2px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Glass highlight layer */
.news-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-md);
    padding: 1px;
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.3) 0%,
            rgba(255, 255, 255, 0.05) 50%,
            rgba(255, 255, 255, 0) 100%);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0.7;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 1;
}

/* Liquid Glass - Illumination Layer (ambient glow) */
.news-item::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-md);
    background: radial-gradient(circle at 30% 20%,
            rgba(137, 207, 240, 0.15) 0%,
            transparent 50%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 0;
}

.news-item:hover::before {
    opacity: 1;
}

.news-item:hover::after {
    opacity: 0.8;
}

.news-item:hover {
    top: -8px;
    /* Use top instead of transform to preserve background-attachment: fixed */
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow:
        0 20px 48px rgba(93, 143, 179, 0.25),
        0 8px 16px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    background: linear-gradient(135deg,
            rgba(93, 143, 179, 0.25) 0%,
            rgba(137, 207, 240, 0.15) 50%,
            rgba(46, 46, 46, 0.4) 100%);
}

@keyframes newsItemFadeIn {
    from {
        opacity: 0;
        /* transform removed to prevent containing block creation */
    }

    to {
        opacity: 1;
        /* transform removed */
    }
}

.news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1em;
    flex-wrap: wrap;
    gap: 0.5em;
}

.news-category {
    display: inline-block;
    padding: 0.3em 0.8em;
    border-radius: var(--radius-base);
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    /* Colors are set inline via JavaScript based on category type */
}

.news-date {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
}

.news-title {
    font-size: 1.3em;
    margin: 0 0 0.8em 0;
    color: var(--color-text-title);
    font-weight: 600;
    line-height: 1.3;
}

.news-content {
    font-size: 0.95em;
    line-height: 1.6;
    color: var(--color-text-body);
    margin: 0 0 1em 0;
}

.news-link {
    display: inline-block;
    color: var(--color-content-type-light);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.3s ease;
    position: relative;
}

.news-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-content-type-light);
    transition: width 0.3s ease;
}

.news-link:hover {
    color: var(--color-content-type-light);
    transform: translateX(3px);
}

.news-link:hover::after {
    width: 100%;
}

.loading-message,
.no-news,
.error-message {
    text-align: center;
    padding: 3em 2em;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1em;
    grid-column: 1 / -1;
}

.error-message {
    color: rgba(231, 76, 60, 0.8);
}

/* View All News Button */
.view-all-news-container {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    margin-top: 2em;
    padding: 0 0 2em 0;
    border-bottom: 1px solid rgba(93, 143, 179, 0.2);
}

.view-all-news-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.8em 2em;
    /* Extends btn-glass with view-all styling */
    background: linear-gradient(135deg,
            rgba(var(--glass-primary-rgb), 0.2) 0%,
            rgba(var(--glass-secondary-rgb), 0.15) 100%);
    backdrop-filter: blur(var(--glass-blur-intro)) saturate(var(--glass-saturation-intro));
    -webkit-backdrop-filter: blur(var(--glass-blur-intro)) saturate(var(--glass-saturation-intro));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-small);
    color: var(--color-accent-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1em;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    box-shadow:
        0 4px 16px var(--color-accent-primary-bg),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.view-all-news-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--color-accent-primary-bg), transparent);
    transition: left 0.5s ease;
}

.view-all-news-button:hover::before {
    left: 100%;
}

.view-all-news-button:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow:
        0 8px 24px var(--color-accent-primary-bg),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg,
            var(--color-accent-primary-bg) 0%,
            rgba(107, 181, 212, 0.2) 100%);
    color: var(--color-accent-primary-light);
}

.view-all-news-button .arrow {
    display: inline-block;
    transition: transform 0.3s ease;
}

.view-all-news-button:hover .arrow {
    transform: translateX(5px);
}

/* News Page Styles */
.news-page-header {
    text-align: center;
    margin: 2em auto 3em;
    max-width: 800px;
}

.news-page-header h1 {
    font-size: 3em;
    margin-bottom: 0.5em;
    color: var(--color-text-title);
    font-weight: 500;
    letter-spacing: -0.02em;
}

.news-page-subtitle {
    font-size: 1.2em;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* Adjust news grid for full page */
body:has(#allNewsContainer) .news-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2em;
}

@media (max-width: 768px) {
    .news-page-header h1 {
        font-size: 2em;
    }

    .news-page-subtitle {
        font-size: 1em;
    }

    .view-all-news-button {
        font-size: 1em;
        padding: 0.7em 1.5em;
    }
}