/* CSS Reset & Variables */
:root {
    /* Colors - Light Mode */
    --primary-color: #e63946;
    --primary-dark: #c1121f;
    --secondary-color: #1d3557;
    --accent-color: #457b9d;
    --background: #f8f9fa;
    --surface: #ffffff;
    --surface-hover: #f1f3f4;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a68;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: 0.3s ease;

    /* Category Colors */
    --local-color: #e63946;
    --finance-color: #2a9d8f;
    --entertainment-color: #9b59b6;
    --sports-color: #e67e22;
    --international-color: #3498db;
    --tech-color: #1abc9c;
    --lifestyle-color: #e91e63;
}

/* Dark Mode */
[data-theme="dark"] {
    --background: #0f0f1a;
    --surface: #1a1a2e;
    --surface-hover: #252542;
    --text-primary: #f8f9fa;
    --text-secondary: #b8c0c8;
    --text-muted: #8892a0;
    --border-color: #2d2d44;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition);
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.main-header {
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
}

.logo a {
    font-size: 1.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.logo-pop {
    color: var(--primary-color);
}

.logo-news {
    color: var(--secondary-color);
}

[data-theme="dark"] .logo-news {
    color: var(--text-primary);
}

.logo-hk {
    color: var(--accent-color);
    font-size: 1.25rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-container {
    display: flex;
    align-items: center;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    transition: all var(--transition);
}

.search-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
}

.search-container input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.95rem;
    width: 200px;
    color: var(--text-primary);
}

.search-container input::placeholder {
    color: var(--text-muted);
}

.search-container button {
    color: var(--text-muted);
    transition: color var(--transition);
}

.search-container button:hover {
    color: var(--primary-color);
}

#darkModeToggle {
    padding: 10px;
    border-radius: var(--radius-md);
    background: var(--background);
    color: var(--text-secondary);
    transition: all var(--transition);
}

#darkModeToggle:hover {
    background: var(--surface-hover);
    color: var(--primary-color);
}

#darkModeToggle .moon-icon {
    display: none;
}

[data-theme="dark"] #darkModeToggle .sun-icon {
    display: none;
}

[data-theme="dark"] #darkModeToggle .moon-icon {
    display: block;
}

/* Navigation */
.main-nav {
    border-top: 1px solid var(--border-color);
}

.nav-list {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-list::-webkit-scrollbar {
    display: none;
}

.nav-link {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: all var(--transition);
}

.nav-link:hover {
    background: var(--surface-hover);
    color: var(--primary-color);
}

.nav-link.active {
    background: var(--primary-color);
    color: white;
}

/* Breaking News Ticker */
.breaking-news {
    background: var(--secondary-color);
    color: white;
    padding: 10px 0;
}

[data-theme="dark"] .breaking-news {
    background: var(--primary-dark);
}

.breaking-news .container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.breaking-label {
    background: var(--primary-color);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.ticker-wrapper {
    flex: 1;
    overflow: hidden;
}

.ticker {
    display: flex;
    animation: ticker 30s linear infinite;
}

.ticker-item {
    white-space: nowrap;
    padding-right: 60px;
    font-size: 0.95rem;
}

@keyframes ticker {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Main Content Layout */
.main-content {
    padding: 32px 0;
}

.main-content .container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 32px;
}

/* Featured Section */
.featured-section {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 24px;
    margin-bottom: 40px;
    grid-column: 1 / -1;
}

.featured-main {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition);
}

.featured-main:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.featured-main .featured-link {
    display: block;
}

.featured-main .featured-image {
    position: relative;
    height: 320px;
    overflow: hidden;
}

.featured-main .featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
}

.featured-main:hover .featured-image img {
    transform: scale(1.05);
}

.featured-content {
    padding: 24px;
}

.featured-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.4;
    color: var(--text-primary);
}

.featured-content p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.7;
}

.article-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.featured-side {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.featured-small {
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    flex: 1;
    transition: all var(--transition);
}

.featured-small:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.featured-small a {
    display: block;
    height: 100%;
}

.featured-small .featured-image {
    position: relative;
    height: 140px;
    overflow: hidden;
}

.featured-small .featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
}

.featured-small:hover .featured-image img {
    transform: scale(1.05);
}

.featured-small h3 {
    padding: 16px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--text-primary);
}

.featured-small time {
    display: block;
    padding: 0 16px 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Category Tags */
.category-tag {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    z-index: 1;
}

.category-tag.local { background: var(--local-color); }
.category-tag.finance { background: var(--finance-color); }
.category-tag.entertainment { background: var(--entertainment-color); }
.category-tag.sports { background: var(--sports-color); }
.category-tag.international { background: var(--international-color); }
.category-tag.tech { background: var(--tech-color); }
.category-tag.lifestyle { background: var(--lifestyle-color); }

/* Icon Background Styles */
.icon-bg {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.icon-bg svg {
    color: rgba(255, 255, 255, 0.9);
    z-index: 0;
}

.local-bg { background: linear-gradient(135deg, #e63946 0%, #c1121f 100%); }
.finance-bg { background: linear-gradient(135deg, #2a9d8f 0%, #1d7a6f 100%); }
.entertainment-bg { background: linear-gradient(135deg, #9b59b6 0%, #7b3f9e 100%); }
.sports-bg { background: linear-gradient(135deg, #e67e22 0%, #c56c17 100%); }
.international-bg { background: linear-gradient(135deg, #3498db 0%, #2573a7 100%); }
.tech-bg { background: linear-gradient(135deg, #1abc9c 0%, #149b81 100%); }
.lifestyle-bg { background: linear-gradient(135deg, #e91e63 0%, #c2185b 100%); }

.featured-main .icon-bg {
    height: 320px;
}

.featured-small .icon-bg {
    height: 140px;
}

.card-image.icon-bg {
    height: 180px;
}

/* News Section */
.news-section {
    grid-column: 1;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.filter-tabs {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border-color);
    transition: all var(--transition);
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* News Grid */
.news-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.news-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

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

.news-card a {
    display: block;
}

.card-image {
    position: relative;
    height: 180px;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
}

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

.card-content {
    padding: 16px;
}

.card-content h3 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 8px;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Load More Button */
.load-more-container {
    text-align: center;
    margin-top: 32px;
}

.load-more-btn {
    padding: 14px 40px;
    background: var(--surface);
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-md);
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 600;
    transition: all var(--transition);
}

.load-more-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.widget {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.widget h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-color);
}

/* Weather Widget */
.weather-content {
    display: flex;
    gap: 16px;
    align-items: center;
}

.weather-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-right: 16px;
    border-right: 1px solid var(--border-color);
}

.weather-main svg {
    color: #f59e0b;
    margin-bottom: 8px;
}

.weather-main .temp {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.weather-details p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* Trending Widget */
.trending-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.trending-list li:last-child {
    border-bottom: none;
}

.trend-rank {
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.trending-list li:nth-child(n+4) .trend-rank {
    background: var(--text-muted);
}

.trending-list a {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.trending-list a:hover {
    color: var(--primary-color);
}

.trend-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Newsletter Widget */
.newsletter-widget p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.newsletter-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.newsletter-form input {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--background);
    color: var(--text-primary);
    transition: all var(--transition);
}

.newsletter-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
}

.newsletter-form button {
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    transition: all var(--transition);
}

.newsletter-form button:hover {
    background: var(--primary-dark);
}

/* SEO Section */
.seo-section {
    background: var(--surface);
    padding: 48px 0;
    border-top: 1px solid var(--border-color);
}

.seo-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.seo-content {
    max-width: 900px;
}

.seo-content p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.8;
    font-size: 0.95rem;
}

.seo-content strong {
    color: var(--text-primary);
}

/* Footer */
.main-footer {
    background: var(--secondary-color);
    color: white;
    padding: 48px 0 24px;
}

[data-theme="dark"] .main-footer {
    background: #0a0a14;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr repeat(3, 1fr);
    gap: 40px;
    margin-bottom: 40px;
}

.footer-brand .logo {
    margin-bottom: 16px;
}

.footer-brand .logo span {
    font-size: 1.5rem;
}

.footer-brand p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.footer-links h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: white;
}

.footer-links ul li {
    margin-bottom: 12px;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: white;
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-bottom p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

.social-links {
    display: flex;
    gap: 16px;
}

.social-links a {
    color: rgba(255, 255, 255, 0.7);
    transition: all var(--transition);
}

.social-links a:hover {
    color: white;
    transform: translateY(-2px);
}

/* Search Results Highlight */
.news-card.hidden {
    display: none;
}

.highlight {
    background: rgba(230, 57, 70, 0.2);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--secondary-color);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

[data-theme="dark"] .toast {
    background: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .news-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    .main-content .container {
        grid-template-columns: 1fr;
    }

    .featured-section {
        grid-template-columns: 1fr;
    }

    .featured-side {
        flex-direction: row;
    }

    .sidebar {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .header-top {
        flex-wrap: wrap;
        gap: 16px;
    }

    .search-container {
        order: 3;
        width: 100%;
    }

    .search-container input {
        width: 100%;
    }

    .news-grid {
        grid-template-columns: 1fr;
    }

    .featured-side {
        flex-direction: column;
    }

    .sidebar {
        grid-template-columns: 1fr;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0 16px;
    }

    .logo a {
        font-size: 1.4rem;
    }

    .featured-main .featured-image {
        height: 220px;
    }

    .featured-content h2 {
        font-size: 1.25rem;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.news-card {
    animation: fadeIn 0.5s ease forwards;
}

.news-card:nth-child(2) { animation-delay: 0.1s; }
.news-card:nth-child(3) { animation-delay: 0.2s; }
.news-card:nth-child(4) { animation-delay: 0.3s; }
.news-card:nth-child(5) { animation-delay: 0.4s; }
.news-card:nth-child(6) { animation-delay: 0.5s; }

/* Scroll to Top Button */
.scroll-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
    z-index: 999;
}

.scroll-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-top:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .main-header,
    .breaking-news,
    .sidebar,
    .main-footer,
    .load-more-btn {
        display: none;
    }

    .main-content .container {
        display: block;
    }

    .news-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
